diff --git a/core/base/CbmMatchRecoToMC.cxx b/core/base/CbmMatchRecoToMC.cxx index 61d4a0d7f39895119e23852ec83c94122983165a..5eb6c6d6cbbd9fcb34825f44628f294fd026acae 100644 --- a/core/base/CbmMatchRecoToMC.cxx +++ b/core/base/CbmMatchRecoToMC.cxx @@ -403,7 +403,7 @@ void CbmMatchRecoToMC::ReadAndCreateDataBranches() { /// FIXME: Temporary fix to catch all versions of the TOF Hit to Digi Match /// array. To be removed after a full review of the TOF reco if (nullptr == fTofHitDigiMatches) { - fTofHitDigiMatches = static_cast<TClonesArray*>(ioman->GetObject("TofCalDigiMatch")); + fTofHitDigiMatches = static_cast<TClonesArray*>(ioman->GetObject("TofHitCalDigiMatch")); if (nullptr == fTofHitDigiMatches) { LOG(warning) << "CbmMatchRecoToMC::ReadAndCreateDataBranches()" << " no TOF Hit to Digi array found!"; @@ -425,6 +425,29 @@ void CbmMatchRecoToMC::ReadAndCreateDataBranches() { IsOutputBranchPersistent("TofHitMatch")); } } + + /// FIXME: temporary hacks due to Digi array resizing and resorting in TOF clusterizer + fTofDigis = ioman->InitObjectAs<std::vector<CbmTofDigi> const *>("TofCalDigi"); + if (nullptr == fTofDigis) { + LOG(info) << "No calibrated tof digi vector in the input files => trying original vector"; + fTofDigis = ioman->InitObjectAs<std::vector<CbmTofDigi> const *>("TofDigi"); + if (nullptr == fTofDigis) { + LOG(fatal) << "No original tof digi vector in the input files!"; + } + } + else + LOG(info) << "Found calibrated tof digi vector in one of the input files"; + + fTofDigiMatch = ioman->InitObjectAs<std::vector<CbmMatch> const *>("TofCalDigiMatch"); + if (nullptr == fTofDigiMatch) { + LOG(info) << "No calibrated tof digi to point match vector in the input files => trying original vector"; + fTofDigiMatch = ioman->InitObjectAs<std::vector<CbmMatch> const *>("TofDigiMatch"); + if (nullptr == fTofDigiMatch) { + LOG(fatal) << "No original tof digi to point match vector in the input files!"; + } + } + else + LOG(info) << "Found calibrated tof digi to point match vector in one of the input files"; } @@ -512,10 +535,15 @@ void CbmMatchRecoToMC::MatchHitsTof(const TClonesArray* HitDigiMatches, TClonesArray* hitMatches) { if (!(HitDigiMatches && hits && hitMatches)) return; - Int_t iNbTofDigis = fDigiManager->GetNofDigis(ECbmModuleId::kTof); + Int_t iNbTofDigis = fTofDigis->size(); + Int_t iNbTofDigiMatches = fTofDigiMatch->size(); + if( iNbTofDigis != iNbTofDigiMatches ) + LOG(fatal) << "CbmMatchRecoToMC::MatchHitsTof => Nb digis in vector not matching nb matches in vector: " + << iNbTofDigis << " VS " << iNbTofDigiMatches; + Int_t nofHits = hits->GetEntriesFast(); - const CbmTofDigi* pTofDigi; - const CbmMatch* pMatchDigiPnt; + CbmTofDigi pTofDigi; + CbmMatch pMatchDigiPnt; for (Int_t iHit = 0; iHit < nofHits; iHit++) { CbmMatch* hitDigiMatch = static_cast<CbmMatch*>(HitDigiMatches->At(iHit)); @@ -536,27 +564,27 @@ void CbmMatchRecoToMC::MatchHitsTof(const TClonesArray* HitDigiMatches, continue; } // if( iNbTofDigis <= iDigiIdx ) - pTofDigi = fDigiManager->Get<CbmTofDigi>(iDigiIdx); - pMatchDigiPnt = fDigiManager->GetMatch(ECbmModuleId::kTof, iDigiIdx); - Int_t iNbPointsDigi = pMatchDigiPnt->GetNofLinks(); + pTofDigi = fTofDigis->at(iDigiIdx); + pMatchDigiPnt = fTofDigiMatch->at(iDigiIdx); + Int_t iNbPointsDigi = pMatchDigiPnt.GetNofLinks(); if (iNbPointsDigi <= 0) { LOG(error) << "CbmMatchRecoToMC::MatchHitsTof => No entries in Digi to point match for Hit #" << iHit << "/" << nofHits << " Digi " << iDigi << "/" << iNbDigisHit << ": " << iNbPointsDigi << " (digi index is " << iDigiIdx << "/" << iNbTofDigis << ") => ignore it!!!"; LOG(error) << " Digi address: 0x" << std::setw(8) << std::hex - << pTofDigi->GetAddress() << std::dec; + << pTofDigi.GetAddress() << std::dec; continue; } // if( iNbTofDigis <= iDigiIdx ) CbmLink lTruePoint = - pMatchDigiPnt->GetMatchedLink(); // Point generating the Digi + pMatchDigiPnt.GetMatchedLink(); // Point generating the Digi Int_t iTruePointIdx = lTruePoint.GetIndex(); for (Int_t iPoint = 0; iPoint < iNbPointsDigi; iPoint++) { - CbmLink lPoint = pMatchDigiPnt->GetLink(iPoint); + CbmLink lPoint = pMatchDigiPnt.GetLink(iPoint); Int_t iPointIdx = lPoint.GetIndex(); if (iPointIdx == iTruePointIdx) hitMatch->AddLink( - CbmLink(pTofDigi->GetTot(), + CbmLink(pTofDigi.GetTot(), iPointIdx, lPoint.GetEntry(), lPoint.GetFile())); // Point generating the Digi diff --git a/core/base/CbmMatchRecoToMC.h b/core/base/CbmMatchRecoToMC.h index 46246efafc813944702e878638254bf6f24f7b0d..27cd9d0c206ca95eb7d510d87b64be83119bba22 100644 --- a/core/base/CbmMatchRecoToMC.h +++ b/core/base/CbmMatchRecoToMC.h @@ -17,6 +17,8 @@ #include <vector> // for vector #include "CbmDefs.h" // for ECbmModuleId +#include "CbmMatch.h" +#include "CbmTofDigi.h" class CbmDigiManager; class CbmMCDataArray; @@ -199,6 +201,8 @@ private: // TOF CbmMCDataArray* fTofPoints = nullptr; //! CbmTofPoint array + const std::vector<CbmTofDigi>* fTofDigis = nullptr; // TOF MC point matches + const std::vector<CbmMatch>* fTofDigiMatch = nullptr; // TOF MC point matches TClonesArray* fTofHits = nullptr; //! CbmTofHit array TClonesArray* fTofHitDigiMatches = nullptr; //! Match Hit -> Digi [out] TClonesArray* fTofHitMatches = nullptr; //! Match Hit -> MC point [out] diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index d819cf4cf2e145a7cf6e6c5f324ce05b448d4bfc..2919b5f44514a9af9a0eadf08db155bc3bd5adef 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -514,9 +514,8 @@ InitStatus CbmL1::Init() fTofHitDigiMatches = 0; } else { - fTofPoints = mcManager->InitBranch("TofPoint"); - fTofHitDigiMatches = static_cast<TClonesArray*>(fManger->GetObject("TofHitMatch")); + fTofHitDigiMatches = static_cast<TClonesArray*>(fManger->GetObject("TofHitCalDigiMatch")); } } else { diff --git a/reco/detectors/tof/CbmTofEventClusterizer.cxx b/reco/detectors/tof/CbmTofEventClusterizer.cxx index cb91f46fc3ca0fee98bf492e09bc492b43e68402..fdae60d85fff3a1baac39b1539a005dffb6ace7d 100644 --- a/reco/detectors/tof/CbmTofEventClusterizer.cxx +++ b/reco/detectors/tof/CbmTofEventClusterizer.cxx @@ -76,7 +76,7 @@ static Double_t dTLEvt = 0.; static Int_t iNSpill = 0; static Int_t iNbTs = 0; -const Double_t fdSpillDuration = 4.; // in seconds +const Double_t fdSpillDuration = 2.; // in seconds const Double_t fdSpillBreak = 0.9; // in seconds static Bool_t bAddBeamCounterSideDigi = kTRUE; @@ -102,8 +102,7 @@ CbmTofEventClusterizer::CbmTofEventClusterizer(const char* name, , fChannelInfo(NULL) , fDigiBdfPar(NULL) , fTrbHeader(NULL) - , fTofPointsColl(NULL) - , fMcTracksColl(NULL) + , fTofDigiPointMatches(NULL) , fDigiMan(nullptr) , fEventsColl(nullptr) , fbWriteHitsInOut(writeDataInOut) @@ -112,6 +111,7 @@ CbmTofEventClusterizer::CbmTofEventClusterizer(const char* name, , fTofDigiMatchColl(NULL) , fTofHitsCollOut(NULL) , fTofDigiMatchCollOut(NULL) + , fTofDigiPointMatchesOut(nullptr) , fiNbHits(0) , fVerbose(verbose) , fStorDigi() @@ -338,6 +338,7 @@ void CbmTofEventClusterizer::SetParContainers() { } void CbmTofEventClusterizer::Exec(Option_t* option) { + fTofDigiPointMatchesOut->clear(); if (fTofCalDigiVecOut) fTofCalDigiVecOut->clear(); if (fEventsColl) { @@ -510,21 +511,11 @@ Bool_t CbmTofEventClusterizer::RegisterInputs() { return kFALSE; } // if( NULL == fTofDigisColl) - /* - fTofPointsColl = (TClonesArray *) fManager->GetObject("TofPoint"); - if( NULL == fTofPointsColl) - { - LOG(error)<<"CbmTofEventClusterizer::RegisterInputs => Could not get the TofPoint TClonesArray!!!"; - return kFALSE; - } // if( NULL == fTofPointsColl) - - fMcTracksColl = (TClonesArray *) fManager->GetObject("MCTrack"); - if( NULL == fMcTracksColl) - { - LOG(error)<<"CbmTofEventClusterizer::RegisterInputs => Could not get the MCTrack TClonesArray!!!"; - return kFALSE; - } // if( NULL == fMcTracksColl) - */ + fTofDigiPointMatches = fManager->InitObjectAs<std::vector<CbmMatch> const *>("TofDigiMatch"); + if (NULL == fTofDigiPointMatches) + LOG(info) << "No tof digi to point matches in the input file"; + else + LOG(info) << "Found tof digi to point matches in the input file"; fEventsColl = dynamic_cast<TClonesArray*>(fManager->GetObject("Event")); if (NULL == fEventsColl) @@ -584,7 +575,7 @@ Bool_t CbmTofEventClusterizer::RegisterOutputs() { tHitDigiMatchBranchName = "ATofDigiMatch"; } else { tHitBranchName = "TofHit"; - tHitDigiMatchBranchName = "TofCalDigiMatch"; + tHitDigiMatchBranchName = "TofHitCalDigiMatch"; } if (NULL == fEventsColl) { @@ -597,16 +588,28 @@ Bool_t CbmTofEventClusterizer::RegisterOutputs() { rootMgr->Register( tHitDigiMatchBranchName, "Tof", fTofDigiMatchColl, fbWriteHitsInOut); + + if(NULL != fTofDigiPointMatches) { + fTofDigiPointMatchesOut = new std::vector<CbmMatch>(); + rootMgr->RegisterAny("TofCalDigiMatch", fTofDigiPointMatchesOut, fbWriteDigisInOut); + } + } else { // CbmEvent - mode //fTofCalDigisCollOut = new TClonesArray("CbmTofDigi"); fTofCalDigiVecOut = new std::vector<CbmTofDigi>(); fTofHitsCollOut = new TClonesArray("CbmTofHit"); fTofDigiMatchCollOut = new TClonesArray("CbmMatch", 100); + //rootMgr->Register( "TofCalDigi","Tof", fTofCalDigisCollOut, fbWriteDigisInOut); rootMgr->RegisterAny("TofCalDigi", fTofCalDigiVecOut, fbWriteDigisInOut); rootMgr->Register(tHitBranchName, "Tof", fTofHitsCollOut, fbWriteHitsInOut); rootMgr->Register( tHitDigiMatchBranchName, "Tof", fTofDigiMatchCollOut, fbWriteHitsInOut); + + if(NULL != fTofDigiPointMatches) { + fTofDigiPointMatchesOut = new std::vector<CbmMatch>(); + rootMgr->RegisterAny("TofCalDigiMatch", fTofDigiPointMatchesOut, fbWriteDigisInOut); + } } LOG(info) << "out branches: " << tHitBranchName << ", " << tHitDigiMatchBranchName; @@ -1415,9 +1418,9 @@ Bool_t CbmTofEventClusterizer::CreateHistos() { fDigiBdfPar->GetNbChan(iSmType, iRpcId), 0, fDigiBdfPar->GetNbChan(iSmType, iRpcId), - 15, + 20, 0, - 15.); + 20.); fhRpcDigiStatus[iDetIndx] = new TH2F( Form("cl_SmT%01d_sm%03d_rpc%03d_DigiStatus", iSmType, iSmId, iRpcId), @@ -1433,19 +1436,20 @@ Bool_t CbmTofEventClusterizer::CreateHistos() { 0, 10.); + const Int_t NLogbin=40; + Double_t edge[NLogbin+1]; + for (Int_t i=0; i<NLogbin+1; i++) edge[i]=TMath::Power(2,i); fhRpcDigiDTLD[iDetIndx] = new TH2F( Form("cl_SmT%01d_sm%03d_rpc%03d_DigiDTLD", iSmType, iSmId, iRpcId), Form("Time distance to last digi of Rpc #%03d in Sm %03d of type %d; " - "channel; t_{digi} - t_{previous digi} (s)", + "channel; t_{digi} - t_{previous digi} (ns)", iRpcId, iSmId, iSmType), fDigiBdfPar->GetNbChan(iSmType, iRpcId) * 2, 0, fDigiBdfPar->GetNbChan(iSmType, iRpcId) * 2, - 1000., - 0., - 5.); + NLogbin, edge); fhRpcDigiDTFD[iDetIndx] = new TH2F( Form("cl_SmT%01d_sm%03d_rpc%03d_DigiDTFD", iSmType, iSmId, iRpcId), @@ -1498,7 +1502,7 @@ Bool_t CbmTofEventClusterizer::CreateHistos() { fhRpcCluRate10s[iDetIndx] = new TH1D( Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSmId, iRpcId), Form(" Clu rate of Rpc #%03d in Sm %03d of type %d in last " - "10s; Time (s); Rate (Hz)", + "10s; Time (s); Counts per 100 #mus", iRpcId, iSmId, iSmType), @@ -2459,6 +2463,7 @@ Bool_t CbmTofEventClusterizer::FillHistos() { StartAnalysisTime = pHit->GetTime(); LOG(info) << "StartAnalysisTime set to " << StartAnalysisTime / 1.E9 << " s. "; + fdStartAna10s=StartAnalysisTime; } Int_t iDetId = (pHit->GetAddress() & DetMask); @@ -5509,24 +5514,9 @@ Bool_t CbmTofEventClusterizer::BuildClusters() { Int_t iNbTofDigi = fTofDigiVec.size(); //Int_t iNbTofDigi = fTofDigisColl->GetEntries(); if (iNbTofDigi > 100000) { - LOG(warning) << "Too many digis in event " << fiNevtBuild; + LOG(warning) << "Too many TOF digis in event " << fiNevtBuild; return kFALSE; } - - LOG(info) << "Nb Raw digi at start: " << iNbTofDigi; - for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) { - //CbmTofDigi *pDigi = (CbmTofDigi*) fTofDigisColl->At( iDigInd ); - CbmTofDigi* pDigi = &(fTofDigiVec.at(iDigInd)); - Int_t iDetIndx = fDigiBdfPar->GetDetInd(pDigi->GetAddress()); - - LOG(info) << "RawDigi" << iDigInd << " " << pDigi - << Form(" Address : 0x%08x ", pDigi->GetAddress()) << " SmT " - << pDigi->GetType() << " Sm " << pDigi->GetSm() << " Rpc " - << pDigi->GetRpc() << " Ch " << pDigi->GetChannel() << " S " - << pDigi->GetSide() << ", DetIndx " << iDetIndx << " : " - << pDigi->ToString(); - } // for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) - if (bAddBeamCounterSideDigi) { // Duplicate type "5" - digis // Int_t iNbDigi=iNbTofDigi; @@ -5549,6 +5539,11 @@ Bool_t CbmTofEventClusterizer::BuildClusters() { pDigi->GetType()); LOG(debug) << "Duplicated digi " << fTofDigiVec.size() << " with address 0x" << std::hex << pDigiN->GetAddress(); + + if( NULL != fTofDigiPointMatches ) { // copy MC Match Object + const CbmMatch digiMatch = (CbmMatch) fTofDigiPointMatches->at(iDigInd); + ((std::vector<CbmMatch>*) fTofDigiPointMatches)->push_back((CbmMatch)digiMatch); + } } } iNbTofDigi = fTofDigiVec.size(); @@ -5561,11 +5556,10 @@ Bool_t CbmTofEventClusterizer::BuildClusters() { fvMulDigi[iDetIndx][iCh] = 0.; } - LOG(info) << "Nb Raw digi at start: " << fTofDigiVec.size(); for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) { //CbmTofDigi *pDigi = (CbmTofDigi*) fTofDigisColl->At( iDigInd ); CbmTofDigi* pDigi = &(fTofDigiVec.at(iDigInd)); - Int_t iDetIndx = fDigiBdfPar->GetDetInd(pDigi->GetAddress()); + Int_t iDetIndx = fDigiBdfPar->GetDetInd(pDigi->GetAddress() & DetMask); LOG(debug) << "RawDigi" << iDigInd << " " << pDigi << Form(" Address : 0x%08x ", pDigi->GetAddress()) << " SmT " @@ -5602,13 +5596,12 @@ Bool_t CbmTofEventClusterizer::BuildClusters() { size_t iDigiCh = pDigi->GetChannel() * 2 + pDigi->GetSide(); if (iDigiCh < fvTimeLastDigi[iDetIndx].size()) { if (fvTimeLastDigi[iDetIndx][iDigiCh] > 0) { - if (fdStartAna10s > 0.) { - Double_t dTimeAna10s = (pDigi->GetTime() - fdStartAna10s) / 1.E9; - if (dTimeAna10s < fdSpillDuration) + if (kTRUE) { // fdStartAna10s > 0.) { + //Double_t dTimeAna10s = (pDigi->GetTime() - fdStartAna10s) / 1.E9; + //if (dTimeAna10s < fdSpillDuration) fhRpcDigiDTLD[iDetIndx]->Fill( iDigiCh, - (pDigi->GetTime() - fvTimeLastDigi[iDetIndx][iDigiCh]) - / 1.E9); + (pDigi->GetTime() - fvTimeLastDigi[iDetIndx][iDigiCh]) ); } } fvTimeLastDigi[iDetIndx][iDigiCh] = pDigi->GetTime(); @@ -5787,20 +5780,6 @@ Bool_t CbmTofEventClusterizer::BuildClusters() { } } // kTRUE end - LOG(info) << "Nb Raw digi at end: " << fTofDigiVec.size(); - for (Int_t iDigInd = 0; iDigInd < fTofDigiVec.size(); iDigInd++) { - //CbmTofDigi *pDigi = (CbmTofDigi*) fTofDigisColl->At( iDigInd ); - CbmTofDigi* pDigi = &(fTofDigiVec.at(iDigInd)); - Int_t iDetIndx = fDigiBdfPar->GetDetInd(pDigi->GetAddress()); - - LOG(info) << "RawDigi" << iDigInd << " " << pDigi - << Form(" Address : 0x%08x ", pDigi->GetAddress()) << " SmT " - << pDigi->GetType() << " Sm " << pDigi->GetSm() << " Rpc " - << pDigi->GetRpc() << " Ch " << pDigi->GetChannel() << " S " - << pDigi->GetSide() << ", DetIndx " << iDetIndx << " : " - << pDigi->ToString(); - } // for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) - // Calibrate RawDigis if (kTRUE) { CbmTofDigi* pDigi; @@ -6455,17 +6434,12 @@ Bool_t CbmTofEventClusterizer::AddNextChan(Int_t iSmType, } else { pHit->Delete(); } - TString sPrintout = "A - Inserted Hit and Match"; - sPrintout += TString::Format( "#%4d (%5.1f %5.1f %5.1f) %7.3f %3lu : ", - fiNbHits, hitPos.X(), hitPos.Y(), hitPos.Z(), dLastTime, vDigiIndRef.size()); CbmMatch* digiMatch = new ((*fTofDigiMatchColl)[fiNbHits]) CbmMatch(); for (size_t i = 0; i < vDigiIndRef.size(); i++) { Double_t dTot = (fTofCalDigiVec->at(vDigiIndRef.at(i))).GetTot(); digiMatch->AddLink( CbmLink(dTot, vDigiIndRef.at(i), fiOutputTreeEntry, fiFileIndex)); - sPrintout += TString::Format( "%3d ", vDigiIndRef.at(i) ); } - LOG(info) << sPrintout; fiNbHits++; vDigiIndRef.clear(); @@ -7175,9 +7149,6 @@ Bool_t CbmTofEventClusterizer::BuildHits() { } else { pHit->Delete(); } - TString sPrintout = "B - Inserted Hit and Match"; - sPrintout += TString::Format( "#%4d (%5.1f %5.1f %5.1f) %7.3f %3lu : ", - fiNbHits, hitPos.X(), hitPos.Y(), hitPos.Z(), dLastTime, vDigiIndRef.size()); CbmMatch* digiMatch = new ((*fTofDigiMatchColl)[fiNbHits]) CbmMatch(); @@ -7188,9 +7159,7 @@ Bool_t CbmTofEventClusterizer::BuildHits() { vDigiIndRef.at(i), fiOutputTreeEntry, fiFileIndex)); - sPrintout += TString::Format( "%3d ", vDigiIndRef.at(i) ); } - LOG(info) << sPrintout; fiNbHits++; // For Histogramming @@ -7472,9 +7441,6 @@ Bool_t CbmTofEventClusterizer::BuildHits() { } else { pHit->Delete(); } - TString sPrintout = "C - Inserted Hit and Match"; - sPrintout += TString::Format( "#%4d (%5.1f %5.1f %5.1f) %7.3f %3lu : ", - fiNbHits, hitPos.X(), hitPos.Y(), hitPos.Z(), dLastTime, vDigiIndRef.size()); CbmMatch* digiMatch = new ((*fTofDigiMatchColl)[fiNbHits]) CbmMatch(); @@ -7483,9 +7449,7 @@ Bool_t CbmTofEventClusterizer::BuildHits() { Double_t dTot = fTofCalDigiVec->at(vDigiIndRef.at(i)).GetTot(); digiMatch->AddLink(CbmLink( dTot, vDigiIndRef.at(i), fiOutputTreeEntry, fiFileIndex)); - sPrintout += TString::Format( "%3d ", vDigiIndRef.at(i) ); } - LOG(info) << sPrintout; fiNbHits++; // For Histogramming @@ -7756,6 +7720,11 @@ Bool_t CbmTofEventClusterizer::CalibRawDigis() { LOG(debug) << "CbmTofEventClusterizer::BuildClusters: Sort " << fTofCalDigiVec->size() << " calibrated digis "; if (iNbTofDigi > 1) { + std::vector<CbmTofDigi>* tTofCalDigiVec=nullptr; + if(NULL != fTofDigiPointMatches) { // temporary copy + tTofCalDigiVec=new std::vector<CbmTofDigi>(*fTofCalDigiVec); + } + // fTofCalDigisColl->Sort(iNbTofDigi); // Time order again, in case modified by the calibration /// Sort the buffers of hits due to the time offsets applied std::sort(fTofCalDigiVec->begin(), @@ -7773,8 +7742,32 @@ Bool_t CbmTofEventClusterizer::CalibRawDigis() { })) LOG(warning) << "CbmTofEventClusterizer::BuildClusters: Sorting not successful "; + + if(NULL != fTofDigiPointMatches) { // generate updated MC point Match Collection + UInt_t iDigiOrg=0; + LOG(info)<<Form("Fill MC Point Matches for %3lu, %3lu digis ",fTofCalDigiVec->size(),tTofCalDigiVec->size()); + for (UInt_t iDigi=0; iDigi<fTofCalDigiVec->size(); iDigi++){ + // find original Digi + CbmTofDigi* outDigi = &(fTofCalDigiVec->at(iDigi)); + Bool_t bFound=kFALSE; + while ( !bFound ) { + for( ; iDigiOrg<tTofCalDigiVec->size(); iDigiOrg++) { + CbmTofDigi* orgDigi = &(tTofCalDigiVec->at(iDigiOrg)); + if ( outDigi->GetAddress() == orgDigi->GetAddress() ) { + CbmMatch digiMatch = (CbmMatch) fTofDigiPointMatches->at(iDigiOrg); + ((std::vector<CbmMatch>*) fTofDigiPointMatchesOut)->push_back((CbmMatch)digiMatch); + LOG(DEBUG)<<Form("Copy MC Point Match for 0x%08x, time %8.2f from %3d to %3d ", + orgDigi->GetAddress(),outDigi->GetTime(),iDigiOrg,iDigi); + bFound=kTRUE; + break; + } + if ( iDigiOrg == tTofCalDigiVec->size()-1 ) iDigiOrg=0; + } + } + } + delete tTofCalDigiVec; // cleanup temporary vector + } } - // } return kTRUE; } diff --git a/reco/detectors/tof/CbmTofEventClusterizer.h b/reco/detectors/tof/CbmTofEventClusterizer.h index 81df1eb10d471518d1b7a458af3ee3c43644499c..be2361f6ce4dd100d4f198820f7817b81b8b241f 100644 --- a/reco/detectors/tof/CbmTofEventClusterizer.h +++ b/reco/detectors/tof/CbmTofEventClusterizer.h @@ -15,7 +15,6 @@ // Input/Output //class CbmTofPoint; class CbmTofHit; -class CbmMatch; class CbmEvent; class CbmVertex; // Geometry @@ -26,13 +25,14 @@ class CbmTofDigiBdfPar; class CbmTofCell; class CbmTofFindTracks; class CbmDigiManager; +#include "CbmTofAddress.h" // in cbmdata/tof +#include "CbmTofDigi.h" +#include "CbmMatch.h" class TTofCalibData; class TTrbHeader; // FAIR classes and includes -#include "CbmTofAddress.h" // in cbmdata/tof -#include "CbmTofDigi.h" #include "FairTask.h" // ROOT Classes and includes @@ -254,8 +254,7 @@ private: TTrbHeader* fTrbHeader; // Input variables - TClonesArray* fTofPointsColl; // TOF MC points - TClonesArray* fMcTracksColl; // MC tracks + const std::vector<CbmMatch>* fTofDigiPointMatches=nullptr; // TOF MC point matches //TClonesArray * fTofDigisColl; // TOF Digis std::vector<CbmTofDigi> fTofDigiVec {}; //! TOF Digis const std::vector<CbmTofDigi>* fT0DigiVec = nullptr; //! T0 Digis @@ -265,8 +264,7 @@ private: // Output variables Bool_t fbWriteHitsInOut; Bool_t fbWriteDigisInOut; - std::vector<CbmTofDigi>* fTofCalDigiVec = - nullptr; //! // Calibrated TOF Digis + std::vector<CbmTofDigi>* fTofCalDigiVec = nullptr; //! // Calibrated TOF Digis TClonesArray* fTofHitsColl; // TOF hits TClonesArray* fTofDigiMatchColl; // TOF Digi Links //TClonesArray * fTofCalDigisCollOut; // Calibrated TOF Digis @@ -274,6 +272,7 @@ private: nullptr; //! // Calibrated TOF Digis TClonesArray* fTofHitsCollOut; // TOF hits TClonesArray* fTofDigiMatchCollOut; // TOF Digi Links + std::vector<CbmMatch>* fTofDigiPointMatchesOut = nullptr; // TOF Digi MC Point Matches Int_t fiNbHits; // Index of the CbmTofHit TClonesArray // Generic diff --git a/reco/detectors/tof/CbmTofFindTracks.cxx b/reco/detectors/tof/CbmTofFindTracks.cxx index 0a5d316101409b0a409329b4cf5abd5959c36fc1..5e02ae5cca4f24191e04456959019af9e028a0f7 100644 --- a/reco/detectors/tof/CbmTofFindTracks.cxx +++ b/reco/detectors/tof/CbmTofFindTracks.cxx @@ -253,7 +253,7 @@ InitStatus CbmTofFindTracks::Init() { } // Get TOF DigiMatch Array - fTofMatchArrayIn = (TClonesArray*) ioman->GetObject("TofCalDigiMatch"); + fTofMatchArrayIn = (TClonesArray*) ioman->GetObject("TofHitCalDigiMatch"); if (!fTofMatchArrayIn) { LOG(fatal) << "CbmTofFindTracks::Init: No TofDigiMatch array!"; return kERROR; @@ -1956,7 +1956,7 @@ void CbmTofFindTracks::FillHistograms(CbmEvent* tEvent) { //if (0 == fMapStationRpcId[iSt]) pHit->SetTime(pTrk->GetT0()); // set time of fake hit, abandoned /* cout << " -D- CbmTofFindTracks::FillHistograms: "<< iSt <<", " - <<fMapStationRpcId[iSt]<<", "<< iH <<", "<< iH0 <<", "<<pHit->ToString() << endl; + <<fMapStationRpcId[iSt]<<", "<< iH <<", "<< iH0 <<", "<<pHit->ToString() << endl; */ Double_t dDZ = pHit->GetZ() - tPar->GetZ(); // z- Distance to reference point @@ -2007,8 +2007,8 @@ void CbmTofFindTracks::FillHistograms(CbmEvent* tEvent) { fhPullY_Smt->Fill((Double_t) fMapRpcIdParInd[fMapStationRpcId[iSt]], dDY); /* - fhPullT_Smt->Fill((Double_t)fMapRpcIdParInd[fMapStationRpcId[iSt]], fTrackletTools->GetTdif(pTrk,fMapStationRpcId[iSt], pHit) ); - fhPullX_Smt->Fill((Double_t)fMapRpcIdParInd[fMapStationRpcId[iSt]], fTrackletTools->GetXdif(pTrk,fMapStationRpcId[iSt], pHit) ); + fhPullT_Smt->Fill((Double_t)fMapRpcIdParInd[fMapStationRpcId[iSt]], fTrackletTools->GetTdif(pTrk,fMapStationRpcId[iSt], pHit) ); + fhPullX_Smt->Fill((Double_t)fMapRpcIdParInd[fMapStationRpcId[iSt]], fTrackletTools->GetXdif(pTrk,fMapStationRpcId[iSt], pHit) ); fhPullY_Smt->Fill((Double_t)fMapRpcIdParInd[fMapStationRpcId[iSt]], fTrackletTools->GetYdif(pTrk,fMapStationRpcId[iSt], pHit) ); */ fhPullZ_Smt->Fill((Double_t) fMapRpcIdParInd[fMapStationRpcId[iSt]],