Changeset 13378
- Timestamp:
- 04/18/12 10:56:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/FPulseTemplate.C
r12919 r13378 30 30 #include <TStyle.h> 31 31 #include <TString.h> 32 #include <TProfile.h> 32 33 33 34 #include <stdio.h> … … 38 39 #define NCELL 1024 39 40 #define FAD_MAX_SAMPLES 1024 40 41 #define MAX_PULS_ORDER 1 41 42 #define HAVE_ZLIB 42 43 … … 67 68 68 69 bool breakout=false; 69 bool UseThisPeak=false; 70 int NEvents;70 71 int gNEvents; 71 72 vector<int16_t> AllPixelDataVector; 72 73 vector<int16_t> StartCellVector; 73 74 unsigned int CurrentEventID; 74 75 size_t PXLxROI; 75 UInt_t RegionOfInterest;76 UInt_t gRegionOfInterest; 76 77 UInt_t NumberOfPixels; 77 78 TString histotitle; … … 83 84 vector<float> drs_triggeroffsetmean; 84 85 85 vector<float> Ameas(FAD_MAX_SAMPLES); // copy of the data (measured amplitude86 vector<float> Vcorr(FAD_MAX_SAMPLES); // corrected Values86 vector<float> Ameas(FAD_MAX_SAMPLES); // copy of the data (measured amplitude 87 vector<float> Vcorr(FAD_MAX_SAMPLES); // corrected Values 87 88 vector<float> Vslide(FAD_MAX_SAMPLES); // sliding average result 88 89 vector<float> Vcfd(FAD_MAX_SAMPLES); // CDF result 89 vector<float> Vcfd2(FAD_MAX_SAMPLES); // CDF result + 2nd sliding average 90 vector<float> Vcfd2(FAD_MAX_SAMPLES); // CDF result + 2nd sliding average 91 92 float gGainMean = 9; 93 float gBSLMean = 0; 90 94 91 95 typedef struct{ … … 94 98 } OverlayMaximum; 95 99 96 typedef struct{ 97 TString name; 98 TString title; 99 TString Mname; 100 TString Mtitle; 101 float yMax; 102 } hist_t; 103 104 hist_t histSetting[4]; 105 106 vector<OverlayMaximum> SingleMaximum; 100 //typedef struct{ 101 // TString name; 102 // TString title; 103 // TString xTitle; 104 // TString yTitle; 105 // float yMax; 106 // float yMin; 107 //} histAttrib_t; 108 109 //histAttrib_t* gHistoAttrib[MAX_PULS_ORDER]; 110 //histAttrib_t* gMaximumAttrib[MAX_PULS_ORDER]; 111 //histAttrib_t* gMaxGausAttrib[MAX_PULS_ORDER]; 112 //histAttrib_t* gProfileAttrib[MAX_PULS_ORDER]; 113 114 107 115 // histograms 108 const int Number OfDebugHistoTypes = 7;116 const int Number_Of_Debug_Histo_Types = 7; 109 117 110 118 const unsigned int … … 117 125 Vcfd2_ = 6; 118 126 127 //const char* gHistoTypes[8] = { 128 // "hPixelOverlay", 129 // "hPixelMax", 130 // "hPixelEdgeOverlay", 131 // "hPixelProfile", 132 // "hAllPixelOverlay", 133 // "hAllPixelMax", 134 // "hAllPixelMaxGaus", 135 // "hAllPixelProfile" 136 //}; 137 119 138 //---------------------------------------------------------------------------- 120 139 // Initialisation of histograms 121 140 //---------------------------------------------------------------------------- 122 141 123 TH1F* h= NULL; 124 TH1F *debugHistos= NULL; 125 TH2F *hOverlayTemp = NULL; 126 TH2F *hPeakOverlay[4];//histogrammm for overlay of detected Peaks 127 TH2F *hSinglePeakOverlay;//histogrammm for overlay of detected Peaks 128 TH2F *hDoublePeakOverlay; 129 TH2F *hTripplePeakOverlay; 130 TH2F *hLargePeakOverlay; 131 132 TH1F *hMaximumTemp = NULL; 133 TH1F *hPeakMaximum[4]; 134 TH1F *hSinglePeakMaximum; 135 TH1F *hDoublePeakMaximum; 136 TH1F *hTripplePeakMaximum; 137 TH1F *hLargePeakMaximum; 138 TH1D *hProjPeak = NULL; 139 int gPeakOverlayXaxisLeft; 140 int hPeakOverlayXaxisRight; 141 142 TObjArray hList; 143 TObjArray hListBaseline; 142 // Temporary Objects 143 TH1F* debugHistos = NULL; 144 TH2F* hOverlayTemp = NULL; 145 TH1F* hMaximumTemp = NULL; 146 TH1D* hProjPeak = NULL; 147 TH1F* hTesthisto = NULL; 148 149 //Pixelwise Histograms 150 TH2F* hPixelOverlay[MAX_PULS_ORDER]= {NULL};//histogrammm for overlay of detected Peaks 151 TProfile* hPixelProfile[MAX_PULS_ORDER] = {NULL};//histogrammm for Profile of detected Peaks 152 TH1F* hPixelMax[MAX_PULS_ORDER] = {NULL}; 153 TH2F* hPixelEdgeOverlay[MAX_PULS_ORDER] = {NULL}; 154 155 //All Pixel Histograms 156 TH2F* hAllPixelOverlay[MAX_PULS_ORDER] = {NULL}; 157 TProfile* hAllPixelProfile[MAX_PULS_ORDER] = {NULL}; 158 TH1F* hAllPixelMax[MAX_PULS_ORDER] = {NULL}; 159 TH1F* hAllPixelMaxGaus[MAX_PULS_ORDER] = {NULL}; 160 161 //Histogram Parameters 162 Int_t gPixelOverlayXaxisLeft = 0; 163 Int_t gPixelOverlayXaxisRight = 0; 164 165 //Root-File Objects 166 TObjArray* hList = NULL; 167 TObjArray* hAllPixelList = NULL; 168 TObjArray* hRootList = NULL; 169 170 //Canvases 171 TCanvas* cgpPixelPulses[MAX_PULS_ORDER] = {NULL}; 172 TCanvas* cgpAllPixelPulses[MAX_PULS_ORDER] = {NULL}; 173 TCanvas* cgpTestHistos = NULL; 174 //TCanvas* gpcDevelopment = NULL; 144 175 145 176 //---------------------------------------------------------------------------- … … 147 178 //---------------------------------------------------------------------------- 148 179 149 void BookHistos( ); 150 void SaveHistograms( const char * ); 180 void BookHistos(int ); 181 void BookPixelHistos(int ); 182 void BookTestHistos( int ); 183 void DeletePixelHistos(int ); 184 void SaveHistograms( const char*, const char*, TObjArray*, int ); 185 void FillHistograms(vector<Region>*, int, int); 186 void PlotPulseShapeOfMaxPropability(unsigned int, int, int); 187 void DrawPulseHistograms(int, int); 188 void FitMaxPropabilityPuls( TH1F* , int ); 189 void DrawMaximumHistograms( int, int ); 190 void DrawTestHistograms( int); 191 192 void UpdateCanvases( int, int); 193 void DeletePixelCanvases( int ); 194 195 void CreateRootFile(const char*, int ); 196 TFile *OpenRootFile(const char*, int ); 197 void CloseRootFile(TFile *tf); 198 TString CreateSubDirName(int); //creates a String containing the path to the subdirectory in root file 199 TString CreateSubDirName(const char* ); 200 //void SetHistogrammSettings( const char*, int, int , int); 201 //void CreatePulseCanvas( TCanvas* , unsigned int, const char* , const char*, const char*, int); 202 //void DeletePulseCanvas( TCanvas* , unsigned int); 203 151 204 152 205 //---------------------------------------------------------------------------- … … 156 209 //---------------------------------------------------------------------------- 157 210 int FPulseTemplate( 158 char* datafilename = "../data/2011/11/10/20111110_005.fits.gz", 159 const char* drsfilename = "../data/2011/11/10/20111110_003.drs.fits.gz", 160 const char* OutRootFileName = "../analysis/20111110_003.test.root", 161 bool ProduceGraphic = true, 162 bool spikeDebug = false, 163 bool fitdata = false, 164 int verbosityLevel = 1, // different verbosity levels can be implemented here 165 int firstevent = 0, 166 int nevents = -1, 167 int firstpixel = 400, 168 int npixel = 1, 169 int PintervalWidth = 5, 170 int PintervalMin = 8, 171 int PintervalMax = 32, //4 Histogramms will be drawn, decide how far pulsehights differ from eachother 172 int avg1 = 14, 173 int avg2 = 8, 174 int OverlayWindowLeft = 70, 175 int OverlayWindowRight = 230) 176 { 177 //----------------------------------------------------------------------------- 178 // histogramm Settings 179 //----------------------------------------------------------------------------- 180 181 gPeakOverlayXaxisLeft = OverlayWindowLeft; 182 hPeakOverlayXaxisRight = OverlayWindowRight; 183 184 gStyle->SetPalette(1,0); 185 gROOT->SetStyle("Plain"); 186 187 // Create (pointer to) Canvases, which are used in every run, 188 // also in 'non-debug' runs 189 // Canvases only need if spike Debug, but I want to deklare 190 // the pointers anyway ... 211 char* datafilename = "../data/2011/11/09/20111109_006.fits.gz", 212 const char* drsfilename = "../data/2011/11/09/20111109_003.drs.fits.gz", 213 const char* OutRootFileName = "../analysis/FPulseTemplate/20111109_006/20111109_006.pulses.root", 214 bool ProduceGraphic = true, 215 int refresh_rate = 500, //refresh rate for canvases 216 bool spikeDebug = false, 217 bool debugPixel = true, 218 bool fitdata = false, 219 int verbosityLevel = 1, // different verbosity levels can be implemented here 220 int firstevent = 272, 221 int nevents = 500, 222 int firstpixel = 1100, 223 int npixel = 1, 224 int AmplWindowWidth = 14, //Width of Window for selection of pulses to histograms 225 float GainMean = 8, 226 float BSLMean = -1, //4 Histogramms will be drawn, decide how far pulsehights differ from eachother 227 int avg1 = 8, 228 int avg2 = 8, 229 int OverlayWindowLeft = 70, 230 int OverlayWindowRight = 230 231 ) 232 { 233 gGainMean = GainMean; 234 gBSLMean = BSLMean; 235 //---------------------------------------------------------------------------- 236 // Save-Root-File Settings 237 //---------------------------------------------------------------------------- 238 CreateRootFile( OutRootFileName, verbosityLevel ); 239 240 241 //---------------------------------------------------------------------------- 242 // root global Settings 243 //---------------------------------------------------------------------------- 244 245 gPixelOverlayXaxisLeft = OverlayWindowLeft; 246 gPixelOverlayXaxisRight = OverlayWindowRight; 247 248 gStyle->SetPalette(1,0); 249 gROOT->SetStyle("Plain"); 250 // gPad->SetGrid(); 251 252 for ( 253 int pulse_order = MAX_PULS_ORDER - 1; 254 pulse_order >= 0 ; 255 pulse_order-- 256 ) 257 { 258 TString cName ="cgpPixelPulses"; 259 cName += pulse_order; 260 TString cTitle ="Pulses of Order: "; 261 cTitle += pulse_order; 262 cgpPixelPulses[pulse_order] = new TCanvas(cName,cTitle, 0,pulse_order*20,800,800); 263 cgpPixelPulses[pulse_order]->Divide(2, 2); 264 cName = "cgpAllPixelPulses"; 265 cName += pulse_order; 266 cTitle ="AllPixel average of puls shapes of Order: "; 267 cTitle += pulse_order; 268 cgpAllPixelPulses[pulse_order] = new TCanvas( cName, cTitle, 801, pulse_order*20, 800, 800 ); 269 cgpAllPixelPulses[pulse_order]->Divide(2, 2); 270 } 271 272 // Create (pointer to) Canvases, which are used in every run, 273 // also in 'non-debug' runs 274 // Canvases only need if spike Debug, but I want to deklare 275 // the pointers anyway ... 276 191 277 TCanvas *cFiltered = NULL; 192 if (spikeDebug){ 278 if (spikeDebug) 279 { 193 280 cFiltered = new TCanvas("cFiltered","filtered DRS Waveforms", 1,310,400,300); 194 281 cFiltered->Divide(1, 3); 195 282 } 196 // Canvases to show the peak template 197 TCanvas *cPulsetypes = NULL; 198 cPulsetypes = new TCanvas("cPulsetypes", "Overlay of detected Peaks", 1, 1, 1400, 700); 199 cPulsetypes->Divide(4,2); 200 201 202 for (int stepper = 0; stepper < 4; stepper++){ 203 if (stepper == 0) histSetting[stepper].yMax = PintervalMin; 204 else if (stepper == 3) histSetting[stepper].yMax = PintervalMax; 205 else histSetting[stepper].yMax = ((PintervalMax-PintervalMin)*(stepper)/3)+PintervalMin; 206 cout << "Max @ " << histSetting[stepper].yMax << endl; 207 histSetting[stepper].name = "hPeakOverlay"; 208 histSetting[stepper].name += stepper; 209 histSetting[stepper].title = "PeakOverlay with Amplitude around "; 210 histSetting[stepper].title += histSetting[stepper].yMax; 211 histSetting[stepper].title += " mV"; 212 histSetting[stepper].Mname = "hPeakMaximum"; 213 histSetting[stepper].Mname += stepper; 214 histSetting[stepper].Mtitle = "Peak (approx) derived with Maximum of above Spektrum with Max of "; 215 histSetting[stepper].Mtitle += histSetting[stepper].yMax; 216 histSetting[stepper].Mtitle += " mV"; 217 } 218 283 284 cgpTestHistos = new TCanvas( "cgpTestHistos", "Test Histograms", 801, 0, 800, 800 ); 285 cgpTestHistos->Divide(2,0); 219 286 //----------------------------------------------------------------------------- 220 287 // Filter-Settings 221 288 //----------------------------------------------------------------------------- 222 289 // CFD filter settings 223 224 225 226 227 290 int k_cfd = 10; 291 vector<double> a_cfd(k_cfd, 0); 292 double b_cfd = 1.; 293 a_cfd[0]=-0.75; 294 a_cfd[k_cfd-1]=1.; 228 295 229 296 //----------------------------------------------------------------------------- … … 233 300 // Open the data file 234 301 235 fits * datafile; 236 // Opens the raw data file and 'binds' the variables given as 237 // Parameters to the data file. So they are filled with 238 // raw data as soon as datafile->GetRow(int) is called. 239 NEvents = openDataFits( datafilename, &datafile, 240 AllPixelDataVector, StartCellVector, CurrentEventID, 241 RegionOfInterest, NumberOfPixels, PXLxROI, verbosityLevel); 242 if (NEvents == 0){ 243 cout << "return code of OpenDataFile:" << datafilename<< endl; 244 cout << "is zero -> aborting." << endl; 245 return 1; 246 } 247 248 if (verbosityLevel > 0) 249 cout <<"number of events in file: "<< NEvents << "\t"; 250 if ( nevents == -1 || nevents > NEvents ) nevents = NEvents; // -1 means all! 251 if (verbosityLevel > 0) 252 cout <<"of, which "<< nevents << "will be processed"<< endl; 253 254 if (verbosityLevel > 0) 255 cout <<"Total # of Pixel: "<< NumberOfPixels << "\t"; 256 if ( npixel == -1 || npixel > (int)NumberOfPixels ) npixel = (int)NumberOfPixels; // -1 means all! 257 if (verbosityLevel > 0) 258 cout <<"of, which "<< npixel << "will be processed"<< endl; 259 //Get the DRS calibration 260 RC = openCalibFits( drsfilename, drs_basemean, drs_gainmean, drs_triggeroffsetmean, TriggerOffsetROI); 261 if (RC == 0){ 302 fits * datafile; 303 // Opens the raw data file and 'binds' the variables given as 304 // Parameters to the data file. So they are filled with 305 // raw data as soon as datafile->GetRow(int) is called. 306 gNEvents = openDataFits( 307 datafilename, 308 &datafile, 309 AllPixelDataVector, 310 StartCellVector, 311 CurrentEventID, 312 gRegionOfInterest, 313 NumberOfPixels, 314 PXLxROI, 315 verbosityLevel 316 ); 317 318 if (gNEvents == 0) 319 { 320 cout << "return code of OpenDataFile:" << datafilename<< endl; 321 cout << "is zero -> aborting." << endl; 322 return 1; 323 } 324 325 if (verbosityLevel > 0) 326 { 327 cout << endl <<"number of events in file: "<< gNEvents << "\t"; 328 } 329 330 if ( nevents == -1 || nevents > gNEvents ) nevents = gNEvents; // -1 means all! 331 332 if (verbosityLevel > 0) 333 { 334 cout <<"of, which "<< nevents << " will be processed"<< endl; 335 cout <<"Total # of Pixel: "<< NumberOfPixels << "\t"; 336 } 337 338 if ( npixel == -1 || npixel > (int)NumberOfPixels ) npixel = (int)NumberOfPixels; // -1 means all! 339 340 if (verbosityLevel > 0) 341 { 342 cout <<"of, which "<< npixel << " will be processed"<< endl; 343 } 344 345 //Get the DRS calibration 346 RC = openCalibFits( drsfilename, drs_basemean, drs_gainmean, drs_triggeroffsetmean, TriggerOffsetROI); 347 if (RC == 0) 348 { 262 349 cout << "return code of openCalibFits:" << drsfilename << endl; 263 350 cout << "is zero -> aborting." << endl; 264 351 return 1; 265 } 266 // Book the histograms 267 BookHistos( ); 268 269 //----------------------------------------------------------------------------- 270 // Loops over Every Event and Pixel 271 //----------------------------------------------------------------------------- 272 for ( int ev = firstevent; ev < firstevent + nevents; ev++) { 273 // Get an Event --> consists of 1440 Pixel ...erm....data 274 datafile->GetRow( ev ); 275 276 //------------------------------------- 277 // Loop over every Pixel of Event 278 //------------------------------------- 279 280 for ( int pix = firstpixel; pix < firstpixel + npixel; pix++ ){ 281 if (verbosityLevel > 0){ 282 cout << endl; 283 if (pix == firstpixel){ 284 cout << "...processing Event: " << CurrentEventID << "/" << nevents << endl; 285 } 352 } 353 354 // Book the histograms 355 BookHistos(verbosityLevel ); 356 BookTestHistos( verbosityLevel ); 357 //------------------------------------- 358 // Loop over every Pixel 359 //------------------------------------- 360 for ( int pixel = firstpixel; pixel < firstpixel + npixel; pixel++ ) 361 { 362 if (verbosityLevel > 0) 363 { 364 cout << "------------------------------------------------" << endl 365 << "...processing Pixel: " << pixel << endl; 366 } 367 368 BookPixelHistos(verbosityLevel ); 369 370 //-------------------------------------------------------------------- 371 // Loops over Every Event of Pixel 372 //-------------------------------------------------------------------- 373 for ( int ev = firstevent; ev < firstevent + nevents; ev++) 374 { 375 // Get an Event --> consists of 1440 Pixel ...erm....data 376 datafile->GetRow( ev ); 377 378 if (verbosityLevel > 0) 379 { 380 cout << "-------------------------------------" << endl 381 << "...processing Event: " << CurrentEventID 382 << "/" << nevents << " of Pixel: " << pixel << endl; 286 383 } 287 384 288 385 //------------------------------------- 386 // Apply Calibration 387 //------------------------------------- 388 if (verbosityLevel > 2) cout << "...applying DrsCalibration"; 389 applyDrsCalibration( 390 Ameas, 391 pixel, 392 12, 393 12, 394 drs_basemean, 395 drs_gainmean, 396 drs_triggeroffsetmean, 397 gRegionOfInterest, 398 AllPixelDataVector, 399 StartCellVector 400 ); 401 if (verbosityLevel > 2) cout << "...done " << endl; 402 403 //------------------------------------- 289 404 // Apply Filters 290 405 //------------------------------------- 291 cout << "...applying DrsCalibration"; 292 applyDrsCalibration( Ameas,pix,12,12, 293 drs_basemean, drs_gainmean, drs_triggeroffsetmean, 294 RegionOfInterest, AllPixelDataVector, StartCellVector); 295 cout << "...done " << endl; 296 297 // finds spikes in the raw data, and interpolates the value 298 // spikes are: 1 or 2 slice wide, positive non physical artifacts 299 cout << "...removeing Spikes"; 300 removeSpikes (Ameas, Vcorr); 301 cout << "...done " << endl; 302 // filter Vcorr with sliding average using FIR filter function 303 cout << "...applying sliding average filter"; 304 sliding_avg(Vcorr, Vslide, avg1); 305 cout << "...done " << endl; 306 // filter Vslide with CFD using FIR filter function 307 cout << "...apllying factfir filter"; 308 factfir(b_cfd , a_cfd, k_cfd, Vslide, Vcfd); 309 cout << "...done " << endl; 310 // filter Vcfd with sliding average using FIR filter function 311 cout << "...applying 2nd sliding average filter"; 312 sliding_avg(Vcfd, Vcfd2, avg2); 313 cout << "...done " << endl; 406 // finds spikes in the raw data, and interpolates the value 407 // spikes are: 1 or 2 slice wide, positive non physical artifacts 408 if (verbosityLevel > 2) cout << "...removeing Spikes"; 409 removeSpikes (Ameas, Vcorr); 410 if (verbosityLevel > 2) cout << "...done " << endl; 411 412 // filter Vcorr with sliding average using FIR filter function 413 if (verbosityLevel > 2) cout << "...applying sliding average filter"; 414 sliding_avg(Vcorr, Vslide, avg1); 415 if (verbosityLevel > 2) cout << "...done " << endl; 416 417 // filter Vslide with CFD using FIR filter function 418 if (verbosityLevel > 2) cout << "...apllying factfir filter"; 419 factfir(b_cfd , a_cfd, k_cfd, Vslide, Vcfd); 420 if (verbosityLevel > 2) cout << "...done " << endl; 421 422 // filter Vcfd with sliding average using FIR filter function 423 if (verbosityLevel > 2) cout << "...applying 2nd sliding average filter"; 424 sliding_avg(Vcfd, Vcfd2, avg2); 425 if (verbosityLevel > 2) cout << "...done " << endl; 314 426 315 427 //------------------------------------- 316 428 // Search vor Zero crossings 317 429 //------------------------------------- 318 // peaks in Ameas[] are found by searching for zero crossings 319 // in Vcfd2 320 // first Argument 1 means ... *rising* edge 321 // second Argument 1 means ... search with stepsize 1 ... 10 is okay as well 322 vector<Region> * zXings = zerosearch( Vcfd2 , 1 , 8); 323 // zXings means "zero cross ings" 324 EnlargeRegion(*zXings, 10, 10); 325 findAbsMaxInRegions(*zXings, Vslide); 326 removeMaximaBelow( *zXings, 3.0); 327 removeRegionWithMaxOnEdge( *zXings, 2); 328 removeRegionOnFallingEdge( *zXings, 100); 430 if (verbosityLevel > 2) cout << endl << "...searching zero crossings" ; 431 // peaks in Ameas[] are found by searching for zero crossings 432 // in Vcfd2 433 // first Argument 1 means ... *rising* edge 434 // second Argument 1 means ... search with stepsize 1 ... 10 is okay as well 435 vector<Region>* pZXings = zerosearch( Vcfd2 , 1 , 8); 436 // pZXings means "zero cross ings" 437 EnlargeRegion(*pZXings, 10, 10); 438 findAbsMaxInRegions(*pZXings, Vslide); 439 removeMaximaBelow( *pZXings, 3.0); 440 removeRegionWithMaxOnEdge( *pZXings, 2); 441 removeRegionOnFallingEdge( *pZXings, 100); 442 findTimeOfHalfMaxLeft(*pZXings, Vslide, gBSLMean, 5, 10, verbosityLevel ); 443 if (verbosityLevel > 2) cout << "...done" << endl; 329 444 330 445 //----------------------------------------------------------------------------- 331 446 // Fill Overlay Histos 332 447 //----------------------------------------------------------------------------- 333 vector<Region>::iterator it; 334 for (it = zXings->begin() ; it < zXings->end() ; it++){ 335 if (it->maxPos < 12 || it->maxPos > RegionOfInterest-12) 336 continue; 337 //domstest->Fill(it->maxPos); 338 int Left = it->maxPos - OverlayWindowLeft; 339 int Right = it->maxPos + OverlayWindowRight; 340 if (Left < 0) 341 Left =0; 342 if (Right > (int)Vcorr.size() ) 343 Right=Vcorr.size() ; 344 345 cout << "...choosing Histogram" ; 346 for(int stepper = 0; stepper < 4; stepper++){ 347 if (Vslide[it->maxPos] >= (histSetting[stepper].yMax - (PintervalWidth/2)) && Vslide[it->maxPos] < (histSetting[stepper].yMax + PintervalWidth/2)){ 348 hOverlayTemp = hPeakOverlay[stepper]; 349 cout << "...#" << stepper ; 350 UseThisPeak = true; 351 break; 352 } 353 else if (stepper > 2){ 354 UseThisPeak = false; 355 cout << "...NONE" << endl ; 356 } 357 } 358 359 // if (Vslide[it->maxPos] >= 5 && Vslide[it->maxPos] < 13) hOverlayTemp = &*hSinglePeakOverlay; 360 // else if (Vslide[it->maxPos] >= 13 && Vslide[it->maxPos] < 23) hOverlayTemp = hDoublePeakOverlay; 361 // else if (Vslide[it->maxPos] >= 23 && Vslide[it->maxPos] < 33) hOverlayTemp = hTripplePeakOverlay; 362 // else if (Vslide[it->maxPos] >= 33) hOverlayTemp = hLargePeakOverlay; 363 if (UseThisPeak){ 364 cout << "...filling" ; 365 for ( int pos = Left; pos < Right; pos++){ 366 // if (Vslide[it->maxPos] >= 5 && Vslide[it->maxPos] < 15) hSinglePeakOverlay->Fill( pos - (it->maxPos), Vslide[pos]); 367 // else if (Vslide[it->maxPos] >= 15 && Vslide[it->maxPos] < 25) hDoublePeakOverlay->Fill( pos - (it->maxPos), Vslide[pos]); 368 // else if (Vslide[it->maxPos] >= 25 && Vslide[it->maxPos] < 35) hTripplePeakOverlay->Fill( pos - (it->maxPos), Vslide[pos]); 369 // else if (Vslide[it->maxPos] >= 35) hOverlayTemp = hLargePeakOverlay; 370 371 hOverlayTemp->Fill( pos - (it->maxPos), Vslide[pos]) ; 372 } 373 cout << "...done" << endl; 374 } 375 376 } 448 FillHistograms(pZXings, AmplWindowWidth, verbosityLevel ); 377 449 378 450 //----------------------------------------------------------------------------- 379 451 // Spike Debug 380 452 //----------------------------------------------------------------------------- 381 if ( spikeDebug ){ 382 // TODO do this correct. The vectors should be the rigt ones... this is just luck 383 debugHistos[Ameas_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 384 debugHistos[Vcorr_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 385 debugHistos[Vslide_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 386 debugHistos[Vcfd_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 387 debugHistos[Vcfd2_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 388 389 for ( unsigned int sl = 0; sl < RegionOfInterest; sl++){ 453 if ( spikeDebug ) 454 { 455 // TODO do this correct. The vectors should be the rigt ones... this is just luck 456 debugHistos[Ameas_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 457 debugHistos[Vcorr_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 458 debugHistos[Vslide_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 459 debugHistos[Vcfd_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 460 debugHistos[Vcfd2_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 461 462 for ( unsigned int sl = 0; sl < gRegionOfInterest; sl++) 463 { 390 464 debugHistos[Ameas_].SetBinContent(sl, Ameas[sl]); 391 465 debugHistos[Vcorr_].SetBinContent(sl, Vcorr[sl]); … … 393 467 debugHistos[Vcfd_].SetBinContent( sl, Vcfd[sl] ); 394 468 debugHistos[Vcfd2_].SetBinContent( sl, Vcfd2[sl] ); 469 } 470 471 472 cFiltered->cd(1); 473 gPad->SetGrid(); 474 debugHistos[Ameas_].Draw(); 475 476 cFiltered->cd(2); 477 gPad->SetGrid(); 478 debugHistos[Vcorr_].Draw(); 479 480 cFiltered->cd(3); 481 gPad->SetGrid(); 482 debugHistos[Vslide_].Draw(); 483 484 TBox *OneBox; 485 vector<TBox*> MyBoxes; 486 for (unsigned int i=0; i<pZXings->size(); i++){ 487 OneBox = new TBox( 488 pZXings->at(i).maxPos -10 , 489 pZXings->at(i).maxVal -0.5, 490 pZXings->at(i).maxPos +10 , 491 pZXings->at(i).maxVal +0.5); 492 OneBox->SetLineColor(kBlue); 493 OneBox->SetLineWidth(1); 494 OneBox->SetFillStyle(0); 495 OneBox->SetFillColor(kRed); 496 MyBoxes.push_back(OneBox); 497 OneBox->Draw(); 498 } 499 500 // cFiltered->cd(3); 501 // gPad->SetGrid(); 502 // debugHistos[Vcfd2_].Draw(); 503 // TLine *zeroline = new TLine(0, 0, 1024, 0); 504 // zeroline->SetLineColor(kBlue); 505 // zeroline->Draw(); 506 507 cFiltered->Update(); 508 509 510 //Process gui events asynchronously during input 511 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); 512 timer.TurnOn(); 513 TString input = Getline("Type 'q' to exit, <return> to go on: "); 514 timer.TurnOff(); 515 if (input=="q\n") { 516 breakout=true; 517 } 518 519 //TODO!!!!!!!!! 520 // do some Garbage collection ... 521 // all the Objects on the heap should be deleted here. 522 523 }// end of if(spikeDebug) 524 525 delete pZXings; 526 if (breakout) break; 527 //------------------------------------- 528 // Draw 1. Set of Pixel Histograms 529 //------------------------------------- 530 if ((ev % refresh_rate) == 0) 531 { 532 DrawPulseHistograms( 533 verbosityLevel, 534 MAX_PULS_ORDER 535 ); 536 DrawTestHistograms( 537 verbosityLevel 538 ); 539 if (ProduceGraphic) 540 { 541 UpdateCanvases( 542 verbosityLevel, 543 MAX_PULS_ORDER 544 ); 545 } 546 } 547 548 if (breakout) break; 549 550 if (verbosityLevel > 2) 551 { 552 cout << endl << "-------------------------------------"<< endl; 553 } 554 }//End of Loop over Events 555 //------------------------------------- 556 // end of Loops over Events 557 //------------------------------------- 558 559 //------------------------------------- 560 // Histogramms of Maximas in Overlay Spectra 561 //------------------------------------- 562 563 PlotPulseShapeOfMaxPropability( 564 MAX_PULS_ORDER, 565 fitdata, 566 verbosityLevel 567 ); 568 569 570 if (verbosityLevel > 2) cout << "...done" << endl; 571 //here is what happends at the end of each loop over all pixels 572 //Save Histograms of Pixel into Output rootfile 573 DrawPulseHistograms( 574 verbosityLevel, 575 MAX_PULS_ORDER 576 ); 577 578 DrawMaximumHistograms( 579 verbosityLevel, 580 MAX_PULS_ORDER 581 ); 582 583 if (ProduceGraphic) 584 { 585 UpdateCanvases( 586 verbosityLevel, 587 MAX_PULS_ORDER 588 ); 589 } 590 591 // SaveHistograms( 592 // OutRootFileName, 593 // CreateSubDirName(pixel), 594 // hList, 595 // verbosityLevel 596 // ); 597 598 if (debugPixel) 599 { 600 //Process gui events asynchronously during input 601 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); 602 timer.TurnOn(); 603 TString input = Getline("Type 'q' to exit, <return> to go on: "); 604 timer.TurnOff(); 605 if (input=="q\n") { 606 break; 607 } 608 } 609 610 DeletePixelHistos(verbosityLevel); 611 612 if (verbosityLevel > 2) 613 { 614 cout << endl << "...End of Pixel" 615 << endl << "------------------------------------------------" 616 << endl; 617 } 618 } 619 // End of Loop over all Pixels 620 621 //------------------------------------- 622 // Draw Histograms 623 //------------------------------------- 624 625 SaveHistograms( //save histograms of all pixel into output root file 626 OutRootFileName, 627 CreateSubDirName("All"), 628 hAllPixelList, 629 verbosityLevel 630 ); 631 632 // SaveHistograms( //save histograms of generell results into output root file 633 // OutRootFileName, 634 // "root", 635 // hRootList, 636 // verbosityLevel 637 // ); 638 639 640 641 if (ProduceGraphic) 642 { 643 UpdateCanvases( 644 verbosityLevel, 645 MAX_PULS_ORDER 646 ); 647 } 648 649 DeletePixelCanvases( verbosityLevel ); 650 return( 0 ); 651 } 652 //---------------------------------------------------------------------------- 653 // end of main function 654 //----------------------------------------------------------------------------- 655 656 657 658 659 //----------------------------------------------------------------------------- 660 // Funktions 661 //----------------------------------------------------------------------------- 662 663 664 void BookPixelHistos( int verbosityLevel) 665 { 666 if (verbosityLevel > 2) cout << endl << "...book pixel histograms" << endl; 667 hList = new TObjArray; 668 TString histoname; 669 for (int order = 0; order < MAX_PULS_ORDER; order ++) 670 { 671 // SetHistogramAttributes( 672 // "PeakOverlay", 673 // order, 674 // gOverlayAttrib, 675 // MaxAmplOfFirstPulse 676 // ); 677 histoname = "hPixelOverlay"; 678 histoname += order; 679 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 680 hPixelOverlay[order] = new TH2F( 681 histoname, 682 "Overlay of detected pulses of one pulse order for one Pixel", 683 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight , 684 (-1*gPixelOverlayXaxisLeft)-0.5, 685 gPixelOverlayXaxisRight-0.5 , 686 512, 687 -55.5, 688 300.5 689 ); 690 hPixelOverlay[order]->SetAxisRange( 691 gBSLMean - 5, 692 (gGainMean*(order+1)) + 10, 693 "Y"); 694 hPixelOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 695 hPixelOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 696 //hPixelProfile->SetBit(TH2F::kCanRebin); 697 hList->Add( hPixelOverlay[order] ); 698 699 //------------------------------------------------------------------------ 700 // SetHistogramAttributes( 701 // "PeakMaximum", 702 // order, 703 // gMaximumAttrib, 704 // MaxAmplOfFirstPulse 705 // ); 706 histoname = "hPixelMax"; 707 histoname += order; 708 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 709 hPixelMax[order] = new TH1F( 710 histoname, 711 "Maximum value of each slice in overlay plot", 712 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight , 713 (-1*gPixelOverlayXaxisLeft)-0.5, 714 gPixelOverlayXaxisRight-0.5 715 ); 716 hPixelMax[order]->SetAxisRange( 717 gBSLMean - 5, 718 (gGainMean*(order+1)) + 10, 719 "Y"); 720 hPixelMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 721 hPixelMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 722 hList->Add( hPixelMax[order] ); 723 724 //------------------------------------------------------------------------ 725 // SetHistogramAttributes( 726 // "PeakMaxGaus", 727 // order, 728 // gMaxGausAttrib, 729 // MaxAmplOfFirstPulse 730 // ); 731 histoname = "hPixelEdgeOverlay"; 732 histoname += order; 733 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 734 hPixelEdgeOverlay[order] = new TH2F( 735 histoname, 736 "Overlay at rising edge of detected pulses of one pulse order for one Pixel ", 737 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight , 738 (-1*gPixelOverlayXaxisLeft)-0.5, 739 gPixelOverlayXaxisRight-0.5 , 740 512, 741 -55.5, 742 300.5 743 ); 744 745 hPixelEdgeOverlay[order]->SetAxisRange( 746 gBSLMean - 5, 747 (gGainMean*(order+1)) + 10, 748 "Y"); 749 hPixelEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 750 hPixelEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 751 hList->Add( hPixelEdgeOverlay[order] ); 752 753 //------------------------------------------------------------------------ 754 // SetHistogramAttributes( 755 // "PeakProfile", 756 // order, 757 // gProfileAttrib, 758 // MaxAmplOfFirstPulse 759 // ); 760 histoname = "hPixelProfile"; 761 histoname += order; 762 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 763 hPixelProfile[order] = new TProfile( 764 histoname, 765 "Mean value of each slice in overlay plot (Tprofile)", 766 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight ,//nbinsx 767 (-1*gPixelOverlayXaxisLeft)-0.5, //xlow 768 gPixelOverlayXaxisRight-0.5 , //xup 769 // 512, //nbinsy 770 -55.5, //ylow 771 300.5, //yup 772 "s"); //option 773 hPixelMax[order]->SetAxisRange( 774 gBSLMean - 5, 775 (gGainMean*(order+1)) + 10, 776 "Y"); 777 hPixelProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 778 hPixelProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 779 //hPixelProfile->SetBit(TH2F::kCanRebin); 780 hList->Add( hPixelProfile[order] ); 781 } 782 if (verbosityLevel > 2) cout << "...done" << endl; 783 } 784 //end of BookPixelHistos 785 //---------------------------------------------------------------------------- 786 787 788 void DeletePixelHistos( int verbosityLevel ) 789 { 790 if (verbosityLevel > 2) cout << endl << "...delete current pixel histograms" ; 791 for (int order = 0; order < MAX_PULS_ORDER; order ++) 792 { 793 if (verbosityLevel > 3) cout << endl << "...deleting hPixelOverlay" << order; 794 delete hPixelOverlay[order]; 795 if (verbosityLevel > 3) cout << endl << "...deleting hPixelMax" << order; 796 delete hPixelMax[order]; 797 if (verbosityLevel > 3) cout << endl << "...deleting hPixelEdgeOverlay" << order; 798 delete hPixelEdgeOverlay[order]; 799 if (verbosityLevel > 3) cout << endl << "...deleting hPixelProfile" << order; 800 delete hPixelProfile[order]; 801 } 802 if (verbosityLevel > 3) cout << endl << "...deleting hList"; 803 delete hList; 804 if (verbosityLevel > 2) cout << endl << "...done" << endl; 805 } 806 //end of DeletePixelHistos 807 //---------------------------------------------------------------------------- 808 809 void BookTestHistos( int verbosityLevel ) 810 { 811 if (verbosityLevel > 2) cout << endl << "...book pixel histograms" << endl; 812 813 hTesthisto = new TH1F ( 814 "hTesthisto", 815 "Deviation of rising edge and maximum", 816 200, 817 -300, 818 300 819 ); 820 hTesthisto->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 821 hTesthisto->GetYaxis()->SetTitle( "counts" ); 822 823 if (verbosityLevel > 2) cout << "...done" << endl; 824 } 825 //end of BookTestHistos 826 //---------------------------------------------------------------------------- 827 828 void BookHistos( int verbosityLevel ) 829 { 830 if (verbosityLevel > 2) cout << endl << "...book histograms" << endl; 831 hAllPixelList = new TObjArray; 832 hRootList = new TObjArray; 833 debugHistos = new TH1F[ Number_Of_Debug_Histo_Types ]; 834 for ( int type = 0; type < Number_Of_Debug_Histo_Types; type++){ 835 debugHistos[ type ].SetBins(1024, 0, 1024); 836 debugHistos[ type ].SetLineColor(1); 837 debugHistos[ type ].SetLineWidth(2); 838 debugHistos[ type ].SetStats(false); 839 840 // set X axis paras 841 debugHistos[ type ].GetXaxis()->SetLabelSize(0.08); 842 debugHistos[ type ].GetXaxis()->SetTitleSize(0.08); 843 debugHistos[ type ].GetXaxis()->SetTitleOffset(1.0); 844 debugHistos[ type ].GetXaxis()->SetTitle(Form("Time slice [%.1f ns/slice]", 1./2.)); 845 846 // set Y axis paras 847 debugHistos[ type ].GetYaxis()->SetLabelSize(0.08); 848 debugHistos[ type ].GetYaxis()->SetTitleSize(0.08); 849 debugHistos[ type ].GetYaxis()->SetTitleOffset(0.3); 850 debugHistos[ type ].GetYaxis()->SetTitle("Amplitude [mV]"); 851 } 852 853 // All Pixel Histograms 854 //------------------------------------------------------------------------ 855 TString histoname; 856 for (int order = 0; order < MAX_PULS_ORDER; order ++) 857 { 858 // SetHistogramAttributes( 859 // "AllPixelPeakOverlay", 860 // order, 861 // gOverlayAttrib, 862 // MaxAmplOfFirstPulse 863 // ); 864 histoname = "hAllPixelOverlay"; 865 histoname += order; 866 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 867 hAllPixelOverlay[order] = new TH2F( 868 histoname, 869 "Overlay of detected Pulses of one Order for All Pixels", 870 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight , 871 (-1*gPixelOverlayXaxisLeft)-0.5, 872 gPixelOverlayXaxisRight-0.5 , 873 512, 874 -55.5, 875 300.5 876 ); 877 hAllPixelOverlay[order]->SetAxisRange( 878 gBSLMean - 5, 879 (gGainMean*(order+1)) + 10, 880 "Y"); 881 hAllPixelOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 882 hAllPixelOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 883 //hAllPixelOverlay->SetBit(TH2F::kCanRebin); 884 hAllPixelList->Add( hAllPixelOverlay[order] ); 885 886 //------------------------------------------------------------------------ 887 888 // SetHistogramAttributes( 889 // "AllPixelPeakMax", 890 // order, 891 // gMaximumAttrib, 892 // MaxAmplOfFirstPulse 893 // ); 894 histoname = "hAllPixelMax"; 895 histoname += order; 896 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 897 hAllPixelMax[order] = new TH1F( 898 histoname, 899 "Maximum value of each slice in overlay plot for All Pixels", 900 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight , 901 (-1*gPixelOverlayXaxisLeft)-0.5, 902 gPixelOverlayXaxisRight-0.5 903 ); 904 hAllPixelMax[order]->SetAxisRange( 905 gBSLMean - 5, 906 (gGainMean*(order+1)) + 10, 907 "Y"); 908 hAllPixelMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 909 hAllPixelMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 910 hAllPixelList->Add( hAllPixelMax[order] ); 911 912 //------------------------------------------------------------------------ 913 // SetHistogramAttributes( 914 // "AllPixelPeakMaxGaus", 915 // order, 916 // gMaxGausAttrib, 917 // MaxAmplOfFirstPulse 918 // ); 919 histoname = "hAllPixelMaxGaus"; 920 histoname += order; 921 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 922 hAllPixelMaxGaus[order] = new TH1F( 923 histoname, 924 "Mean value of each slice in overlay plot for All Pixels", 925 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight , 926 (-1*gPixelOverlayXaxisLeft)-0.5, 927 gPixelOverlayXaxisRight-0.5 928 ); 929 hAllPixelMaxGaus[order]->SetAxisRange( 930 gBSLMean - 5, 931 (gGainMean*(order+1)) + 10, 932 "Y"); 933 hAllPixelMaxGaus[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 934 hAllPixelMaxGaus[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 935 hAllPixelList->Add( hAllPixelMaxGaus[order] ); 936 937 //------------------------------------------------------------------------ 938 // SetHistogramAttributes( 939 // "AllPixelPeakProfile", 940 // order, 941 // gProfileAttrib, 942 // MaxAmplOfFirstPulse 943 // ); 944 histoname = "hAllPixelProfile"; 945 histoname += order; 946 if (verbosityLevel > 3) cout << "...booking " << histoname << endl; 947 hAllPixelProfile[order] = new TProfile( 948 histoname, 949 "Mean value of each slice in overlay plot for All Pixels (Tprofile)", 950 gPixelOverlayXaxisLeft + gPixelOverlayXaxisRight ,//nbinsx 951 (-1*gPixelOverlayXaxisLeft)-0.5, //xlow 952 gPixelOverlayXaxisRight-0.5 , //xup 953 // 512, //nbinsy 954 -55.5, //ylow 955 300.5, //yup 956 "s"); //option 957 hAllPixelProfile[order]->SetAxisRange( 958 gBSLMean - 5, 959 (gGainMean*(order+1)) + 10, 960 "Y"); 961 hAllPixelProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 962 hAllPixelProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); 963 //hPixelProfile->SetBit(TH2F::kCanRebin); 964 hAllPixelList->Add( hAllPixelProfile[order] ); 965 966 967 968 }//end of for over order 969 if (verbosityLevel > 2) cout << "...done" << endl; 970 } 971 // end of BookHistos 972 //---------------------------------------------------------------------------- 973 974 975 void CreateRootFile(const char * loc_fname, int verbosityLevel) 976 { 977 TFile* tf = new TFile(loc_fname,"UPDATE"); 978 if (tf->IsZombie()) 979 { 980 cout << "Error opening file" << endl; 981 exit(-1); 982 } 983 else { 984 if (verbosityLevel > 1) cout << "creating root-file successfull" << endl; 985 tf->Close(); 986 } 987 } 988 //end of CreateRootFile 989 //---------------------------------------------------------------------------- 990 991 992 TFile* OpenRootFile(const char * loc_fname, int verbosityLevel) 993 { 994 TFile* tf = new TFile(loc_fname,"UPDATE"); 995 if (tf->IsZombie()) 996 { 997 cout << "Error opening file" << endl; 998 exit(-1); 999 } 1000 else { 1001 if (verbosityLevel > 1) cout << "...opening root-file:" 1002 << loc_fname 1003 << " successfull" << endl; 1004 } 1005 return tf; 1006 } 1007 //end of OpenRootFile 1008 //---------------------------------------------------------------------------- 1009 1010 1011 void CloseRootFile(TFile* tf) 1012 { 1013 if (tf->IsZombie()) 1014 { 1015 cout << "Error closing file" << endl; 1016 exit(-1); 1017 } else { 1018 tf->Close(); 1019 } 1020 } 1021 //end of CloseRootFile 1022 //---------------------------------------------------------------------------- 1023 1024 1025 void SaveHistograms( 1026 const char* loc_fname, 1027 const char* subdirectory, 1028 TObjArray* histList, 1029 int verbosityLevel 1030 ) 1031 { 1032 if (verbosityLevel > 2) cout << endl 1033 << "...saving pixel histograms to subdirectory: " 1034 << subdirectory << endl ; 1035 1036 TFile* tf = OpenRootFile(loc_fname, verbosityLevel); 1037 if ( subdirectory != "root") 1038 { 1039 tf->cd(); 1040 tf->mkdir(subdirectory,subdirectory); 1041 tf->cd(subdirectory); 1042 } 1043 else 1044 { 1045 tf->cd(); 1046 } 1047 histList->Write(); // write the major histograms into the top level directory 1048 if (verbosityLevel > 3) tf->ls(); 1049 CloseRootFile( tf ); // close the file 1050 if (verbosityLevel > 2) cout << "...done" << endl; 1051 } 1052 // end of SaveHistograms 1053 //---------------------------------------------------------------------------- 1054 1055 1056 TString CreateSubDirName(int pixel) 1057 { 1058 TString path = "Pixel_"; 1059 path += pixel; 1060 // cout << "path " << path << endl ; 1061 return path; 1062 } 1063 // end of CreateSubDirName 1064 //---------------------------------------------------------------------------- 1065 1066 TString CreateSubDirName(const char* title) 1067 { 1068 TString path = title; 1069 path += "_Pixel"; 1070 // cout << "path " << path << endl ; 1071 return path; 1072 } 1073 // end of CreateSubDirName 1074 //---------------------------------------------------------------------------- 1075 1076 void FillHistograms( 1077 vector<Region>* pZXings, 1078 int AmplWindowWidth, 1079 int verbosityLevel 1080 ) 1081 { 1082 if (verbosityLevel > 2) cout << endl << "...filling pulse histograms" ; 1083 bool use_this_peak=false; 1084 int order_of_pulse=0; 1085 vector<Region>::iterator reg; 1086 1087 //Loop over all found zerocrossings in Region 1088 for (reg = pZXings->begin() ; reg < pZXings->end() ; reg++) 1089 { 1090 //skip those who are at the Rim of the ROI 1091 if (reg->maxPos < 12 || (unsigned int) reg->maxPos > gRegionOfInterest-12) 1092 { 1093 if (verbosityLevel > 2) cout << endl << "\t...out of range" << endl; 1094 continue; 1095 } 1096 //domstest->Fill(reg->maxPos); 1097 1098 // Define axis range of Histogram 1099 int Left = reg->maxPos - gPixelOverlayXaxisLeft; 1100 int Right = reg->maxPos + gPixelOverlayXaxisRight; 1101 int EdgeLeft = reg->halfRisingEdgePos - gPixelOverlayXaxisLeft; 1102 int EdgeRight = reg->halfRisingEdgePos + gPixelOverlayXaxisRight; 1103 1104 if (Left < 0) Left =0; 1105 if (Right > (int)Vcorr.size() ) Right=Vcorr.size() ; 1106 1107 hTesthisto->Fill( reg->maxPos - reg->halfRisingEdgePos ) ; 1108 1109 if (verbosityLevel > 2) cout << endl << "\t...choosing Histogram" ; 1110 1111 //determine order of pulse and which histogram shall be filled 1112 if (verbosityLevel > 2) cout << endl << "\t...choosing Histogram" ; 1113 for(int order = 0; order < MAX_PULS_ORDER; order++) 1114 { 1115 if (Ameas[reg->maxPos] >= ((gGainMean*(order+1)) - (AmplWindowWidth/2)) 1116 && Ameas[reg->maxPos] < ((gGainMean*(order+1)) + AmplWindowWidth/2)) 1117 { 1118 //hOverlayTemp = hPixelOverlay[order]; 1119 if (verbosityLevel > 2) cout << "...#" << order ; 1120 order_of_pulse = order; 1121 use_this_peak = true; 1122 break; 1123 } 1124 else if (order >= (MAX_PULS_ORDER - 1)){ 1125 use_this_peak = false; 1126 if (verbosityLevel > 2) cout << "...NONE" << endl ; 395 1127 } 396 397 398 cFiltered->cd(1);399 gPad->SetGrid();400 debugHistos[Vcorr_].Draw();401 402 cFiltered->cd(2);403 gPad->SetGrid();404 debugHistos[Vslide_].Draw();405 406 TBox *OneBox;407 vector<TBox*> MyBoxes;408 for (unsigned int i=0; i<zXings->size(); i++){409 OneBox = new TBox(410 zXings->at(i).maxPos -10 ,411 zXings->at(i).maxVal -0.5,412 zXings->at(i).maxPos +10 ,413 zXings->at(i).maxVal +0.5);414 OneBox->SetLineColor(kBlue);415 OneBox->SetLineWidth(1);416 OneBox->SetFillStyle(0);417 OneBox->SetFillColor(kRed);418 MyBoxes.push_back(OneBox);419 OneBox->Draw();420 }421 422 cFiltered->cd(3);423 gPad->SetGrid();424 debugHistos[Vcfd2_].Draw();425 TLine *zeroline = new TLine(0, 0, 1024, 0);426 zeroline->SetLineColor(kBlue);427 zeroline->Draw();428 429 cFiltered->Update();430 431 //OVERLAY PEAKS432 for(int stepper = 0; stepper < 4; stepper++){433 cPulsetypes->cd(stepper+1);434 gPad->SetGrid();435 hPeakOverlay[stepper]->Draw("COLZ");436 }437 438 439 // cPulsetypes->cd(1);440 // gPad->SetGrid();441 // hSinglePeakOverlay->Draw("COLZ");442 //443 // cPulsetypes->cd(2);444 // gPad->SetGrid();445 // hDoublePeakOverlay->Draw("COLZ");446 //447 // cPulsetypes->cd(3);448 // gPad->SetGrid();449 // hTripplePeakOverlay->Draw("COLZ");450 //451 // cPulsetypes->cd(4);452 // gPad->SetGrid();453 // hLargePeakOverlay->Draw("COLZ");454 455 cPulsetypes->Modified();456 cPulsetypes->Update();457 458 //Process gui events asynchronously during input459 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);460 timer.TurnOn();461 TString input = Getline("Type 'q' to exit, <return> to go on: ");462 timer.TurnOff();463 if (input=="q\n") {464 breakout=true;465 }466 467 //TODO!!!!!!!!!468 // do some Garbage collection ...469 // all the Objects on the heap should be deleted here.470 471 }// end of if(spikeDebug)472 473 delete zXings;474 if (breakout)475 break;476 477 }478 //-------------------------------------479 // end of loop over pixels480 //-------------------------------------481 if (ProduceGraphic){482 if (ev % 50 == 0){483 484 //OVERLAY PEAKS485 cout << "...drawing histograms after Loop over Pixels" ;486 for(int stepper = 0; stepper < 4; stepper++){487 cPulsetypes->cd(stepper+1);488 gPad->SetGrid();489 hPeakOverlay[stepper]->Draw("COLZ");490 cout << "..." << stepper << "/3" ;491 }492 // cPulsetypes->cd(1);493 // gPad->SetGrid();494 // hSinglePeakOverlay->Draw("COLZ");495 //496 // cPulsetypes->cd(2);497 // gPad->SetGrid();498 // hDoublePeakOverlay->Draw("hLargePeakOverlayCOLZ");499 //500 // cPulsetypes->cd(3);501 // gPad->SetGrid();502 // hTripplePeakOverlay->Draw("COLZ");503 //504 // cPulsetypes->cd(4);505 // gPad->SetGrid();506 // hLargePeakOverlay->Draw("COLZ");507 // cPulsetypes->cd(5);508 // hSinglePeakMaximum->Draw("");509 cout << "...done" << endl;510 cPulsetypes->Modified();511 cPulsetypes->Update();512 }513 }514 if (breakout)515 break;516 1128 } 517 1129 518 //------------------------------------- 519 // end of loop over Events 520 //------------------------------------- 521 522 //------------------------------------- 523 // Histogramm of Maximas in Overlay Spectra 524 //------------------------------------- 525 cout << "...producing Maximum peaks:" << endl; 526 for (unsigned int cnt = 0 ; cnt < 4 ; cnt ++){ 527 cout << "\t ...peak type " << cnt; 528 hOverlayTemp = hPeakOverlay[cnt]; 529 hMaximumTemp = hPeakMaximum[cnt]; 530 // if (cnt == 1){ 531 // hMaximumTemp = hSinglePeakMaximum; 532 // hOverlayTemp = hSinglePeakOverlay; 533 // } 534 // else if (cnt == 2){ 535 // hMaximumTemp = hDoublePeakMaximum; 536 // hOverlayTemp = hDoublePeakOverlay; 537 // } 538 // else if (cnt == 3){ 539 // hMaximumTemp = hTripplePeakMaximum; 540 // hOverlayTemp = hTripplePeakOverlay; 541 // } 542 // else if (cnt == 4){ 543 // hMaximumTemp = hLargePeakMaximum; 544 // hOverlayTemp = hLargePeakOverlay; 545 // } 546 // resize vector SingleMaximum to number of timeslices in Overlay Spectra 547 SingleMaximum.resize(hOverlayTemp->GetNbinsX()); 548 cout << "\t ...peak type " << cnt; 549 //put maximumvalue of every Y-projection of every timeslice into vector 550 for (int TimeSlice = 0; TimeSlice <= hOverlayTemp->GetNbinsX(); TimeSlice++ ){ 551 histotitle = "hproj_py"; 552 histotitle += cnt ; 553 hProjPeak = hOverlayTemp->ProjectionY(histotitle, TimeSlice, TimeSlice, ""); 554 SingleMaximum[ TimeSlice ].maxAmpl = (hProjPeak->GetMaximumBin() * 0.5) - 3.5; 555 SingleMaximum[ TimeSlice ].countOfMax = hProjPeak->GetBinContent( hProjPeak->GetMaximumBin() ); 556 hMaximumTemp->SetBinContent(TimeSlice, SingleMaximum[ TimeSlice ].maxAmpl ); 557 } 558 cout << "...done" << endl; 559 if (fitdata){ 560 cout << "...calculating Landaufit" ; 561 hMaximumTemp->Fit("landau", "", "", -50, 250); 562 cout << "...done" << endl; 1130 //Fill overlay und profile histograms 1131 if (use_this_peak){ 1132 if (verbosityLevel > 2) cout << "...filling" ; 1133 for ( int pos = Left; pos < Right; pos++){ 1134 hPixelOverlay[order_of_pulse]->Fill( pos - (reg->maxPos), Ameas[pos]) ; 1135 hPixelProfile[order_of_pulse]->Fill( pos - (reg->maxPos), Ameas[pos]) ; 1136 hAllPixelOverlay[order_of_pulse]->Fill( pos - (reg->maxPos), Ameas[pos]) ; 1137 hAllPixelProfile[order_of_pulse]->Fill( pos - (reg->maxPos), Ameas[pos]) ; 1138 } 1139 for ( int pos = EdgeLeft; pos < EdgeRight; pos++){ 1140 // cout << endl << "###filling edge histo###" << endl; 1141 hPixelEdgeOverlay[order_of_pulse]->Fill( pos - (reg->halfRisingEdgePos), Ameas[pos]) ; 1142 // cout << endl << "######" << endl; 1143 } 1144 if (verbosityLevel > 2) cout << "...done" << endl; 563 1145 } 564 } 565 //------------------------------------- 566 // Draw Histograms 567 //------------------------------------- 568 if (ProduceGraphic){ 569 //OVERLAY PEAKS 570 cout << "...drawing overlay histograms" ; 571 for(int stepper = 0; stepper < 4; stepper++){ 572 cPulsetypes->cd(stepper+1); 573 gPad->SetGrid(); 574 hPeakOverlay[stepper]->ResetStats(); 575 hPeakOverlay[stepper]->Draw("COLZ"); 576 } 577 cout << "...done" << endl; 578 cout << "...drawing peak-shape histograms" ; 579 for(int stepper = 0; stepper < 4; stepper++){ 580 cPulsetypes->cd(5+stepper); 581 gPad->SetGrid(); 582 hPeakMaximum[stepper]->ResetStats(); 583 hPeakMaximum[stepper]->Draw(); 584 } 585 cout << "...done" << endl; 586 587 //cout << "producing...So" << endl; 588 // cPulsetypes->cd(1); 589 // gPad->SetGrid(); 590 // hSinglePeakOverlay->ResetStats(); 591 // hSinglePeakOverlay->Draw("COLZ"); 592 //cout << "producing...DO" << endl; 593 // cPulsetypes->cd(2); 594 // gPad->SetGrid(); 595 // hDoublePeakOverlay->ResetStats(); 596 // hDoublePeakOverlay->Draw("COLZ"); 597 //cout << "producing...TO" << endl; 598 // cPulsetypes->cd(3); 599 // gPad->SetGrid(); 600 // hTripplePeakOverlay->ResetStats(); 601 // hTripplePeakOverlay->Draw("COLZ"); 602 //cout << "producing...LO" << endl; 603 // cPulsetypes->cd(4); 604 // gPad->SetGrid(); 605 // hLargePeakOverlay->ResetStats(); 606 // hLargePeakOverlay->Draw("COLZ"); 607 //cout << "producing...SM" << endl; 608 // cPulsetypes->cd(5); 609 // hSinglePeakMaximum->ResetStats(); 610 // hSinglePeakMaximum->Draw(""); 611 //cout << "producing...DM" << endl; 612 // cPulsetypes->cd(6); 613 // hDoublePeakMaximum->ResetStats(); 614 // hDoublePeakMaximum->Draw(""); 615 //cout << "producing...TM" << endl; 616 // cPulsetypes->cd(7); 617 // hTripplePeakMaximum->ResetStats(); 618 // hTripplePeakMaximum->Draw(""); 619 //cout << "producing...LM" << endl; 620 // cPulsetypes->cd(8); 621 // hLargePeakMaximum->ResetStats(); 622 // hLargePeakMaximum->Draw(""); 623 //cout << "producing...Done" << endl; 624 625 626 627 628 cPulsetypes->Modified(); 629 cPulsetypes->Update(); 630 631 // cPixelPeakOverlay->cd(); 632 // hPixelPeakOverlay->Draw("COLZ"); 633 // cPixelPeakOverlay->Modified(); 634 // cPixelPeakOverlay->Update(); 635 1146 //Breakout option 1147 if (breakout) 1148 break; 1149 } 1150 if (verbosityLevel > 2) cout << "...done" << endl; 1151 } 1152 // end of FillHistograms 1153 //---------------------------------------------------------------------------- 1154 1155 void DrawTestHistograms( 1156 int verbosityLevel 1157 ) 1158 { 1159 if (verbosityLevel > 2) cout << endl << "...drawing pulse histograms" ; 1160 1161 cgpTestHistos->cd(1); 1162 hTesthisto->Draw(); 1163 } 1164 // end of DrawTestHistograms 1165 //---------------------------------------------------------------------------- 1166 1167 void DrawPulseHistograms( 1168 int verbosityLevel, 1169 int max_pulse_order 1170 ) 1171 { 1172 if (verbosityLevel > 2) cout << endl << "...drawing pulse histograms" ; 1173 for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++) 1174 { 1175 cgpPixelPulses[pulse_order]->cd(1); 1176 hPixelOverlay[pulse_order]->Draw("COLZ"); 1177 cgpPixelPulses[pulse_order]->cd(2); 1178 hPixelProfile[pulse_order]->Draw("COLZ"); 1179 cgpPixelPulses[pulse_order]->cd(3); 1180 hPixelEdgeOverlay[pulse_order]->Draw("COLZ"); 1181 // cgpPixelPulses[pulse_order]->cd(4); 1182 // hTesthisto->Draw(); 1183 1184 cgpAllPixelPulses[pulse_order]->cd(1); 1185 hAllPixelOverlay[pulse_order]->Draw("COLZ"); 1186 cgpAllPixelPulses[pulse_order]->cd(2); 1187 hAllPixelProfile[pulse_order]->Draw("COLZ"); 1188 1189 } 1190 } 1191 // end of DrawPulseHistograms 1192 //---------------------------------------------------------------------------- 1193 1194 1195 void DrawMaximumHistograms( 1196 int verbosityLevel, 1197 int max_pulse_order 1198 ) 1199 { 1200 if (verbosityLevel > 2) cout << endl << "...drawing maximum histograms" ; 1201 for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++) 1202 { 1203 cgpPixelPulses[pulse_order]->cd(4); 1204 hPixelMax[pulse_order]->Draw("LF2"); 1205 1206 cgpAllPixelPulses[pulse_order]->cd(4); 1207 hAllPixelMax[pulse_order]->Draw(); 1208 // cgpAllPixelPulses[pulse_order]->cd(3); 1209 // hAllPixelMaxGaus[pulse_order]->Draw("COLZ"); 1210 } 1211 } 1212 // end of DrawMaximumHistograms 1213 //---------------------------------------------------------------------------- 1214 1215 1216 void UpdateCanvases( 1217 int verbosityLevel, 1218 int max_pulse_order 1219 ) 1220 { 1221 if (verbosityLevel > 3) cout << endl << "...updating canvases" ; 1222 for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++) 1223 { 1224 cgpPixelPulses[pulse_order]->Modified(); 1225 cgpPixelPulses[pulse_order]->Update(); 1226 cgpAllPixelPulses[pulse_order]->Modified(); 1227 cgpAllPixelPulses[pulse_order]->Update(); 1228 cgpTestHistos->Modified(); 1229 cgpTestHistos->Update(); 1230 } 1231 } 1232 // end of UpdateCanvases 1233 //---------------------------------------------------------------------------- 1234 1235 1236 1237 void 1238 PlotPulseShapeOfMaxPropability( 1239 unsigned int max_pulse_order, 1240 int fitdata, 1241 int verbosityLevel 1242 ) 1243 { 1244 if (verbosityLevel > 2) cout << endl 1245 << "...calculating pulse shape of max. propability" 1246 << endl; 1247 for (unsigned int pulse_order = 0 ; pulse_order < max_pulse_order ; pulse_order ++) 1248 { 1249 if (verbosityLevel > 2) cout << "\t...calculating of " 1250 << "pulse order " << pulse_order; 1251 // vector max_value_of to number of timeslices in Overlay Spectra 1252 vector<OverlayMaximum> max_value_of; 1253 max_value_of.resize(hPixelOverlay[pulse_order]->GetNbinsX()); 1254 1255 for (int TimeSlice = 0; 1256 TimeSlice <= hPixelOverlay[pulse_order]->GetNbinsX(); 1257 TimeSlice++ ) 1258 { 1259 histotitle = "hproj_py"; //generate title of histogram of which MaxVal 1260 histotitle += pulse_order ; //will be calculated 1261 1262 //put maximumvalue of every Y-projection of every timeslice into vector 1263 hProjPeak = hPixelOverlay[pulse_order]->ProjectionY(histotitle, TimeSlice, TimeSlice, ""); 1264 max_value_of[ TimeSlice ].maxAmpl = (hProjPeak->GetMaximumBin() * 0.5) - 3.5; 1265 max_value_of[ TimeSlice ].countOfMax = hProjPeak->GetBinContent( hProjPeak->GetMaximumBin() ); 1266 hPixelMax[pulse_order]->SetBinContent(TimeSlice, max_value_of[ TimeSlice ].maxAmpl ); 636 1267 } 637 SaveHistograms( OutRootFileName ); 638 639 return( 0 ); 640 } 641 642 // booking and parameter settings for all histos 643 void BookHistos( ){ 644 645 debugHistos = new TH1F[ NumberOfDebugHistoTypes ]; 646 for ( int type = 0; type < NumberOfDebugHistoTypes; type++){ 647 debugHistos[ type ].SetBins(1024, 0, 1024); 648 debugHistos[ type ].SetLineColor(1); 649 debugHistos[ type ].SetLineWidth(2); 650 651 // set X axis paras 652 debugHistos[ type ].GetXaxis()->SetLabelSize(0.1); 653 debugHistos[ type ].GetXaxis()->SetTitleSize(0.1); 654 debugHistos[ type ].GetXaxis()->SetTitleOffset(1.2); 655 debugHistos[ type ].GetXaxis()->SetTitle(Form("Time slice (%.1f ns/slice)", 1./2.)); 656 657 // set Y axis paras 658 debugHistos[ type ].GetYaxis()->SetLabelSize(0.1); 659 debugHistos[ type ].GetYaxis()->SetTitleSize(0.1); 660 debugHistos[ type ].GetYaxis()->SetTitleOffset(0.3); 661 debugHistos[ type ].GetYaxis()->SetTitle("Amplitude (a.u.)"); 1268 1269 if (verbosityLevel > 2) cout << "\t...done" << endl; 1270 1271 if (fitdata) 1272 { 1273 FitMaxPropabilityPuls( 1274 hPixelMax[pulse_order], 1275 verbosityLevel 1276 ); 662 1277 } 663 /* 664 ProjHistos = new TH1D[ NumberOfTimeSlices ]; 665 for ( int type = 0; type < NumberOfTimeSlices; type++){ 666 ProjHistos[ type ].SetBins(1024, 0, 1024); 667 ProjHistos[ type ].SetLineColor(1); 668 ProjHistos[ type ].SetLineWidth(2); 669 670 // set X axis paras 671 ProjHistos[ type ].GetXaxis()->SetLabelSize(0.1); 672 ProjHistos[ type ].GetXaxis()->SetTitleSize(0.1); 673 ProjHistos[ type ].GetXaxis()->SetTitleOffset(1.2); 674 ProjHistos[ type ].GetXaxis()->SetTitle(Form("Time slice (%.1f ns/slice)", 1./2.)); 675 676 // set Y axis paras 677 ProjHistos[ type ].GetYaxis()->SetLabelSize(0.1); 678 ProjHistos[ type ].GetYaxis()->SetTitleSize(0.1); 679 ProjHistos[ type ].GetYaxis()->SetTitleOffset(0.3); 680 ProjHistos[ type ].GetYaxis()->SetTitle("Amplitude (a.u.)"); 681 } 682 */ 683 684 //----------------------------------------------------------------------------- 685 686 for (int stepper = 0; stepper < 4; stepper ++){ 687 hPeakOverlay[stepper] = new TH2F(histSetting[stepper].name, histSetting[stepper].title, 688 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*gPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 689 512, -55.5, 300.5); 690 hPeakOverlay[stepper]->SetAxisRange(-5.5, histSetting[stepper].yMax+ 25.5, "Y"); 691 hPeakOverlay[stepper]->GetXaxis()->SetTitle( "Timeslices" ); 692 hPeakOverlay[stepper]->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 693 //hSinglePeakOverlay->SetBit(TH2F::kCanRebin); 694 hList.Add( hPeakOverlay[stepper] ); 695 696 hPeakMaximum[stepper] = new TH1F(histSetting[stepper].Mname, histSetting[stepper].Mtitle, 697 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , 698 (-1*gPeakOverlayXaxisLeft)-0.5, 699 hPeakOverlayXaxisRight-0.5 700 ); 701 hPeakMaximum[stepper]->SetAxisRange(-0.5, histSetting[stepper].yMax + 15.5, "Y"); 702 hPeakMaximum[stepper]->GetXaxis()->SetTitle( "Timeslices" ); 703 hPeakMaximum[stepper]->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 704 hList.Add( hPeakMaximum[stepper] ); 705 } 706 //----------------------------------------------------------------------------- 707 708 709 710 //----------------------------------------------------------------------------- 711 hSinglePeakOverlay = new TH2F("hSinglePeakOverlay", "Overlay of detected Single Photon Peaks", 712 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*gPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 713 512, -55.5, 300.5); 714 hSinglePeakOverlay->SetAxisRange(-5.5, 35.5, "Y"); 715 hSinglePeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 716 hSinglePeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 717 //hSinglePeakOverlay->SetBit(TH2F::kCanRebin); 718 hList.Add( hSinglePeakOverlay ); 719 720 hSinglePeakMaximum = new TH1F("hSinglePeakMaximum", "Single Peak derived with Maximum of above Spektrum", 721 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , 722 (-1*gPeakOverlayXaxisLeft)-0.5, 723 hPeakOverlayXaxisRight-0.5 724 ); 725 hSinglePeakMaximum->SetAxisRange(-0.5, 25.5, "Y"); 726 hSinglePeakMaximum->GetXaxis()->SetTitle( "Timeslices" ); 727 hSinglePeakMaximum->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 728 hList.Add( hSinglePeakMaximum ); 729 //----------------------------------------------------------------------------- 730 731 hDoublePeakOverlay = new TH2F("hDoublePeakOverlay", "Overlay of detected Double Photon Peaks", 732 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*gPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 733 512, -55.5, 300.5); 734 hDoublePeakOverlay->SetAxisRange(-5.5, 35.5, "Y"); 735 hDoublePeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 736 hDoublePeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 737 //hSinglePeakOverlay->SetBit(TH2F::kCanRebin); 738 hList.Add( hDoublePeakOverlay );; 739 740 hDoublePeakMaximum = new TH1F("hSinglePeakMaximum", "Double Peak derived with Maximum of above Spektrum", 741 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , 742 (-1*gPeakOverlayXaxisLeft)-0.5, 743 hPeakOverlayXaxisRight-0.5 744 ); 745 hDoublePeakMaximum->SetAxisRange(-0.5, 25.5, "Y"); 746 hDoublePeakMaximum->GetXaxis()->SetTitle( "Timeslices" ); 747 hDoublePeakMaximum->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 748 hList.Add( hDoublePeakMaximum ); 749 //----------------------------------------------------------------------------- 750 751 hTripplePeakOverlay= new TH2F("hTripplePeakOverlay", "Overlay of detected Tripple Photon Peaks", 752 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*gPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 753 512, -55.5, 300.5); 754 hTripplePeakOverlay->SetAxisRange(-5.5, 35.5, "Y"); 755 hTripplePeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 756 hTripplePeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 757 //hTripplePeakOverlay->SetBit(TH2F::kCanRebin); 758 hList.Add( hTripplePeakOverlay );; 759 760 hTripplePeakMaximum = new TH1F("hSinglePeakMaximum", "Triple Peak derived with Maximum of above Spektrum", 761 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , 762 (-1*gPeakOverlayXaxisLeft)-0.5, 763 hPeakOverlayXaxisRight-0.5 764 ); 765 hTripplePeakMaximum->SetAxisRange(-0.5, 25.5, "Y"); 766 hTripplePeakMaximum->GetXaxis()->SetTitle( "Timeslices" ); 767 hTripplePeakMaximum->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 768 hList.Add( hTripplePeakMaximum ); 769 //----------------------------------------------------------------------------- 770 771 hLargePeakOverlay= new TH2F("hLargePeakOverlay", "Overlay of detected Multi Photon Peaks", 772 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*gPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 773 512, -5.5, 300.5 ); 774 hLargePeakOverlay->SetAxisRange(-5.5, 200.5, "Y"); 775 hLargePeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 776 hLargePeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 777 //hLargePeakOverlay->SetBit(TH2F::kCanRebin); 778 hList.Add( hLargePeakOverlay );; 779 780 hLargePeakMaximum = new TH1F("hLargePeakMaximum", "Peak derived with Maximum of above Spektrum", 781 gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , 782 (-1*gPeakOverlayXaxisLeft)-0.5, 783 hPeakOverlayXaxisRight-0.5 784 ); 785 hLargePeakMaximum->SetAxisRange(-0.5, 50.5, "Y"); 786 hLargePeakMaximum->GetXaxis()->SetTitle( "Timeslices" ); 787 hLargePeakMaximum->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 788 hList.Add( hLargePeakMaximum ); 789 //----------------------------------------------------------------------------- 790 791 // hPixelPeakOverlay = new TH2F("hPixelPeakOverlay", "Maximum of Statistic of overlayed Peaks", 792 // gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*gPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 793 // 512, -55.5, 200.5 ); 794 // hPixelPeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 795 // hPixelPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 796 // hList.Add( hPixelPeakOverlay ); 797 798 // hEventPeakOverlay = new TH2F("hEventPeakOverlay", "Overlay of detected Peaks of all Pixel of one Event", 799 // gPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*gPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 800 // 4096, -48.5, 200.5 ); 801 // hEventPeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 802 // hEventPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 803 // hList.Add( hEventPeakOverlay ); 804 805 } 806 807 void SaveHistograms(const char * loc_fname ){ 808 // create the histogram file (replace if already existing) 809 TFile tf( loc_fname, "RECREATE"); 810 811 hList.Write(); // write the major histograms into the top level directory 812 813 tf.Close(); // close the file 814 } // end of SaveHistograms( char * loc_fname ) 815 1278 } 1279 } 1280 1281 1282 void 1283 FitMaxPropabilityPuls( 1284 TH1F* hMaximumTemp, 1285 int verbosityLevel 1286 ) 1287 { 1288 if (verbosityLevel > 2) cout << "...fit Landau in histograms" ; 1289 if (verbosityLevel > 2) cout << "\t...calculating Landaufit" ; 1290 hMaximumTemp->Fit("landau", "", "", -50, 250); 1291 if (verbosityLevel > 2) cout << "...done" << endl; 1292 } 1293 1294 1295 //void SetHistogrammSettings( 1296 // const char* histoType, 1297 // int max_puls_order, 1298 // int MaxAmplOfFirstPulse, 1299 // int verbosityLevel 1300 // ) 1301 //{ 1302 // if (verbosityLevel > 2) cout << endl << "...set histogram Settings" << endl; 1303 // for (int pulse_order = 1; pulse_order <= max_puls_order; pulse_order++) 1304 // { 1305 // qHistSetting[pulse_order].yMax = (MaxAmplOfFirstPulse * pulse_order); 1306 // cout << "\t Max @ " << gHistSetting[pulse_order].yMax << endl; 1307 // gHistSetting[pulse_order].name = "h"; 1308 // gHistSetting[pulse_order].name += histoType; 1309 // gHistSetting[pulse_order].name += "PeakOverlay"; 1310 // gHistSetting[pulse_order].name += pulse_order; 1311 // gHistSetting[pulse_order].title = "PeakOverlay with Amplitude around "; 1312 // gHistSetting[pulse_order].title += gHistSetting[pulse_order].yMax; 1313 // gHistSetting[pulse_order].title += " mV"; 1314 // gHistSetting[pulse_order].Mname = "h"; 1315 // gHistSetting[pulse_order].Mname += histoType; 1316 // gHistSetting[pulse_order].Mname += "PeakMaximum"; 1317 // gHistSetting[pulse_order].Mname += pulse_order; 1318 // gHistSetting[pulse_order].Mtitle = "Peak (approx) derived with Maximum of above Spektrum with Max of "; 1319 // gHistSetting[pulse_order].Mtitle += gHistSetting[pulse_order].yMax; 1320 // gHistSetting[pulse_order].Mtitle += " mV"; 1321 // } 1322 // if (verbosityLevel > 2) cout << "...done" << endl; 1323 //} 1324 1325 1326 //void CreatePulseCanvas( 1327 // TCanvas* array_of_canvases, 1328 // unsigned int max_pulse_order, 1329 // const char* canvas_name, 1330 // const char* canvas_title, 1331 // const char* pixel, 1332 // int verbosityLevel 1333 // ) 1334 //{ 1335 // if (verbosityLevel > 2) cout << "...building Canvases" ; 1336 1337 // for ( 1338 // unsigned int pulse_order = 1; 1339 // pulse_order <= max_pulse_order; 1340 // pulse_order++ 1341 // ) 1342 // { 1343 // TString name = canvas_name; 1344 // name += " "; 1345 // name += pulse_order; 1346 // name += " "; 1347 1348 // TString title = "Order "; 1349 // title += pulse_order; 1350 // title += " "; 1351 // title += canvas_title; 1352 // title += " of "; 1353 // title += pixel; 1354 // title += ". Pixel"; 1355 1356 // array_of_canvases[pulse_order] = new TCanvas(name, title, 1, 1, 1400, 700); 1357 // array_of_canvases[pulse_order].Divide(2,2); 1358 // } 1359 // if (verbosityLevel > 2) cout << "...done" << endl; 1360 //} 1361 1362 1363 //void 1364 //DeletePulseCanvas( 1365 // TCanvas* array_of_canvases, 1366 // unsigned int max_pulse_order 1367 // ) 1368 //{ 1369 // for ( 1370 // unsigned int pulse_order = 1; 1371 // pulse_order <= max_pulse_order; 1372 // pulse_order++ 1373 // ) 1374 // { 1375 // delete array_of_canvases[pulse_order]; 1376 // } 1377 //} 1378 1379 1380 1381 1382 void 1383 DeletePixelCanvases( int verbosityLevel ) 1384 { 1385 if (verbosityLevel > 2) cout << endl << "...delete pixel Canvas" ; 1386 for (int pulse_order = 0; pulse_order < MAX_PULS_ORDER; pulse_order ++) 1387 { 1388 delete cgpPixelPulses[pulse_order]; 1389 } 1390 } 1391 1392 //---------------------------------------------------------------------------- 1393 //---------------------------------------------------------------------------- 1394 1395 //void SetHistogramAttributes( 1396 // const char* histoType, 1397 // int pulse_order, 1398 // histAttrib_t* histoAttrib, 1399 // int max_ampl_of_first_pulse 1400 // ) 1401 //{ 1402 // histoAttrib[pulse_order].yMax = (max_ampl_of_first_pulse * pulse_order); 1403 // histoAttrib[pulse_order].yMin = (histoAttrib[pulse_order].yMax/2); 1404 // histoAttrib[pulse_order].name = "h"; 1405 // histoAttrib[pulse_order].name += histoType; 1406 // histoAttrib[pulse_order].name = "_"; 1407 // histoAttrib[pulse_order].name += pulse_order; 1408 1409 // histoAttrib[pulse_order].title += histoType; 1410 // histoAttrib[pulse_order].title += " with Amplitude around "; 1411 // histoAttrib[pulse_order].title += histoAttrib[pulse_order].yMax; 1412 // histoAttrib[pulse_order].title += " mV"; 1413 1414 // histoAttrib[pulse_order].xTitle += "Timeslices [a.u.]"; 1415 // histoAttrib[pulse_order].yTitle += "Amplitude [mV]"; 1416 //}
Note:
See TracChangeset
for help on using the changeset viewer.