30 #include "CbmTofHit.h"
38 #include "TDatabasePDG.h"
53 static bool compareZ(
const int& a,
const int& b) {
93 if (fVerbose >= 10) cout <<
"ReadEvent: start." << endl;
105 if (fVerbose >= 10) cout <<
"ReadEvent: clear is done." << endl;
107 vector<TmpHit> tmpHits;
108 vector<TmpStrip> tmpStrips;
109 vector<TmpStrip> tmpStripsB;
134 vector<CbmLink*> ToFPointsMatch;
139 for (DFSET::iterator set_it =
vFileEvent.begin();
142 Int_t iFile = set_it->first;
143 Int_t iEvent = set_it->second;
148 for (Int_t iMC = 0; iMC < nMvdPointsInEvent; iMC++) {
159 Double_t dtrck =
dFEI(iFile, iEvent, MC.
ID);
162 Int_t IND_Track = trk_it->second;
165 MC.
ID = trk_it->second;
181 for (Int_t iMC = 0; iMC < nMC; iMC++) {
193 Double_t dtrck =
dFEI(iFile, iEvent, MC.
ID);
196 Int_t IND_Track = trk_it->second;
199 MC.
ID = trk_it->second;
224 Double_t dtrck =
dFEI(iFile, iEvent, MC.
ID);
227 Int_t IND_Track = trk_it->second;
231 MC.
ID = trk_it->second;
245 for (Int_t iMC = 0; iMC <
fTrdPoints->
Size(iFile, iEvent); iMC++) {
258 (MC.
z > sta[iSt].
z[0] - 4.0)
263 Double_t dtrck =
dFEI(iFile, iEvent, MC.
ID);
266 Int_t IND_Track = trk_it->second;
270 MC.
ID = trk_it->second;
281 ToFPointsMatch.resize(0);
284 for (
int j = 0; j <
fTofHits->GetEntries(); j++) {
297 for (
int iLink = 1; iLink < matchHitMatch->
GetNofLinks(); iLink++) {
304 TVector3 pos_cur, pos_old, pos_hit;
307 pt_cur->Position(pos_cur);
308 pt->Position(pos_old);
311 if (
fabs(pos_cur.Z() - pos_hit.Z())
312 <
fabs(pos_old.Z() - pos_hit.Z())) {
318 ToFPointsMatch.push_back(link);
323 for (UInt_t iMC = 0; iMC < ToFPointsMatch.size(); iMC++) {
328 int eventNr = ToFPointsMatch[iMC]->GetEntry();
330 if (eventNr != iEvent)
continue;
333 ToFPointsMatch[iMC]->GetIndex(),
334 ToFPointsMatch[iMC]->GetFile(),
335 ToFPointsMatch[iMC]->GetEntry(),
341 Double_t dtrck =
dFEI(iFile, eventNr, MC.
ID);
345 Int_t IND_Track = trk_it->second;
349 MC.
ID = trk_it->second;
357 ToFPointsMatch[iMC]->GetIndex() +
nMvdPoints + nStsPoints
367 for (
unsigned int iTr = 0; iTr <
vMCTracks.size(); iTr++) {
380 vMCTracks[iTr].mother_ID = map_it->second;
383 if (fVerbose >= 10) cout <<
"Points in vMCTracks are sorted." << endl;
398 for (
int j = 0; j <
listMvdHits->GetEntries(); j++) {
489 tmpHits.push_back(th);
494 if (fVerbose >= 10) cout <<
"ReadEvent: mvd hits are gotten." << endl;
505 for (Int_t j = 0; j < nEnt; j++) {
566 for (Int_t iFrontLink = 0;
569 const CbmLink& frontLink = frontClusterMatch->
GetLink(iFrontLink);
571 for (Int_t iBackLink = 0;
575 if (frontLink == backLink) {
576 stsHitMatch.
AddLink(frontLink);
583 Float_t bestWeight = 0.f;
584 for (Int_t iLink = 0; iLink < stsHitMatch.
GetNofLinks(); iLink++) {
593 Double_t dtrck =
dFEI(iFile, iEvent, iIndex);
596 iMC = trk_it->second;
609 tmpHits.push_back(th);
620 for (
int j = 0; j < nEnt; j++) {
631 Int_t stationNumber =
635 int DetId = stationNumber * 3 + layerNumber;
683 for (Int_t iLink = 0; iLink < matchHitMatch->
GetNofLinks(); iLink++) {
691 Double_t dtrck =
dFEI(iFile, iEvent, iIndex);
694 th.
iMC = trk_it->second;
726 tmpHits.push_back(th);
734 for (
int j = 0; j <
listTrdHits->GetEntries(); j++) {
873 tmpHits.push_back(th);
882 for (
int j = 0; j <
fTofHits->GetEntries(); j++) {
936 Int_t iFile = ToFPointsMatch[j]->GetFile();
937 Int_t iEvent = ToFPointsMatch[j]->GetEntry();
939 Int_t iIndex = ToFPointsMatch[j]->GetIndex() +
nMvdPoints + nStsPoints
942 Double_t dtrck =
dFEI(iFile, iEvent, iIndex);
945 th.
iMC = trk_it->second;
963 tmpHits.push_back(th);
969 if (fVerbose >= 10) cout <<
"ReadEvent: sts hits are gotten." << endl;
977 int NStrips = 0, NStripsB = 0;
978 for (
int ih = 0; ih < nHits; ih++) {
984 for (
int is = 0; is < NStrips; is++) {
992 for (
int is = 0; is < NStripsB; is++) {
1008 tmpStrips.push_back(tmp);
1018 tmpStripsB.push_back(tmp1);
1024 Int_t NEffStrips = 0, NEffStripsB = 0;
1025 for (
int i = 0;
i < NStrips;
i++) {
1032 fData_->
vSFlag.push_back(flag);
1034 for (
int i = 0;
i < NStripsB;
i++) {
1041 fData_->
vSFlagB.push_back(flag);
1045 if (fVerbose >= 10) cout <<
"ReadEvent: strips are read." << endl;
1051 for (
int i = 0;
i < nHits;
i++) {
1088 float z_tmp = -111.;
1094 z_tmp = 0.5 * (point->
GetZOut() + point->GetZ());
1098 z_tmp = mh_m->
GetZ();
1110 z_tmp = mh_m->
GetZ();
1152 for (k = 0; k < vStsZPos_temp.size(); k++) {
1153 if (vStsZPos_temp[k] == z_tmp) {
1158 if (k == vStsZPos_temp.size()) {
1159 h.iz = vStsZPos_temp.size();
1160 vStsZPos_temp.push_back(z_tmp);
1193 if (fVerbose >= 10) cout <<
"ReadEvent: mvd and sts are saved." << endl;
1197 if (vStsZPos_temp.size() != 0) {
1198 vector<float> vStsZPos_temp2;
1199 vStsZPos_temp2.clear();
1200 vStsZPos_temp2.push_back(vStsZPos_temp[0]);
1201 vector<int> newToOldIndex;
1202 newToOldIndex.clear();
1203 newToOldIndex.push_back(0);
1205 for (
unsigned int k = 1; k < vStsZPos_temp.size(); k++) {
1206 vector<float>::iterator itpos = vStsZPos_temp2.begin() + 1;
1207 vector<int>::iterator iti = newToOldIndex.begin() + 1;
1208 for (; itpos < vStsZPos_temp2.end(); itpos++, iti++) {
1209 if (vStsZPos_temp[k] < *itpos) {
1210 vStsZPos_temp2.insert(itpos, vStsZPos_temp[k]);
1211 newToOldIndex.insert(iti, k);
1215 if (itpos == vStsZPos_temp2.end()) {
1216 vStsZPos_temp2.push_back(vStsZPos_temp[k]);
1217 newToOldIndex.push_back(k);
1222 if (fVerbose >= 10) cout <<
"ReadEvent: z-pos are sorted." << endl;
1224 for (
unsigned int k = 0; k < vStsZPos_temp2.size(); k++)
1225 fData_->
vStsZPos.push_back(vStsZPos_temp2[k]);
1227 int size_nto_tmp = newToOldIndex.size();
1228 vector<int> oldToNewIndex;
1229 oldToNewIndex.clear();
1230 oldToNewIndex.resize(size_nto_tmp);
1231 for (
int k = 0; k < size_nto_tmp; k++)
1232 oldToNewIndex[newToOldIndex[k]] = k;
1235 for (
int k = 0; k < size_hs_tmp; k++)
1239 if (fVerbose >= 10) cout <<
"ReadEvent: z-pos are saved." << endl;
1252 if (fVerbose >= 10) cout <<
"HitMatch is done." << endl;
1253 if (fVerbose >= 10) cout <<
"MCPoints and MCTracks are saved." << endl;
1256 if (fVerbose >= 10) cout <<
"ReadEvent is done." << endl;
1266 int nvtracks = 0, nvtrackscurr = 0;
1270 for (DFSET::iterator set_it =
vFileEvent.begin();
1273 Int_t iFile = set_it->first;
1274 Int_t iEvent = set_it->second;
1280 for (Int_t iMCTrack = 0; iMCTrack < nMCTrack; iMCTrack++) {
1282 L1_DYNAMIC_CAST<CbmMCTrack*>(
fMCTracks->
Get(iFile, iEvent, iMCTrack));
1283 if (!MCTrack)
continue;
1288 if (mother_ID < 0 && mother_ID != -2) mother_ID = -iEvent - 1;
1295 Double_t q = 1, mass = 0.;
1297 && ((TParticlePDG*) TDatabasePDG::Instance()->GetParticle(pdg))) {
1298 q = TDatabasePDG::Instance()->GetParticle(pdg)->Charge() / 3.0;
1299 mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
1303 CbmL1MCTrack T(mass, q, vr, vp, IND_Track, mother_ID, pdg);
1317 if (nvtrackscurr > nvtracks) {
1319 nvtracks = nvtrackscurr;
1331 if (nvtrackscurr > nvtracks)
PrimVtx = Vtxcurr;
1334 if (fVerbose &&
PrimVtx.
MC_ID == 999) cout <<
"No primary vertex !!!" << endl;
1342 TVector3 xyzI,
PI, xyzO, PO;
1344 Double_t time = 0.f;
1355 mcID = pt->GetTrackID();
1356 time = pt->GetTime();
1378 mcID = pt->GetTrackID();
1379 time = pt->GetTime();
1390 Double_t Time_MC_point =
1392 if (Time_MC_point < StartTime)
return 1;
1394 if (Time_MC_point > EndTime)
return 1;
1401 mcID = pt->GetTrackID();
1402 time = pt->GetTime();
1426 mcID = pt->GetTrackID();
1428 time = pt->GetTime();
1438 Double_t Time_MC_point =
1440 if (Time_MC_point < StartTime)
return 1;
1442 if (Time_MC_point > EndTime)
return 1;
1449 mcID = pt->GetTrackID();
1450 time = pt->GetTime();
1453 TVector3 xyz = .5 * (xyzI + xyzO);
1454 TVector3 P = .5 * (
PI + PO);
1467 MC->
xOut = xyzO.X();
1468 MC->
yOut = xyzO.Y();
1469 MC->
zOut = xyzO.Z();
1481 if (MC->
ID < 0)
return 1;
1483 L1_DYNAMIC_CAST<CbmMCTrack*>(
fMCTracks->
Get(file, event, MC->
ID));
1484 if (!MCTrack)
return 1;
1488 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(MC->
pdg);
1490 MC->
q = particlePDG->Charge() / 3.0;
1491 MC->
mass = particlePDG->Mass();
1506 for (
int iH = 0; iH < NHits; iH++) {
1515 vector<int> iEvent1;
1526 Float_t Sum_of_front = 0;
1527 Float_t Sum_of_back = 0;
1530 for (Int_t iFrontLink = 0;
1533 const CbmLink& frontLink = frontClusterMatch->
GetLink(iFrontLink);
1534 Sum_of_front = Sum_of_front + frontLink.
GetWeight();
1537 for (Int_t iBackLink = 0; iBackLink < backClusterMatch->
GetNofLinks();
1540 Sum_of_back = Sum_of_back + backLink.
GetWeight();
1543 for (Int_t iFrontLink = 0;
1546 const CbmLink& frontLink = frontClusterMatch->
GetLink(iFrontLink);
1550 for (Int_t iBackLink = 0; iBackLink < backClusterMatch->
GetNofLinks();
1556 if (frontLink == backLink) {
1557 stsHitMatch.
AddLink(frontLink);
1558 stsHitMatch.
AddLink(backLink);
1563 Float_t bestWeight = 0.f;
1564 Float_t totalWeight = 0.f;
1565 for (Int_t iLink = 0; iLink < stsHitMatch.
GetNofLinks(); iLink++) {
1570 iEvent1.push_back(iEvent);
1577 int nMvdPoints_ = 0;
1582 Double_t dtrck =
dFEI(iFile, iEvent, iIndex + nMvdPoints_);
1590 iP = trk_it->second;
1598 for (
unsigned int i = 0;
i < iEvent1.size();
i++) {
1610 vMCPoints[idPoint].hitIds.push_back(iH);