PandaRoot
BSEmcMCHitProductionProcess.h
Go to the documentation of this file.
1 #ifndef BSEMCMCHITPRODUCTIONPROCESS_HH
2 #define BSEMCMCHITPRODUCTIONPROCESS_HH
3 
4 #include <map>
5 #include <string>
6 #include <vector>
7 
8 #include "Rtypes.h"
9 #include "RtypesCore.h"
10 #include "TClonesArray.h"
11 #include "TVector3.h"
12 
13 #include "FairMultiLinkedData.h"
14 
15 #include "PndContainerI.h"
16 #include "PndParameterRegister.h"
17 #include "PndProcess.h"
18 
21 #include "BSEmcSortMCTruthAlgo.h"
22 
23 class PndMCTrack;
24 class BSEmcMCPoint;
25 class BSEmcMCHit;
28 class TBuffer;
29 class TClass;
30 class TMemberInspector;
32 template <class T>
33 class PndInputContainerI;
34 template <class T>
36 
37 struct BSEmcVolume {
38  virtual Bool_t InsideVolume(const TVector3 &t_point) const = 0;
39  virtual ~BSEmcVolume(){};
40 };
41 
42 struct BSEmcVolumeDisk : public BSEmcVolume { // needed for MC matching. Assume barrel structure
43  Double_t fMinR{-1};
44  Double_t fMaxR{-1};
45  Double_t fMinZ{-1};
46  Double_t fMaxZ{-1};
47  BSEmcVolumeDisk(Double_t t_minR, Double_t t_maxR, Double_t t_minZ, Double_t t_maxZ) : fMinR(t_minR), fMaxR(t_maxR), fMinZ(t_minZ), fMaxZ(t_maxZ){};
48  virtual ~BSEmcVolumeDisk(){};
49 
50  Bool_t InsideVolume(const TVector3 &t_point) const
51  {
52  if (t_point.Z() > fMinZ && t_point.Z() < fMaxZ) {
53  if (t_point.Perp() > fMinR && t_point.Perp() < fMaxR) {
54  return kTRUE;
55  }
56  }
57  return kFALSE;
58  };
59 };
60 
61 struct BSEmcVolumeBox : public BSEmcVolume {
62  Double_t fMinX{-1}, fMaxX{-1};
63  Double_t fMinY{-1}, fMaxY{-1};
64  Double_t fMinZ{-1}, fMaxZ{-1};
65 
66  BSEmcVolumeBox(Double_t t_minX, Double_t t_maxX, Double_t t_minY, Double_t t_maxY, Double_t t_minZ, Double_t t_maxZ)
67  : fMinX(t_minX), fMaxX(t_maxX), fMinY(t_minY), fMaxY(t_maxY), fMinZ(t_minZ), fMaxZ(t_maxZ){};
68  virtual ~BSEmcVolumeBox(){};
69 
70  Bool_t InsideVolume(const TVector3 &t_point) const
71  {
72  if (t_point.Z() > fMinZ && t_point.Z() < fMaxZ) {
73  if (t_point.Y() > fMinY && t_point.Y() < fMaxY) {
74  if (t_point.X() > fMinX && t_point.X() < fMaxX) {
75  return kTRUE;
76  }
77  }
78  }
79  return kFALSE;
80  };
81 };
82 
95 class BSEmcMCHitProductionProcess : private BSEmcSortMCTruthAlgo, public PndProcess<BSEmcMCHitProductionData> {
96  public:
98  virtual ~BSEmcMCHitProductionProcess();
99  virtual void SetData(BSEmcMCHitProductionData *t_pdata) /*override*/;
100  virtual void SetupParameters(const PndParameterRegister *t_parameter) /*override*/;
101  virtual void SetDetectorName(const std::string &t_detectorname) /*override*/;
102  virtual void Process() /*override*/;
103  void SetHitParName(const std::string &t_parName) { fHitParName = t_parName; }
104  void SetPositionParName(const std::string &t_parName) { fPositionParName = t_parName; }
105  void SetVolume(BSEmcVolume *t_volume) { fBoundaryVolume = t_volume; }
106 
107  private:
108  virtual Double_t GetEnergy(const BSEmcMCPoint *t_point) const;
109  virtual Double_t GetTime(const BSEmcMCPoint *t_point) const;
110  virtual Bool_t GetEntering(const BSEmcMCPoint *t_point) const;
111  virtual Bool_t GetExiting(const BSEmcMCPoint *t_point) const;
112  virtual FairMultiLinkedData GetTracks(const BSEmcMCPoint *t_point) const;
113  virtual Int_t GetMCTrackID(const BSEmcMCPoint *t_point) const;
114  virtual Bool_t SkipPoint(const BSEmcMCPoint *t_point) const;
115 
116  virtual void CreateHits(std::vector<BSEmcMCPoint *> t_points);
117  void Reset();
118  Int_t FindMCIndex(const BSEmcMCPoint *t_point);
119  Int_t FindMCIndexIterative(const BSEmcMCPoint *t_point, Int_t t_mcIndex);
120 
121  void SetClusterIdForPoint(BSEmcMCPoint *t_point);
122  void StoreHits();
123  virtual void StoreHit(Int_t t_detId, Double_t t_time, std::vector<Int_t> &t_mctrackIds, const FairMultiLinkedData &t_entering, const FairMultiLinkedData &t_exiting);
124 
125  protected:
126  std::string fHitParName{""};
127  std::string fPositionParName{""};
128  PndInputContainerI<PndMCTrack> *fMCTrackArray{nullptr};
129  PndOutputContainerI<BSEmcMCPoint> *fPointArray{nullptr};
130  PndOutputContainerI<BSEmcMCHit> *fHitArray{nullptr};
131  Double_t fEnergyThreshold{-1};
132  Double_t fCutMotherParticle{-1};
133  Double_t fCutSameTrack{-1};
134  BSEmcCrystalPositionPar *fPositionPar{nullptr};
135  BSEmcVolume *fBoundaryVolume{nullptr};
136 
137  std::map<Int_t, Float_t> fTrackEnergy{};
138  std::map<Int_t, Float_t> fTrackTime{}; // time of first point
139  std::map<Int_t, std::vector<Int_t>> fTrackMcTruth{}; // McTruth MC track which deposited energy in the crystal
140  std::map<Int_t, std::vector<Int_t>> fPointMatch{}; // DetId , PointIds with same DetId
141  std::map<Int_t, FairMultiLinkedData> fTrackEntering{}; // DetId, link to tracks entering same DetId
142  std::map<Int_t, FairMultiLinkedData> fTrackExiting{}; // DetId, link to track exiting same DetId
143  std::map<Int_t, const BSEmcMCPoint *> fLastPointForTrack{}; // <mcTrackId, last point of track seen>
144  std::map<Int_t, std::map<Int_t, Double_t>> fShower{}; // <DetId <MCTrackIndex, DepositedEnergy>> MCTruth deposited energy per crystal and (primary) mc particle type
145 
146  ClassDef(BSEmcMCHitProductionProcess, 1);
147 };
148 
149 #endif /*BSEMCMCHITPRODUCTIONPROCESS_HH*/
Base Process class.
Definition: PndProcess.h:24
Process to create BSEmcMCHits out of BSEmcMCPoints.
Bool_t InsideVolume(const TVector3 &t_point) const
void SetHitParName(const std::string &t_parName)
Bool_t InsideVolume(const TVector3 &t_point) const
void SetPositionParName(const std::string &t_parName)
BSEmcVolumeDisk(Double_t t_minR, Double_t t_maxR, Double_t t_minZ, Double_t t_maxZ)
DataStruct to pass addresses to data Container between BSEmcMCHitProducerTask and PndProcess<BSEmcMCH...
BSEmcVolumeBox(Double_t t_minX, Double_t t_maxX, Double_t t_minY, Double_t t_maxY, Double_t t_minZ, Double_t t_maxZ)
virtual Bool_t InsideVolume(const TVector3 &t_point) const =0
Parameter for crystal positions.
represents a mc hit in an emc crystal
Definition: BSEmcMCPoint.h:28
void SetVolume(BSEmcVolume *t_volume)
Interface to a datacontainer to be used in PandaROOT.
Base class for algo that require the cleansortmclist.
Helper class to indirect the Parameter fetching via the FairRuntimeDb.
represents the deposited energy of one emc crystal from simulation
Definition: BSEmcMCHit.h:32