Index: fact/tools/rootmacros/PulseTemplates/pixel.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 13584)
+++ fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 13590)
@@ -22,4 +22,26 @@
 
 //}
+//Pixel::Pixel(
+//        int         pixelID,
+//        int         maxPulsorder,
+//        int         verbosityLevel,
+//        bool        stats,
+//        TFile*      filename
+//        )
+//{
+//    mChid                   = pixelID;
+//    mStats                  = stats;
+//    mMaxPulseOrder          = maxPulsorder;
+//    mVerbosityLevel         = verbosityLevel;
+
+//    hMaxOverlay  = new TH2F*[mMaxPulseOrder];
+//    hEdgeOverlay = new TH2F*[mMaxPulseOrder];
+//    hMaxProfile  = new TProfile*[mMaxPulseOrder];
+//    hEdgeProfile = new TProfile*[mMaxPulseOrder];
+
+//    hList           = new TObjArray;
+
+//    LoadPulseHistos( filename );
+//}
 
 Pixel::Pixel(
@@ -27,4 +49,6 @@
         int         maxPulsorder,
         int         verbosityLevel,
+        bool        stats,
+//        TFile*      filename,
         int         pixelOverlayXaxisLeft,
         int         pixelOverlayXaxisRight,
@@ -35,4 +59,5 @@
 {
     mChid                   = pixelID;
+    mStats                  = stats;        ///TODO: HANDOVER THE VALUE
     mMaxPulseOrder          = maxPulsorder;
     mVerbosityLevel         = verbosityLevel;
@@ -96,39 +121,18 @@
 {
     if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
-    TString histo_name;
-    TString histo_title;
-
     for (int order = 0; order < mMaxPulseOrder; order++)
     {
-        histo_name =    "hMaxOverlay";
-        histo_name +=   mChid;
-        histo_name +=   "_";
-        histo_name +=   order;
-
-        histo_title =   "Overlay of detected pulses of one pulse order for one Pixel ";
-        histo_title +=   "[Pixel_Order] ";
-        histo_title +=  mChid;
-        histo_title +=   "_";
-        histo_title +=   order;
-
-        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
+        if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxOverlay", order) << endl;
         hMaxOverlay[order]=new TH2F(
-                histo_name,
-                histo_title,
-                mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
-                (-1*mPixelOverlayXaxisLeft)-0.5,
-                mPixelOverlayXaxisRight-0.5 ,
-                512,
-                -55.5,
-                200.5
-                );
-/*
-                SetHistogramAttributes(
-                            "PeakMaxGaus",
-                            order,
-                            gMaxGausAttrib,
-                            MaxAmplOfFirstPulse
-                            );
-                            */
+                    HistoName("hMaxOverlay", order),
+                    HistoTitle("Overlay of detected pulses of", order),
+                    mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
+                    (-1*mPixelOverlayXaxisLeft)-0.5,
+                    mPixelOverlayXaxisRight-0.5 ,
+                    512,
+                    -55.5,
+                    200.5
+                    );
+
         hMaxOverlay[order]->SetAxisRange(
                     mBSLMean - 5,
@@ -138,30 +142,13 @@
         hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
         //hMaxProfile->SetBit(TH2F::kCanRebin);
+        hMaxOverlay[order]->SetStats(mStats);
         hList->Add( hMaxOverlay[order] );
 
 //------------------------------------------------------------------------
-/*
-        SetHistogramAttributes(
-                    "PeakMaxGaus",
-                    order,
-                    gMaxGausAttrib,
-                    MaxAmplOfFirstPulse
-                    );
-                    */
-        histo_name =    "hEdgeOverlay";
-        histo_name +=   mChid;
-        histo_name +=   "_";
-        histo_name +=   order;
-
-        histo_title =   "Overlay at rising edge of detected pulses of one pulse order for one Pixel ";
-        histo_title +=   "[Pixel_Order] ";
-        histo_title +=  mChid;
-        histo_title +=   "_";
-        histo_title +=   order;
-
-        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
+
+        if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeOverlay", order) << endl;
         hEdgeOverlay[order] = new TH2F(
-                    histo_name,
-                    histo_title,
+                    HistoName("hEdgeOverlay", order),
+                    HistoTitle("Overlay at rising edge of detected pulses of", order),
                     mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
                     (-1*mPixelOverlayXaxisLeft)-0.5,
@@ -178,30 +165,13 @@
         hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
         hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
+        hEdgeOverlay[order]->SetStats(mStats);
         hList->Add( hEdgeOverlay[order] );
 
     //------------------------------------------------------------------------
-/*
-        SetHistogramAttributes(
-                    "PeakMaxGaus",
-                    order,
-                    gMaxGausAttrib,
-                    MaxAmplOfFirstPulse
-                    );
-                    */
-        histo_name =    "hMaxProfile";
-        histo_name +=   mChid;
-        histo_name +=   "_";
-        histo_name +=   order;
-
-        histo_title =   "Mean value of each slice in overlay plot (Tprofile) ";
-        histo_title +=   "[Pixel_Order] ";
-        histo_title +=  mChid;
-        histo_title +=   "_";
-        histo_title +=   order;
-
-        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
+
+        if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxProfile", order) << endl;
         hMaxProfile[order] = new TProfile(
-                    histo_name,
-                    histo_title,
+                    HistoName("hMaxProfile", order),
+                    HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
                     mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
                     (-1*mPixelOverlayXaxisLeft)-0.5,                 //xlow
@@ -218,31 +188,14 @@
         hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
         //hMaxProfile->SetBit(TH2F::kCanRebin);
+        hMaxProfile[order]->SetStats(mStats);
         hList->Add( hMaxProfile[order] );
 
 
     //------------------------------------------------------------------------
-/*
-        SetHistogramAttributes(
-                    "PeakMaxGaus",
-                    order,
-                    gMaxGausAttrib,
-                    MaxAmplOfFirstPulse
-                    );
-                    */
-        histo_name = "hEdgeProfile";
-        histo_name +=   mChid;
-        histo_name +=   "_";
-        histo_name += order;
-
-        histo_title =   "Mean value of each slice in overlay plot (Tprofile) ";
-        histo_title +=   "[Pixel_Order] ";
-        histo_title +=  mChid;
-        histo_title +=   "_";
-        histo_title +=   order;
-
-        if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
+
+        if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeProfile", order) << endl;
         hEdgeProfile[order] = new TProfile(
-                    histo_name,
-                    histo_title,
+                    HistoName("hEdgeProfile", order),
+                    HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
                     mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
                     (-1*mPixelOverlayXaxisLeft)-0.5,                 //xlow
@@ -260,4 +213,5 @@
         hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
         //hMaxProfile->SetBit(TH2F::kCanRebin);
+        hEdgeProfile[order]->SetStats(mStats);
         hList->Add( hEdgeProfile[order] );
 
@@ -299,6 +253,4 @@
         int x_min = 0;
         int x_max = 0;
-        TString histo_name;
-        TString histo_title;
 
         for (int order =0; order < mMaxPulseOrder; order++)
@@ -310,23 +262,19 @@
             if (mOptions.Contains("S"))
             {
-
-                histo_name =    "hSlopeRisingEdge";
-                histo_name +=   mChid;
-                histo_name +=   "_";
-                histo_name +=   order;
-                histo_title =   "Distribution of rising edge's slope [Pixel_Order] ";
-                histo_title +=  mChid;
-                histo_title +=   "_";
-                histo_title +=   order;
-                if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
+                if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
                 hSlopeRisingEdge[order] = new TH1F (
-                            histo_name,
-                            histo_title,
+                            HistoName("hSlopeRisingEdge", order),
+                            HistoTitle("Distribution of rising edge's slope", order),
                             600,
                             -10.1,
                             10.1
                             );
+                hSlopeRisingEdge[order]->SetAxisRange(
+                                    -1,
+                                    7,
+                                    "X");
                 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Slope Amplitude/time [mV/timeslices]" );
                 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
+                hSlopeRisingEdge[order]->SetStats(mStats);
                 hList->Add( hSlopeRisingEdge[order] );
             }
@@ -337,22 +285,19 @@
                 x_max = 35;
 
-                histo_name =    "hRisingEdgeToMax";
-                histo_name +=   mChid;
-                histo_name +=   "_";
-                histo_name +=    order;
-                histo_title =   "Distance from rising edge to pulse's maximum [Pixel_Order] ";
-                histo_title +=  mChid;
-                histo_title +=   "_";
-                histo_title +=   order;
-                if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
+                if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hRisingEdgeToMax", order) << endl;
                 hRisingEdgeToMax[order] = new TH1I (
-                            histo_name,
-                            histo_title,
+                            HistoName("hRisingEdgeToMax", order),
+                            HistoTitle("Distance from rising edge to pulse's maximum", order),
                             x_max -x_min,
                             x_min,
                             x_max
                             );
+                hSlopeRisingEdge[order]->SetAxisRange(
+                                    -5,
+                                    25,
+                                    "X");
                 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
                 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
+                hRisingEdgeToMax[order]->SetStats(mStats);
                 hList->Add( hRisingEdgeToMax[order] );
             }
@@ -362,17 +307,8 @@
                 x_min = 10;
                 x_max = 290;
-
-                histo_name =    "hPosOfMax";
-                histo_name +=   mChid;
-                histo_name +=   "_";
-                histo_name +=   order;
-                histo_title =   "Distribution of pulse's maximum's positon [Pixel_Order] ";
-                histo_title +=  mChid;
-                histo_title +=   "_";
-                histo_title +=   order;
-                if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
+                if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPosOfMax", order) << endl;
                 hPosOfMax[order] = new TH1I (
-                            histo_name,
-                            histo_title,
+                            HistoName("hPosOfMax", order),
+                            HistoTitle("Distribution of pulse's maximum's positon", order),
                             x_max - x_min,
                             x_min,
@@ -381,4 +317,5 @@
                 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
                 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
+                hRisingEdgeToMax[order]->SetStats(mStats);
                 hList->Add( hPosOfMax[order] );
             }
@@ -571,4 +508,46 @@
 //----------------------------------------------------------------------------
 
+void
+Pixel::LoadPulseHistos(
+        TFile*      filename
+        )
+{
+    filename->cd();
+    filename->cd(CreateSubDirName( mChid ));
+    for (int order = 0; order < mMaxPulseOrder; order++)
+    {
+        hMaxOverlay[order]  = (TH2F*)filename->Get( HistoName("hMaxOverlay", order) );
+        hEdgeOverlay[order] = (TH2F*)filename->Get( HistoName("hEdgeOverlay", order) );
+        hMaxProfile[order]  = (TProfile*)filename->Get( HistoName("hMaxProfile", order) );
+        hEdgeProfile[order] = (TProfile*)filename->Get( HistoName("hEdgeProfile", order) );
+    }
+}
+
+TString
+Pixel::HistoName(
+        TString     histoname,
+        int         order
+        )
+{
+    histoname +=   mChid;
+    histoname +=   "_";
+    histoname +=   order;
+    return histoname;
+}
+
+TString
+Pixel::HistoTitle(
+        TString     histo_title,
+        int         order
+        )
+{
+    histo_title +=   " [Pixel_Order] ";
+    histo_title +=   mChid;
+    histo_title +=   "_";
+    histo_title +=   order;
+    return histo_title;
+}
+
+
 //============================= ACESS      ===================================
 //============================= INQUIRY    ===================================
