@@ -75,8 +75,8 @@ using timeEst = o2::dataformats::TimeStampWithError<float, float>;
7575class CheckResidSpec : public Task
7676{
7777 public:
78- CheckResidSpec (std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, GTrackID::mask_t src, bool drawOnly)
79- : mDataRequest (dr), mGGCCDBRequest (gr), mTracksSrc (src), mDrawOnly (drawOnly)
78+ CheckResidSpec (std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, GTrackID::mask_t src, bool drawOnly, bool postProcOnly )
79+ : mDataRequest (dr), mGGCCDBRequest (gr), mTracksSrc (src), mDrawOnly (drawOnly), mPostProcOnly (postProcOnly)
8080 {
8181 }
8282 ~CheckResidSpec () final = default ;
@@ -110,6 +110,7 @@ class CheckResidSpec : public Task
110110 GTrackID::mask_t mTracksSrc {};
111111
112112 bool mDrawOnly = false ;
113+ bool mPostProcOnly = false ;
113114 bool mDraw = false ;
114115 bool mFillHistos = true ;
115116 bool mFillTree = true ;
@@ -179,8 +180,17 @@ void CheckResidSpec::init(InitContext& ic)
179180
180181void CheckResidSpec::run (ProcessingContext& pc)
181182{
183+ bool quit = false ;
184+ if (mPostProcOnly ) {
185+
186+ postProcessHistos ();
187+ quit = true ;
188+ }
182189 if (mDrawOnly ) {
183190 drawHistos ();
191+ quit = true ;
192+ }
193+ if (quit) {
184194 pc.services ().get <ControlService>().endOfStream ();
185195 pc.services ().get <ControlService>().readyToQuit (QuitRequest::Me);
186196 return ;
@@ -689,43 +699,53 @@ void CheckResidSpec::bookHistos()
689699void CheckResidSpec::postProcessHistos ()
690700{
691701 printf (" Fitting histos\n " );
702+ if (!mHMan ) {
703+ if (mHManV .empty ()) {
704+ LOGP (warn, " nothing to process" );
705+ return ;
706+ }
707+ mHMan = mHManV [0 ].get ();
708+ }
692709 const auto & params = o2::checkresid::CheckResidConfig::Instance ();
693710 auto gs = new TF1 (" gs" , " gaus" , -1 , 1 );
711+ int maxH = mPostProcOnly ? mHManV .size () : 1 ;
694712 TObjArray arr;
695- auto * histm = mHMan ;
696- auto fitSlices = [&](int id) {
697- auto h2 = histm->getHisto2F (id);
698- if (!h2 || h2->GetEntries () < params.minHistoStat2Fit ) {
699- return ;
700- }
701- h2->FitSlicesY (gs, 0 , -1 , 0 , " QNR" , &arr);
702- arr.SetOwner (true );
703- TH1* hmean = (TH1*)arr.RemoveAt (1 );
704- if (hmean) {
705- hmean->SetTitle (Form (" <%s>" , h2->GetTitle ()));
706- histm->addHisto (hmean, id + 1 );
707- }
708- TH1* hsig = (TH1*)arr.RemoveAt (2 );
709- if (hsig) {
710- hsig->SetTitle (Form (" #sigma(%s)" , h2->GetTitle ()));
711- histm->addHisto (hsig, id + 2 );
712- }
713- };
714- for (int ioffs = 0 ; ioffs <= 3 ; ioffs++) { // vs phi, Z, pT, tgl
715- int offs = ioffs * 1000 ;
716- for (int iht = 0 ; iht < 2 ; iht++) { // resid, pull
717- int offsV = iht == 0 ? 0 : 5 ;
718- for (int il = 0 ; il < 8 ; il++) {
719- for (int iyz = 0 ; iyz < 2 ; iyz++) {
720- fitSlices (il * 10 + iyz * 100 + offsV + offs);
721- }
713+ for (int ihm = 0 ; ihm < maxH; ihm++) {
714+ auto * histm = mHManV [ihm].get ();
715+ auto fitSlices = [&](int id) {
716+ auto h2 = histm->getHisto2F (id);
717+ if (!h2 || h2->GetEntries () < params.minHistoStat2Fit ) {
718+ return ;
719+ }
720+ h2->FitSlicesY (gs, 0 , -1 , 0 , " QNR" , &arr);
721+ arr.SetOwner (true );
722+ TH1* hmean = (TH1*)arr.RemoveAt (1 );
723+ if (hmean) {
724+ hmean->SetTitle (Form (" <%s>" , h2->GetTitle ()));
725+ histm->addHisto (hmean, id + 1 );
726+ }
727+ TH1* hsig = (TH1*)arr.RemoveAt (2 );
728+ if (hsig) {
729+ hsig->SetTitle (Form (" #sigma(%s)" , h2->GetTitle ()));
730+ histm->addHisto (hsig, id + 2 );
722731 }
723- for (int ip = 0 ; ip < 5 ; ip++) {
724- fitSlices (10000 + ip * 10 + offsV + offs);
732+ };
733+ for (int ioffs = 0 ; ioffs <= 3 ; ioffs++) { // vs phi, Z, pT, tgl
734+ int offs = ioffs * 1000 ;
735+ for (int iht = 0 ; iht < 2 ; iht++) { // resid, pull
736+ int offsV = iht == 0 ? 0 : 5 ;
737+ for (int il = 0 ; il < 8 ; il++) {
738+ for (int iyz = 0 ; iyz < 2 ; iyz++) {
739+ fitSlices (il * 10 + iyz * 100 + offsV + offs);
740+ }
741+ }
742+ for (int ip = 0 ; ip < 5 ; ip++) {
743+ fitSlices (10000 + ip * 10 + offsV + offs);
744+ }
725745 }
726746 }
747+ histm->write ();
727748 }
728- histm->write ();
729749 delete gs;
730750}
731751
@@ -922,11 +942,11 @@ void CheckResidSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
922942 }
923943}
924944
925- DataProcessorSpec getCheckResidSpec (GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly)
945+ DataProcessorSpec getCheckResidSpec (GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly, bool postProcOnly )
926946{
927947 std::vector<OutputSpec> outputs;
928948 auto dataRequest = std::make_shared<DataRequest>();
929- if (!drawOnly) {
949+ if (!drawOnly && !postProcOnly ) {
930950 bool useMC = false ;
931951 dataRequest->requestTracks (srcTracks, useMC);
932952 dataRequest->requestClusters (srcClusters, useMC);
@@ -954,7 +974,7 @@ DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t
954974 " check-resid" ,
955975 dataRequest->inputs ,
956976 outputs,
957- AlgorithmSpec{adaptFromTask<CheckResidSpec>(dataRequest, ggRequest, srcTracks, drawOnly)},
977+ AlgorithmSpec{adaptFromTask<CheckResidSpec>(dataRequest, ggRequest, srcTracks, drawOnly, postProcOnly )},
958978 opts};
959979}
960980
0 commit comments