From 523b6ebd79fbec0f61abae74a911e8633530d19a Mon Sep 17 00:00:00 2001 From: Shinsuke OTA Date: Wed, 26 Aug 2020 06:07:52 +0900 Subject: [PATCH] [mod][ota/artemis-ribf113!17] use max event number instead of entry --- TCatEvalGainShiftProcessor.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/TCatEvalGainShiftProcessor.cc b/TCatEvalGainShiftProcessor.cc index 6b6eed5..5f8c106 100644 --- a/TCatEvalGainShiftProcessor.cc +++ b/TCatEvalGainShiftProcessor.cc @@ -2,7 +2,7 @@ * @brief evaluation of gain shift and obtain correction parameters * * @date Create : 2020-07-27 14:08:51 JST - * Last Modified : 2020-08-21 15:28:42 JST (ota) + * Last Modified : 2020-08-22 10:53:48 JST (ota) * @author: Shinsuke OTA * * This processor diagnoses the status of each readout pad and @@ -26,6 +26,7 @@ #include "TH2Poly.h" #include #include +#include "TRunInfo.h" #ifdef HAVE_MPI_H #include @@ -120,6 +121,17 @@ void TCatEvalGainShiftProcessor::EndOfRun() Error(__func__,"Error no readout pad is found named '%s'\n",fReadoutPadName.Value().Data()); return; } + + const char* runHeaderName = "runheader"; + TList *runInfoList = (TList*)tree->GetUserInfo()->FindObject(runHeaderName); + if (!runInfoList) { + Error(__func__,"Could not find run header named '%s",runHeaderName); + return; + } + TRunInfo *runInfo = (TRunInfo*)runInfoList->At(0); + const int maxEventNumber = runInfo->GetEventNumber(); + + //////////////////////////////////////////////////////////////////////// // // prepare output directories and histograms for diagnosis and correction results @@ -130,8 +142,8 @@ void TCatEvalGainShiftProcessor::EndOfRun() TAnalysisInfo::AddTo(file); // prepare for histogram - const int nEvents = chain->GetEntries(); - const int nBins = TMath::Max(1,TMath::FloorNint(nEvents/fEventsModulus)); + const int nEntries = chain->GetEntries(); + const int nBins = TMath::Max(1,TMath::FloorNint(maxEventNumber/fEventsModulus)); const int nPads = readoutPad->GetEntries(); std::vector< std::vector > scalesArray(nPads,std::vector(nBins,1.)); std::vector eventBorders(nBins); @@ -184,12 +196,12 @@ void TCatEvalGainShiftProcessor::EndOfRun() diaghists[i] = new TH2F(hname,htitle,ndiag,-0.5,ndiag-0.5,ndiag,-0.5,ndiag-0.5); diaghists[i]->SetDirectory(diagdir); - fHists[i] = new TH2F(hname,htitle,nBins,0.,nEvents,rangeYaxis[0],rangeYaxis[1],rangeYaxis[2]); + fHists[i] = new TH2F(hname,htitle,nBins,0.,maxEventNumber,rangeYaxis[0],rangeYaxis[1],rangeYaxis[2]); } // loop over pads - for (int ievt = 0; ievt < nEvents; ++ievt) { + for (int ievt = 0; ievt < nEntries; ++ievt) { chain->GetEntry(ievt); if (!track || !header) continue; const int evtid = header->GetEventNumber(); @@ -384,7 +396,7 @@ void TCatEvalGainShiftProcessor::EndOfRun() fout.close(); - Info(__func__,"Diagnosis done for %d events in %s%04d",nEvents,runName.Data(),runNumber); + Info(__func__,"Diagnosis done for %d entries selected from %d events in %s%04d",nEntries,maxEventNumber,runName.Data(),runNumber); Info(__func__," Total %d pads",nPads); Info(__func__," Bad %zu pads CntThres = %f, RatioThres = %f",std::count(isBad.begin(),isBad.end(),true),fCountThreshold.Value(),fCountRatioThreshold.Value()); Info(__func__," Shift %zu pads Thres = %f",std::count(hasGainShift.begin(),hasGainShift.end(),true),fDeviationThreshold.Value()); -- GitLab