ATLAS Offline Software
Loading...
Searching...
No Matches
TBEMECXTalkToyModel Class Reference

#include <TBEMECXTalkToyModel.h>

Inheritance diagram for TBEMECXTalkToyModel:
Collaboration diagram for TBEMECXTalkToyModel:

Public Member Functions

 TBEMECXTalkToyModel (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize () override
virtual StatusCode process (CaloCellContainer *theCellContainer, const EventContext &ctx) const override

Private Member Functions

StatusCode processOnCellIterators (const CaloCellContainer::iterator &itrCellBeg, const CaloCellContainer::iterator &itrCellEnd) const

Private Attributes

std::vector< int > m_caloNums
bool m_caloSelection
const CaloCell_IDm_calo_id
float m_xtalkScaleLong
float m_xtalkScaleEta
float m_xtalkScaleEMEC2Eta

Detailed Description

Definition at line 15 of file TBEMECXTalkToyModel.h.

Constructor & Destructor Documentation

◆ TBEMECXTalkToyModel()

TBEMECXTalkToyModel::TBEMECXTalkToyModel ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 31 of file TBEMECXTalkToyModel.cxx.

35 :base_class (type, name, parent),
36 m_caloSelection(false),
37 m_calo_id(nullptr)
38{
39 declareProperty("CaloNums",m_caloNums);
40 declareProperty("XTalkScaleLong", m_xtalkScaleLong);
41 declareProperty("XTalkScaleEta", m_xtalkScaleEta);
42 declareProperty("XTalkScaleEMEC2Eta",m_xtalkScaleEMEC2Eta);
43 m_caloNums.clear();
44 //default: process all calo
45 m_caloNums.push_back( static_cast<int>(CaloCell_ID::NSUBCALO) );
46}
std::vector< int > m_caloNums
const CaloCell_ID * m_calo_id

Member Function Documentation

◆ initialize()

StatusCode TBEMECXTalkToyModel::initialize ( )
overridevirtual

Definition at line 56 of file TBEMECXTalkToyModel.cxx.

57{
58 unsigned int nSubCalo=static_cast<unsigned int>(CaloCell_ID::NSUBCALO) ;
59
60 //check calo number specified
61 m_caloSelection = true ;
62 if (m_caloNums.size()==0) {
63 ATH_MSG_WARNING (" no calo specified for correction. Will do nothing. ");
64 return StatusCode::SUCCESS;
65 } else if (m_caloNums.size()>nSubCalo ) {
66 ATH_MSG_ERROR (" More than "
67 << nSubCalo << " calo specified. Must be wrong. Stop.");
68 return StatusCode::FAILURE;
69 } else if (m_caloNums.size()==1 && m_caloNums[0]==static_cast<int>(nSubCalo)) {
70 m_caloSelection = false ;
71 ATH_MSG_INFO (" Correction will be applied on all calo.");
72 } else {
73 for (unsigned int index=0; index < m_caloNums.size() ; ++index) {
74 if (m_caloNums[index]<0 || m_caloNums[index]>=static_cast<int>(nSubCalo) ) {
75 ATH_MSG_ERROR ("Invalid calo specification:"
76 << m_caloNums[index] << "Stop.");
77 return StatusCode::FAILURE;
78 } else {
79 ATH_MSG_INFO (" Correction will be applied on calo:"
80 << static_cast<int>(m_caloNums[index]));
81 }
82 }
83 }
84
85 ATH_CHECK(detStore()->retrieve(m_calo_id,"CaloCell_ID"));
86
87 ATH_MSG_VERBOSE ("XTalkScaleLong = " << m_xtalkScaleLong);
88 ATH_MSG_VERBOSE ("XTalkScaleEta = " << m_xtalkScaleEta);
89 ATH_MSG_VERBOSE ("XTalkScaleEMEC2Eta = " << m_xtalkScaleEMEC2Eta);
90 ATH_MSG_VERBOSE ("Initialization completed successfully" );
91
92 return StatusCode::SUCCESS;
93
94}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
str index
Definition DeMoScan.py:362
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ process()

StatusCode TBEMECXTalkToyModel::process ( CaloCellContainer * theCellContainer,
const EventContext & ctx ) const
overridevirtual

Definition at line 96 of file TBEMECXTalkToyModel.cxx.

98{
100
101 if (!m_caloSelection) {
102 // no selection mode (faster)
103 CaloCellContainer::iterator itrCellBeg=theCont->begin();
104 CaloCellContainer::iterator itrCellEnd=theCont->end();
105
106 sc = processOnCellIterators(itrCellBeg, itrCellEnd );
107 if (sc.isFailure())
108 ATH_MSG_WARNING ("Failure from processOnCellIterators");
109 }else {
110 // selection mode
111
112 for (std::vector<int>::const_iterator itrCalo=m_caloNums.begin();itrCalo!=m_caloNums.end();++itrCalo){
113
114
115 CaloCell_ID::SUBCALO caloNum=static_cast<CaloCell_ID::SUBCALO>(*itrCalo);
116
117 CaloCellContainer::iterator itrCellBeg=theCont->beginCalo(caloNum);
118 CaloCellContainer::iterator itrCellEnd=theCont->endCalo(caloNum);
119
120 if (!theCont->hasCalo(caloNum))
121 {
122 ATH_MSG_WARNING (" Attempt to apply correction but CaloCellContainer has not been filled for this calo : "
123 << *itrCalo);
124 } else
125 {
126 sc=processOnCellIterators(itrCellBeg, itrCellEnd );
127 if (sc.isFailure())
128 ATH_MSG_WARNING ("Failure from processOnCellIterators for calo "
129 << static_cast<int> (caloNum));
130 }
131 }
132 }
133
134 return StatusCode::SUCCESS ;
135}
static Double_t sc
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
StatusCode processOnCellIterators(const CaloCellContainer::iterator &itrCellBeg, const CaloCellContainer::iterator &itrCellEnd) const
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ processOnCellIterators()

StatusCode TBEMECXTalkToyModel::processOnCellIterators ( const CaloCellContainer::iterator & itrCellBeg,
const CaloCellContainer::iterator & itrCellEnd ) const
private

Definition at line 137 of file TBEMECXTalkToyModel.cxx.

139{
140 IdentifierHash myHashMin,myHashMax;
141 m_calo_id->calo_cell_hash_range (CaloCell_ID::LAREM,myHashMin,myHashMax);
142 unsigned int myCellHashOffset = myHashMin;
143
145 std::map<Identifier,CaloCell*> cellMap;
146 std::map<Identifier,float> energyMap;
147 for (itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
148 CaloCell * theCell = *itrCell;
149 cellMap.insert(std::pair<Identifier,CaloCell*>(theCell->ID(),theCell));
150 energyMap.insert(std::pair<Identifier,float>(theCell->ID(),theCell->energy()));
151 }
152
153 for (itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
154 CaloCell * theCell = *itrCell;
155 const CaloDetDescrElement* element = theCell->caloDDE();
156
157 if (element->is_lar_em_endcap_inner()) {
159
160 if (sample==6) { // this is the EMEC2
161 std::map<Identifier,float>::iterator cellItEng = energyMap.find(theCell->ID());
162 if (cellItEng==energyMap.end()) {
163 ATH_MSG_ERROR ("Identifier not found in energyMap");
164 return StatusCode::FAILURE;
165 }
166 double e = (*cellItEng).second;
167
168 const CaloCell_ID::SUBCALO mySubDet = element->getSubCalo();
169 std::vector<IdentifierHash> theNeighbors;
170
171 int otherSubDet;
172 Identifier myId = theCell->ID();
173 IdentifierHash myHashId = m_calo_id->subcalo_cell_hash(myId,otherSubDet);
174
175 // longitudinal neighbor (N1)
176 m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::nextInSamp,theNeighbors);
177 ATH_MSG_DEBUG ("N1 theNeighbors.size() = " << theNeighbors.size());
178 IdentifierHash nId = theNeighbors.at(0)-myCellHashOffset;
179 myId = m_calo_id->cell_id(mySubDet,nId);
180 std::map<Identifier,CaloCell*>::iterator cellIt = cellMap.find(myId);
181 if (cellIt==cellMap.end()) {
182 ATH_MSG_ERROR ("neighbor CaloCell object not found in cellMap");
183 return StatusCode::FAILURE;
184 }
185 CaloCell * theCellN1 = (*cellIt).second;
186 if (!theCellN1) {
187 ATH_MSG_ERROR ("neighbor CaloCell object not found in cellMap");
188 return StatusCode::FAILURE;
189 }
190 cellItEng = energyMap.find(theCellN1->ID());
191 if (cellItEng==energyMap.end()) {
192 ATH_MSG_ERROR ( "Identifier not found in energyMap" );
193 return StatusCode::FAILURE;
194 }
195 double eN1 = (*cellItEng).second;
196
197 // neighbors in eta of EMEC3 cell (N2,N3) -- only if they exist
198 int EMEC3neighbors = 0;
199 myHashId = m_calo_id->subcalo_cell_hash(theCellN1->ID(),otherSubDet);
200 //
201 m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::nextInEta,theNeighbors);
202 ATH_MSG_DEBUG ( "N2 theNeighbors.size() = " << theNeighbors.size() );
203 CaloCell * theCellN2 = 0x0;
204 double eN2 = 0.;
205 if (theNeighbors.size()>0) {
206 nId = theNeighbors.at(0)-myCellHashOffset;
207 myId = m_calo_id->cell_id(mySubDet,nId);
208 cellIt = cellMap.find(myId);
209 if (cellIt!=cellMap.end()) {
210 theCellN2 = (*cellIt).second;
211 cellItEng = energyMap.find(theCellN2->ID());
212 if (cellItEng==energyMap.end()) {
213 ATH_MSG_ERROR ( "Identifier not found in energyMap" );
214 return StatusCode::FAILURE;
215 }
216 eN2 = (*cellItEng).second;
217 EMEC3neighbors++;
218 }
219 }
220 //
221 m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::prevInEta,theNeighbors);
222 ATH_MSG_DEBUG ( "N3 theNeighbors.size() = " << theNeighbors.size() );
223 CaloCell * theCellN3 = 0x0;
224 double eN3 = 0.;
225 if (theNeighbors.size()>0) {
226 nId = theNeighbors.at(0)-myCellHashOffset;
227 myId = m_calo_id->cell_id(mySubDet,nId);
228 cellIt = cellMap.find(myId);
229 if (cellIt!=cellMap.end()) {
230 theCellN3 = (*cellIt).second;
231 cellItEng = energyMap.find(theCellN3->ID());
232 if (cellItEng==energyMap.end()) {
233 ATH_MSG_ERROR ( "Identifier not found in energyMap" );
234 return StatusCode::FAILURE;
235 }
236 eN3 = (*cellItEng).second;
237 EMEC3neighbors++;
238 }
239 }
240
241 // neighbors in eta of EMEC2 cell (N4,N5) -- only if they exist
242 int EMEC2neighbors = 0;
243 myHashId = m_calo_id->subcalo_cell_hash(theCell->ID(),otherSubDet);
244 //
245 m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::nextInEta,theNeighbors);
246 ATH_MSG_DEBUG ( "N4 theNeighbors.size() = " << theNeighbors.size() );
247 CaloCell * theCellN4 = 0x0;
248 double eN4 = 0.;
249 if (theNeighbors.size()>0) {
250 nId = theNeighbors.at(0)-myCellHashOffset;
251 myId = m_calo_id->cell_id(mySubDet,nId);
252 cellIt = cellMap.find(myId);
253 if (cellIt!=cellMap.end()) {
254 theCellN4 = (*cellIt).second;
255 cellItEng = energyMap.find(theCellN4->ID());
256 if (cellItEng==energyMap.end()) {
257 ATH_MSG_ERROR ( "Identifier not found in energyMap" );
258 return StatusCode::FAILURE;
259 }
260 eN4 = (*cellItEng).second;
261 EMEC2neighbors++;
262 }
263 }
264 //
265 m_calo_id->get_neighbours(myHashId+myCellHashOffset,LArNeighbours::prevInEta,theNeighbors);
266 ATH_MSG_DEBUG ( "N5 theNeighbors.size() = " << theNeighbors.size() );
267 CaloCell * theCellN5 = 0x0;
268 double eN5 = 0.;
269 if (theNeighbors.size()>0) {
270 nId = theNeighbors.at(0)-myCellHashOffset;
271 myId = m_calo_id->cell_id(mySubDet,nId);
272 cellIt = cellMap.find(myId);
273 if (cellIt!=cellMap.end()) {
274 theCellN5 = (*cellIt).second;
275 cellItEng = energyMap.find(theCellN5->ID());
276 if (cellItEng==energyMap.end()) {
277 ATH_MSG_ERROR ( "Identifier not found in energyMap" );
278 return StatusCode::FAILURE;
279 }
280 eN5 = (*cellItEng).second;
281 EMEC2neighbors++;
282 }
283 }
284
285 double rescaled_e = (1.-m_xtalkScaleLong-EMEC3neighbors*m_xtalkScaleEta-EMEC2neighbors*m_xtalkScaleEMEC2Eta)*e
286 + m_xtalkScaleLong*eN1 + m_xtalkScaleEta*(eN2+eN3) + m_xtalkScaleEMEC2Eta*(eN4+eN5)
287 + (theCell->energy()-e);
288 double rescaled_eN1 = 0;
289 if (theCellN1) rescaled_eN1 = (1.-m_xtalkScaleLong)*eN1 + m_xtalkScaleLong*e + (theCellN1->energy()-eN1);
290 double rescaled_eN2 = 0.;
291 if (theCellN2) rescaled_eN2 = (1.-m_xtalkScaleEta)*eN2 + m_xtalkScaleEta*e + (theCellN2->energy()-eN2);
292 double rescaled_eN3 = 0.;
293 if (theCellN3) rescaled_eN3 = (1.-m_xtalkScaleEta)*eN3 + m_xtalkScaleEta*e + (theCellN3->energy()-eN3);
294 /*
295 double rescaled_eN4 = 0.;
296 if (theCellN4) rescaled_eN4 = (1.-m_xtalkScaleEMEC2Eta)*eN4 + m_xtalkScaleEMEC2Eta*e + (theCellN4->energy()-eN4);
297 double rescaled_eN5 = 0.;
298 if (theCellN5) rescaled_eN5 = (1.-m_xtalkScaleEMEC2Eta)*eN5 + m_xtalkScaleEMEC2Eta*e + (theCellN5->energy()-eN5);
299 */
300
301 ATH_MSG_DEBUG ("");
302 ATH_MSG_DEBUG ( "neighbors of cell [" << m_calo_id->show_to_string(theCell ->ID(),0,'/') << "] : " );
303 if (theCellN1)
304 ATH_MSG_DEBUG ( " N1 = [" << m_calo_id->show_to_string(theCellN1->ID(),0,'/') << "]" );
305 if (theCellN2)
306 ATH_MSG_DEBUG ( " N2 = [" << m_calo_id->show_to_string(theCellN2->ID(),0,'/') << "]" );
307 if (theCellN3)
308 ATH_MSG_DEBUG ( " N3 = [" << m_calo_id->show_to_string(theCellN3->ID(),0,'/') << "]" );
309 if (theCellN4)
310 ATH_MSG_DEBUG ( " N4 = [" << m_calo_id->show_to_string(theCellN4->ID(),0,'/') << "]" );
311 if (theCellN5)
312 ATH_MSG_DEBUG ( " N5 = [" << m_calo_id->show_to_string(theCellN5->ID(),0,'/') << "]" );
313
314 ATH_MSG_DEBUG ( "EMEC2 cell : energy before = " << e << " | energy after rescaling = " << rescaled_e );
315 ATH_MSG_DEBUG ( " "
316 << (1.-m_xtalkScaleLong-EMEC3neighbors*m_xtalkScaleEta-EMEC2neighbors*m_xtalkScaleEMEC2Eta)*e
317 << " | " << m_xtalkScaleLong*eN1
318 << " | " << m_xtalkScaleEta*(eN2+eN3)
319 << " | " << m_xtalkScaleEMEC2Eta*(eN4+eN5)
320 << " | " << (theCell->energy()-e) );
321 ATH_MSG_DEBUG ( "EMEC3 cell (N1): energy before = " << eN1 << " | energy after rescaling = " << rescaled_eN1 );
323 << " | " << (theCellN1->energy()-eN1) );
324 if (theCellN2) {
325 ATH_MSG_DEBUG ( "EMEC3 cell (N2): energy before = " << eN2 << " | energy after rescaling = " << rescaled_eN2 );
326 ATH_MSG_DEBUG ( " " << (1.-m_xtalkScaleEta)*eN2 + m_xtalkScaleEta*e
327 << " | " << (theCellN2->energy()-eN2) );
328 }
329 if (theCellN3) {
330 ATH_MSG_DEBUG ( "EMEC3 cell (N3): energy before = " << eN3 << " | energy after rescaling = " << rescaled_eN3 );
331 ATH_MSG_DEBUG ( " " << (1.-m_xtalkScaleEta)*eN3 + m_xtalkScaleEta*e
332 << " | " << (theCellN3->energy()-eN3) );
333 }
334 /*
335 if (theCellN4) {
336 log << MSG::DEBUG << "EMEC2 cell (N4): energy before = " << eN4 << " | energy after rescaling = " << rescaled_eN4 << endmsg;
337 log << MSG::DEBUG << " " << (1.-m_xtalkScaleEMEC2Eta)*eN4 + m_xtalkScaleEMEC2Eta*e
338 << " | " << (theCellN4->energy()-eN4) << endmsg;
339 }
340 if (theCellN5) {
341 log << MSG::DEBUG << "EMEC2 cell (N5): energy before = " << eN5 << " | energy after rescaling = " << rescaled_eN5 << endmsg;
342 log << MSG::DEBUG << " " << (1.-m_xtalkScaleEMEC2Eta)*eN5 + m_xtalkScaleEMEC2Eta*e
343 << " | " << (theCellN5->energy()-eN5) << endmsg;
344 }
345 */
346 theCell ->setEnergy(rescaled_e);
347 if (theCellN1) theCellN1->setEnergy(rescaled_eN1);
348 if (theCellN2) theCellN2->setEnergy(rescaled_eN2);
349 if (theCellN3) theCellN3->setEnergy(rescaled_eN3);
350 //if (theCellN4) theCellN4->setEnergy(rescaled_eN4);
351 //if (theCellN5) theCellN5->setEnergy(rescaled_eN5);
352 }
353 }
354 }
355 return StatusCode::SUCCESS;
356}
#define ATH_MSG_DEBUG(x)
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
double energy() const
get energy (data member)
Definition CaloCell.h:327
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
virtual void setEnergy(float energy)
set energy
Definition CaloCell.h:472
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
CaloCell_ID::CaloSample getSampling() const
cell sampling
bool is_lar_em_endcap_inner() const
cell belongs to the inner wheel of EM end cap

Member Data Documentation

◆ m_calo_id

const CaloCell_ID* TBEMECXTalkToyModel::m_calo_id
private

Definition at line 37 of file TBEMECXTalkToyModel.h.

◆ m_caloNums

std::vector<int> TBEMECXTalkToyModel::m_caloNums
private

Definition at line 32 of file TBEMECXTalkToyModel.h.

◆ m_caloSelection

bool TBEMECXTalkToyModel::m_caloSelection
private

Definition at line 35 of file TBEMECXTalkToyModel.h.

◆ m_xtalkScaleEMEC2Eta

float TBEMECXTalkToyModel::m_xtalkScaleEMEC2Eta
private

Definition at line 42 of file TBEMECXTalkToyModel.h.

◆ m_xtalkScaleEta

float TBEMECXTalkToyModel::m_xtalkScaleEta
private

Definition at line 41 of file TBEMECXTalkToyModel.h.

◆ m_xtalkScaleLong

float TBEMECXTalkToyModel::m_xtalkScaleLong
private

Definition at line 40 of file TBEMECXTalkToyModel.h.


The documentation for this class was generated from the following files: