12 #include "FairRootManager.h"
14 #include "TClonesArray.h"
21 static map<string, map<int, Double_t>> maxDx;
22 static map<string, map<int, Double_t>> maxDy;
23 static map<string, map<int, Double_t>> maxDt;
24 static Double_t maxTofDtx = 0;
25 static Double_t maxTofDty = 0;
27 static void UpdateMax(map<
string, map<int, Double_t>>& errorMap,
31 map<string, map<int, Double_t>>::iterator
i = errorMap.find(stationName);
33 if (
i == errorMap.end()) {
34 errorMap[stationName][stationNumber] =
v;
38 map<int, Double_t>::iterator j =
i->second.find(stationNumber);
40 if (j ==
i->second.end()) {
41 i->second[stationNumber] =
v;
45 if (j->second <
v) j->second =
v;
49 UpdateMax(
string stationName,
int stationNumber,
const CbmPixelHit* hit) {
50 UpdateMax(maxDx, stationName, stationNumber, hit->
GetDx());
51 UpdateMax(maxDy, stationName, stationNumber, hit->
GetDy());
52 UpdateMax(maxDt, stationName, stationNumber, hit->
GetTimeError());
54 if (stationName ==
"Tof") {
55 Double_t dtx = hit->
GetDx() / hit->
GetZ();
57 if (maxTofDtx < dtx) maxTofDtx = dtx;
59 Double_t dty = hit->
GetDy() / hit->
GetZ();
61 if (maxTofDty < dty) maxTofDty = dty;
67 static void DumpMax(map<
string, map<int, Double_t>>& errorMap,
68 const char* errorName) {
69 cout << errorName <<
":" << endl;
71 for (map<
string, map<int, Double_t>>::const_iterator
i = errorMap.begin();
74 for (map<int, Double_t>::const_iterator j =
i->second.begin();
77 cout <<
i->first <<
"[" << j->first <<
"] = " << j->second << endl;
83 static void DumpMax() {
87 cout <<
"ToF dtx: " << maxTofDtx << endl;
88 cout <<
"ToF dty: " << maxTofDty << endl;
91 #endif //DO_ERROR_STAT
102 FairRootManager* ioman = FairRootManager::Instance();
103 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"StsHit"));
107 Int_t nofHits =
fHitArray->GetEntriesFast();
109 for (Int_t
i = 0;
i < nofHits; ++
i) {
116 UpdateMax(
"Sts", stationNumber, hit);
117 #endif //DO_ERROR_STAT
149 const set<Double_t>& stationZs) {
156 for (set<Double_t>::const_iterator
i = stationZs.begin();
157 i != stationZs.end();
179 FairRootManager* ioman = FairRootManager::Instance();
180 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"MCTrack"));
185 fXScats.push_back(list<Double_t>());
186 fYScats.push_back(list<Double_t>());
191 Int_t nofTracks =
fHitArray->GetEntriesFast();
194 for (Int_t
i = 0;
i < nofTracks; ++
i) {
206 const list<EPrimaryParticleId> ppids =
213 bool isPrimary =
false;
224 default: isPrimary = track.
motherInd < 0;
227 if (isPrimary)
break;
230 if (!isPrimary)
continue;
234 for (map<Double_t, list<Point>>::const_iterator j = track.
points.begin();
237 if (j->second.empty()) {
243 if (!isRef)
continue;
245 Point vertexPoint = {track.
x, track.
y, track.
z};
246 list<Point> vertexList;
247 vertexList.push_back(vertexPoint);
248 map<Double_t, list<Point>>::const_iterator jPrev = track.
points.end();
249 vector<list<Double_t>>::iterator xScIter =
fXScats.begin();
251 vector<list<Double_t>>::iterator yScIter =
fYScats.begin();
254 for (map<Double_t, list<Point>>::const_iterator j = track.
points.begin();
257 map<Double_t, list<Point>>::const_iterator jNext = j;
260 if (jNext == track.
points.end())
break;
262 const list<Point>& points0 =
263 (j == track.
points.begin()) ? vertexList : jPrev->second;
264 const list<Point>& points1 = j->second;
265 const list<Point>& points2 = jNext->second;
266 list<Double_t>& xScats = *xScIter;
267 list<Double_t>& yScats = *yScIter;
269 for (list<Point>::const_iterator k = points0.begin();
272 const Point& p0 = *k;
274 for (list<Point>::const_iterator l = points1.begin();
277 const Point& p1 = *l;
278 Double_t deltaZ01 = p1.
z - p0.
z;
279 Double_t tx = (p1.
x - p0.
x) / deltaZ01;
280 Double_t ty = (p1.
y - p0.
y) / deltaZ01;
282 for (list<Point>::const_iterator
m = points2.begin();
286 Double_t deltaZ12 = p2.
z - p1.
z;
287 Double_t
x = p1.
x + tx * deltaZ12;
288 Double_t
y = p1.
y + ty * deltaZ12;
289 xScats.push_back(p2.
x -
x);
290 yScats.push_back(p2.
y -
y);
302 Double_t
Sigma(
const list<Double_t>& values) {
303 if (values.empty())
return 0;
307 for (list<Double_t>::const_iterator
i = values.begin();
i != values.end();
313 mean /= values.size();
316 for (list<Double_t>::const_iterator
i = values.begin();
i != values.end();
319 Double_t delta =
v - mean;
320 var += delta * delta;
323 var /= values.size();
325 return TMath::Sqrt(var);
329 vector<list<Double_t>>::const_iterator i2 =
fYScats.begin();
331 for (vector<list<Double_t>>::const_iterator
i =
fXScats.begin();
334 const list<Double_t>& xScats = *
i;
335 const list<Double_t>& yScats = *i2;
336 Double_t xSigma =
Sigma(xScats);
337 Double_t ySigma =
Sigma(yScats);
353 track.
points[stationZ].push_back(point);
388 FairRootManager* ioman = FairRootManager::Instance();
389 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"StsPoint"));
393 Int_t nofPoints =
fHitArray->GetEntriesFast();
395 for (Int_t
i = 0;
i < nofPoints; ++
i) {
398 Int_t trackInd = point->GetTrackID();
400 if (trackInd < 0)
continue;
402 Int_t stationNumber =
404 Double_t stationZ =
fStationZs[stationNumber];
422 FairRootManager* ioman = FairRootManager::Instance();
423 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"RichHit"));
430 Int_t nofHits =
fHitArray->GetEntriesFast();
432 for (Int_t
i = 0;
i < nofHits; ++
i) {
460 UpdateMax(
"Rich", 0, hit);
461 #endif //DO_ERROR_STAT
473 FairRootManager* ioman = FairRootManager::Instance();
474 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"RichPoint"));
478 Int_t nofPoints =
fHitArray->GetEntriesFast();
480 for (Int_t
i = 0;
i < nofPoints; ++
i) {
483 Int_t trackInd = point->GetTrackID();
485 if (trackInd < 0)
continue;
489 trackInd, stationZ, point->GetX(), point->GetY(), point->GetZ());
521 FairRootManager* ioman = FairRootManager::Instance();
522 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"MuchPixelHit"));
557 Int_t nofHits =
fHitArray->GetEntriesFast();
559 for (Int_t
i = 0;
i < nofHits; ++
i) {
562 int muchStationNumber =
565 int stationNumber = muchStationNumber * 3 + layerNumber;
602 UpdateMax(
"Much", stationNumber, hit);
603 #endif //DO_ERROR_STAT
611 FairRootManager* ioman = FairRootManager::Instance();
612 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"MuchPoint"));
616 Int_t nofPoints =
fHitArray->GetEntriesFast();
618 for (Int_t
i = 0;
i < nofPoints; ++
i) {
621 Int_t trackInd = point->GetTrackID();
623 if (trackInd < 0)
continue;
625 Int_t muchStationNumber =
629 Int_t stationNumber = muchStationNumber * 3 + layerNumber;
630 Double_t stationZ =
fStationZs[stationNumber];
643 FairRootManager* ioman = FairRootManager::Instance();
644 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"TrdHit"));
651 Int_t nofHits =
fHitArray->GetEntriesFast();
653 for (Int_t
i = 0;
i < nofHits; ++
i) {
700 UpdateMax(
"Trd", stationNumber, hit);
701 #endif //DO_ERROR_STAT
709 FairRootManager* ioman = FairRootManager::Instance();
710 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"TrdPoint"));
714 Int_t nofPoints =
fHitArray->GetEntriesFast();
716 for (Int_t
i = 0;
i < nofPoints; ++
i) {
719 Int_t trackInd = point->GetTrackID();
721 if (trackInd < 0)
continue;
724 Double_t stationZ =
fStationZs[stationNumber];
737 FairRootManager* ioman = FairRootManager::Instance();
738 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"TofHit"));
742 Int_t nofHits =
fHitArray->GetEntriesFast();
744 for (Int_t
i = 0;
i < nofHits; ++
i) {
752 UpdateMax(
"Tof", 0, hit);
753 #endif //DO_ERROR_STAT
763 FairRootManager* ioman = FairRootManager::Instance();
764 fHitArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"TofPoint"));
768 Int_t nofPoints =
fHitArray->GetEntriesFast();
770 for (Int_t
i = 0;
i < nofPoints; ++
i) {
773 Int_t trackInd = point->GetTrackID();
775 if (trackInd < 0)
continue;
779 trackInd, stationZ, point->GetX(), point->GetY(), point->GetZ());
789 for (map<string, CbmBinnedHitReader*>::iterator
i =
fReaders.begin();
795 #endif //DO_ERROR_STAT
799 for (map<string, CbmBinnedHitReader*>::iterator
i =
fReaders.begin();
806 for (map<string, CbmBinnedHitReader*>::iterator
i =
fReaders.begin();
824 map<string, CbmBinnedHitReader*>::iterator
i =
fReaders.find(name);
833 map<string, CbmBinnedHitReader*>::iterator
i =
fReaders.find(name);
837 string nameStr(name);
840 if (nameStr ==
"sts")
842 else if (nameStr ==
"rich")
844 else if (nameStr ==
"much")
846 else if (nameStr ==
"trd")
848 else if (nameStr ==
"tof")
850 else if (nameStr ==
"mctrack")
852 else if (nameStr ==
"stsmc")
854 else if (nameStr ==
"richmc")
856 else if (nameStr ==
"muchmc")
858 else if (nameStr ==
"trdmc")
860 else if (nameStr ==
"tofmc")
863 if (0 != newReader)
fReaders[name] = newReader;