#include #include #include #include #include #include const int NPaddles = 6; const int NPMTs = 2; const int NHits = 3; /* to run: root -b .L AnalyzeCutDown.C++ Analyze("pathToHistoFile") .q */ void GetHitHistos(TH1D *HitHistos[(NPaddles)][(NHits)], int Wall, int Tube); void GetCounterHistos(TH1D *CounterHistos[(NPaddles)][(NPMTs)], int Wall); // ANALYSIS FUNCTION ======================================================== void Analyze(const char *InputHisto) { TH1D *hHitsWall1Tube1[(NPaddles)][(NHits)]; TH1D *hCountersWall1[(NPaddles)][(NPMTs)]; if ((!InputHisto) || (!(*InputHisto))) return; TFile *file = TFile::Open(InputHisto, "READ"); if (!file) { std::cout << "Analyze : bad input file!" << std::endl; return; } if (!(file->cd("VetoAfterPulseAlg"))) { std::cout << "Analyze : no VetoAfterPulseAlg directory!" << std::endl; delete file; return; } // make output .txt data table #if 1 /* 0 or 1 */ std::cout << "Analyze : creating txt file!" << std::endl; #endif /* 0 or 1 */ FILE *data_table = fopen("AfterPulsingAnalysis.txt", "w"); if (!data_table) { std::cout << "Analyze : bad txt file!" << std::endl; delete file; return; } // get histos from file GetHitHistos(hHitsWall1Tube1, 1, 1); GetCounterHistos(hCountersWall1, 1); #if 1 /* 0 or 1 */ std::cout << "Analyze : got all available histos!" << std::endl; #endif /* 0 or 1 */ fprintf(data_table, "AFTERPULSING ANALYSIS \n\n"); fprintf(data_table, "%% X AP = percent of events with at least X afterpulses \n\n"); fprintf(data_table, "Wall \t Paddle \t PMT \t %% 1 AP \t %% 2 AP \t %% 3 AP \n"); // WALL 1 WEST PMTs (1) for(int pad = 0; pad < NPaddles; pad++) { double delta_times[(NHits)]; double percents[(NHits)]; double total_evts; if (!(hCountersWall1[pad][0])) continue; total_evts = (hCountersWall1[pad][0])->GetEntries(); for(int hit = 0; hit < NHits; hit++) { if (!(hHitsWall1Tube1[pad][hit])) continue; delta_times[hit] = hHitsWall1Tube1[pad][hit]->Integral(0,100); percents[hit] = (delta_times[hit] / total_evts)*100.0; } //Hit loop fprintf(data_table, "1 \t %d \t 1 \t %f \t %f \t %f", pad+1, percents[0], percents[1], percents[2]); } //Paddle loop fclose(data_table); delete file; } //Analyze // GET HIT HISTOS FUNCTION ================================================= void GetHitHistos(TH1D *HitHistos[(NPaddles)][(NHits)], int Wall, int Tube) { for(int pad = 0; pad < NPaddles; pad++) { for(int hit = 0; hit < NHits; hit++) { TString HitHistoName = TString::Format("Delta_Times_Hits_1_-_%d_Wall%d_Paddle%d_Tube%d", hit+2, Wall, pad+1, Tube); gDirectory->GetObject(HitHistoName, HitHistos[pad][hit]); #if 1 /* 0 or 1 */ if (!(HitHistos[pad][hit])) { std::cout << "GetHitHistos : no histo : " << HitHistoName << std::endl; } else { std::cout << "GetHitHistos : found : " << HitHistoName << std::endl; } #endif /* 0 or 1 */ } //Hit loop } //Paddle loop } //GetHitHistos // GET COUNTER HISTOS FUNCTION ============================================ void GetCounterHistos(TH1D *CounterHistos[(NPaddles)][(NPMTs)], int Wall) { for(int pad = 0; pad < NPaddles; pad++) { for(int pmt = 0; pmt < NPMTs; pmt++) { TString CounterHistoName = TString::Format("Hit_1_Times_Wall%d_Paddle%d_PMT%d", Wall, pad+1, pmt+1); gDirectory->GetObject(CounterHistoName, CounterHistos[pad][pmt]); #if 1 /* 0 or 1 */ if (!(CounterHistos[pad][pmt])) { std::cout << "GetCounterHistos : no histo : " << CounterHistoName << std::endl; } else { std::cout << "GetCounterHistos : found : " << CounterHistoName << std::endl; } #endif /* 0 or 1 */ } //PMT loop } //Paddle loop } //GetCounterHistos