ATLAS Offline Software
Loading...
Searching...
No Matches
METCaloRegionsTool.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5*/
6
7// METCaloRegionsTool.cxx
8// Implementation file for class METCaloRegionsTool
9//
10// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
11//
12// Author: P Loch, S Resconi, TJ Khoo, AS Mete
14
15// METReconstruction includes
17
18// MET EDM
19#if defined(XAOD_STANDALONE) || defined(XAOD_ANALYSIS)
20#else
23#endif
24
25namespace met {
26
27 using std::vector;
28 //
29 using xAOD::IParticle;
30 //
33 //
34 using xAOD::MissingET;
36
37 // Initialize s_CaloRegionNames
39 {
40 "EMB",
41 "EME",
42 "FCAL",
43 "HEC",
44 "PEMB",
45 "PEME",
46 "TILE"
47 };
48
50 // Public methods:
52
53 // Constructors
57 {
58 }
59
60 // Athena algtool's Hooks
63 {
64 ATH_MSG_DEBUG("Initializing " << name() << "...");
65
66 #if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS)
67 ATH_CHECK( m_noiseCDOKey.initialize() );
68 #endif
69 // Either Cells or Clusters
72
73 return StatusCode::SUCCESS;
74 }
75
77 // Protected methods:
79
81 {
82
83 ATH_MSG_DEBUG ("In execute: " << name() << "...");
84
85 // Create the container and push back the new MET terms
87 MissingETContainer* metCont = static_cast<MissingETContainer*>( metTerm_EMB->container() );
88
89 // Push region terms to the container
90 for( int i=0; i < REGIONS_TOTAL; ++i) {
91 // Create the new terms
92 if( i > 0 ) {
93 metCont->push_back( new MissingET(0.,0.,0.) );
94 }
95 // Set Name and Source
96 metCont->at(i)->setName( s_CaloRegionNames[i] );
97 metCont->at(i)->setSource( source );
98 }
99 // The last term is Trigger MET if asked for by the user
101 std::string termName = "";
102 for( int i=0; i<3; ++i) {
103 switch(i) {
104 case 0: termName = "AllCells"; break;
105 case 1: termName = "Cells_Abs2S"; break;
106 case 2: termName = "Cells_Abs2S_m5S"; break;
107 }
108 metCont->push_back( new MissingET(0.,0.,0.) );
109 metCont->at(REGIONS_TOTAL+i)->setName( termName );
111 }
112 }
113
114 StatusCode sc = StatusCode::SUCCESS;
115
116 // Either Cells or Clusters
117 if(m_calo_useCells) {
118 // Retrieve the cell container
120
121 #if defined(XAOD_STANDALONE) || defined(XAOD_ANALYSIS)
122 #else
123 if (!caloCellCont.isValid()) {
124 ATH_MSG_WARNING("Couldn't set up ReadHandle for Calo Cell Container "<<m_caloCellKey.key());
125 ATH_MSG_WARNING("Unable to retrieve input cell cluster container");
126 return StatusCode::SUCCESS;
127
128 }
129 #endif
130 // Fill MET
131 sc = fillCellMet(metCont,caloCellCont.cptr());
132 } else {
133 // Retrieve the calo container
135 if (!caloClusCont.isValid()) {
136 ATH_MSG_WARNING("Unable to retrieve input calo cluster container"<<m_caloClusterKey.key());
137 return StatusCode::SUCCESS;
138
139 }
140 // Fill MET
141 sc=fillClusterMet(metCont,caloClusCont.cptr());
142 } // end if use clusters if/else
143
144 // Debug information
145 for( int i=0; i < REGIONS_TOTAL; ++i) {
146 MissingET* currentTerm = (MissingET*) metCont->at(i);
147 if(!currentTerm) continue;
148 ATH_MSG_DEBUG ( "MET Calo term name " << currentTerm->name() <<
149 ", source " << currentTerm->source() <<
150 ", mpx " << currentTerm->mpx() <<
151 ", mpy " << currentTerm->mpy() <<
152 ", met " << currentTerm->met() <<
153 ", sumet " << currentTerm->sumet()
154 );
155 } // end debug information
156
157 if(sc.isFailure()) {
158 ATH_MSG_WARNING("Unable to fill cell/cluster MET");
159 }
160
161 return StatusCode::SUCCESS;
162 }
163
164 // Find MetTerm name for a given sampling
166 {
167 switch(sample) {
168 case CaloSampling::EMB1:
169 case CaloSampling::EMB2:
170 case CaloSampling::EMB3:
171 return metContainer->at(EMB);
172 //
173 case CaloSampling::EME1:
174 case CaloSampling::EME2:
175 case CaloSampling::EME3:
176 return metContainer->at(EME);
177 //
178 case CaloSampling::FCAL0:
179 case CaloSampling::FCAL1:
180 case CaloSampling::FCAL2:
181 return metContainer->at(FCAL);
182 //
183 case CaloSampling::HEC0:
184 case CaloSampling::HEC1:
185 case CaloSampling::HEC2:
186 case CaloSampling::HEC3:
187 return metContainer->at(HEC);
188 //
189 case CaloSampling::PreSamplerB:
190 return metContainer->at(PEMB);
191 //
192 case CaloSampling::PreSamplerE:
193 return metContainer->at(PEME);
194 //
195 case CaloSampling::TileBar0:
196 case CaloSampling::TileBar1:
197 case CaloSampling::TileBar2:
198 case CaloSampling::TileExt0:
199 case CaloSampling::TileExt1:
200 case CaloSampling::TileExt2:
201 case CaloSampling::TileGap1:
202 case CaloSampling::TileGap2:
203 case CaloSampling::TileGap3:
204 return metContainer->at(TILE);
205 //
206 default: return nullptr;
207 }
208 }
209
210 // Fill Cell MET
212 const CaloCellContainer* caloCellContainer) const
213 {
214 #if defined (XAOD_STANDALONE) || defined(XAOD_ANALYSIS)
215 ATH_MSG_WARNING("Cell information is only available in athena framework");
216 #else
218 const CaloNoise* noiseCDO=*noiseHdl;
219 // Loop over all cells
220 for (const CaloCell* cell : *caloCellContainer) {
221
222 // Retrieve the sampling
223 CaloSampling::CaloSample sample = (CaloSampling::CaloSample) cell->caloDDE()->getSampling();
224
225 // Calculate Et/phi
226 double e_cell = cell->energy();
227 double et_cell = e_cell/cosh(cell->eta());
228 double phi_cell = cell->phi();
229
230 // Find the associated MET
231 MissingET* metTerm = findMetTerm(metContainer, sample);
232 if(!metTerm) {
233 ATH_MSG_WARNING("Invalid calo sample MET pointer");
234 continue;
235 }
236
237 // Add to MET for the Calo regions
238 metTerm->add(et_cell*cos(phi_cell),
239 et_cell*sin(phi_cell),
240 et_cell);
241
242 // Trigger MET
244 #if defined(XAOD_STANDALONE) || defined(XAOD_ANALYSIS)
245 double noise_cell = 0;
246 #else
247 double noise_cell = noiseCDO->getNoise(cell->ID(),cell->gain());
248 #endif
249 // All cells
250 metContainer->at(REGIONS_TOTAL)->add(et_cell*cos(phi_cell),
251 et_cell*sin(phi_cell),
252 et_cell);
253 // |E| > 2*sigma
254 if( fabs(e_cell) < 2.0*noise_cell ) continue;
255 metContainer->at(REGIONS_TOTAL+1)->add(et_cell*cos(phi_cell),
256 et_cell*sin(phi_cell),
257 et_cell);
258 // E > -5*sigma
259 if( e_cell < -5.0*noise_cell ) continue;
260 metContainer->at(REGIONS_TOTAL+2)->add(et_cell*cos(phi_cell),
261 et_cell*sin(phi_cell),
262 et_cell);
263 }
264 } // end of loop overall cells
265 #endif
266 return StatusCode::SUCCESS;
267 } // end of fillCellMet
268
269 // Fill Cluster MET
271 const CaloClusterContainer* caloClusContainer) const
272 {
273
274 // Loop over all clusters
275 for(const auto *iClus : *caloClusContainer) {
276 // Loop over all samplings
277 for(int iSample=CaloSampling::PreSamplerB;
278 iSample<=CaloSampling::FCAL2; ++iSample) {
279
281
282 // Eta is only defined if Energy != 0
283 if(fabs(iClus->eSample(sample))>0) {
284
285 // Calculate Et/phi
286 double et_sample = iClus->eSample(sample)/cosh(iClus->etaSample(sample));
287 double phi_sample = iClus->phiSample(sample);
288
289 // Find the associated MET
290 MissingET* metTerm = findMetTerm(metContainer, sample);
291 if(!metTerm) {
292 ATH_MSG_WARNING("Invalid calo sample MET pointer");
293 continue;
294 }
295
296 // Add to MET
297 metTerm->add(et_sample*cos(phi_sample),
298 et_sample*sin(phi_sample),
299 et_sample);
300 } // end of energy>0 if
301 } // end of loop over samplings
302 } // end of loop over clusters
303 return StatusCode::SUCCESS;
304 } // end of fillClusterMet
305
306}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
Container class for CaloCell.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:34
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const SG::AuxVectorData * container() const
Return the container holding this element.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< bool > m_calo_doTriggerMet
static const std::string s_CaloRegionNames[]
StatusCode fillClusterMet(xAOD::MissingETContainer *metContainer, const xAOD::CaloClusterContainer *caloClusContainer) const
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClusterKey
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Gaudi::Property< bool > m_calo_useCells
StatusCode fillCellMet(xAOD::MissingETContainer *metContainer, const CaloCellContainer *caloCellContainer) const
static xAOD::MissingET * findMetTerm(xAOD::MissingETContainer *metContainer, CaloSampling::CaloSample sample)
virtual StatusCode execute(xAOD::MissingET *metTerm, xAOD::MissingETComponentMap *metMap) const override
SG::ReadHandleKey< CaloCellContainer > m_caloCellKey
Class providing the definition of the 4-vector interface.
float sumet() const
Returns.
void add(const IParticle *particle)
Add particle kinematics to MET.
MissingETBase::Types::bitmask_t source() const
MET object source tag.
float met() const
Returns .
const std::string & name() const
Identifier getters.
float mpx() const
Returns .
float mpy() const
Returns .
uint64_t bitmask_t
Type for status word bit mask.
MissingETComponentMap_v1 MissingETComponentMap
Version control by type definition.
MissingET_v1 MissingET
Version control by type defintion.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
static Types::bitmask_t clusterEM(Region reg=Region::FullAcceptance)
Bit mask for MET term from EMTopo signal objects.
@ Calo
Indicator for MET terms reconstructed from calorimeter signals alone.