21 #include "FairLogger.h"
22 #include "FairRootManager.h"
25 #include "Riostream.h"
26 #include "TClonesArray.h"
33 , fTofPointsColl(NULL)
35 , fRealTofPoints(NULL)
36 , fTofRealPntMatches(NULL) {}
54 Bool_t isSimulation = kFALSE;
56 LOG(info) <<
"CbmTofMergeMcPoints::Init with GeoVersion " << iGeoVersion;
58 if (
k12b > iGeoVersion) {
59 LOG(error) <<
"CbmTofMergeMcPoints::Init => Only compatible with "
60 "geometries after v12b !!!";
67 LOG(info) <<
"CbmTofMergeMcPoints::Init with GeoVersion "
70 switch (iGeoVersion) {
74 LOG(error) <<
"CbmTofMergeMcPoints::Init => Invalid geometry!!!"
91 static Int_t eventNo = 0;
92 LOG(info) <<
"CbmTofMergeMcPoints::Exec eventNo=" << eventNo++;
98 FairRootManager* ioman = FairRootManager::Instance();
100 LOG(fatal) <<
"CbmTofMergeMcPoints::ReadAndCreateDataBranches() NULL "
106 LOG(fatal) <<
"CbmTofMergeMcPoints::ReadAndCreateDataBranches => Could not "
107 "get the MCTrack TClonesArray!!!";
112 LOG(fatal) <<
"CbmTofMergeMcPoints::ReadAndCreateDataBranches => Could not "
113 "get the TofPoint TClonesArray!!!";
118 ioman->Register(
"RealisticTofPoint",
121 IsOutputBranchPersistent(
"RealisticTofPoint"));
123 ioman->Register(
"TofRealPntMatch",
126 IsOutputBranchPersistent(
"TofRealPntMatch"));
131 const TClonesArray*
points,
132 TClonesArray* realisticPoints,
133 TClonesArray* pointsMatches) {
134 if (!(
points && realisticPoints && pointsMatches))
return;
136 Int_t iNbTracks =
tracks->GetEntriesFast();
137 Int_t iNbTofPoints =
points->GetEntriesFast();
148 for (Int_t iTrk = 0; iTrk < iNbTracks; iTrk++) {
153 std::pair<Int_t, std::vector<Int_t>>(iTrk, std::vector<Int_t>()));
160 std::vector<Int_t> vMeanIdPnts(iNbTofPoints, -1);
163 for (Int_t iPnt = 0; iPnt < iNbTofPoints; iPnt++) {
166 iTrackId = pPnt->GetTrackID();
173 Int_t iMeanMcPointId = 0;
174 Int_t iMeanChannel = 0;
175 Double_t dMeanPosX = 0;
176 Double_t dMeanPosY = 0;
177 Double_t dMeanPosZ = 0;
178 Double_t dMeanTime = 0;
179 Double_t dMeanMomX = 0;
180 Double_t dMeanMomY = 0;
181 Double_t dMeanMomZ = 0;
182 Double_t dMeanLen = 0;
183 Double_t dTotELoss = 0;
184 Int_t iNbPntInMean = 0;
185 Int_t iMeanModType = -1;
186 Int_t iMeanModule = -1;
187 Int_t iMeanCounter = -1;
188 for (std::map<Int_t, std::vector<Int_t>>::iterator it =
fTofPntTrkMap.begin();
194 while (0 < (it->second).size()) {
198 Int_t iPntIdxList = (it->second).size() - 1;
200 iDetId = pPnt->GetDetectorID();
209 dMeanPosX = pPnt->GetX();
210 dMeanPosY = pPnt->GetY();
211 dMeanPosZ = pPnt->GetZ();
212 dMeanTime = pPnt->GetTime();
213 dMeanMomX = pPnt->GetPx();
214 dMeanMomY = pPnt->GetPy();
215 dMeanMomZ = pPnt->GetPz();
216 dMeanLen = pPnt->GetLength();
217 dTotELoss = pPnt->GetEnergyLoss();
219 vMeanIdPnts[(it->second)[iPntIdxList]] = iMeanMcPointId;
221 (it->second).pop_back();
226 iPntIdxList = (it->second).size() - 1;
227 while (0 <= iPntIdxList && 0 < (it->second).size()) {
231 iDetId = pPnt->GetDetectorID();
236 if ((iMeanModType == iModType) && (iMeanModule == iModule)
237 && (iMeanCounter == iCounter)) {
241 dMeanPosX += pPnt->GetX();
242 dMeanPosY += pPnt->GetY();
243 dMeanPosZ += pPnt->GetZ();
244 dMeanTime += pPnt->GetTime();
245 dMeanMomX += pPnt->GetPx();
246 dMeanMomY += pPnt->GetPy();
247 dMeanMomZ += pPnt->GetPz();
248 dMeanLen += pPnt->GetLength();
249 dTotELoss += pPnt->GetEnergyLoss();
252 vMeanIdPnts[(it->second)[iPntIdxList]] = iMeanMcPointId;
255 (it->second).erase((it->second).begin() + iPntIdxList);
256 iPntIdxList = (it->second).size() - 1;
265 iMeanChannel /= iNbPntInMean;
266 dMeanPosX /= iNbPntInMean;
267 dMeanPosY /= iNbPntInMean;
268 dMeanPosZ /= iNbPntInMean;
269 dMeanTime /= iNbPntInMean;
270 dMeanMomX /= iNbPntInMean;
271 dMeanMomY /= iNbPntInMean;
272 dMeanMomZ /= iNbPntInMean;
273 dMeanLen /= iNbPntInMean;
281 TVector3 meanPos(dMeanPosX, dMeanPosY, dMeanPosZ);
282 TVector3 meanMom(dMeanMomX, dMeanMomY, dMeanMomZ);
284 new ((*realisticPoints)[iMeanMcPointId])
301 for (Int_t iPnt = 0; iPnt < iNbTofPoints; iPnt++) {