ATLAS Offline Software
TileHitVecToCntTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //**************************************************************************
6 // Filename : TileHitVecToCntTool.h
7 // Author : Vishnu Zutshi
8 // Created : Dec. 2009
9 //
10 // DESCRIPTION
11 //
12 // TileHitVecToCnt copies all TileHits from TileHitVector (AthenaHitsVector)
13 // to TileHitContainer (identifiable container) without any corrections.
14 // If pileup option is set, all hits are merged. The pileup is done bunchXing
15 // by bunchXing (main difference from TileHitVecToCnt). If several hits have
16 // the same ID, energy and time from all of them is stored in vectors
17 // inside single TileHit.
18 //
19 // Properties (JobOption Parameters):
20 //
21 // TileHitVectors string Name of TileHitVector to read
22 // TileHitContainer string Name of TileHitContainer to write
23 // TileInfoName string Name of object in TDS with all parameters
24 // PileUp bool Do or not pileup
25 // HitTimeFlag int Working with hit times
26 //**************************************************************************
27 
28 #ifndef TILESIMALGS_TILEHITVECTOCNTTOOL_H
29 #define TILESIMALGS_TILEHITVECTOCNTTOOL_H
30 
31 // Tile includes
38 
39 // Athena includes
44 // Pile up
46 
48 
49 // Gaudi includes
50 #include "GaudiKernel/ServiceHandle.h"
51 #include "GaudiKernel/SystemOfUnits.h"
52 
53 // Avoid pushing dependencies into clients- just fwd declare the following:
54 
55 class TileID;
56 class TileTBID;
57 class TileHWID;
58 class TileHit;
60 class Identifier;
61 class TileCablingService;
62 class TileHitCollection;
63 
64 
65 namespace CLHEP {
66  class HepRandomEngine;
67 }
68 
69 // C++ STL includes
70 #include <string>
71 #include <vector>
72 
85 
86 public:
87  TileHitVecToCntTool(const std::string& type, const std::string& name, const IInterface* parent);
88  StatusCode initialize() override final;
89  virtual StatusCode prepareEvent(const EventContext& ctx, unsigned int /*nInputEvents*/) override final;
90  virtual StatusCode mergeEvent(const EventContext& ctx) override final;
91  virtual StatusCode processBunchXing(int bunchXing,
92  SubEventIterator bSubEvents,
93  SubEventIterator eSubEvents) override final;
94  virtual StatusCode processAllSubEvents(const EventContext& ctx) override final;
95  StatusCode finalize() override final;
96 
97 private:
99  void processHitVectorForOverlay(const TileHitVector* inputHits, int& nHit, double& eHitTot);
100  void processHitVectorForPileUp(const TileHitVector* inputHits, double SubEvtTimOffset, int& nHit, double& eHitTot, bool isSignal = false);
101  void processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* hitCont, CLHEP::HepRandomEngine * engine);
102  // Method to apply photostatistics effect
103  double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine* engine, const TileSamplingFraction* samplingFraction, int drawerIdx);
104  void findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont);
105  void findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont);
106  void findAndMergeMultipleHitsInChannel(std::unique_ptr<TileHitNonConstContainer>& hitCont);
107  void mergeExtraHitToChannelHit(TileHit* extraHit, TileHit* channelHit);
108 
109  Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."};
110  StringArrayProperty m_inputKeys{this, "TileHitVectors", {"TileHitVec"},
111  "Name of input hit vectors (default=TileHitVec)" };
112  SG::ReadHandleKeyArray<TileHitVector> m_hitVectorKeys{this, "TileHitVectorKeys", {}, "Do not set manually!"};
113  std::vector<std::string> m_hitVectorNames{};
114 
115  SG::WriteHandleKey<TileHitContainer> m_hitContainerKey{this,"TileHitContainer","TileHitCnt",
116  "Output Tile hit container key"};
117 
118  SG::WriteHandleKey<TileHitContainer> m_hitContainer_DigiHSTruthKey{this,"TileHitContainer_DigiHSTruth","TileHitCnt_DigiHSTruth",
119  "Output DigiHSTruth Tile hit container key"};
120 
125  "TileSamplingFraction", "TileSamplingFraction", "Input Tile sampling fraction"};
126 
127  bool m_run2{false};
128  bool m_run2plus{false};
129  Gaudi::Property<bool> m_pileUp{this, "PileUp", false,
130  "To switch on pileup (default=false)"};
131  Gaudi::Property<double> m_deltaT{this, "DeltaT", 1.0*Gaudi::Units::nanosecond,
132  "Minimal Time granularity in TileHit (default=1ns)"};
133  Gaudi::Property<int> m_timeFlag{this, "HitTimeFlag", 0,
134  "Special options to deal with times of hits for cosmics and TB (default=0)"};
135  Gaudi::Property<double> m_triggerTime{this, "TriggerTime", 0.0,
136  "Fixed trigger time value (default=0)"};
137  Gaudi::Property<double> m_maxHitTime{this, "MaxHitTime", 150.5*Gaudi::Units::nanosecond,
138  "All sub-hits with time above m_maxHitTime will be ignored"};
139  Gaudi::Property<double> m_photoStatisticsWindow{this, "PhotostatWindow", 62.5*Gaudi::Units::nanosecond,
140  "Sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics"};
141  Gaudi::Property<int> m_photoElectronStatistics{this, "PhotostatType", 2,
142  "Method to apply photostatistics (default=2)"};
143  Gaudi::Property<bool> m_skipNoHit{this, "SkipNoHit", false,
144  "Skip events with no Tile hits (default=false)"};
145  Gaudi::Property<bool> m_rndmEvtOverlay{this, "RndmEvtOverlay", false,
146  "Pileup and/or noise added by overlaying random events (default=false)"};
147  Gaudi::Property<bool> m_useTriggerTime{this, "UseTriggerTime", false,
148  "Take trigger time from external tool (default=false)"};
149  Gaudi::Property<bool> m_doDigiTruth{this, "DoHSTruthReconstruction", false,
150  "DigiTruth reconstruction"};
151  Gaudi::Property<bool> m_usePhotoStatistics{this,
152  "usePhotoStatistics", true, "Simulate photo statistics effect (default=true)"};
153  Gaudi::Property<bool> m_mergeMultipleHitsInChannel{this, "MergeMultipleHitsInChannel", true,
154  "Find and merge multiple hits for the same channel in container (default=true)"};
155  PublicToolHandle<ITriggerTime> m_triggerTimeTool{this, "TriggerTimeTool", "",
156  "Name of trigger time tool (default='')"};
157 
158  ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""};
159 
160  const TileID* m_tileID{nullptr};
161  const TileTBID* m_tileTBID{nullptr};
162  const TileHWID* m_tileHWID{nullptr};
163 
164  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""};
165  Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Tile_HitVecToCnt", ""};
167 
168  std::vector<TileHit*> m_allHits;
169  std::vector<TileHit*> m_allHits_DigiHSTruth;
170  std::unique_ptr<TileHitNonConstContainer> m_hits{};
171  std::unique_ptr<TileHitNonConstContainer> m_hits_DigiHSTruth{};
172 
173  int m_mbtsOffset{0}; //<! index of first MBTS hit in m_allHits vector
174  static const int N_SIDE = 2;
175  static const int N_PHI = 8;
176  static const int N_ETA = 2;
177  static const int N_MBTS_CELLS = N_SIDE * N_PHI * N_ETA;
178  inline int mbts_index(int side, int phi, int eta) const {
179  return (side * N_PHI + phi) * N_ETA + eta + m_mbtsOffset;
180  }
181  static const int E4_SIDE = -1;
182  static const int E4_ETA = 2;
183  static const int E4_N_PHI = 4;
184  static const int N_E4PRIME_CELLS = E4_N_PHI;
185  inline int e4pr_index(int phi) const {
186  return phi + N_MBTS_CELLS + m_mbtsOffset;
187  }
188 
189  ServiceHandle<TileCablingSvc> m_cablingSvc{this, "TileCablingSvc", "TileCablingSvc", ""};
192  std::vector<bool> m_E1merged;
193  std::vector<bool> m_MBTSmerged;
194  enum CELL_TOWER{E1_TOWER = 10};
195 };
196 
197 #endif // TILESIMALGS_TILEHITVECTOCNTTOOL_H
TileHitVecToCntTool::N_E4PRIME_CELLS
static const int N_E4PRIME_CELLS
Definition: TileHitVecToCntTool.h:184
TileHitVecToCntTool::m_cabling
const TileCablingService * m_cabling
Definition: TileHitVecToCntTool.h:190
TileCablingSvc.h
TileHitVecToCntTool::createContainers
StatusCode createContainers()
Definition: TileHitVecToCntTool.cxx:239
TileHitVecToCntTool::CELL_TOWER
CELL_TOWER
Definition: TileHitVecToCntTool.h:194
TileHitVecToCntTool::E4_N_PHI
static const int E4_N_PHI
Definition: TileHitVecToCntTool.h:183
TileHitVecToCntTool::m_hitContainer_DigiHSTruthKey
SG::WriteHandleKey< TileHitContainer > m_hitContainer_DigiHSTruthKey
Definition: TileHitVecToCntTool.h:118
TileHitVecToCntTool::m_hitContainerKey
SG::WriteHandleKey< TileHitContainer > m_hitContainerKey
Definition: TileHitVecToCntTool.h:115
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
python.SystemOfUnits.nanosecond
int nanosecond
Definition: SystemOfUnits.py:119
TileHitVecToCntTool::E4_SIDE
static const int E4_SIDE
Definition: TileHitVecToCntTool.h:181
TileHitVecToCntTool::m_samplingFractionKey
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Definition: TileHitVecToCntTool.h:124
TileHitVecToCntTool::m_tileTBID
const TileTBID * m_tileTBID
Pointer to TileID helper.
Definition: TileHitVecToCntTool.h:161
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TileHitVecToCntTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: TileHitVecToCntTool.h:158
TileHitVecToCntTool::initialize
StatusCode initialize() override final
Definition: TileHitVecToCntTool.cxx:51
AtlasHitsVector
Definition: AtlasHitsVector.h:33
TileHitVecToCntTool::m_hitVectorNames
std::vector< std::string > m_hitVectorNames
Definition: TileHitVecToCntTool.h:113
TileHitVecToCntTool::m_pileUp
Gaudi::Property< bool > m_pileUp
if true => pileup mode is activated
Definition: TileHitVecToCntTool.h:129
TileHitVecToCntTool::m_timeFlag
Gaudi::Property< int > m_timeFlag
special options to deal with times of hits for cosmics and TB
Definition: TileHitVecToCntTool.h:133
TileHitVecToCntTool::processBunchXing
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
Definition: TileHitVecToCntTool.cxx:667
TileHitVecToCntTool::m_mbtsOffset
int m_mbtsOffset
Definition: TileHitVecToCntTool.h:173
TileHitVecToCntTool::TileHitVecToCntTool
TileHitVecToCntTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: TileHitVecToCntTool.cxx:44
TileFragHash.h
TileHitVecToCntTool::m_hits_DigiHSTruth
std::unique_ptr< TileHitNonConstContainer > m_hits_DigiHSTruth
pointer to hits container
Definition: TileHitVecToCntTool.h:171
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
TileHitVecToCntTool::m_inputKeys
StringArrayProperty m_inputKeys
vector with the names of TileHitVectors to use
Definition: TileHitVecToCntTool.h:110
TileHitVecToCntTool::m_mergeMultipleHitsInChannel
Gaudi::Property< bool > m_mergeMultipleHitsInChannel
Definition: TileHitVecToCntTool.h:153
TileFragHash
Hash table for Tile fragments (==drawers ==collections in StoreGate)
Definition: TileFragHash.h:24
TileHitCollection
Definition: TileHitCollection.h:12
TileHitVecToCntTool::processHitVectorForOverlay
void processHitVectorForOverlay(const TileHitVector *inputHits, int &nHit, double &eHitTot)
Definition: TileHitVecToCntTool.cxx:289
TileHitVecToCntTool::m_hitVectorKeys
SG::ReadHandleKeyArray< TileHitVector > m_hitVectorKeys
Definition: TileHitVecToCntTool.h:112
TileHitVecToCntTool::m_useTriggerTime
Gaudi::Property< bool > m_useTriggerTime
if true => take trigger time from external tool or from m_triggerTime
Definition: TileHitVecToCntTool.h:147
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TileHitVecToCntTool::m_cablingSvc
ServiceHandle< TileCablingSvc > m_cablingSvc
Definition: TileHitVecToCntTool.h:189
TileHWID
Helper class for TileCal online (hardware) identifiers.
Definition: TileHWID.h:49
TileHitVecToCntTool::processHitVectorWithoutPileUp
void processHitVectorWithoutPileUp(const TileHitVector *inputHits, int &nHit, double &eHitTot, TileHitNonConstContainer *hitCont, CLHEP::HepRandomEngine *engine)
Definition: TileHitVecToCntTool.cxx:471
TileHitVecToCntTool::m_run2plus
bool m_run2plus
if true => RUN2+ geometry with merged E1 (and E4' in RUN2)
Definition: TileHitVecToCntTool.h:128
TileHitVecToCntTool::N_MBTS_CELLS
static const int N_MBTS_CELLS
Definition: TileHitVecToCntTool.h:177
TileHitVecToCntTool::m_run2
bool m_run2
if true => RUN2 geometry with E4' and merged E1
Definition: TileHitVecToCntTool.h:127
SG::WriteHandleKey< TileHitContainer >
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
TileHitVecToCntTool::m_usePhotoStatistics
Gaudi::Property< bool > m_usePhotoStatistics
Definition: TileHitVecToCntTool.h:151
TileSamplingFraction
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
Definition: TileSamplingFraction.h:16
TileHitVecToCntTool::m_tileHWID
const TileHWID * m_tileHWID
Pointer to TileID helper.
Definition: TileHitVecToCntTool.h:162
TileDetDescrManager
Definition: TileDetDescrManager.h:33
TileSamplingFraction.h
TileID
Helper class for TileCal offline identifiers.
Definition: TileID.h:68
TileHitVecToCntTool::mergeEvent
virtual StatusCode mergeEvent(const EventContext &ctx) override final
Definition: TileHitVecToCntTool.cxx:832
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TileHitVecToCntTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Random number generator engine to use.
Definition: TileHitVecToCntTool.h:164
TileHitVecToCntTool::m_onlyUseContainerName
Gaudi::Property< bool > m_onlyUseContainerName
Definition: TileHitVecToCntTool.h:109
TileHitVecToCntTool::m_rndmEvtOverlay
Gaudi::Property< bool > m_rndmEvtOverlay
If true => overlay with random event (zero-luminosity pile-up)
Definition: TileHitVecToCntTool.h:145
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
TileHitVecToCntTool::m_deltaT
Gaudi::Property< double > m_deltaT
minimal time granularity for TileHit
Definition: TileHitVecToCntTool.h:131
TileHitVecToCntTool::findAndMergeMultipleHitsInChannel
void findAndMergeMultipleHitsInChannel(std::unique_ptr< TileHitNonConstContainer > &hitCont)
Definition: TileHitVecToCntTool.cxx:1219
TileHitVecToCntTool::m_fragHashFunc
TileFragHash m_fragHashFunc
Definition: TileHitVecToCntTool.h:191
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TileHitVecToCntTool::prepareEvent
virtual StatusCode prepareEvent(const EventContext &ctx, unsigned int) override final
Definition: TileHitVecToCntTool.cxx:275
TileHitVecToCntTool::m_triggerTimeTool
PublicToolHandle< ITriggerTime > m_triggerTimeTool
tool to take the time from
Definition: TileHitVecToCntTool.h:155
TileCablingService
Definition: TileCablingService.h:23
TileHitVecToCntTool::mergeExtraHitToChannelHit
void mergeExtraHitToChannelHit(TileHit *extraHit, TileHit *channelHit)
Definition: TileHitVecToCntTool.cxx:1260
PileUpToolBase
Definition: PileUpToolBase.h:18
TileHitVecToCntTool::findAndMergeMBTS
void findAndMergeMBTS(TileHitCollection *coll, int frag_id, TileHitNonConstContainer *hitCont)
Definition: TileHitVecToCntTool.cxx:1160
TileHitVecToCntTool
This AlgTool merges TileHits from different AthenaHitVectors and stores the result in a TileHitContai...
Definition: TileHitVecToCntTool.h:84
TileHitVecToCntTool::m_skipNoHit
Gaudi::Property< bool > m_skipNoHit
if true => skip events with no Tile hits
Definition: TileHitVecToCntTool.h:143
TileHitVecToCntTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
Definition: TileHitVecToCntTool.cxx:738
ReadCondHandleKey.h
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
TileHitVecToCntTool::e4pr_index
int e4pr_index(int phi) const
Definition: TileHitVecToCntTool.h:185
TileHitVecToCntTool::mbts_index
int mbts_index(int side, int phi, int eta) const
Definition: TileHitVecToCntTool.h:178
TileHitVecToCntTool::m_hits
std::unique_ptr< TileHitNonConstContainer > m_hits
pointer to hits container
Definition: TileHitVecToCntTool.h:170
TileHitVecToCntTool::m_allHits
std::vector< TileHit * > m_allHits
vector for all TileHits
Definition: TileHitVecToCntTool.h:168
TileHitVector.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TileHitVecToCntTool::m_maxHitTime
Gaudi::Property< double > m_maxHitTime
all sub-hits with time above m_maxHitTime will be ignored
Definition: TileHitVecToCntTool.h:137
TileHitVecToCntTool::m_allHits_DigiHSTruth
std::vector< TileHit * > m_allHits_DigiHSTruth
vector for all TileHits
Definition: TileHitVecToCntTool.h:169
TileHitVecToCntTool::N_ETA
static const int N_ETA
Definition: TileHitVecToCntTool.h:176
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
TileHitContainer.h
SG::ReadCondHandleKey< TileSamplingFraction >
TileHitNonConstContainer.h
Helper class for building a TileHitContainer.
TileHitNonConstContainer
This is a minimal version of a TileHitContainer in which the saved collections remain non-const.
Definition: TileHitNonConstContainer.h:31
TileHitVecToCntTool::m_MBTSmerged
std::vector< bool > m_MBTSmerged
Definition: TileHitVecToCntTool.h:193
TileHitVecToCntTool::m_photoStatisticsWindow
Gaudi::Property< double > m_photoStatisticsWindow
sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics
Definition: TileHitVecToCntTool.h:139
TileHitVecToCntTool::m_doDigiTruth
Gaudi::Property< bool > m_doDigiTruth
Definition: TileHitVecToCntTool.h:149
PileUpMergeSvc.h
the preferred mechanism to access information from the different event stores in a pileup job.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TileHitVecToCntTool::E4_ETA
static const int E4_ETA
Definition: TileHitVecToCntTool.h:182
TileHitVecToCntTool::m_photoElectronStatistics
Gaudi::Property< int > m_photoElectronStatistics
photoelectron statistics type: 0 - Poisson, 1 - "new" Poisson + Gauss, 2 - Poisson->Gauss
Definition: TileHitVecToCntTool.h:141
TileHitVecToCntTool::findAndMergeE1
void findAndMergeE1(TileHitCollection *coll, int frag_id, TileHitNonConstContainer *hitCont)
Definition: TileHitVecToCntTool.cxx:1102
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
TileTBID
Helper class for TileCal offline identifiers of ancillary testbeam detectors and MBTS.
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:65
TileHitVecToCntTool::processHitVectorForPileUp
void processHitVectorForPileUp(const TileHitVector *inputHits, double SubEvtTimOffset, int &nHit, double &eHitTot, bool isSignal=false)
Definition: TileHitVecToCntTool.cxx:335
TileHitVecToCntTool::m_tileID
const TileID * m_tileID
Pointer to TileID helper.
Definition: TileHitVecToCntTool.h:160
TileHitVecToCntTool::E1_TOWER
@ E1_TOWER
Definition: TileHitVecToCntTool.h:194
PileUpToolBase.h
helper base class IPileUpTool::toProcess().
TileHitVecToCntTool::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition: TileHitVecToCntTool.h:166
TileHitVecToCntTool::m_E1merged
std::vector< bool > m_E1merged
Definition: TileHitVecToCntTool.h:192
TileHitVecToCntTool::finalize
StatusCode finalize() override final
Definition: TileHitVecToCntTool.cxx:997
ITriggerTime.h
interface to a tool that returns the time offset of the current trigger. Used by PileUpMergeSvc
TileHitVecToCntTool::N_PHI
static const int N_PHI
Definition: TileHitVecToCntTool.h:175
TileHitVecToCntTool::m_triggerTime
Gaudi::Property< double > m_triggerTime
fixed trigger time value (default=0)
Definition: TileHitVecToCntTool.h:135
TileHitVecToCntTool::applyPhotoStatistics
double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine *engine, const TileSamplingFraction *samplingFraction, int drawerIdx)
Definition: TileHitVecToCntTool.cxx:1022
IAthRNGSvc.h
ServiceHandle< PileUpMergeSvc >
TileHitVecToCntTool::N_SIDE
static const int N_SIDE
Definition: TileHitVecToCntTool.h:174
Identifier
Definition: IdentifierFieldParser.cxx:14