Ignore:
Timestamp:
11/18/11 18:22:42 (13 years ago)
Author:
Jens Buss
Message:
...now has most propable Single peak in one Histogram with Landau-fit
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/rootmacros/tpeak.C

    r12545 r12556  
    7474vector<float> Vcfd(FAD_MAX_SAMPLES);    // CDF result
    7575vector<float> Vcfd2(FAD_MAX_SAMPLES);    // CDF result + 2nd sliding average
     76
    7677typedef struct{
    7778  float maxAmpl;
     
    9697TH1F *hMaxPeakOverlay;
    9798//TH2F *hPixelPeakOverlay;
    98 TH2F *hEventPeakOverlay;
     99//TH2F *hEventPeakOverlay;
    99100int hPeakOverlayXaxisLeft,hPeakOverlayXaxisRight;
    100101
     
    140141        TCanvas *cFiltered = NULL;
    141142        if (spikeDebug){
    142                 cFiltered = new TCanvas("cFiltered","filtered DRS Waveforms",1,10,400,300);
     143                cFiltered = new TCanvas("cFiltered","filtered DRS Waveforms", 1,310,400,300);
    143144                cFiltered->Divide(1, 3);
    144145        }
    145146        // Canvases to show the peak template
    146147        TCanvas *cPeakOverlay = NULL;
    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);
     148        cPeakOverlay = new TCanvas("cPeakOverlay", "Overlay of detected Peaks", 1, 1, 1200, 600);
     149        cPeakOverlay->Divide(2,1);
     150//        // All peaks of one Pixel
     151//        TCanvas *cPixelPeakOverlay = NULL;
     152//        cPixelPeakOverlay = new TCanvas("cPixelPeakOverlay", "Overlay of detected Peaks of all Events of one Pixel", 401, 1, 400, 400);
     153//        // All Peaks of one Event
     154//        TCanvas *cYProjection = NULL;
     155//        cYProjection = new TCanvas("cYProjection", "Y Projection of peak overlay for each bin ", 802, 1, 400, 400);
    155156
    156157
     
    205206  if (verbosityLevel > 0)
    206207    cout <<"of, which "<< npixel << "will be processed"<< endl;
    207 
    208208//Get the DRS calibration
    209209        FOpenCalibFile( drsfilename,
     
    212212                                        drs_triggeroffsetmean,
    213213                                        drs_n);
    214 
     214cout << "test4" << endl;
    215215// Book the histograms
    216216        BookHistos( );
     
    276276                                            hPeakOverlay->Fill( pos - (it->maxPos), Vslide[pos]) ;
    277277//                                            hPixelPeakOverlay->Fill( pos - (it->maxPos), Vcorr[pos]) ;
    278                                             hEventPeakOverlay->Fill( pos - (it->maxPos), 2*Vcorr[pos]) ;
     278//                                            hEventPeakOverlay->Fill( pos - (it->maxPos), 2*Vcorr[pos]) ;
    279279                                        }
    280280                                }
     
    364364                                if (ProduceGraphic){
    365365                                                if (ev % 50 == 0){
    366                 //OVERLAY PEAKS
    367                 cPeakOverlay->cd(1);
    368                 hPeakOverlay->Draw("COLZ");
    369                 cPeakOverlay->cd(2);
    370                 hMaxPeakOverlay->Draw("COLZ");
    371                 cPeakOverlay->Modified();
    372                 cPeakOverlay->Update();
    373 
    374 //                cPixelPeakOverlay->cd();
    375 //                hPixelPeakOverlay->Draw("COLZ");
    376 //                cPixelPeakOverlay->Modified();
    377 //                cPixelPeakOverlay->Update();
     366
     367                    //OVERLAY PEAKS
     368                    cPeakOverlay->cd(1);
     369                    hPeakOverlay->Draw("COLZ");
     370                    cPeakOverlay->cd(2);
     371                  //  hMaxPeakOverlay->Draw("");
     372                    cPeakOverlay->Modified();
     373                    cPeakOverlay->Update();
    378374                  }
    379375                                }
     
    385381// end of loop over Events
    386382//-------------------------------------
    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 
     383
     384//-------------------------------------
     385// Histogramm of Maximas in Overlay Spectra
     386//-------------------------------------
     387      // resize vector SingleMaximum to number of timeslices in Overlay Spectra
     388      SingleMaximum.resize(hPeakOverlay->GetNbinsX());
     389
     390      //put maximumvalue of every Y-projection of every timeslice into vector
     391      for (int TimeSlice = 0; TimeSlice <= hPeakOverlay->GetNbinsX(); TimeSlice++ ){
     392        TH1D* hProjPeak =       hPeakOverlay->ProjectionY("proj_py", TimeSlice, TimeSlice, "");
     393        SingleMaximum[ TimeSlice ].maxAmpl = (hProjPeak->GetMaximumBin() * 0.5) - 54;
     394        SingleMaximum[ TimeSlice ].countOfMax = hProjPeak->GetBinContent( hProjPeak->GetMaximumBin() );
     395        hMaxPeakOverlay->SetBinContent(TimeSlice, SingleMaximum[ TimeSlice ].maxAmpl );
     396      }
     397      hMaxPeakOverlay->Fit("landau", "", "", -50, 250);
     398
     399//-------------------------------------
     400// Draw Histograms
     401//-------------------------------------
    399402        if (ProduceGraphic){
    400403            //OVERLAY PEAKS
    401404            cPeakOverlay->cd(1);
    402405            hPeakOverlay->Draw("COLZ");
    403 //            cPeakOverlay->Modified();
    404 //            cPeakOverlay->Update();
    405406            cPeakOverlay->cd(2);
    406407            hMaxPeakOverlay->Draw("");
     
    414415
    415416        }
    416 
    417 
    418 //        cPixelPeakOverlay->cd();
    419 //        hPixelPeakOverlay->Draw();
    420 //        cPixelPeakOverlay->Modified();
    421 //        cPixelPeakOverlay->Update();
    422 
    423417        SaveHistograms( OutRootFileName );
    424418
     
    482476        hMaxPeakOverlay->GetXaxis()->SetTitle( "Timeslices" );
    483477        hMaxPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" );
    484         //hMaxPeakOverlay->SetBit(TH2F::kCanRebin);
    485478        hList.Add( hMaxPeakOverlay );
    486479
     
    492485//        hList.Add( hPixelPeakOverlay );
    493486
    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 );
     487//        hEventPeakOverlay = new TH2F("hEventPeakOverlay", "Overlay of detected Peaks of all Pixel of one Event",
     488//               hPeakOverlayXaxisLeft + hPeakOverlayXaxisRight , (-1*hPeakOverlayXaxisLeft)-0.5, hPeakOverlayXaxisRight-0.5 ,
     489//               4096, -48.5, 200.5 );
     490//        hEventPeakOverlay->GetXaxis()->SetTitle( "Timeslices" );
     491//        hEventPeakOverlay->GetYaxis()->SetTitle( "Amplitude [a.u.]" );
     492//        hList.Add( hEventPeakOverlay );
    500493
    501494}
Note: See TracChangeset for help on using the changeset viewer.