All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
SimDigital.h
Go to the documentation of this file.
1 #ifndef SimDigital_HHH
2 #define SimDigital_HHH
3 
4 #include "marlin/Processor.h"
5 #include "lcio.h"
6 #include <vector>
7 #include <string>
8 #include <map>
9 #include <set>
10 #include <utility>
11 #include <limits>
12 #include <memory>
13 
14 #include <EVENT/LCCollection.h>
15 #include <EVENT/SimCalorimeterHit.h>
16 #include <IMPL/CalorimeterHitImpl.h>
17 #include <IMPL/LCCollectionVec.h>
18 #include <IMPL/LCFlagImpl.h>
19 
20 #include <marlin/Global.h>
21 
22 #include <TFile.h>
23 #include <TF2.h>
24 #include <TH1.h>
25 
26 #include "CalorimeterHitType.h" //in MarlinUtil
27 #include "marlinutil/LCGeometryTypes.h"
28 
29 #include <AIDA/IHistogramFactory.h>
30 #include <AIDA/IHistogram1D.h>
31 
32 #include "SimDigitalGeom.h"
33 #include "ChargeSpreader.h"
34 #include "ChargeInducer.h"
35 #include "EfficiencyManager.h"
36 
37 class TH1F;
38 class TF1;
39 class TTree;
40 
41 namespace AIDA
42 {
43 class ITuple ;
44 }
45 
46 using namespace lcio ;
47 using namespace marlin ;
48 
49 /**
50 \addtogroup CaloDigi CaloDigi
51 @{
52  * Digitization for the SDHcal - based on NewLDCCaloDigi.
53  * @author G.Grenier, IPNL
54  * @author R.Han, IPNL
55  * @author A.Steen, IPNL
56  * @author G.Garillot, IPNL
57  * @author B.Li, IPNL
58  * @version $Id$
59  */
60 
61 
63 {
65  : step{}
66  {}
67  StepAndCharge(LCVector3D vec , float _length, float _time)
68  : step{vec} , stepLength{_length} , time{_time}
69  {}
70  LCVector3D step ;
71  float charge = 0 ;
72  float stepLength = 0 ;
73  float time = 0 ;
74 } ;
75 
76 struct AsicKey
77 {
78  AsicKey(int l , int aI = -1 , int aJ = -1) : layerID(l) , asicI(aI) , asicJ(aJ) {}
79  int layerID ;
80  int asicI ;
81  int asicJ ;
82 
83  bool operator<(const AsicKey& b) const
84  {
85  return std::tie( layerID , asicI , asicJ ) < std::tie(b.layerID , b.asicI , b.asicJ ) ;
86  }
87  bool operator==(const AsicKey& b) const
88  {
89  return std::tie( layerID , asicI , asicJ ) == std::tie(b.layerID , b.asicI , b.asicJ ) ;
90  }
91 } ;
92 
93 /**
94 \addtogroup SimDigital SimDigital
95 @{
96 Digitization for the SDHcal - based on NewLDCCaloDigi.
97 
98 */
99 class SimDigital : public Processor
100 {
101  public:
102  virtual Processor* newProcessor() { return new SimDigital ; }
103  SimDigital() ;
104 
105  /** Called at the begin of the job before anything is read.
106  * Use to initialize the processor, e.g. book histograms.
107  */
108  virtual void init() ;
109 
110  /** Called for every event - the working horse.
111  */
112  virtual void processEvent( LCEvent * evt ) ;
113 
114  SimDigital(const SimDigital &toCopy) = delete ;
115  void operator=(const SimDigital &toCopy) = delete ;
116 
117 
118  private :
119  //intermediate storage class
120  struct hitMemory
121  {
123  : ahit(nullptr) , relatedHits() , maxEnergydueToHit(-1) , rawHit(-1)
124  {}
125 
126  std::unique_ptr<CalorimeterHitImpl> ahit = nullptr ;
127 
128  std::set<int> relatedHits{};
129  float maxEnergydueToHit = -1 ;
130  int rawHit = -1 ;
131 
132  hitMemory(const hitMemory& other) = delete ;
133  hitMemory& operator=(const hitMemory& other) = delete ;
134  } ;
135 
136  typedef std::map<dd4hep::long64, hitMemory> cellIDHitMap ;
137 
138 
139  void processCollection(LCCollection* inputCol , LCCollectionVec*& outputCol , LCCollectionVec*& outputRelCol , CHT::Layout layout) ;
140  cellIDHitMap createPotentialOutputHits(LCCollection* col , SimDigitalGeomCellId* aGeomCellId) ;
141 
142  void removeAdjacentStep(std::vector<StepAndCharge>& vec) ;
143  void fillTupleStep(const std::vector<StepAndCharge>& vec , int level) ;
144  void removeHitsBelowThreshold(cellIDHitMap& myHitMap , float threshold) ;
145  void applyThresholds(cellIDHitMap& myHitMap) ;
146 
147  std::vector<std::string> _inputCollections{};
148 
149  std::vector<std::string> _outputCollections{};
150  std::vector<std::string> _outputRelCollections{};
151 
152  LCFlagImpl flag {} ;
153  LCFlagImpl flagRel {} ;
154 
155  std::map<std::string, int> _counters{};
156  std::vector<float> _thresholdHcal{};
157 
158  std::vector<double> _hitCharge = {};
159 
160  std::map<dd4hep::long64 , std::vector<LCGenericObject*>> geneMap = {};
161 
162  float _cellSize = 0 ;
163  float _gasGapWidth = 1.2f ;
164 
165  //charge spreader
166  std::string chargeSpreaderOption = "Uniform" ;
167  std::string spreaderMapFile = "" ;
169  ChargeSpreader* chargeSpreader = nullptr ;
170 
171  std::string polyaOption = "Uniform" ;
172  std::string polyaMapFile = "" ;
173  float polyaQbar = 0.0f ;
174  float polyaTheta = 0.0f ;
175  ChargeInducer* chargeInducer = nullptr ;
176  int _polyaRandomSeed = 1 ;
177 
178  float _angleCorrPow = 0.4f ;
179 
180  double timeCut = std::numeric_limits<double>::max() ;
181  double stepLengthCut = -1.0 ;
182 
183  bool _linkSteps = false ;
184  bool _doThresholds = true ;
185 
186  std::string efficiencyOption = "Uniform" ;
187  std::string effMapFile = "" ;
188  EfficiencyManager* efficiency = nullptr ;
189  float _constEffMapValue = 0.97f ;
190 
191  float _absZstepFilter = 0.0005f ;
192  float _minXYdistanceBetweenStep = 0.5f ;
193  bool _keepAtLeastOneStep = true ;
194 
195  AIDA::ITuple* _debugTupleStepFilter = nullptr ;
196  AIDA::ITuple* _tupleStepFilter = nullptr ;
197  AIDA::ITuple* _tupleCollection = nullptr ;
198 
199  AIDA::IHistogram1D* _histoCellCharge = nullptr ;
200 
201  std::string _encodingType = "LCGEO" ;
202 } ;
203 
204 /** @} @} */
205 
206 #endif
AsicKey(int l, int aI=-1, int aJ=-1)
Definition: SimDigital.h:78
LCVector3D step
Definition: SimDigital.h:70
int layerID
Definition: SimDigital.h:79
int asicI
Definition: SimDigital.h:80
std::map< dd4hep::long64, hitMemory > cellIDHitMap
Definition: SimDigital.h:136
bool operator<(const AsicKey &b) const
Definition: SimDigital.h:83
StepAndCharge(LCVector3D vec, float _length, float _time)
Definition: SimDigital.h:67
int asicJ
Definition: SimDigital.h:81
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55
ChargeSpreaderParameters chargeSpreaderParameters
Definition: SimDigital.h:168
virtual Processor * newProcessor()
Definition: SimDigital.h:102
bool operator==(const AsicKey &b) const
Definition: SimDigital.h:87