ATLAS Offline Software
TBBeamQualityEMFractionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //#####################################################
6 //# #
7 //# File : TBBeamQualityEMFractionTool.cxx #
8 //# Package: TBRec #
9 //# #
10 //# Author : Marco Bieri <mbieri@sfu.ca> #
11 //# #
12 //# #
13 //#####################################################
14 
16 
19 
20 #include "Identifier/Identifier.h"
21 
23  const std::string& name,
24  const IInterface* parent)
26  m_emecID_help(nullptr),
27  m_hecID_help(nullptr),
28  m_fcalID_help(nullptr),
29  m_em_frac(0)
30 {
31  declareInterface<TBBeamQualityTool>(this);
32  declareProperty("EM_fraccut",m_em_fraccut=0.2);
33  declareProperty("EM_fracnumsamp",m_em_fracnumsamp);
34  declareProperty("EM_fracdensamp",m_em_fracdensamp);
35  declareProperty("EM_fracnumdet",m_em_fracnumdet="none");
36  declareProperty("EM_fracdendet",m_em_fracdendet="none");
37 }
38 
40 { }
41 
43 { //init
44  MsgStream log(msgSvc(),name());
45  log << MSG::DEBUG
46  << "initialize"
47  << endmsg;
48 
49  StatusCode sc;
50 
51  m_hecID_help = NULL;
52  m_emecID_help = NULL;
53  m_fcalID_help = NULL;
54 
55  /*
56  // retrieve detector description manager for LAr subsystem
57  const DataHandle<LArDetDescrManager> m_larMgr;
58  sc = detStore()->retrieve(m_larMgr);
59  if (sc.isFailure()) {
60  log << MSG::ERROR << "unable to retrieve LArDetDescrManager from detector store"<< endmsg;
61  return sc;
62  }
63 
64  //obtainine Identifier helpers
65  m_hecID_help = m_larMgr->get_hec_id();
66  if (!m_hecID_help) {
67  log << MSG::ERROR << "unable to obtain hec id " << endmsg;
68  return StatusCode::FAILURE;
69  }
70  m_emecID_help = m_larMgr->get_em_id();
71  if (!m_emecID_help) {
72  log << MSG::ERROR << "unable to obtain emec id " << endmsg;
73  return StatusCode::FAILURE;
74  }
75 
76  m_fcalID_help = m_larMgr->get_fcal_id();
77  if (!m_fcalID_help) {
78  log << MSG::ERROR << "unable to obtain fcal id " << endmsg;
79  return StatusCode::FAILURE;
80  }
81  */
82 
83 
84  // retrieve detector description manager for LAr subsystem
85  const CaloCell_ID* idHelper = nullptr;
86  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
87 
88  //obtainine Identifier helpers
89  m_hecID_help = idHelper->hec_idHelper();
90  if (!m_hecID_help) {
91  log << MSG::ERROR << "unable to obtain hec id " << endmsg;
92  return StatusCode::FAILURE;
93  }
94  m_emecID_help = idHelper->em_idHelper();
95  if (!m_emecID_help) {
96  log << MSG::ERROR << "unable to obtain emec id " << endmsg;
97  return StatusCode::FAILURE;
98  }
99 
100  m_fcalID_help = idHelper->fcal_idHelper();
101  if (!m_fcalID_help) {
102  log << MSG::ERROR << "unable to obtain fcal id " << endmsg;
103  return StatusCode::FAILURE;
104  }
105 
106 
107 
108  log<<MSG::DEBUG<<"Got to before p_toolSvc"<<endmsg;
109 
110  if (m_em_fracnumdet=="HEC") {
111  m_em_fracnumsamp.push_back(8);
112  m_em_fracnumsamp.push_back(9);
113  m_em_fracnumsamp.push_back(10);
114  }
115  if (m_em_fracdendet=="HEC") {
116  m_em_fracdensamp.push_back(8);
117  m_em_fracdensamp.push_back(9);
118  m_em_fracdensamp.push_back(10);
119  }
120  if (m_em_fracnumdet=="EMEC") {
121  m_em_fracnumsamp.push_back(6);
122  m_em_fracnumsamp.push_back(7);
123  }
124  if (m_em_fracdendet=="EMEC") {
125  m_em_fracdensamp.push_back(6);
126  m_em_fracdensamp.push_back(7);
127  }
128  if (m_em_fracnumdet=="FCAL") {
129  m_em_fracnumsamp.push_back(21);
130  m_em_fracnumsamp.push_back(22);
131  m_em_fracnumsamp.push_back(23);
132  }
133  if (m_em_fracdendet=="FCAL") {
134  m_em_fracdensamp.push_back(21);
135  m_em_fracdensamp.push_back(22);
136  m_em_fracdensamp.push_back(23);
137  }
138 
139  return StatusCode::SUCCESS;
140 }//init
141 
143 {//accept
144 
145  MsgStream log(msgSvc(),name());
146 
147  log << MSG::DEBUG
148  << "TBBeamQualityEMFractionTool: Started Accept"
149  << endmsg;
150 
151  StatusCode sc;
152 
153  log << MSG::DEBUG << "m_em_fracnumdet: "<<m_em_fracnumdet<<endmsg;
154  log << MSG::DEBUG << "m_em_fracdendet: "<<m_em_fracdendet<<endmsg;
155  log << MSG::DEBUG << " called for: "<<particles.size()<<" particles"<<endmsg;
156 
157  // setting up layers (h6)
158 
159  // setting tmp variables
160  // resetting the numerator and denominato to 0
161 
162  //long chan =0;
163  float numenergy=0;
164  float denenergy=0;
165  for (int i=0;i<500;++i) {
166  m_Mlayer[i]=0;
167  }
168 
169  //Accesing the CaloCellContainer
170  const CaloCellContainer* cellContainer = nullptr;
171 
172  sc = evtStore()->retrieve(cellContainer);
173  if (sc.isFailure()) {
174  log << MSG::ERROR << "couldn't get the calo cells from storegate" << endmsg;
175  log << MSG::ERROR << "here is what is in storegate: " << evtStore()->dump() << endmsg;
176  return StatusCode::FAILURE;
177  }
178 
179  for (const CaloCell* cell_ptr : *cellContainer) {
180 
181  //obtaining dde pointer
182  const CaloDetDescrElement* caloDDE_ptr = cell_ptr->caloDDE();
183 
184  //obtaining SubCalo
185  //const CaloCell_ID::SUBCALO subcalo = caloDDE_ptr->getSubCalo();
186 
187  //obtaining sampling (layer)
188  const CaloCell_ID::CaloSample sampling = caloDDE_ptr->getSampling();
189 
190  // This map will have the layers as an index and increment the energy
191  // Does this for ALL layers ( all detectors )
192 
193  m_Mlayer[sampling]+=cell_ptr->energy();
194 
195  } //iterating
196 
197  // picking out layers of interest and filling numerator and denominator energies.
198 
199  for (unsigned int i=0;i<m_em_fracnumsamp.size();++i) {
200  numenergy+=m_Mlayer.find(m_em_fracnumsamp[i])->second;
201  }
202 
203  for (unsigned int i=0;i<m_em_fracdensamp.size();++i) {
204  denenergy+=m_Mlayer.find(m_em_fracdensamp[i])->second;
205  }
206 
207  if (denenergy!=0) {
208  m_em_frac=numenergy/denenergy;
209 
210  if (m_em_frac<m_em_fraccut) {
211  return StatusCode::SUCCESS;
212  }
213  else {
214  return StatusCode::FAILURE;
215  }
216  }
217  else {
218  return StatusCode::FAILURE;
219  }
220 }//accept
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TBBeamQualityEMFractionTool::m_em_frac
float m_em_frac
Definition: TBBeamQualityEMFractionTool.h:55
CaloCell_ID::em_idHelper
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition: CaloCell_ID.h:63
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
TBBeamQualityEMFractionTool::accept
virtual StatusCode accept(const std::vector< std::string > &) override
Definition: TBBeamQualityEMFractionTool.cxx:142
TBBeamQualityEMFractionTool::m_em_fracdendet
std::string m_em_fracdendet
Definition: TBBeamQualityEMFractionTool.h:52
TBBeamQualityEMFractionTool::initializeTool
virtual StatusCode initializeTool() override
Definition: TBBeamQualityEMFractionTool.cxx:42
TBBeamQualityEMFractionTool::m_em_fracdensamp
std::vector< double > m_em_fracdensamp
Definition: TBBeamQualityEMFractionTool.h:50
TBBeamQualityEMFractionTool::m_em_fracnumsamp
std::vector< double > m_em_fracnumsamp
Definition: TBBeamQualityEMFractionTool.h:49
TBBeamQualityEMFractionTool::m_em_fraccut
float m_em_fraccut
Definition: TBBeamQualityEMFractionTool.h:48
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCell_ID.h
CaloCell_ID::hec_idHelper
const LArHEC_ID * hec_idHelper() const
access to HEC idHelper
Definition: CaloCell_ID.h:69
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TBBeamQualityEMFractionTool::m_emecID_help
const LArEM_ID * m_emecID_help
Definition: TBBeamQualityEMFractionTool.h:42
TBBeamQualityEMFractionTool::m_fcalID_help
const LArFCAL_ID * m_fcalID_help
Definition: TBBeamQualityEMFractionTool.h:44
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TBBeamQualityEMFractionTool::~TBBeamQualityEMFractionTool
virtual ~TBBeamQualityEMFractionTool()
Definition: TBBeamQualityEMFractionTool.cxx:39
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
TBBeamQualityTool
Definition: TBBeamQualityTool.h:26
TBBeamQualityEMFractionTool::m_em_fracnumdet
std::string m_em_fracnumdet
Definition: TBBeamQualityEMFractionTool.h:51
TBBeamQualityEMFractionTool::m_hecID_help
const LArHEC_ID * m_hecID_help
Definition: TBBeamQualityEMFractionTool.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
TBBeamQualityEMFractionTool::m_Mlayer
std::map< float, float > m_Mlayer
Definition: TBBeamQualityEMFractionTool.h:53
TBBeamQualityEMFractionTool.h
TBBeamQualityEMFractionTool::TBBeamQualityEMFractionTool
TBBeamQualityEMFractionTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TBBeamQualityEMFractionTool.cxx:22
CaloCell_ID::fcal_idHelper
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Definition: CaloCell_ID.h:75