4 #include "marlin/Processor.h"
12 #include <EVENT/LCCollection.h>
13 #include <EVENT/SimCalorimeterHit.h>
14 #include <IMPL/CalorimeterHitImpl.h>
15 #include <IMPL/LCCollectionVec.h>
16 #include <IMPL/LCFlagImpl.h>
17 #include <UTIL/CellIDEncoder.h>
18 #include <UTIL/CellIDDecoder.h>
19 #include <marlin/Global.h>
20 #include <gear/GearParameters.h>
21 #include <gear/CalorimeterParameters.h>
22 #include <gear/LayerLayout.h>
29 #include "CalorimeterHitType.h"
30 #include "marlinutil/LCGeometryTypes.h"
40 using namespace lcio ;
41 using namespace marlin ;
47 #define SIMDIGITAL_WITHECAL
49 #ifdef SIMDIGITAL_WITHECAL
50 const int MAX_LAYERS = 200;
51 const int MAX_STAVES = 16;
78 static void bookTuples(
const marlin::Processor* proc);
82 std::vector<StepAndCharge> decode(SimCalorimeterHit *hit);
83 void encode(CalorimeterHitImpl *hit,
int delta_I,
int delta_J);
84 void setLayerLayout( CHT::Layout layout);
86 const LCVector3D& normalToRPCPlane() {
return _normal;}
87 const LCVector3D& Iaxis() {
return _Iaxis;}
88 const LCVector3D& Jaxis() {
return _Jaxis;}
92 int K() {
return _trueLayer;}
93 int stave() {
return _stave;}
94 int module() {
return _module;}
97 enum HCAL_GEOM {VIDEAU,TESLA};
104 const float* _hitPosition;
105 CellIDDecoder<SimCalorimeterHit> _decoder;
106 CellIDEncoder<CalorimeterHitImpl> _encoder;
107 const gear::LayerLayout* _layerLayout;
109 CHT::Layout _currentHCALCollectionCaloLayout;
113 static AIDA::ITuple* _tupleHit;
114 enum {TH_DETECTOR,TH_CHTLAYOUT,TH_MODULE,TH_STAVE,TH_LAYER,TH_I,TH_J,
116 TH_NORMALX,TH_NORMALY,TH_NORMALZ,
119 static AIDA::ITuple* _tupleStep;
120 enum {TS_DETECTOR,TS_CHTLAYOUT,TS_HITCELLID,TS_NSTEP,
121 TS_HITX,TS_HITY,TS_HITZ,
122 TS_STEPX,TS_STEPY,TS_STEPZ,
123 TS_DELTAI,TS_DELTAJ,TS_DELTALAYER};
134 virtual void setRPCFrame()=0;
138 int stave() {
return _layerInfo._stave;}
139 int module() {
return _layerInfo._module;}
140 LCVector3D& normal() {
return _layerInfo._normal;}
141 LCVector3D& Iaxis() {
return _layerInfo._Iaxis;}
142 LCVector3D& Jaxis() {
return _layerInfo._Jaxis;}
178 typedef std::pair<int,int> I_J_Coordinates;
179 virtual void addCharge(
float charge,
float pos_I,
float pos_J)=0;
180 void newHit(
float cell_Size) {_chargeMap.clear();_cellSize=cell_Size;}
181 const std::map<I_J_Coordinates,float>& chargeMap() {
return _chargeMap;}
184 std::map<I_J_Coordinates,float> _chargeMap;
192 void addCharge(
float charge,
float pos_I,
float pos_J);
205 void addCharge(
float charge,
float pos_I,
float pos_J);
209 std::string _function_description;
210 std::vector<float> _functionParameters;
211 float _normalisation;
212 float _RPC_PadSeparation;
222 void addCharge(
float charge,
float pos_I,
float pos_J);
225 std::vector<float> _erfWidth;
226 std::vector<float> _erfWeigth;
227 float _normalisation;
228 float _RPC_PadSeparation;
237 virtual float getEfficiency(
int I,
int J,
int K,
int stave,
int module)=0;
244 virtual float getEfficiency(
int I,
int J,
int K,
int stave,
int module) {
return value;}
254 virtual float getEfficiency(
int I,
int J,
int K,
int stave,
int module)
256 std::map<int,float>::iterator it=_effMap.find( (I-1)/8+((J-1)/8)*12+K*1000 );
257 return (it != _effMap.end() ? it->second : 1.0);
260 std::map<int,float> _effMap;
266 virtual Processor* newProcessor() {
return new SimDigital;}
272 virtual void init() ;
276 virtual void processRunHeader( LCRunHeader* run ) ;
280 virtual void processEvent( LCEvent * evt ) ;
282 virtual void check( LCEvent * evt ) ;
288 #ifdef SIMDIGITAL_WITHECAL
289 virtual void fillECALGaps() ;
293 #ifdef SIMDIGITAL_WITHECAL
294 std::vector<std::string> _ecalCollections;
295 std::string _outputEcalCollection0;
296 std::string _outputEcalCollection1;
297 std::string _outputEcalCollection2;
298 std::vector<std::string> _outputEcalCollections;
299 std::vector<float> _calibrCoeffEcal;
300 std::vector<int> _ecalLayers;
302 float _thresholdEcal;
303 int _ecalGapCorrection;
304 float _ecalGapCorrectionFactor;
305 float _ecalModuleGapCorrectionFactor;
306 float _ecalEndcapCorrectionFactor;
307 std::vector<CalorimeterHitImpl*> _calHitsByStaveLayer[MAX_STAVES][MAX_LAYERS];
308 std::vector<int> _calHitsByStaveLayerModule[MAX_STAVES][MAX_LAYERS];
310 float _zOfEcalEndcap;
311 float _barrelPixelSizeT[MAX_LAYERS];
312 float _barrelPixelSizeZ[MAX_LAYERS];
313 float _endcapPixelSizeX[MAX_LAYERS];
314 float _endcapPixelSizeY[MAX_LAYERS];
315 float _barrelStaveDir[MAX_STAVES][2];
319 std::vector<std::string> _hcalCollections;
320 std::vector<std::string> _outputHcalCollections;
321 std::map<std::string, int> _counters;
322 std::vector<float> _thresholdHcal;
323 std::vector<float>_calibrCoeffHcal;
324 std::string _outputRelCollection;
325 bool _printSimDigital;
327 double _polyaAverageCharge, _polyaFunctionWidthParameter;
329 LCCollectionVec* _relcol;
330 #ifdef SIMDIGITAL_WITHECAL
331 void registerECALparameters();
332 void setECALgeometry();
333 void processECAL(LCEvent* evt, LCFlagImpl& flag);
335 void processHCAL(LCEvent* evt, LCFlagImpl& flag);
342 hitMemory() : ahit(0),relatedHits(), maxEnergydueToHit(-1), rawHit(-1) {}
343 CalorimeterHitImpl *ahit;
344 std::set<int> relatedHits;
345 float maxEnergydueToHit;
348 float depositedEnergyInRPC;
354 std::string _chargeSplitterOption;
355 std::string _effMapFileName;
356 float _constEffMapValue;
357 std::string _effMapOption;
359 float _absZstepFilter;
360 bool _keepAtLeastOneStep;
361 float _minXYdistanceBetweenStep;
362 AIDA::ITuple* _debugTupleStepFilter;
363 AIDA::ITuple* _tupleStepFilter;
364 AIDA::ITuple* _tupleCollection;
368 class ThresholdIsBelow
372 ThresholdIsBelow(
float f) : value(f) {;}
373 bool operator()(std::pair<int,hitMemory> f) {
return f.second.ahit->getEnergy()<value;}
377 class absZGreaterThan
380 absZGreaterThan(
float val) : _value(val) {}
381 bool operator()(
StepAndCharge& v) {
return fabs( v.step.z() ) >_value;}
388 randomGreater(
float val) : _value(val) {}
389 bool operator()(
StepAndCharge& v) {
return double(rand())/RAND_MAX>_value;}
394 void remove_adjacent_step(std::vector<StepAndCharge>& vec);
395 void fillTupleStep(std::vector<StepAndCharge>& vec,
int level);
397 LCCollectionVec * processHCALCollection(LCCollection * col ,CHT::Layout layout, LCFlagImpl& flag);
398 void createPotentialOutputHits(std::map<int,hitMemory>& myHitMap, LCCollection *col,
SimDigitalGeomCellId& aGeomCellId);
399 void removeHitsBelowThreshold(std::map<int,hitMemory>& myHitMap,
float threshold);
400 void applyThresholds(std::map<int,hitMemory>& myHitMap);
Definition: SimDigital.h:163
Definition: SimDigital.h:173
Definition: SimDigital.h:151
Definition: SimDigital.h:199
Definition: SimDigital.h:75
Definition: SimDigital.h:65
Definition: SimDigital.h:216
Definition: SimDigital.h:129
Definition: SimDigital.h:250
Definition: SimDigital.h:234
Definition: SimDigital.h:264
Definition: SimDigital.h:240
Definition: SimDigital.h:157
Definition: SimDigital.h:145