Changeset 12545 for fact/tools/rootmacros
- Timestamp:
- 11/17/11 15:00:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/tpeak.C
r12392 r12545 74 74 vector<float> Vcfd(FAD_MAX_SAMPLES); // CDF result 75 75 vector<float> Vcfd2(FAD_MAX_SAMPLES); // CDF result + 2nd sliding average 76 76 typedef struct{ 77 float maxAmpl; 78 float countOfMax; 79 } OverlayMaximum; 80 vector<OverlayMaximum> SingleMaximum; 77 81 // histograms 78 82 const int NumberOfDebugHistoTypes = 7; 83 79 84 const unsigned int 80 85 Ameas_ = 0, … … 89 94 TH1F *debugHistos; 90 95 TH2F *hPeakOverlay; //histogrammm for overlay of detected Peaks 96 TH1F *hMaxPeakOverlay; 97 //TH2F *hPixelPeakOverlay; 98 TH2F *hEventPeakOverlay; 91 99 int hPeakOverlayXaxisLeft,hPeakOverlayXaxisRight; 92 100 … … 103 111 char *datafilename = "data/20111016_013.fits.gz", 104 112 const char *drsfilename = "../../20111016_011.drs.fits.gz", 105 const char *OutRootFileName = "../analysis/ fpeak_cdf.Coutput.root",113 const char *OutRootFileName = "../analysis/tpeak_cdf.Coutput.root", 106 114 int firstevent = 0, 107 115 int nevents = -1, … … 137 145 // Canvases to show the peak template 138 146 TCanvas *cPeakOverlay = NULL; 139 cPeakOverlay = new TCanvas("cPeakOverlay", "Overlay of detected Peaks", 1, 310, 400, 400); 147 cPeakOverlay = new TCanvas("cPeakOverlay", "Overlay of detected Peaks", 1, 1, 400, 600); 148 cPeakOverlay->Divide(1,2); 149 // All peaks of one Pixel 150 TCanvas *cPixelPeakOverlay = NULL; 151 cPixelPeakOverlay = new TCanvas("cPixelPeakOverlay", "Overlay of detected Peaks of all Events of one Pixel", 401, 1, 400, 400); 152 // All Peaks of one Event 153 TCanvas *cYProjection = NULL; 154 cYProjection = new TCanvas("cYProjection", "Y Projection of peak overlay for each bin ", 802, 1, 400, 400); 155 140 156 141 157 … … 258 274 for ( int pos = Left; pos < Right; pos++){ 259 275 260 hPeakOverlay->Fill( pos - (it->maxPos), Vcorr[pos]) ; 276 hPeakOverlay->Fill( pos - (it->maxPos), Vslide[pos]) ; 277 // hPixelPeakOverlay->Fill( pos - (it->maxPos), Vcorr[pos]) ; 278 hEventPeakOverlay->Fill( pos - (it->maxPos), 2*Vcorr[pos]) ; 261 279 } 262 280 } … … 316 334 317 335 //OVERLAY PEAKS 318 cPeakOverlay->cd( );336 cPeakOverlay->cd(1); 319 337 hPeakOverlay->Draw("COLZ"); 320 338 cPeakOverlay->Modified(); … … 347 365 if (ev % 50 == 0){ 348 366 //OVERLAY PEAKS 349 cPeakOverlay->cd( );367 cPeakOverlay->cd(1); 350 368 hPeakOverlay->Draw("COLZ"); 369 cPeakOverlay->cd(2); 370 hMaxPeakOverlay->Draw("COLZ"); 351 371 cPeakOverlay->Modified(); 352 372 cPeakOverlay->Update(); 353 } 373 374 // cPixelPeakOverlay->cd(); 375 // hPixelPeakOverlay->Draw("COLZ"); 376 // cPixelPeakOverlay->Modified(); 377 // cPixelPeakOverlay->Update(); 378 } 354 379 } 355 380 if (breakout) 356 381 break; 357 382 } 383 358 384 //------------------------------------- 359 385 // end of loop over Events 360 386 //------------------------------------- 361 if (ProduceGraphic){ 362 //OVERLAY PEAKS 363 cPeakOverlay->cd(); 364 hPeakOverlay->Draw("COLZ"); 365 cPeakOverlay->Modified(); 366 cPeakOverlay->Update(); 367 } 387 //TH1D* hProjPeak = TH2::ProjectionY(const char* name = "proj_py", Int_t firstxbin = 0, Int_t lastxbin = -1, Option_t* option = ""); 388 SingleMaximum.resize(hPeakOverlay->GetNbinsX()); 389 for (int TimeSlice = 0; TimeSlice <= hPeakOverlay->GetNbinsX(); TimeSlice++ ){ 390 TH1D* hProjPeak = hPeakOverlay->ProjectionY("proj_py", TimeSlice, TimeSlice, ""); 391 SingleMaximum[ TimeSlice ].maxAmpl = (hProjPeak->GetMaximumBin() * 0.5) - 55.5; 392 SingleMaximum[ TimeSlice ].countOfMax = hProjPeak->GetBinContent( hProjPeak->GetMaximumBin() ); 393 // cout << "Timeslice:" << "\t" << "MaxAmplitude" << "\t" << "Counts" << "\t" << "max. Value on X Axis: " << endl; 394 // cout << TimeSlice << "\t \t" << SingleMaximum[ TimeSlice ].maxAmpl << "\t \t" << SingleMaximum[ TimeSlice ].countOfMax<< "\t \t" << ((hProjPeak->GetNbinsX() * 0.5) -55.5)<< endl; 395 hMaxPeakOverlay->SetBinContent(TimeSlice, SingleMaximum[ TimeSlice ].maxAmpl ); 396 397 } 398 399 if (ProduceGraphic){ 400 //OVERLAY PEAKS 401 cPeakOverlay->cd(1); 402 hPeakOverlay->Draw("COLZ"); 403 // cPeakOverlay->Modified(); 404 // cPeakOverlay->Update(); 405 cPeakOverlay->cd(2); 406 hMaxPeakOverlay->Draw(""); 407 cPeakOverlay->Modified(); 408 cPeakOverlay->Update(); 409 410 // cPixelPeakOverlay->cd(); 411 // hPixelPeakOverlay->Draw("COLZ"); 412 // cPixelPeakOverlay->Modified(); 413 // cPixelPeakOverlay->Update(); 414 415 } 416 417 418 // cPixelPeakOverlay->cd(); 419 // hPixelPeakOverlay->Draw(); 420 // cPixelPeakOverlay->Modified(); 421 // cPixelPeakOverlay->Update(); 368 422 369 423 SaveHistograms( OutRootFileName ); … … 393 447 debugHistos[ type ].GetYaxis()->SetTitle("Amplitude (a.u.)"); 394 448 } 395 hPeakOverlay = new TH2F("hPeakOverlay", "Overlay of detected Peaks", 396 hPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*hPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 397 4096, -48.5, 1999.5 ); 449 /* 450 ProjHistos = new TH1D[ NumberOfTimeSlices ]; 451 for ( int type = 0; type < NumberOfTimeSlices; type++){ 452 ProjHistos[ type ].SetBins(1024, 0, 1024); 453 ProjHistos[ type ].SetLineColor(1); 454 ProjHistos[ type ].SetLineWidth(2); 455 456 // set X axis paras 457 ProjHistos[ type ].GetXaxis()->SetLabelSize(0.1); 458 ProjHistos[ type ].GetXaxis()->SetTitleSize(0.1); 459 ProjHistos[ type ].GetXaxis()->SetTitleOffset(1.2); 460 ProjHistos[ type ].GetXaxis()->SetTitle(Form("Time slice (%.1f ns/slice)", 1./2.)); 461 462 // set Y axis paras 463 ProjHistos[ type ].GetYaxis()->SetLabelSize(0.1); 464 ProjHistos[ type ].GetYaxis()->SetTitleSize(0.1); 465 ProjHistos[ type ].GetYaxis()->SetTitleOffset(0.3); 466 ProjHistos[ type ].GetYaxis()->SetTitle("Amplitude (a.u.)"); 467 } 468 */ 469 hPeakOverlay = new TH2F("hPeakOverlay", "Overlay of detected Peaks", 470 hPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*hPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 471 512, -55.5, 200.5 ); 398 472 hPeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 399 473 hPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 474 //hPeakOverlay->SetBit(TH2F::kCanRebin); 400 475 hList.Add( hPeakOverlay ); 476 477 hMaxPeakOverlay = new TH1F("hMaxPeakOverlay", "Single Peak derived with Maximum of above Spektrum", 478 hPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , 479 (-1*hPeakOverlayXaxisLeft)-0.5, 480 hPeakOverlayXaxisRight-0.5 481 ); 482 hMaxPeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 483 hMaxPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 484 //hMaxPeakOverlay->SetBit(TH2F::kCanRebin); 485 hList.Add( hMaxPeakOverlay ); 486 487 // hPixelPeakOverlay = new TH2F("hPixelPeakOverlay", "Maximum of Statistic of overlayed Peaks", 488 // hPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*hPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 489 // 512, -55.5, 200.5 ); 490 // hPixelPeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 491 // hPixelPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 492 // hList.Add( hPixelPeakOverlay ); 493 494 hEventPeakOverlay = new TH2F("hEventPeakOverlay", "Overlay of detected Peaks of all Pixel of one Event", 495 hPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*hPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 , 496 4096, -48.5, 200.5 ); 497 hEventPeakOverlay->GetXaxis()->SetTitle( "Timeslices" ); 498 hEventPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" ); 499 hList.Add( hEventPeakOverlay ); 401 500 402 501 }
Note:
See TracChangeset
for help on using the changeset viewer.