Index: fact/tools/rootmacros/PulseTemplates/FPulseOverlay.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/FPulseOverlay.C	(revision 13501)
+++ fact/tools/rootmacros/PulseTemplates/FPulseOverlay.C	(revision 13519)
@@ -27,4 +27,5 @@
 #include <TStyle.h>
 #include <TString.h>
+#include <TObjArray.h>
 
 #include <stdio.h>
@@ -185,19 +186,19 @@
 //----------------------------------------------------------------------------
 int FPulseOverlay(
-        char*           datafilename        = "../../data/2011/11/09/20111109_006.fits.gz",
+        const char*     datafilename        = "../../data/2011/11/09/20111109_006.fits.gz",
         const char*     drsfilename         = "../../data/2011/11/09/20111109_003.drs.fits.gz",
         const char*     OutRootFileName     = "../../analysis/FPulseTemplate/20111109_006/20111109_006.pulses.root",
-        bool            ProduceGraphic      = true,
+        bool            ProduceGraphic      = false,
         bool            spikeDebug          = false,
-        bool            debugPixel          = true,
+        bool            debugPixel          = false,
         bool            testmode            = false,
         bool            saveResults         = false,
-        int             verbosityLevel      = 4,        // different verbosity levels can be implemented here
-        int             firstevent          = 0,
+        int             verbosityLevel      = 6,        // different verbosity levels can be implemented here
+        int             firstevent          = 1,        // Hast to be between 1 and infinity NOT 0!!!!
         int             nevents             = 10,
         int             firstpixel          = 0,
-        int             npixel              = 80,
-        int             sampleSetSize       = 36,
-        int             maxPulseOrder       = 1,
+        int             npixel              = -1,
+        int             sampleSetSize       = 40,
+        int             maxPulseOrder       = 3,
         int             AmplWindowWidth     = 14,       //Width of Window for selection of pulses to histograms
         TString         histoOptions        = "S",
@@ -216,4 +217,8 @@
     Pixel** pixel = new Pixel*[sampleSetSize];
 
+    for (int i = 0 ; i < sampleSetSize; i++)
+    {
+        pixel[i] = NULL;
+    }
 //----------------------------------------------------------------------------
 //	Save-Root-File Settings
@@ -402,5 +407,5 @@
     {
 
-        if (verbosityLevel >= 0)
+        if (verbosityLevel == 0)
         {
             cout << "------------------------------------------------" << endl
@@ -414,13 +419,18 @@
 // Loop over every Event of Pixel Set
 //--------------------------------------------------------------------
-        for ( int ev = firstevent; ev < firstevent + nevents; ev++)
+        for ( int ev = firstevent ; ev < firstevent + nevents; ev++)
         {
             // Get an Event --> consists of 1440 Pixel ...erm....data
+            cout << endl << "processing event " << ev << endl;
             datafile->GetRow( ev );
 
-            if (verbosityLevel > 0)
+            if (verbosityLevel == 1)
             {
              cout << "-------------------------------------" << endl
-                  << "...processing Event: " << CurrentEventID
+                  << "...processing Sample from Pixel "
+                  << firstPixelOfSample
+                  << " to Pixel "
+                  << firstPixelOfSample+sampleSetSize-1
+                  << "... Event: " << CurrentEventID
                   << "/" << nevents << endl;
             }
@@ -434,8 +444,14 @@
                     pixelID++ )
             {
-                if (verbosityLevel > 0)
+                if (verbosityLevel > 1)
                 {
                  cout << "-------------------------------------" << endl
-                      << "...processing Pixel: " << pixelID
+                      << "...processing Sample from Pixel "
+                      << firstPixelOfSample
+                      << " to Pixel "
+                      << firstPixelOfSample+sampleSetSize-1
+                      << "... Event: " << CurrentEventID
+                      << "/" << nevents << endl
+                      << " Pixel: " << pixelID
                       << "/" << firstpixel + npixel -1 << endl;
                 }
@@ -456,4 +472,8 @@
                                 histoOptions
                                 );
+                    cout << "Created Pixel# Set " << pixelID
+                         << " Pixel# Get " << pixel[pixelID]->mChid
+                         << " Adress " << &pixel[pixelID] << endl;
+
                 }
 
@@ -482,4 +502,7 @@
                 // spikes are: 1 or 2 slice wide, positive non physical artifacts
                 if (verbosityLevel > 2) cout << "...removeing Spikes";
+                cout << "blaaa" << endl;
+                cout << "blaaa" << endl;
+
                 removeSpikes (Ameas, Vcorr);
                 if (verbosityLevel > 2) cout << "...done " << endl;
@@ -499,4 +522,5 @@
                 sliding_avg(Vcfd, Vcfd2, avg2);
                 if (verbosityLevel > 2) cout << "...done " << endl;
+                cout << "miauuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu" << endl;
 
 //-------------------------------------
@@ -521,14 +545,17 @@
 // Fill Overlay Histos
 //-----------------------------------------------------------------------------
-                FillHistograms(
-                            pixel[pixelID],
-                            pZXings,
-                            AmplWindowWidth,
-                            ev,
-                            histoOptions,
-                            maxPulseOrder,
-                            verbosityLevel
-                            );
-
+                cout << endl << "Filling Histograms of Pixel# [Set] " << pixelID
+                     << " Pixel# [Got] " << pixel[pixelID]->mChid
+                     << " Adress " << &pixel[pixelID] << endl;
+//                FillHistograms(
+//                            pixel[pixelID],
+//                            pZXings,
+//                            AmplWindowWidth,
+//                            ev,
+//                            histoOptions,
+//                            maxPulseOrder,
+//                            verbosityLevel
+//                            );
+                cout << endl << "got out of fillhisto" << endl;
 //-----------------------------------------------------------------------------
 // Spike Debug
@@ -577,5 +604,5 @@
                 if (breakout) break;
 
-                if (verbosityLevel > 2)
+                if (verbosityLevel > 1)
                 {
                     cout << endl << "...End of Pixel"
@@ -586,4 +613,9 @@
 // end of Loops over Sample
 //-------------------------------------
+
+            cout << endl << "Last Pixel# [Set] " << (firstPixelOfSample + sampleSetSize-1);
+            cout << " Pixel# [Got] " << pixel[firstPixelOfSample + sampleSetSize-1]->mChid
+                 << " Adress " << &pixel[firstPixelOfSample + sampleSetSize-1]
+                 << " Adress [Got]" << &pixel[firstPixelOfSample + sampleSetSize-1]->mChid;
 
         }//End of Loop over Events
@@ -626,4 +658,7 @@
 
             //Save Histograms of Pixels into Output rootfile
+            cout << endl << "Saving Pixel# [Set] " << pixelID
+                 << " Pixel# [Got] " << pixel[pixelID]->mChid
+                 << " Adress " << &pixel[pixelID];
             pixel[pixelID]->SavePixelHistograms( OutRootFileName, saveResults );
 
@@ -642,4 +677,8 @@
             }
 
+            cout << endl << "Deleting Pixel# [Set] " << pixelID
+                 << " Pixel# [Got] " << pixel[pixelID]->mChid
+                 << " Adress " << &pixel[pixelID]
+                 << " ChidAdress " << &pixel[pixelID]->mChid ;
             delete pixel[pixelID];
 
@@ -782,13 +821,14 @@
         )
 {
+    cout << endl << "begin Pixel " << CurrentPixel->mChid << endl;
     if (verbosityLevel > 2) cout << endl << "...filling pulse histograms" ;
     bool use_this_peak=false;
     int order_of_pulse=0;
     vector<Region>::iterator reg;
-
+    cout << endl << "begin for " << endl;
     //Loop over all found zerocrossings in Region
     for (reg = pZXings->begin() ; reg < pZXings->end() ; reg++)
     {
-
+    cout << endl << "for" << endl;
         //skip those who are at the Rim of the ROI
         if (reg->maxPos < 12 || (unsigned int) reg->maxPos > gRegionOfInterest-12)
@@ -797,5 +837,5 @@
             continue;
         }
-
+    cout << endl << "def" << endl;
         // Define axis range of Histogram
         int Left        = reg->maxPos - gPixelOverlayXaxisLeft;
@@ -815,5 +855,6 @@
 
         //determine order of pulse and which histogram shall be filled
-        if (verbosityLevel > 2) cout << endl << "\t...choosing Histogram" ;
+//        if (verbosityLevel > 2)
+            cout << endl << "\t...choosing Histogram" ;
         for(int order = 0; order < maxPulseOrder; order++)
         {
@@ -835,13 +876,15 @@
                 if ( histoOptions.Contains("S") )
                 {
-                     if (verbosityLevel > 2) cout << endl << "\t...filling Edge Histogram" ;
+//                     if (verbosityLevel > 2)
+                         cout << endl << "\t...filling Edge Histogram" ;
                     CurrentPixel->hSlopeRisingEdge[order]->Fill( reg->slopeOfRisingEdge ) ;
                 }
             }
         }
-
+        cout << endl << "middle" << endl;
         //Fill overlay und profile histograms
         if (use_this_peak){
-            if (verbosityLevel > 2) cout << "...filling" ;
+//            if (verbosityLevel > 2)
+                cout << "...filling" ;
             for ( int pos = Left; pos < Right; pos++){
 //                if ();
@@ -862,4 +905,5 @@
    }
     if (verbosityLevel > 2) cout << "...done" << endl;
+    cout << endl << "end" << endl;
 }
 // end of FillHistograms
@@ -992,2 +1036,11 @@
 
 }// end of if(spikeDebug)
+
+
+int main()
+{
+
+FPulseOverlay();
+return 0;
+
+}
