ATLAS Offline Software
Loading...
Searching...
No Matches
TileHitVecToCntTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
46// Pile up
48
49// Gaudi includes
50#include "GaudiKernel/ServiceHandle.h"
51#include "GaudiKernel/SystemOfUnits.h"
52#include <memory>
53
54// Avoid pushing dependencies into clients- just fwd declare the following:
55
56class TileID;
57class TileTBID;
58class TileHWID;
59class TileHit;
61class Identifier;
64
65
66namespace CLHEP {
67 class HepRandomEngine;
68}
69
70// C++ STL includes
71#include <string>
72#include <vector>
73
84
86
87public:
88 TileHitVecToCntTool(const std::string& type, const std::string& name, const IInterface* parent);
89 StatusCode initialize() override final;
90 virtual StatusCode prepareEvent(const EventContext& ctx, unsigned int /*nInputEvents*/) override final;
91 virtual StatusCode mergeEvent(const EventContext& ctx) override final;
92 virtual StatusCode processBunchXing(int bunchXing,
93 SubEventIterator bSubEvents,
94 SubEventIterator eSubEvents) override final;
95 virtual StatusCode processAllSubEvents(const EventContext& ctx) override final;
96 virtual StatusCode processAllSubEvents(const EventContext& ctx) const;
97 StatusCode finalize() override final;
98
99private:
100 StatusCode createContainers();
101 void processHitVectorForOverlay(const TileHitVector* inputHits, std::unique_ptr<TileHitNonConstContainer>& hits, int& nHit, double& eHitTot) const;
102 void processHitVectorForPileUp(const TileHitVector* inputHits, double SubEvtTimOffset, std::vector<std::unique_ptr<TileHit>>& allHits,
103 std::vector<std::unique_ptr<TileHit>>& allHits_DigiHSTruth, int& nHit, double& eHitTot, bool isSignal = false) const;
104 void processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* hitCont, CLHEP::HepRandomEngine * engine) const;
105 // Method to apply photostatistics effect
106 double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine* engine, const TileSamplingFraction* samplingFraction, int drawerIdx) const;
107 void findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont) const;
108 void findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont) const;
109 void findAndMergeMultipleHitsInChannel(std::unique_ptr<TileHitNonConstContainer>& hitCont) const;
110 void mergeExtraHitToChannelHit(TileHit* extraHit, TileHit* channelHit) const;
111 void putAllHitsInContainer(std::vector<std::unique_ptr<TileHit>>& allHits,
112 std::vector<std::unique_ptr<TileHit>>& allHits_DigiHSTruth,
113 std::unique_ptr<TileHitNonConstContainer>& hits,
114 std::unique_ptr<TileHitNonConstContainer>& hits_DigiHSTruth,
115 SG::OwnershipPolicy ownPolicy) const;
116 StatusCode commitContainers(const EventContext& ctx,
117 std::unique_ptr<TileHitNonConstContainer>& hits,
118 std::unique_ptr<TileHitNonConstContainer>& hits_DigiHSTruth,
119 SG::OwnershipPolicy ownPolicy) const;
120 void prepareAllHits(std::vector<std::unique_ptr<TileHit>>& allHits) const;
121
122
123 Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."};
124 StringArrayProperty m_inputKeys{this, "TileHitVectors", {"TileHitVec"},
125 "Name of input hit vectors (default=TileHitVec)" };
126 SG::ReadHandleKeyArray<TileHitVector> m_hitVectorKeys{this, "TileHitVectorKeys", {}, "Do not set manually!"};
127 std::vector<std::string> m_hitVectorNames{};
128
129 SG::WriteHandleKey<TileHitContainer> m_hitContainerKey{this,"TileHitContainer","TileHitCnt",
130 "Output Tile hit container key"};
131
132 SG::WriteHandleKey<TileHitContainer> m_hitContainer_DigiHSTruthKey{this,"TileHitContainer_DigiHSTruth","TileHitCnt_DigiHSTruth",
133 "Output DigiHSTruth Tile hit container key"};
134
139 "TileSamplingFraction", "TileSamplingFraction", "Input Tile sampling fraction"};
140
141 bool m_run2{false};
142 bool m_run2plus{false};
143 Gaudi::Property<bool> m_pileUp{this, "PileUp", false,
144 "To switch on pileup (default=false)"};
145 Gaudi::Property<double> m_deltaT{this, "DeltaT", 1.0*Gaudi::Units::nanosecond,
146 "Minimal Time granularity in TileHit (default=1ns)"};
147 Gaudi::Property<int> m_timeFlag{this, "HitTimeFlag", 0,
148 "Special options to deal with times of hits for cosmics and TB (default=0)"};
149 Gaudi::Property<double> m_triggerTime{this, "TriggerTime", 0.0,
150 "Fixed trigger time value (default=0)"};
151 Gaudi::Property<double> m_maxHitTime{this, "MaxHitTime", 150.5*Gaudi::Units::nanosecond,
152 "All sub-hits with time above m_maxHitTime will be ignored"};
153 Gaudi::Property<double> m_photoStatisticsWindow{this, "PhotostatWindow", 62.5*Gaudi::Units::nanosecond,
154 "Sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics"};
155 Gaudi::Property<int> m_photoElectronStatistics{this, "PhotostatType", 2,
156 "Method to apply photostatistics (default=2)"};
157 Gaudi::Property<bool> m_skipNoHit{this, "SkipNoHit", false,
158 "Skip events with no Tile hits (default=false)"};
159 Gaudi::Property<bool> m_rndmEvtOverlay{this, "RndmEvtOverlay", false,
160 "Pileup and/or noise added by overlaying random events (default=false)"};
161 Gaudi::Property<bool> m_useTriggerTime{this, "UseTriggerTime", false,
162 "Take trigger time from external tool (default=false)"};
163 Gaudi::Property<bool> m_doDigiTruth{this, "DoHSTruthReconstruction", false,
164 "DigiTruth reconstruction"};
165 Gaudi::Property<bool> m_usePhotoStatistics{this,
166 "usePhotoStatistics", true, "Simulate photo statistics effect (default=true)"};
167 Gaudi::Property<bool> m_mergeMultipleHitsInChannel{this, "MergeMultipleHitsInChannel", true,
168 "Find and merge multiple hits for the same channel in container (default=true)"};
169 SG::ReadHandleKey<CosTrigTime> m_triggerTimeKey{this,"CosTimeKey", "", "To take the trigger time from"};
170 ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""};
171
172 const TileID* m_tileID{nullptr};
173 const TileTBID* m_tileTBID{nullptr};
174 const TileHWID* m_tileHWID{nullptr};
175
176 ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""};
178 Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Tile_HitVecToCnt", ""};
179
180 std::vector<std::unique_ptr<TileHit>> m_allHits;
181 std::vector<std::unique_ptr<TileHit>> m_allHits_DigiHSTruth;
182 std::unique_ptr<TileHitNonConstContainer> m_hits{};
183 std::unique_ptr<TileHitNonConstContainer> m_hits_DigiHSTruth{};
184
185 int m_mbtsOffset{0}; //<! index of first MBTS hit in m_allHits vector
186 static const int N_SIDE = 2;
187 static const int N_PHI = 8;
188 static const int N_ETA = 2;
189 static const int N_MBTS_CELLS = N_SIDE * N_PHI * N_ETA;
190 inline int mbts_index(int side, int phi, int eta) const {
191 return (side * N_PHI + phi) * N_ETA + eta + m_mbtsOffset;
192 }
193 static const int E4_SIDE = -1;
194 static const int E4_ETA = 2;
195 static const int E4_N_PHI = 4;
196 static const int N_E4PRIME_CELLS = E4_N_PHI;
197 inline int e4pr_index(int phi) const {
198 return phi + N_MBTS_CELLS + m_mbtsOffset;
199 }
200
201 ServiceHandle<TileCablingSvc> m_cablingSvc{this, "TileCablingSvc", "TileCablingSvc", ""};
204 std::vector<bool> m_E1merged;
205 std::vector<bool> m_MBTSmerged;
207};
208
209#endif // TILESIMALGS_TILEHITVECTOCNTTOOL_H
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
the preferred mechanism to access information from the different event stores in a pileup job.
helper base class IPileUpTool::toProcess().
Property holding a SG store/key/clid from which a WriteHandle is made.
Helper class for building a TileHitContainer.
AtlasHitsVector< TileHit > TileHitVector
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
Hash table for Tile fragments (==drawers ==collections in StoreGate)
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
This is a minimal version of a TileHitContainer in which the saved collections remain non-const.
TileHitVecToCntTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
bool m_run2plus
if true => RUN2+ geometry with merged E1 (and E4' in RUN2)
Gaudi::Property< bool > m_rndmEvtOverlay
If true => overlay with random event (zero-luminosity pile-up)
void processHitVectorForPileUp(const TileHitVector *inputHits, double SubEvtTimOffset, std::vector< std::unique_ptr< TileHit > > &allHits, std::vector< std::unique_ptr< TileHit > > &allHits_DigiHSTruth, int &nHit, double &eHitTot, bool isSignal=false) const
double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine *engine, const TileSamplingFraction *samplingFraction, int drawerIdx) const
std::unique_ptr< TileHitNonConstContainer > m_hits
pointer to hits container
virtual StatusCode prepareEvent(const EventContext &ctx, unsigned int) override final
SG::WriteHandleKey< TileHitContainer > m_hitContainer_DigiHSTruthKey
void findAndMergeMultipleHitsInChannel(std::unique_ptr< TileHitNonConstContainer > &hitCont) const
Gaudi::Property< double > m_photoStatisticsWindow
sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics
void prepareAllHits(std::vector< std::unique_ptr< TileHit > > &allHits) const
SG::ReadHandleKey< CosTrigTime > m_triggerTimeKey
void findAndMergeMBTS(TileHitCollection *coll, int frag_id, TileHitNonConstContainer *hitCont) const
int mbts_index(int side, int phi, int eta) const
Gaudi::Property< bool > m_useTriggerTime
if true => take trigger time from external tool or from m_triggerTime
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
std::vector< std::string > m_hitVectorNames
static const int N_MBTS_CELLS
int e4pr_index(int phi) const
virtual StatusCode mergeEvent(const EventContext &ctx) override final
ServiceHandle< IAthRNGSvc > m_rndmSvc
Random number generator engine to use.
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
void mergeExtraHitToChannelHit(TileHit *extraHit, TileHit *channelHit) const
ServiceHandle< PileUpMergeSvc > m_mergeSvc
StatusCode commitContainers(const EventContext &ctx, std::unique_ptr< TileHitNonConstContainer > &hits, std::unique_ptr< TileHitNonConstContainer > &hits_DigiHSTruth, SG::OwnershipPolicy ownPolicy) const
void processHitVectorForOverlay(const TileHitVector *inputHits, std::unique_ptr< TileHitNonConstContainer > &hits, int &nHit, double &eHitTot) const
StringArrayProperty m_inputKeys
vector with the names of TileHitVectors to use
void processHitVectorWithoutPileUp(const TileHitVector *inputHits, int &nHit, double &eHitTot, TileHitNonConstContainer *hitCont, CLHEP::HepRandomEngine *engine) const
const TileID * m_tileID
Pointer to TileID helper.
std::vector< std::unique_ptr< TileHit > > m_allHits_DigiHSTruth
vector for all TileHits
const TileHWID * m_tileHWID
Pointer to TileID helper.
Gaudi::Property< double > m_deltaT
minimal time granularity for TileHit
Gaudi::Property< double > m_maxHitTime
all sub-hits with time above m_maxHitTime will be ignored
SG::ReadHandleKeyArray< TileHitVector > m_hitVectorKeys
bool m_run2
if true => RUN2 geometry with E4' and merged E1
Gaudi::Property< bool > m_mergeMultipleHitsInChannel
Gaudi::Property< bool > m_pileUp
if true => pileup mode is activated
void findAndMergeE1(TileHitCollection *coll, int frag_id, TileHitNonConstContainer *hitCont) const
SG::WriteHandleKey< TileHitContainer > m_hitContainerKey
const TileCablingService * m_cabling
Gaudi::Property< bool > m_skipNoHit
if true => skip events with no Tile hits
Gaudi::Property< int > m_photoElectronStatistics
photoelectron statistics type: 0 - Poisson, 1 - "new" Poisson + Gauss, 2 - Poisson->Gauss
std::vector< std::unique_ptr< TileHit > > m_allHits
vector for all TileHits
static const int E4_N_PHI
Gaudi::Property< bool > m_usePhotoStatistics
StatusCode initialize() override final
std::vector< bool > m_E1merged
static const int N_E4PRIME_CELLS
ServiceHandle< TileCablingSvc > m_cablingSvc
Gaudi::Property< int > m_timeFlag
special options to deal with times of hits for cosmics and TB
const TileTBID * m_tileTBID
Pointer to TileID helper.
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
void putAllHitsInContainer(std::vector< std::unique_ptr< TileHit > > &allHits, std::vector< std::unique_ptr< TileHit > > &allHits_DigiHSTruth, std::unique_ptr< TileHitNonConstContainer > &hits, std::unique_ptr< TileHitNonConstContainer > &hits_DigiHSTruth, SG::OwnershipPolicy ownPolicy) const
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
Gaudi::Property< bool > m_onlyUseContainerName
Gaudi::Property< double > m_triggerTime
fixed trigger time value (default=0)
std::unique_ptr< TileHitNonConstContainer > m_hits_DigiHSTruth
pointer to hits container
Gaudi::Property< bool > m_doDigiTruth
std::vector< bool > m_MBTSmerged
StatusCode finalize() override final
Helper class for TileCal offline identifiers.
Definition TileID.h:67
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
Helper class for TileCal offline identifiers of ancillary testbeam detectors and MBTS.
HandleKeyArray< ReadHandle< T >, ReadHandleKey< T >, Gaudi::DataHandle::Reader > ReadHandleKeyArray
OwnershipPolicy