PandaRoot
PndEmcHitProducer.h
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndEmcHitProducer header file -----
3 // ----- Created 14/08/06 by S.Spataro -----
4 // -------------------------------------------------------------------------
5 #ifndef PNDEMCHITPRODUCER_H
6 #define PNDEMCHITPRODUCER_H
7 
8 #include <PndPersistencyTask.h>
9 #include <map>
10 #include <string>
11 #include <limits>
12 
13 #include "TH1F.h"
14 #include "TFile.h"
15 #include "TVector3.h"
16 
17 #include "PndEmcHit.h"
18 #include "PndEmcStructure.h"
19 #include "PndEmcMapper.h"
20 
21 #include "PndMCTrack.h"
22 #include "TClonesArray.h"
23 
24 #include <set>
25 #include <vector>
26 
27 class TObjectArray;
28 
29 class PndEmcDigiPar;
30 class PndEmcGeoPar;
32 
33 using std::cout;
34 using std::endl;
35 using std::map;
36 
42 struct PndEmcVolume {
43  virtual bool InsideVolume(TVector3 point) = 0;
44 };
45 
46 struct PndEmcVolumeDisk : public PndEmcVolume { // needed for MC matching. Assume barrel structure
47  double fMinR;
48  double fMaxR;
49  double fMinZ;
50  double fMaxZ;
51  PndEmcVolumeDisk(double minR, double maxR, double minZ, double maxZ) : fMinR(minR), fMaxR(maxR), fMinZ(minZ), fMaxZ(maxZ){};
52  bool InsideVolume(TVector3 point)
53  {
54  if (point.Z() > fMinZ && point.Z() < fMaxZ) {
55  if (point.Perp() > fMinR && point.Perp() < fMaxR) {
56  return true;
57  }
58  }
59  return false;
60  };
61 };
62 
63 struct PndEmcVolumeBox : public PndEmcVolume {
64  double fMinX, fMaxX;
65  double fMinY, fMaxY;
66  double fMinZ, fMaxZ;
67 
68  PndEmcVolumeBox(double minX, double maxX, double minY, double maxY, double minZ, double maxZ) : fMinX(minX), fMaxX(maxX), fMinY(minY), fMaxY(maxY), fMinZ(minZ), fMaxZ(maxZ){};
69  bool InsideVolume(TVector3 point)
70  {
71  if (point.Z() > fMinZ && point.Z() < fMaxZ)
72  if (point.Y() > fMinY && point.Y() < fMaxY)
73  if (point.X() > fMinX && point.X() < fMaxX)
74  return true;
75  return false;
76  };
77 };
78 
80 
81  public:
82  typedef std::map<Int_t, Float_t> mapper;
83 
86 
87  PndEmcHitProducer(Bool_t val);
88 
91 
93  virtual InitStatus Init();
94 
96  virtual void Exec(Option_t *opt);
97 
98  PndEmcHit *AddHit(Int_t trackID, Int_t detID, Float_t energy, Float_t time, std::vector<Int_t> &mctruth, FairMultiLinkedData entering, FairMultiLinkedData exiting,
99  std::set<Int_t> &clusterIDs);
100 
101  // PndEmcHit* AddHit(Int_t trackID, Int_t detID, Float_t energy, Float_t time,std::vector<PndEmcPoint*> pointList);
102  // not implemented
103  // void CreateStructure();
104 
105  void SetStorageOfData(Bool_t val); // Method to specify whether hits are stored or not.
106  void SetNonuniformityFile(const char *filename) { fNonuniformityFile = filename; };
107  void SetDayOne(bool d = true) { fDayOne = d; };
108 
109  void FinishEvent() { fEntryNr++; }
110  void FinishTask();
111 
112  protected:
113  int FindMCIndex(PndEmcPoint *point);
114  int FindMCIndexIterative(PndEmcPoint *point, int mcIndex);
115 
116  private:
117  Int_t fUse_nonuniformity;
118  TString fNonuniformityFile;
120  TClonesArray *fPointArray;
121  TClonesArray *fMCTrackArray;
122 
124  TClonesArray *fHitArray;
125  // TClonesArray* fMcTrackArray;
126 
127  TObjArray *fVolumeArray;
128 
130  Int_t fMapVersion;
131  Float_t fEnergyThreshold;
132 
133  mapper emcX;
134  mapper emcY;
135  mapper emcZ;
136 
137  PndEmcStructure *fEmcStr;
138  PndEmcMapper *fMapper;
139 
140  PndEmcDigiPar *fDigiPar;
141  PndEmcGeoPar *fGeoPar;
142  PndEmcDigiNonuniformityPar *fNonuniformityPar;
143 
145  virtual void SetParContainers();
146 
147  Bool_t fStoreHits; // Flag which specify whether hits are stored or not
148 
149  void cleansortmclist(std::vector<Int_t> &newlist, TClonesArray *mcTrackArray);
150 
152  PndEmcHitProducer &operator=(const PndEmcHitProducer &) { return *this; }
153 
154  ClassDef(PndEmcHitProducer, 1);
155 
156  map<Int_t, Float_t> fTrackEnergy;
157  map<Int_t, Float_t> fTrackTime; // time of first point
158  map<Int_t, std::vector<Int_t>> fTrackMcTruth; // McTruth MC track which deposited energy in the crystal
159  map<Int_t, std::vector<Int_t>> fPointMatch; // DetId , PointIds with same DetId
160  map<Int_t, FairMultiLinkedData> fTrackEntering; // DetId, link to tracks entering same DetId
161  map<Int_t, FairMultiLinkedData> fTrackExiting; // DetId, link to track exiting same DetId
162  map<Int_t, std::set<Int_t>> fClusterIDs; // DetId, cluster ids of all point with energy above threshold
163  map<Int_t, PndEmcPoint *> fLastPointForTrack; // <mcTrackId, last point of track seen>
164  map<Int_t, std::map<Int_t, Double_t>> fShower; // <DetId <MCTrackIndex, DepositedEnergy>> MCTruth deposited energy per crystal and (primary) mc particle type
165  std::vector<PndEmcVolume *> fEmcVolumes;
166  double fCutSameTrack;
167  double fCutMotherParticle;
168  double fCutMotherParticleShashlyk;
169  int fEntryNr;
170 
171  bool fDayOne;
172  bool AcceptDayOne(PndEmcPoint *p);
173 };
174 #endif
represents a mc hit in an emc crystal
Definition: PndEmcPoint.h:19
void SetNonuniformityFile(const char *filename)
Emc geometry mapper.
Definition: PndEmcMapper.h:22
PndEmcVolumeDisk(double minR, double maxR, double minZ, double maxZ)
creates PndEmcHits from PndEmcPoints
geometry helper class
parameter set of Emc digitisation
Definition: PndEmcDigiPar.h:12
PndEmcVolumeBox(double minX, double maxX, double minY, double maxY, double minZ, double maxZ)
represents the deposited energy of one emc crystal from simulation
Definition: PndEmcHit.h:28
virtual bool InsideVolume(TVector3 point)=0
bool InsideVolume(TVector3 point)
bool InsideVolume(TVector3 point)
std::map< Int_t, Float_t > mapper
void SetDayOne(bool d=true)