Index: fact/tools/rootmacros/PulseTemplates/pixel.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 13499)
+++ fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 13500)
@@ -26,5 +26,5 @@
         int         bSLMean,
         int         gainMean,
-        TString options
+        TString     options
         )
 {
@@ -38,25 +38,21 @@
     mGainMean               = gainMean;
 
-//    hMaxOverlay     = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F*));
-    hMaxOverlay = new TH2F*[mMaxPulseOrder];
-//    hEdgeOverlay    = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F*));
+    hMaxOverlay  = new TH2F*[mMaxPulseOrder];
     hEdgeOverlay = new TH2F*[mMaxPulseOrder];
-//    hMaxProfile     = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
-    hMaxProfile = new TProfile*[mMaxPulseOrder];
-//    hEdgeProfile    = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
+    hMaxProfile  = new TProfile*[mMaxPulseOrder];
     hEdgeProfile = new TProfile*[mMaxPulseOrder];
-    if (mOptions == "S")
-    {
-//        hSlopeRisingEdge= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
+
+    if (mOptions.Contains("S") )
+    {
         hSlopeRisingEdge = new TH1F*[mMaxPulseOrder];
     }
-    if (mOptions == "R")
-    {
-//        hRisingEdgeToMax= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
+
+    if (mOptions.Contains("R") )
+    {
         hRisingEdgeToMax = new TH1F*[mMaxPulseOrder];
     }
-    if (mOptions == "P")
-    {
-//        hPosOfMax       = (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
+
+    if (mOptions.Contains("P") )
+    {
         hPosOfMax = new TH1F*[mMaxPulseOrder];
     }
@@ -96,8 +92,11 @@
     TString histo_name;
 
-    for (int order =0; order > mMaxPulseOrder; order++)
-    {
-        histo_name = "hMaxOverlay";
-        histo_name += order;
+    for (int order = 0; order < mMaxPulseOrder; order++)
+    {
+        histo_name =    "hMaxOverlay";
+        histo_name +=   mChid;
+        histo_name +=   "_";
+        histo_name +=   order;
+        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
         hMaxOverlay[order]=new TH2F(
                 histo_name,
@@ -118,5 +117,4 @@
                             );
                             */
-        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
         hMaxOverlay[order]->SetAxisRange(
                     mBSLMean - 5,
@@ -127,8 +125,4 @@
         //hMaxProfile->SetBit(TH2F::kCanRebin);
         hList->Add( hMaxOverlay[order] );
-    }
-
-    for (int order = 0; order < mMaxPulseOrder; order ++)
-    {
 
 //------------------------------------------------------------------------
@@ -141,7 +135,9 @@
                     );
                     */
-        histo_name = "hEdgeOverlay";
-        histo_name += order;
-        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
+        histo_name =    "hEdgeOverlay";
+        histo_name +=   mChid;
+        histo_name +=   "_";
+        histo_name +=   order;
+        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
         hEdgeOverlay[order] = new TH2F(
                     histo_name,
@@ -172,7 +168,9 @@
                     );
                     */
-        histo_name = "hMaxProfile";
-        histo_name += order;
-        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
+        histo_name =    "hMaxProfile";
+        histo_name +=   mChid;
+        histo_name +=   "_";
+        histo_name +=   order;
+        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
         hMaxProfile[order] = new TProfile(
                     histo_name,
@@ -205,6 +203,8 @@
                     */
         histo_name = "hEdgeProfile";
+        histo_name +=   mChid;
+        histo_name +=   "_";
         histo_name += order;
-        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
+        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
         hEdgeProfile[order] = new TProfile(
                     histo_name,
@@ -260,9 +260,11 @@
 Pixel::BookDistributionHistos( )
 {
-    if (mOptions != "")
-    {
+    if (!mOptions.IsNull() )
+    {
+        cout << endl << "#" ;
         TString histo_name;
-        for (int order =0; order > mMaxPulseOrder; order++)
+        for (int order =0; order < mMaxPulseOrder; order++)
         {
+            cout << endl << "##" ;
             if (mVerbosityLevel > 2) cout << endl
                                           << "...book distribution histograms"
@@ -271,6 +273,9 @@
             if (mOptions.Contains("S"))
             {
-                histo_name = "hSlopeRisingEdge";
-                histo_name += order;
+                histo_name =    "hSlopeRisingEdge";
+                histo_name +=   mChid;
+                histo_name +=   "_";
+                histo_name +=   order;
+                if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
                 hSlopeRisingEdge[order] = new TH1F (
                             histo_name,
@@ -287,6 +292,9 @@
             if (mOptions.Contains("R"))
             {
-                histo_name = "hRisingEdgeToMax";
-                histo_name += order;
+                histo_name =    "hRisingEdgeToMax";
+                histo_name +=   mChid;
+                histo_name +=   "_";
+                histo_name +=    order;
+                if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
                 hRisingEdgeToMax[order] = new TH1F (
                             histo_name,
@@ -303,6 +311,9 @@
             if (mOptions.Contains("P"))
             {
-                histo_name = "hPosOfMax";
-                histo_name += order;
+                histo_name =    "hPosOfMax";
+                histo_name +=   mChid;
+                histo_name +=   "_";
+                histo_name +=   order;
+                if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
                 hPosOfMax[order] = new TH1F (
                             histo_name,
@@ -319,4 +330,5 @@
             if (mVerbosityLevel > 2) cout << "...done" << endl;
         }
+        cout << endl << "###" ;
     }
 }
@@ -364,5 +376,5 @@
 Pixel::DeletePixelHistos()
 {
-    if (mVerbosityLevel > 2) cout << endl << "...delete current overlay histograms" ;
+    if (mVerbosityLevel > 2) cout << endl << "\t...delete current overlay histograms" ;
 
     for (int order = 0;
@@ -370,17 +382,17 @@
          order ++)
     {
-        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxOverlay";
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
         delete hMaxOverlay[order];
 
-        if (mVerbosityLevel > 3) cout << endl << "...deleting hEdgeOverlay";
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
         delete hEdgeOverlay[order];
 
-        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile";
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
         delete hMaxProfile[order];
 
-        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile2";
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2";
         delete hEdgeProfile[order];
     }
-    if (mVerbosityLevel > 3) cout << endl << "...deleting histogram Arrays";
+    if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
     delete[] hMaxOverlay;
     hMaxOverlay = NULL;
@@ -401,5 +413,6 @@
 Pixel::DeleteDistributionHistos()
 {
-    if (mVerbosityLevel > 2) cout << endl << "...delete current distribution histograms" ;
+    if (mVerbosityLevel > 2) cout << endl
+                                  << "\t...delete current distribution histograms" ;
 
     for (int order = 0;
@@ -407,25 +420,52 @@
          order ++)
     {
-        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxOverlay";
-        delete hSlopeRisingEdge[order];
-
-        if (mVerbosityLevel > 3) cout << endl << "...deleting hEdgeOverlay";
-        delete hRisingEdgeToMax[order];
-
-        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile";
-        delete hPosOfMax[order];
-
-    }
-    if (mVerbosityLevel > 3) cout << endl << "...deleting histogram Arrays";
-
-
-    delete[] hSlopeRisingEdge;
-    hSlopeRisingEdge = NULL;
-
-    delete[] hRisingEdgeToMax;
-    hRisingEdgeToMax = NULL;
-
-    delete[] hPosOfMax;
-    hPosOfMax = NULL;
+        if (mOptions.Contains("S"))
+        {
+            if (mVerbosityLevel > 3) cout << endl
+                                          << "\t\t...deleting hSlopeRisingEdge"
+                                          << mChid << "_" << order ;
+            delete hSlopeRisingEdge[order];
+        }
+
+        if (mOptions.Contains("R"))
+        {
+            if (mVerbosityLevel > 3) cout << endl
+                                          << "\t\t...deleting hRisingEdgeToMax"
+                                          << mChid << "_" << order ;
+//            delete hRisingEdgeToMax[order];
+        }
+
+        if (mOptions.Contains("P"))
+        {
+            if (mVerbosityLevel > 3) cout << endl
+                                          << "\t\t...deleting hPosOfMax"
+                                          << mChid << "_" << order ;
+
+//            delete hPosOfMax[order];
+        }
+
+    }
+    if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
+
+    if (mOptions.Contains("S"))
+    {
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hSlopeRisingEdge";
+//        delete[] hSlopeRisingEdge;
+        hSlopeRisingEdge = NULL;
+    }
+
+    if (mOptions.Contains("R"))
+    {
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hRisingEdgeToMax";
+//        delete[] hRisingEdgeToMax;
+        hRisingEdgeToMax = NULL;
+    }
+
+    if (mOptions.Contains("P"))
+    {
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPosOfMax";
+//        delete[] hPosOfMax;
+        hPosOfMax = NULL;
+    }
 }
 // end of DeletePixelHistos
