Overlay  0.16.0
OverlayTiming.h
1 #ifndef OverlayTiming_h
2 #define OverlayTiming_h 1
3 
4 #include "marlin/Processor.h"
5 #include "marlin/EventModifier.h"
6 
7 #include "lcio.h"
8 
9 #include <cmath>
10 
11 namespace overlay {
12 
46  class OverlayTiming : public marlin::Processor, public marlin::EventModifier
47  {
48  public:
49  virtual marlin::Processor* newProcessor();
50 
51  OverlayTiming();
52 
53  virtual void init();
54 
55  virtual const std::string &name() const;
56 
57  virtual void processRunHeader(EVENT::LCRunHeader *run) ;
58 
59  virtual void modifyEvent(EVENT::LCEvent *evt);
60 
61  virtual void check(EVENT::LCEvent *evt);
62 
63  virtual void end();
64 
65  protected:
66  float time_of_flight(float x, float y, float z) const;
67 
68  void define_time_windows(const std::string &Collection_name);
69 
70  void crop_collection(EVENT::LCCollection *collection);
71 
72  void merge_collections(EVENT::LCCollection *source_collection, EVENT::LCCollection *dest_collection, float time_offset);
73 
74  long long cellID2long(int id0, int id1) const;
75 
76  float _T_diff;
77  int _nBunchTrain;
78 
79  unsigned int _nRun ;
80  unsigned int _nEvt ;
81  StringVec _inputFileNames ;
82 
83  int _BX_phys;
84  float _NOverlay;
85  unsigned int overlay_file_list;
86  float _BeamCal_int,_ETD_int, _EcalBarrel_int, _EcalBarrelPreShower_int, _EcalEndcap_int, _EcalEndcapPreShower_int, _EcalEndcapRing_int, _EcalEndcapRingPreShower_int;
87  float _FTD_int, _HcalBarrelReg_int, _HcalEndCapRings_int, _HcalEndCaps_int, _LHcal_int, _LumiCal_int, _MuonBarrel_int, _MuonEndCap_int, _SET_int, _SIT_int, _VXD_int;
88  float _EcalPlug_int, _VXDB_int, _VXDE_int, _ITB_int, _ITE_int, _OTB_int, _OTE_int;
89  float _TPC_int, _TPCSpacePoint_int;
90 
91  IO::LCReader* overlay_Eventfile_reader;
92 
93  float this_start;
94  float this_stop;
95  int _ranSeed;
96 
97  std::string _mcParticleCollectionName;
98  std::string _mcPhysicsParticleCollectionName;
99  std::string currentDest;
100  bool TPC_hits;
101 
102  float _tpcVdrift_mm_ns ;
103  bool _randomBX, _Poisson;
104 
105  typedef std::map<long long, EVENT::SimCalorimeterHit*> DestMap;
106  typedef std::map<std::string, DestMap> CollDestMap;
107  CollDestMap collDestMap;
108  };
109 
110  //------------------------------------------------------------------------------------------------------------------------------------------
111 
112  marlin::Processor *OverlayTiming::newProcessor()
113  {
114  return new OverlayTiming;
115  }
116 
117  //------------------------------------------------------------------------------------------------------------------------------------------
118 
119  const std::string &OverlayTiming::name() const
120  {
121  return marlin::Processor::name();
122  }
123 
124  //------------------------------------------------------------------------------------------------------------------------------------------
125 
126  inline float OverlayTiming::time_of_flight(float x, float y, float z) const
127  {
128  //returns the time of flight to the radius in ns
129  // mm/m/s = 10^{-3}s = 10^6 ns d.h. 299 mm/ns
130  return std::sqrt((x * x) + (y * y) + (z * z))/299.792458;
131  }
132 
133  //------------------------------------------------------------------------------------------------------------------------------------------
134 
135  inline long long OverlayTiming::cellID2long(int id0, int id1) const
136  {
137  return ((long long) id0 << 32) | id1;
138  }
139 
140 } // namespace
141 
142 #endif
143 
OverlayTiming processor for overlaying background to each bunch crossing of a bunch train...
Definition: OverlayTiming.h:46