CbmRoot
HitReader.cxx
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
7 #include "HitReader.h"
8 #include "CbmMuchGeoScheme.h"
9 #include "CbmMuchPixelHit.h"
10 #include "CbmStsSetup.h"
11 #include "CbmTrdHit.h"
12 #include "FairRootManager.h"
13 #include "Station.h"
14 #include "TClonesArray.h"
15 
16 using namespace std;
17 
18 //#define DO_ERROR_STAT
19 
20 #ifdef DO_ERROR_STAT
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;
26 
27 static void UpdateMax(map<string, map<int, Double_t>>& errorMap,
28  string stationName,
29  int stationNumber,
30  Double_t v) {
31  map<string, map<int, Double_t>>::iterator i = errorMap.find(stationName);
32 
33  if (i == errorMap.end()) {
34  errorMap[stationName][stationNumber] = v;
35  return;
36  }
37 
38  map<int, Double_t>::iterator j = i->second.find(stationNumber);
39 
40  if (j == i->second.end()) {
41  i->second[stationNumber] = v;
42  return;
43  }
44 
45  if (j->second < v) j->second = v;
46 }
47 
48 static void
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());
53 
54  if (stationName == "Tof") {
55  Double_t dtx = hit->GetDx() / hit->GetZ();
56 
57  if (maxTofDtx < dtx) maxTofDtx = dtx;
58 
59  Double_t dty = hit->GetDy() / hit->GetZ();
60 
61  if (maxTofDty < dty) maxTofDty = dty;
62  }
63 }
64 
65 #include <iostream>
66 
67 static void DumpMax(map<string, map<int, Double_t>>& errorMap,
68  const char* errorName) {
69  cout << errorName << ":" << endl;
70 
71  for (map<string, map<int, Double_t>>::const_iterator i = errorMap.begin();
72  i != errorMap.end();
73  ++i) {
74  for (map<int, Double_t>::const_iterator j = i->second.begin();
75  j != i->second.end();
76  ++j)
77  cout << i->first << "[" << j->first << "] = " << j->second << endl;
78  }
79 
80  cout << endl;
81 }
82 
83 static void DumpMax() {
84  DumpMax(maxDx, "Dx");
85  DumpMax(maxDy, "Dy");
86  DumpMax(maxDt, "Dt");
87  cout << "ToF dtx: " << maxTofDtx << endl;
88  cout << "ToF dty: " << maxTofDty << endl;
89 }
90 
91 #endif //DO_ERROR_STAT
92 
94 
95 CbmBinnedHitReader::CbmBinnedHitReader() : fStations(), fHitArray(0) {}
96 
98 
100 public:
102  FairRootManager* ioman = FairRootManager::Instance();
103  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("StsHit"));
104  }
105 
106  void Read() {
107  Int_t nofHits = fHitArray->GetEntriesFast();
108 
109  for (Int_t i = 0; i < nofHits; ++i) {
110  const CbmPixelHit* hit =
111  static_cast<const CbmPixelHit*>(fHitArray->At(i));
112  int stationNumber =
114  fStations[stationNumber]->AddHit(ECbmModuleId::kSts, hit, i);
115 #ifdef DO_ERROR_STAT
116  UpdateMax("Sts", stationNumber, hit);
117 #endif //DO_ERROR_STAT
118  }
119  }
120 };
121 
122 #include "CbmMCTrack.h"
123 
125 
127 private:
128  struct Point {
129  Double_t x;
130  Double_t y;
131  Double_t z;
132  };
133 
134  struct Track {
135  Int_t pdg;
136  Int_t motherInd;
137  Double_t x;
138  Double_t y;
139  Double_t z;
140  map<Double_t, list<Point>> points;
141 
142  Track() : pdg(-1), motherInd(-1), x(0), y(0), z(0), points() {}
143 
144  void Init(Int_t pdgCode,
145  Int_t mi,
146  Double_t vx,
147  Double_t vy,
148  Double_t vz,
149  const set<Double_t>& stationZs) {
150  pdg = pdgCode;
151  motherInd = mi;
152  x = vx;
153  y = vy;
154  z = vz;
155 
156  for (set<Double_t>::const_iterator i = stationZs.begin();
157  i != stationZs.end();
158  ++i)
159  points[*i] = list<Point>();
160  }
161  };
162 
163 public:
165  static CbmBinnedMCTrackReader* instance = 0;
166 
167  if (0 == instance) {
168  AddReader("mctrack");
169  instance = static_cast<CbmBinnedMCTrackReader*>(
170  CbmBinnedHitReader::Instance("mctrack"));
171  }
172 
173  return instance;
174  }
175 
176 public:
179  FairRootManager* ioman = FairRootManager::Instance();
180  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("MCTrack"));
181  }
182 
183  void AddStation(CbmBinnedStation* station) {
184  fStationZs.insert(station->GetMinZ());
185  fXScats.push_back(list<Double_t>());
186  fYScats.push_back(list<Double_t>());
187  }
188 
189  void Read() {
190  fTracks.clear();
191  Int_t nofTracks = fHitArray->GetEntriesFast();
192  fTracks.resize(nofTracks);
193 
194  for (Int_t i = 0; i < nofTracks; ++i) {
195  const CbmMCTrack* mcTrack =
196  static_cast<const CbmMCTrack*>(fHitArray->At(i));
197  Int_t motherInd = mcTrack->GetMotherId();
198  Double_t x = mcTrack->GetStartX();
199  Double_t y = mcTrack->GetStartY();
200  Double_t z = mcTrack->GetStartZ();
201  fTracks[i].Init(mcTrack->GetPdgCode(), motherInd, x, y, z, fStationZs);
202  }
203  }
204 
205  void Handle() {
206  const list<EPrimaryParticleId> ppids =
208 
209  for (vector<Track>::const_iterator i = fTracks.begin(); i != fTracks.end();
210  ++i) {
211  const Track& track = *i;
212 
213  bool isPrimary = false;
214 
215  for (EPrimaryParticleId ppi : ppids) {
216  switch (ppi) {
217  case ppiJpsi: {
218  if (track.motherInd >= 0)
219  isPrimary = 443 == fTracks[track.motherInd].pdg;
220 
221  break;
222  }
223 
224  default: isPrimary = track.motherInd < 0;
225  }
226 
227  if (isPrimary) break;
228  }
229 
230  if (!isPrimary) continue;
231 
232  bool isRef = true;
233 
234  for (map<Double_t, list<Point>>::const_iterator j = track.points.begin();
235  j != track.points.end();
236  ++j) {
237  if (j->second.empty()) {
238  isRef = false;
239  break;
240  }
241  }
242 
243  if (!isRef) continue;
244 
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();
250  ++xScIter;
251  vector<list<Double_t>>::iterator yScIter = fYScats.begin();
252  ++yScIter;
253 
254  for (map<Double_t, list<Point>>::const_iterator j = track.points.begin();
255  j != track.points.end();
256  ++j) {
257  map<Double_t, list<Point>>::const_iterator jNext = j;
258  ++jNext;
259 
260  if (jNext == track.points.end()) break;
261 
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;
268 
269  for (list<Point>::const_iterator k = points0.begin();
270  k != points0.end();
271  ++k) {
272  const Point& p0 = *k;
273 
274  for (list<Point>::const_iterator l = points1.begin();
275  l != points1.end();
276  ++l) {
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;
281 
282  for (list<Point>::const_iterator m = points2.begin();
283  m != points2.end();
284  ++m) {
285  const Point& p2 = *m;
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);
291  }
292  }
293  }
294 
295  jPrev = j;
296  ++xScIter;
297  ++yScIter;
298  }
299  }
300  }
301 
302  Double_t Sigma(const list<Double_t>& values) {
303  if (values.empty()) return 0;
304 
305  Double_t mean = 0;
306 
307  for (list<Double_t>::const_iterator i = values.begin(); i != values.end();
308  ++i) {
309  Double_t v = *i;
310  mean += v;
311  }
312 
313  mean /= values.size();
314  Double_t var = 0;
315 
316  for (list<Double_t>::const_iterator i = values.begin(); i != values.end();
317  ++i) {
318  Double_t v = *i;
319  Double_t delta = v - mean;
320  var += delta * delta;
321  }
322 
323  var /= values.size();
324 
325  return TMath::Sqrt(var);
326  }
327 
328  void Finish() {
329  vector<list<Double_t>>::const_iterator i2 = fYScats.begin();
330 
331  for (vector<list<Double_t>>::const_iterator i = fXScats.begin();
332  i != fXScats.end();
333  ++i) {
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);
338  fSettings->AddStationScats(xSigma, ySigma);
339  ++i2;
340  }
341 
342  fSettings->setChanged();
343  fSettings->setInputVersion(-2, 1);
344  }
345 
346  void AddPoint(Int_t trackInd,
347  Double_t stationZ,
348  Double_t x,
349  Double_t y,
350  Double_t z) {
351  Track& track = fTracks[trackInd];
352  Point point = {x, y, z};
353  track.points[stationZ].push_back(point);
354  }
355 
356 private:
357  set<Double_t> fStationZs;
358  vector<Track> fTracks;
359  vector<list<Double_t>> fXScats;
360  vector<list<Double_t>> fYScats;
361 };
362 
364 protected:
368  , fStationZs() {}
371 
372 public:
373  void AddStation(CbmBinnedStation* station) {
374  fTrackReader->AddStation(station);
375  fStationZs.push_back(station->GetMinZ());
376  }
377 
378 protected:
380  vector<Double_t> fStationZs;
381 };
382 
383 #include "CbmStsPoint.h"
384 
386 public:
388  FairRootManager* ioman = FairRootManager::Instance();
389  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("StsPoint"));
390  }
391 
392  void Read() {
393  Int_t nofPoints = fHitArray->GetEntriesFast();
394 
395  for (Int_t i = 0; i < nofPoints; ++i) {
396  const CbmStsPoint* point =
397  static_cast<const CbmStsPoint*>(fHitArray->At(i));
398  Int_t trackInd = point->GetTrackID();
399 
400  if (trackInd < 0) continue;
401 
402  Int_t stationNumber =
403  CbmStsSetup::Instance()->GetStationNumber(point->GetDetectorID());
404  Double_t stationZ = fStationZs[stationNumber];
405  fTrackReader->AddPoint(trackInd,
406  stationZ,
407  (point->GetXIn() + point->GetXOut()) / 2,
408  (point->GetYIn() + point->GetYOut()) / 2,
409  (point->GetZIn() + point->GetZOut()) / 2);
410  }
411  }
412 };
413 
414 #include "CbmLink.h"
415 #include "CbmMatch.h"
416 #include "rich/CbmRichDigi.h"
417 #include "rich/CbmRichPoint.h"
418 
420 public:
422  FairRootManager* ioman = FairRootManager::Instance();
423  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("RichHit"));
424  }
425 
428 
429  void Read() {
430  Int_t nofHits = fHitArray->GetEntriesFast();
431 
432  for (Int_t i = 0; i < nofHits; ++i) {
433  /*const */ CbmPixelHit* hit =
434  static_cast</*const */ CbmPixelHit*>(fHitArray->At(i));
435 
436  /*int digiIndex = hit->GetRefId();
437  const CbmRichDigi* digi = static_cast<const CbmRichDigi*>(fDigiArray->At(digiIndex));
438  CbmMatch* digiMatch = digi->GetMatch();
439 
440  vector<CbmLink> links = digiMatch->GetLinks();
441  Double_t t = 0;
442  int cnt = 0;
443 
444  for (int j = 0; j < links.size(); ++j)
445  {
446  const CbmRichPoint* point = static_cast<const CbmRichPoint*> (fPointArray->Get(links[j]));
447  t += point->GetTime();
448  ++cnt;
449  }
450 
451  if (0 < cnt)
452  t /= cnt;*/
453 
454  hit->SetTime(0);
455  hit->SetTimeError(4);
456  hit->SetDx(0.175);
457  hit->SetDy(0.175);
458  fStations[0]->AddHit(ECbmModuleId::kRich, hit, i);
459 #ifdef DO_ERROR_STAT
460  UpdateMax("Rich", 0, hit);
461 #endif //DO_ERROR_STAT
462  }
463  }
464 
465 private:
466  //TClonesArray* fDigiArray;
467  //CbmMCDataArray* fPointArray;
468 };
469 
471 public:
473  FairRootManager* ioman = FairRootManager::Instance();
474  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("RichPoint"));
475  }
476 
477  void Read() {
478  Int_t nofPoints = fHitArray->GetEntriesFast();
479 
480  for (Int_t i = 0; i < nofPoints; ++i) {
481  const CbmRichPoint* point =
482  static_cast<const CbmRichPoint*>(fHitArray->At(i));
483  Int_t trackInd = point->GetTrackID();
484 
485  if (trackInd < 0) continue;
486 
487  Double_t stationZ = fStationZs[0];
489  trackInd, stationZ, point->GetX(), point->GetY(), point->GetZ());
490  }
491  }
492 };
493 
494 #include "CbmMuchCluster.h"
495 #include "CbmMuchDigi.h"
496 #include "CbmMuchPoint.h"
497 #include "CbmTrdPoint.h"
498 #include "TH1.h"
499 
501 private:
502  /*TClonesArray* fMuchClusters;
503  TClonesArray* fMuchDigis;
504  TClonesArray* fMuchPoints;
505  TH1F* fHitResidualXHisto;
506  TH1F* fHitResidualYHisto;
507  TH1F* fHitResidualTHisto;
508  TH1F* fHitPullTHisto;*/
509 
510 public:
513  /*, fMuchClusters(nullptr)
514  , fMuchDigis(nullptr)
515  , fMuchPoints(nullptr)
516  , fHitResidualXHisto(nullptr)
517  , fHitResidualYHisto(nullptr)
518  , fHitResidualTHisto(nullptr)
519  , fHitPullTHisto(nullptr)*/
520  {
521  FairRootManager* ioman = FairRootManager::Instance();
522  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("MuchPixelHit"));
523 
524  /*fMuchClusters = static_cast<TClonesArray*> (ioman->GetObject("MuchCluster"));
525  fMuchDigis = static_cast<TClonesArray*> (ioman->GetObject("MuchDigi"));
526  fMuchPoints = static_cast<TClonesArray*> (ioman->GetObject("MuchPoint"));
527  fHitResidualXHisto = new TH1F("muchHitResidualXHisto", "muchHitResidualXHisto", 200, -10., 10.);
528  fHitResidualYHisto = new TH1F("muchHitResidualYHisto", "muchHitResidualYHisto", 200, -10., 10.);
529  fHitResidualTHisto = new TH1F("muchHitResidualTHisto", "muchHitResidualTHisto", 1000, -20., 80.);
530  fHitPullTHisto = new TH1F("muchHitPullTHisto", "muchHitPullTHisto", 200, -10., 10.);*/
531  }
532 
533  /*void SaveHisto(TH1* histo)
534  {
535  TFile* curFile = TFile::CurrentFile();
536  TString histoName = histo->GetName();
537  histoName += ".root";
538  TFile fh(histoName.Data(), "RECREATE");
539  histo->Write();
540  fh.Close();
541  delete histo;
542  TFile::CurrentFile() = curFile;
543  }
544 
545  void Finish()
546  {
547  SaveHisto(fHitResidualXHisto);
548  SaveHisto(fHitResidualYHisto);
549  SaveHisto(fHitResidualTHisto);
550  SaveHisto(fHitPullTHisto);
551  }*/
552 
555 
556  void Read() {
557  Int_t nofHits = fHitArray->GetEntriesFast();
558 
559  for (Int_t i = 0; i < nofHits; ++i) {
560  /*const */ CbmMuchPixelHit* hit =
561  static_cast</*const */ CbmMuchPixelHit*>(fHitArray->At(i));
562  int muchStationNumber =
564  int layerNumber = CbmMuchGeoScheme::GetLayerIndex(hit->GetAddress());
565  int stationNumber = muchStationNumber * 3 + layerNumber;
566 
567  /*Double_t t = 0;
568  int cnt = 0;
569  Int_t clusterId = hit->GetRefId();
570  const CbmMuchCluster* cluster = static_cast<const CbmMuchCluster*> (fMuchClusters->At(clusterId));
571  Int_t nofDigis = cluster->GetNofDigis();
572 
573  for (Int_t j = 0; j < nofDigis; ++j)
574  {
575  Int_t digiId = cluster->GetDigi(j);
576  const CbmMuchDigi* digi = static_cast<const CbmMuchDigi*> (fMuchDigis->At(digiId));
577  const CbmMatch* match = digi->GetMatch();
578  Int_t nofLinks = match->GetNofLinks();
579 
580  for (Int_t k = 0; k < nofLinks; ++k)
581  {
582  const CbmLink& link = match->GetLink(k);
583  const CbmMuchPoint* muchPoint = static_cast<const CbmMuchPoint*> (fMuchPoints->At(link.GetIndex()));
584  fHitResidualXHisto->Fill(hit->GetX() - (muchPoint->GetXIn() + muchPoint->GetXOut()) / 2);
585  fHitResidualYHisto->Fill(hit->GetY() - (muchPoint->GetYIn() + muchPoint->GetYOut()) / 2);
586  fHitResidualTHisto->Fill(hit->GetTime() - muchPoint->GetTime());
587  fHitPullTHisto->Fill((hit->GetTime() - muchPoint->GetTime() - 17.23) / hit->GetTimeError());
588  t += muchPoint->GetTime();
589  ++cnt;
590  }
591  }
592 
593  if (0 < cnt)
594  t /= cnt;*/
595 
596  //hit->SetTime(0);
597 
598  hit->SetTime(hit->GetTime() - 17.23);
599  //hit->SetTimeError(10);
600  fStations[stationNumber]->AddHit(ECbmModuleId::kMuch, hit, i);
601 #ifdef DO_ERROR_STAT
602  UpdateMax("Much", stationNumber, hit);
603 #endif //DO_ERROR_STAT
604  }
605  }
606 };
607 
609 public:
611  FairRootManager* ioman = FairRootManager::Instance();
612  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("MuchPoint"));
613  }
614 
615  void Read() {
616  Int_t nofPoints = fHitArray->GetEntriesFast();
617 
618  for (Int_t i = 0; i < nofPoints; ++i) {
619  const CbmMuchPoint* point =
620  static_cast<const CbmMuchPoint*>(fHitArray->At(i));
621  Int_t trackInd = point->GetTrackID();
622 
623  if (trackInd < 0) continue;
624 
625  Int_t muchStationNumber =
626  CbmMuchGeoScheme::GetStationIndex(point->GetDetectorID());
627  Int_t layerNumber =
628  CbmMuchGeoScheme::GetLayerIndex(point->GetDetectorID());
629  Int_t stationNumber = muchStationNumber * 3 + layerNumber;
630  Double_t stationZ = fStationZs[stationNumber];
631  fTrackReader->AddPoint(trackInd,
632  stationZ,
633  (point->GetXIn() + point->GetXOut()) / 2,
634  (point->GetYIn() + point->GetYOut()) / 2,
635  (point->GetZIn() + point->GetZOut()) / 2);
636  }
637  }
638 };
639 
641 public:
643  FairRootManager* ioman = FairRootManager::Instance();
644  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("TrdHit"));
645  }
646 
649 
650  void Read() {
651  Int_t nofHits = fHitArray->GetEntriesFast();
652 
653  for (Int_t i = 0; i < nofHits; ++i) {
654  /*const */ CbmTrdHit* hit =
655  static_cast</*const */ CbmTrdHit*>(fHitArray->At(i));
656  int stationNumber = hit->GetPlaneId();
657  /*Int_t clusterId = hit->GetRefId();
658  const CbmCluster* cluster = static_cast<const CbmCluster*> (fClusterArray->At(clusterId));
659  Int_t nDigis = cluster->GetNofDigis();
660  Double_t t = 0;
661  Double_t x = 0;
662  Double_t y = 0;
663  int cnt = 0;
664  int nofNegs = 0;
665 
666  for (Int_t j = 0; j < nDigis; ++j)
667  {
668  const CbmMatch* digiMatch = static_cast<const CbmMatch*> (fDigiMatchArray->At(cluster->GetDigi(j)));
669  Int_t nMCs = digiMatch->GetNofLinks();
670 
671  for (Int_t k = 0; k < nMCs; ++k)
672  {
673  const CbmLink& lnk = digiMatch->GetLink(k);
674  const CbmTrdPoint* point = static_cast<const CbmTrdPoint*> (fPointArray->Get(lnk));
675  t += point->GetTime();
676  x += (point->GetXIn() + point->GetXOut()) / 2;
677  y += (point->GetYIn() + point->GetYOut()) / 2;
678  ++cnt;
679  }
680  }
681 
682  if (0 < cnt)
683  {
684  t /= cnt;
685  x /= cnt;
686  //hit->SetX(x);
687  y /= cnt;
688  //hit->SetY(y);
689  }
690  else
691  x = 1;*/
692 
693  //hit->SetTime(t);
694  hit->SetTime(0);
695  hit->SetTimeError(10000);
696  //hit->SetDx(hit->GetDx() * 4);
697  //hit->SetDy(hit->GetDy() * 4);
698  fStations[stationNumber]->AddHit(ECbmModuleId::kTrd, hit, i);
699 #ifdef DO_ERROR_STAT
700  UpdateMax("Trd", stationNumber, hit);
701 #endif //DO_ERROR_STAT
702  }
703  }
704 };
705 
707 public:
709  FairRootManager* ioman = FairRootManager::Instance();
710  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("TrdPoint"));
711  }
712 
713  void Read() {
714  Int_t nofPoints = fHitArray->GetEntriesFast();
715 
716  for (Int_t i = 0; i < nofPoints; ++i) {
717  const CbmTrdPoint* point =
718  static_cast<const CbmTrdPoint*>(fHitArray->At(i));
719  Int_t trackInd = point->GetTrackID();
720 
721  if (trackInd < 0) continue;
722 
723  Int_t stationNumber = CbmTrdAddress::GetLayerId(point->GetDetectorID());
724  Double_t stationZ = fStationZs[stationNumber];
725  fTrackReader->AddPoint(trackInd,
726  stationZ,
727  (point->GetXIn() + point->GetXOut()) / 2,
728  (point->GetYIn() + point->GetYOut()) / 2,
729  (point->GetZIn() + point->GetZOut()) / 2);
730  }
731  }
732 };
733 
735 public:
737  FairRootManager* ioman = FairRootManager::Instance();
738  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("TofHit"));
739  }
740 
741  void Read() {
742  Int_t nofHits = fHitArray->GetEntriesFast();
743 
744  for (Int_t i = 0; i < nofHits; ++i) {
745  /*const */ CbmPixelHit* hit =
746  static_cast</*const */ CbmPixelHit*>(fHitArray->At(i));
747 
748  if (hit->GetTimeError() <= 0) hit->SetTimeError(4);
749 
750  fStations[0]->AddHit(ECbmModuleId::kTof, hit, i);
751 #ifdef DO_ERROR_STAT
752  UpdateMax("Tof", 0, hit);
753 #endif //DO_ERROR_STAT
754  }
755  }
756 };
757 
758 #include "CbmTofPoint.h"
759 
761 public:
763  FairRootManager* ioman = FairRootManager::Instance();
764  fHitArray = static_cast<TClonesArray*>(ioman->GetObject("TofPoint"));
765  }
766 
767  void Read() {
768  Int_t nofPoints = fHitArray->GetEntriesFast();
769 
770  for (Int_t i = 0; i < nofPoints; ++i) {
771  const CbmTofPoint* point =
772  static_cast<const CbmTofPoint*>(fHitArray->At(i));
773  Int_t trackInd = point->GetTrackID();
774 
775  if (trackInd < 0) continue;
776 
777  Double_t stationZ = fStationZs[0];
779  trackInd, stationZ, point->GetX(), point->GetY(), point->GetZ());
780  }
781  }
782 };
783 
785 public:
787 
788  void Read() {
789  for (map<string, CbmBinnedHitReader*>::iterator i = fReaders.begin();
790  i != fReaders.end();
791  ++i)
792  i->second->Read();
793 #ifdef DO_ERROR_STAT
794  DumpMax();
795 #endif //DO_ERROR_STAT
796  }
797 
798  void Handle() {
799  for (map<string, CbmBinnedHitReader*>::iterator i = fReaders.begin();
800  i != fReaders.end();
801  ++i)
802  i->second->Handle();
803  }
804 
805  void Finish() {
806  for (map<string, CbmBinnedHitReader*>::iterator i = fReaders.begin();
807  i != fReaders.end();
808  ++i)
809  i->second->Finish();
810  }
811 };
812 
814  static CbmBinnedAllHitReader* allReader = 0;
815 
816  if (0 == allReader) allReader = new CbmBinnedAllHitReader;
817 
818  return allReader;
819 }
820 
821 map<string, CbmBinnedHitReader*> CbmBinnedHitReader::fReaders;
822 
824  map<string, CbmBinnedHitReader*>::iterator i = fReaders.find(name);
825 
826  if (i != fReaders.end())
827  return i->second;
828  else
829  return 0;
830 }
831 
832 void CbmBinnedHitReader::AddReader(const char* name) {
833  map<string, CbmBinnedHitReader*>::iterator i = fReaders.find(name);
834 
835  if (i != fReaders.end()) return;
836 
837  string nameStr(name);
838  CbmBinnedHitReader* newReader = 0;
839 
840  if (nameStr == "sts")
841  newReader = new CbmBinnedStsHitReader;
842  else if (nameStr == "rich")
843  newReader = new CbmBinnedRichHitReader;
844  else if (nameStr == "much")
845  newReader = new CbmBinnedMuchHitReader;
846  else if (nameStr == "trd")
847  newReader = new CbmBinnedTrdHitReader;
848  else if (nameStr == "tof")
849  newReader = new CbmBinnedTofHitReader;
850  else if (nameStr == "mctrack")
851  newReader = new CbmBinnedMCTrackReader;
852  else if (nameStr == "stsmc")
853  newReader = new CbmBinnedStsMCReader;
854  else if (nameStr == "richmc")
855  newReader = new CbmBinnedRichMCReader;
856  else if (nameStr == "muchmc")
857  newReader = new CbmBinnedMuchMCReader;
858  else if (nameStr == "trdmc")
859  newReader = new CbmBinnedTrdMCReader;
860  else if (nameStr == "tofmc")
861  newReader = new CbmBinnedTofMCReader;
862 
863  if (0 != newReader) fReaders[name] = newReader;
864 }
CbmRichPoint.h
CbmBinnedMCTrackReader::fYScats
vector< list< Double_t > > fYScats
Definition: HitReader.cxx:360
CbmBinnedMCTrackReader::Point
Definition: HitReader.cxx:128
CbmMuchPoint::GetXOut
Double_t GetXOut() const
Definition: CbmMuchPoint.h:73
CbmHit::GetZ
Double_t GetZ() const
Definition: CbmHit.h:70
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmMCTrack::GetStartX
Double_t GetStartX() const
Definition: CbmMCTrack.h:75
CbmBinnedMCTrackReader::Finish
void Finish()
Definition: HitReader.cxx:328
CbmTrdPoint::GetYOut
Double_t GetYOut() const
Definition: CbmTrdPoint.h:67
CbmMuchDigi.h
CbmMuchPoint
Definition: CbmMuchPoint.h:21
CbmBinnedMCPointReader
Definition: HitReader.cxx:363
CbmTrdPoint::GetZIn
Double_t GetZIn() const
Definition: CbmTrdPoint.h:65
CbmBinnedHitReader::fHitArray
TClonesArray * fHitArray
Definition: HitReader.h:49
CbmStsPoint::GetXOut
Double_t GetXOut() const
Definition: CbmStsPoint.h:84
CbmBinnedMCTrackReader::Sigma
Double_t Sigma(const list< Double_t > &values)
Definition: HitReader.cxx:302
CbmBinnedTofHitReader::Read
void Read()
Definition: HitReader.cxx:741
CbmStsSetup.h
CbmPixelHit::GetDx
Double_t GetDx() const
Definition: CbmPixelHit.h:85
CbmBinnedRichHitReader::CbmBinnedRichHitReader
CbmBinnedRichHitReader()
Definition: HitReader.cxx:421
CbmBinnedHitReader::fStations
std::vector< CbmBinnedStation * > fStations
Definition: HitReader.h:48
CbmBinnedMCTrackReader::Point::x
Double_t x
Definition: HitReader.cxx:129
CbmBinnedMuchHitReader::CbmBinnedMuchHitReader
CbmBinnedMuchHitReader(const CbmBinnedMuchHitReader &)=delete
CbmBinnedMuchMCReader::Read
void Read()
Definition: HitReader.cxx:615
CbmBinnedStation::GetMinZ
Double_t GetMinZ() const
Definition: Station.h:435
CbmBinnedHitReader::~CbmBinnedHitReader
virtual ~CbmBinnedHitReader()
Definition: HitReader.cxx:97
CbmBinnedTrdMCReader::Read
void Read()
Definition: HitReader.cxx:713
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
CbmBinnedMCPointReader::fStationZs
vector< Double_t > fStationZs
Definition: HitReader.cxx:380
CbmBinnedMCTrackReader::fStationZs
set< Double_t > fStationZs
Definition: HitReader.cxx:357
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmBinnedMCTrackReader::CbmBinnedMCTrackReader
CbmBinnedMCTrackReader()
Definition: HitReader.cxx:177
CbmBinnedTrdMCReader
Definition: HitReader.cxx:706
CbmBinnedMCPointReader::fTrackReader
CbmBinnedMCTrackReader * fTrackReader
Definition: HitReader.cxx:379
CbmTrdHit
data class for a reconstructed Energy-4D measurement in the TRD
Definition: CbmTrdHit.h:35
CbmBinnedMCTrackReader::Point::y
Double_t y
Definition: HitReader.cxx:130
CbmBinnedRichHitReader::operator=
CbmBinnedRichHitReader & operator=(const CbmBinnedRichHitReader &)=delete
CbmStsSetup::Instance
static CbmStsSetup * Instance()
Definition: CbmStsSetup.cxx:293
CbmBinnedMuchHitReader::Read
void Read()
Definition: HitReader.cxx:556
CbmBinnedRichHitReader::Read
void Read()
Definition: HitReader.cxx:429
CbmTrdPoint::GetXOut
Double_t GetXOut() const
Definition: CbmTrdPoint.h:66
CbmBinnedAllHitReader::Read
void Read()
Definition: HitReader.cxx:788
CbmTrdAddress::GetLayerId
static UInt_t GetLayerId(UInt_t address)
Return layer ID from address.
Definition: CbmTrdAddress.h:69
CbmStsPoint::GetZOut
Double_t GetZOut() const
Definition: CbmStsPoint.h:86
CbmBinnedMCTrackReader::Handle
void Handle()
Definition: HitReader.cxx:205
CbmBinnedMCTrackReader::Track::motherInd
Int_t motherInd
Definition: HitReader.cxx:136
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmBinnedRichHitReader::CbmBinnedRichHitReader
CbmBinnedRichHitReader(const CbmBinnedRichHitReader &)=delete
CbmStsPoint
Definition: CbmStsPoint.h:27
CbmMatch.h
CbmBinnedTrdHitReader::CbmBinnedTrdHitReader
CbmBinnedTrdHitReader()
Definition: HitReader.cxx:642
CbmBinnedMuchHitReader::operator=
CbmBinnedMuchHitReader & operator=(const CbmBinnedMuchHitReader &)=delete
CbmBinnedMCTrackReader::fXScats
vector< list< Double_t > > fXScats
Definition: HitReader.cxx:359
CbmBinnedMCTrackReader::Point::z
Double_t z
Definition: HitReader.cxx:131
CbmPixelHit::GetDy
Double_t GetDy() const
Definition: CbmPixelHit.h:86
CbmHit::GetTimeError
Double_t GetTimeError() const
Definition: CbmHit.h:76
ppiJpsi
@ ppiJpsi
Definition: Settings.h:25
CbmBinnedTofHitReader
Definition: HitReader.cxx:734
Station.h
CbmBinnedMCPointReader::operator=
CbmBinnedMCPointReader & operator=(const CbmBinnedMCPointReader &)=delete
CbmPixelHit::SetDy
void SetDy(Double_t dy)
Definition: CbmPixelHit.h:105
CbmBinnedHitReader::fSettings
static CbmBinnedSettings * fSettings
Definition: HitReader.h:53
CbmMuchPoint::GetYOut
Double_t GetYOut() const
Definition: CbmMuchPoint.h:74
CbmRichDigi.h
CbmMuchCluster.h
Data container for MUCH clusters.
CbmBinnedAllHitReader
Definition: HitReader.cxx:784
CbmBinnedMCTrackReader::Track
Definition: HitReader.cxx:134
CbmMCTrack::GetStartZ
Double_t GetStartZ() const
Definition: CbmMCTrack.h:77
CbmBinnedHitReader::CbmBinnedHitReader
CbmBinnedHitReader()
Definition: HitReader.cxx:95
CbmBinnedMCTrackReader::Instance
static CbmBinnedMCTrackReader * Instance()
Definition: HitReader.cxx:164
CbmBinnedSettings::GetPrimaryParticles
const std::list< EPrimaryParticleId > GetPrimaryParticles() const
Definition: Settings.h:208
CbmBinnedHitReader::Instance
static CbmBinnedHitReader * Instance()
Definition: HitReader.cxx:813
CbmMuchGeoScheme::GetLayerIndex
static Int_t GetLayerIndex(Int_t address)
Definition: CbmMuchGeoScheme.h:71
CbmMuchGeoScheme::GetStationIndex
static Int_t GetStationIndex(Int_t address)
Definition: CbmMuchGeoScheme.h:68
CbmMuchPoint.h
CbmBinnedMuchHitReader
Definition: HitReader.cxx:500
CbmBinnedMCTrackReader::Track::y
Double_t y
Definition: HitReader.cxx:138
CbmBinnedHitReader::fReaders
static std::map< std::string, CbmBinnedHitReader * > fReaders
Definition: HitReader.h:52
CbmBinnedHitReader
Definition: HitReader.h:26
CbmBinnedTofMCReader
Definition: HitReader.cxx:760
CbmBinnedSettings::AddStationScats
void AddStationScats(Double_t x, Double_t y)
Definition: Settings.h:190
CbmBinnedStation
Definition: Station.h:29
CbmMuchPoint::GetZOut
Double_t GetZOut() const
Definition: CbmMuchPoint.h:75
CbmStsSetup::GetStationNumber
Int_t GetStationNumber(Int_t address)
Definition: CbmStsSetup.cxx:187
CbmHit::GetTime
Double_t GetTime() const
Definition: CbmHit.h:75
CbmStsPoint::GetYOut
Double_t GetYOut() const
Definition: CbmStsPoint.h:85
CbmHit::GetAddress
Int_t GetAddress() const
Definition: CbmHit.h:73
CbmBinnedSettings::Instance
static CbmBinnedSettings * Instance()
Definition: Settings.h:29
CbmBinnedHitReader::AddReader
static void AddReader(const char *name)
Definition: HitReader.cxx:832
CbmBinnedMCPointReader::AddStation
void AddStation(CbmBinnedStation *station)
Definition: HitReader.cxx:373
ECbmModuleId::kRich
@ kRich
Ring-Imaging Cherenkov Detector.
CbmBinnedMCPointReader::CbmBinnedMCPointReader
CbmBinnedMCPointReader(const CbmBinnedMCPointReader &)=delete
CbmPixelHit::SetDx
void SetDx(Double_t dx)
Definition: CbmPixelHit.h:104
CbmMuchPoint::GetZIn
Double_t GetZIn() const
Definition: CbmMuchPoint.h:72
CbmBinnedRichMCReader::Read
void Read()
Definition: HitReader.cxx:477
CbmTrdHit.h
Class for hits in TRD detector.
CbmBinnedTrdMCReader::CbmBinnedTrdMCReader
CbmBinnedTrdMCReader()
Definition: HitReader.cxx:708
CbmStsPoint::GetXIn
Double_t GetXIn() const
Definition: CbmStsPoint.h:81
HitReader.h
CbmBinnedMuchMCReader
Definition: HitReader.cxx:608
CbmBinnedRichMCReader
Definition: HitReader.cxx:470
CbmTrdPoint::GetZOut
Double_t GetZOut() const
Definition: CbmTrdPoint.h:68
CbmBinnedMCTrackReader::Track::z
Double_t z
Definition: HitReader.cxx:139
CbmBinnedTrdHitReader
Definition: HitReader.cxx:640
CbmBinnedMCTrackReader::Track::Track
Track()
Definition: HitReader.cxx:142
CbmStsPoint::GetYIn
Double_t GetYIn() const
Definition: CbmStsPoint.h:82
CbmTrdPoint
Definition: CbmTrdPoint.h:23
CbmBinnedMuchHitReader::CbmBinnedMuchHitReader
CbmBinnedMuchHitReader()
Definition: HitReader.cxx:511
CbmHit::SetTimeError
void SetTimeError(Double_t error)
Definition: CbmHit.h:89
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmHit::SetTime
void SetTime(Double_t time)
Definition: CbmHit.h:84
CbmBinnedMCTrackReader::AddPoint
void AddPoint(Int_t trackInd, Double_t stationZ, Double_t x, Double_t y, Double_t z)
Definition: HitReader.cxx:346
CbmBinnedTrdHitReader::CbmBinnedTrdHitReader
CbmBinnedTrdHitReader(const CbmBinnedTrdHitReader &)=delete
CbmMCTrack::GetStartY
Double_t GetStartY() const
Definition: CbmMCTrack.h:76
CbmBinnedMCTrackReader::Track::x
Double_t x
Definition: HitReader.cxx:137
CbmBinnedTrdHitReader::Read
void Read()
Definition: HitReader.cxx:650
CbmStsPoint.h
CbmMCTrack.h
CbmBinnedAllHitReader::Handle
void Handle()
Definition: HitReader.cxx:798
CbmBinnedTofMCReader::Read
void Read()
Definition: HitReader.cxx:767
CbmBinnedMCTrackReader
Definition: HitReader.cxx:126
CbmBinnedMCTrackReader::AddStation
void AddStation(CbmBinnedStation *station)
Definition: HitReader.cxx:183
v
__m128 v
Definition: L1/vectors/P4_F32vec4.h:1
CbmBinnedRichMCReader::CbmBinnedRichMCReader
CbmBinnedRichMCReader()
Definition: HitReader.cxx:472
CbmTrdPoint::GetXIn
Double_t GetXIn() const
Definition: CbmTrdPoint.h:63
CbmBinnedStsMCReader
Definition: HitReader.cxx:385
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmMuchPoint::GetYIn
Double_t GetYIn() const
Definition: CbmMuchPoint.h:71
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmBinnedStsHitReader::CbmBinnedStsHitReader
CbmBinnedStsHitReader()
Definition: HitReader.cxx:101
CbmStsPoint::GetZIn
Double_t GetZIn() const
Definition: CbmStsPoint.h:83
CbmTofPoint.h
CbmBinnedAllHitReader::Finish
void Finish()
Definition: HitReader.cxx:805
CbmBinnedStsHitReader::Read
void Read()
Definition: HitReader.cxx:106
m
__m128 m
Definition: L1/vectors/P4_F32vec4.h:26
CbmMuchPixelHit.h
Class for pixel hits in MUCH detector.
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTrdPoint.h
CbmBinnedMCTrackReader::Track::Init
void Init(Int_t pdgCode, Int_t mi, Double_t vx, Double_t vy, Double_t vz, const set< Double_t > &stationZs)
Definition: HitReader.cxx:144
CbmMuchPoint::GetXIn
Double_t GetXIn() const
Definition: CbmMuchPoint.h:70
CbmBinnedAllHitReader::CbmBinnedAllHitReader
CbmBinnedAllHitReader()
Definition: HitReader.cxx:786
CbmBinnedRichHitReader
Definition: HitReader.cxx:419
CbmPixelHit
Definition: CbmPixelHit.h:21
CbmBinnedMuchMCReader::CbmBinnedMuchMCReader
CbmBinnedMuchMCReader()
Definition: HitReader.cxx:610
CbmBinnedSettings
Definition: Settings.h:27
CbmBinnedMCTrackReader::Read
void Read()
Definition: HitReader.cxx:189
CbmBinnedTofMCReader::CbmBinnedTofMCReader
CbmBinnedTofMCReader()
Definition: HitReader.cxx:762
CbmBinnedMCTrackReader::fTracks
vector< Track > fTracks
Definition: HitReader.cxx:358
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmBinnedMCTrackReader::Track::pdg
Int_t pdg
Definition: HitReader.cxx:135
CbmTofPoint
Geometric intersection of a MC track with a TOFb detector.
Definition: CbmTofPoint.h:40
EPrimaryParticleId
EPrimaryParticleId
Definition: Settings.h:25
CbmMuchPixelHit
Definition: CbmMuchPixelHit.h:17
CbmMuchGeoScheme.h
CbmBinnedMCPointReader::CbmBinnedMCPointReader
CbmBinnedMCPointReader()
Definition: HitReader.cxx:365
CbmRichPoint
Definition: CbmRichPoint.h:24
CbmBinnedTofHitReader::CbmBinnedTofHitReader
CbmBinnedTofHitReader()
Definition: HitReader.cxx:736
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmTrdPoint::GetYIn
Double_t GetYIn() const
Definition: CbmTrdPoint.h:64
CbmBinnedTrdHitReader::operator=
CbmBinnedTrdHitReader & operator=(const CbmBinnedTrdHitReader &)=delete
CbmBinnedStsMCReader::CbmBinnedStsMCReader
CbmBinnedStsMCReader()
Definition: HitReader.cxx:387
CbmBinnedStsMCReader::Read
void Read()
Definition: HitReader.cxx:392
CbmBinnedMCTrackReader::Track::points
map< Double_t, list< Point > > points
Definition: HitReader.cxx:140
CbmBinnedStsHitReader
Definition: HitReader.cxx:99
CbmTrdHit::GetPlaneId
Int_t GetPlaneId() const
Inherited from CbmBaseHit.
Definition: CbmTrdHit.h:73