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