diff --git a/macro/run/run_reco.C b/macro/run/run_reco.C index 79de51cd1db946f9f3effd6cbca6ae071e1e093e..990a4ddcfb2113b83fdf7de66185d704d117fb0a 100644 --- a/macro/run/run_reco.C +++ b/macro/run/run_reco.C @@ -305,6 +305,7 @@ void run_reco(TString input = "", } // ------------------------------------------------------------------------ + /* // ----- Local reconstruction in MVD ---------------------------------- if (useMvd) { @@ -496,6 +497,7 @@ void run_reco(TString input = "", } //? time-based reco +*/ // ----- Parameter database -------------------------------------------- std::cout << std::endl << std::endl; std::cout << "-I- " << myName << ": Set runtime DB" << std::endl; diff --git a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx index 5dbb08525c90f386050cdd713d000edc94b8db60..2bee8ae22dfd7dec56779c6c69a4d1f2749e1102 100644 --- a/reco/eventbuilder/digis/CbmBuildEventsQA.cxx +++ b/reco/eventbuilder/digis/CbmBuildEventsQA.cxx @@ -34,8 +34,51 @@ CbmBuildEventsQA::~CbmBuildEventsQA() {} // =========================================================================== +// ===== Task initialisation ============================================= +InitStatus CbmBuildEventsQA::Init() { + + // --- Get FairRootManager instance + FairRootManager* ioman = FairRootManager::Instance(); + assert(ioman); + + // --- Get input array (CbmEvent) + fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("CbmEvent")); + if (nullptr == fEvents) { + LOG(fatal) << "CbmBuildEventsQA::Init" + << "No CbmEvent TClonesArray found!"; + } + + // --- DigiManager instance + fDigiMan = CbmDigiManager::Instance(); + fDigiMan->Init(); + + // --- Check input data + for (ECbmModuleId system = ECbmModuleId::kMvd; + system < ECbmModuleId::kNofSystems; + ++system) { + if (fDigiMan->IsMatchPresent(system)) { + LOG(info) << GetName() << ": Found match branch for " + << CbmModuleList::GetModuleNameCaps(system); + fSystems.push_back(system); + } + } + if (fSystems.empty()) { + LOG(fatal) << GetName() << ": No match branch found!"; + return kFATAL; + } + + return kSUCCESS; +} +// =========================================================================== + + // ===== Task execution ================================================== -void CbmBuildEventsQA::Exec(Option_t*) { +void CbmBuildEventsQA::Exec(Option_t*) { SurveyEvents(); } +// =========================================================================== + + +// ===== Event survey ==================================================== +void CbmBuildEventsQA::SurveyEvents() { // --- Time and counters TStopwatch timer; @@ -126,50 +169,9 @@ void CbmBuildEventsQA::Exec(Option_t*) { // =========================================================================== -// ===== Task initialisation ============================================= -InitStatus CbmBuildEventsQA::Init() { - - // --- Get FairRootManager instance - FairRootManager* ioman = FairRootManager::Instance(); - assert(ioman); - - // --- Get input array (CbmEvent) - fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("CbmEvent")); - if (nullptr == fEvents) { - LOG(fatal) << "CbmBuildEventsQA::Init" - << "No CbmEvent TClonesArray found!"; - } - - // --- DigiManager instance - fDigiMan = CbmDigiManager::Instance(); - fDigiMan->Init(); - - // --- Check input data - for (ECbmModuleId system = ECbmModuleId::kMvd; - system < ECbmModuleId::kNofSystems; - ++system) { - if (fDigiMan->IsMatchPresent(system)) { - LOG(info) << GetName() << ": Found match branch for " - << CbmModuleList::GetModuleNameCaps(system); - fSystems.push_back(system); - } - } - if (fSystems.empty()) { - LOG(fatal) << GetName() << ": No match branch found!"; - return kFATAL; - } - - return kSUCCESS; -} -// =========================================================================== - - // ===== Match event ===================================================== void CbmBuildEventsQA::MatchEvent(CbmEvent* event) { - // TODO: This functionality should later be moved to the class - // CbmMatchRecoToMC - // --- Get event match object. If present, will be cleared first. If not, // --- it will be created. CbmMatch* match = event->GetMatch(); @@ -184,25 +186,36 @@ void CbmBuildEventsQA::MatchEvent(CbmEvent* event) { // LOG(info) << GetName() << ": Event " << event->GetNumber() // << ", STS digis : " << event->GetNofData(ECbmDataType::kStsDigi); - // --- Loop over digis - Int_t iNbDigis = event->GetNofData(GetDigiType(fRefDetector)); - for (Int_t iDigi = 0; iDigi < iNbDigis; iDigi++) { - Int_t index = event->GetIndex(GetDigiType(fRefDetector), iDigi); - const CbmMatch* digiMatch = fDigiMan->GetMatch(fRefDetector, index); - assert(digiMatch); - - // --- Update event match with digi links - // --- N.b.: The member "index" of CbmLink has here no meaning, since - // --- there is only one MC event per tree entry. - for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { - Int_t file = digiMatch->GetLink(iLink).GetFile(); - Int_t entry = digiMatch->GetLink(iLink).GetEntry(); - Double_t weight = digiMatch->GetLink(iLink).GetWeight(); - // LOG(info) << "Adding link (weight, entry, file): " << weight << " " - // << entry << " " << file; - match->AddLink(weight, 0, entry, file); - } //# links in digi - } //#digis + // --- Loop over all detector systems + for (ECbmModuleId& system : fSystems) { + + //Skip if reference detectors exist and current system isn't one + if (!fRefDetectors.empty() + && std::find(fRefDetectors.begin(), fRefDetectors.end(), system) + == fRefDetectors.end()) { + continue; + } + + // --- Loop over digis in event + Int_t iNbDigis = event->GetNofData(GetDigiType(system)); + for (Int_t iDigi = 0; iDigi < iNbDigis; iDigi++) { + Int_t index = event->GetIndex(GetDigiType(system), iDigi); + const CbmMatch* digiMatch = fDigiMan->GetMatch(system, index); + assert(digiMatch); + + // --- Update event match with digi links + // --- N.b.: The member "index" of CbmLink has here no meaning, since + // --- there is only one MC event per tree entry. + for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) { + Int_t file = digiMatch->GetLink(iLink).GetFile(); + Int_t entry = digiMatch->GetLink(iLink).GetEntry(); + Double_t weight = digiMatch->GetLink(iLink).GetWeight(); + // LOG(info) << "Adding link (weight, entry, file): " << weight << " " + // << entry << " " << file; + match->AddLink(weight, 0, entry, file); + } //# links in digi + } //#digis + } } // =========================================================================== diff --git a/reco/eventbuilder/digis/CbmBuildEventsQA.h b/reco/eventbuilder/digis/CbmBuildEventsQA.h index e146f36142b2d806200e385abee42d18f5f9659e..c89cd26f26de81709a836a16bea2cb5c027a2093 100644 --- a/reco/eventbuilder/digis/CbmBuildEventsQA.h +++ b/reco/eventbuilder/digis/CbmBuildEventsQA.h @@ -34,6 +34,10 @@ public: /** Task execution **/ virtual void Exec(Option_t* opt); + /** Add a reference detector **/ + void AddRefDetector(ECbmModuleId RefDetector) { + fRefDetectors.push_back(RefDetector); + } private: CbmDigiManager* fDigiMan = nullptr; //! @@ -50,9 +54,12 @@ private: **/ void MatchEvent(CbmEvent* event); + /** Check if digis in reco events belong to correct MC event **/ + void SurveyEvents(); + ECbmDataType GetDigiType(ECbmModuleId system); - ECbmModuleId fRefDetector = ECbmModuleId::kSts; + std::vector<ECbmModuleId> fRefDetectors; // Detectors used for MC matching CbmBuildEventsQA(const CbmBuildEventsQA&); CbmBuildEventsQA& operator=(const CbmBuildEventsQA&);