13#include "GaudiKernel/ServiceHandle.h"
14#include "GaudiKernel/ITHistSvc.h"
15#include "Gaudi/Property.h"
28 , ISvcLocator* pSvcLocator)
50 m_mytree =
new TTree(
"mytree",
"mytree");
81 histSvc->regTree(
"/MYSTREAM/myTree",
m_mytree).ignore();
91 if(
m_tileID==0)
throw std::runtime_error(
"ISF_HitAnalysis: Invalid Tile ID helper");
101 return StatusCode::SUCCESS;
109 return StatusCode::SUCCESS;
123 std::vector<const CaloCalibrationHitContainer *> v_cchc;
127 ATH_MSG_WARNING(
"SG does not contain calibration hit container " << containerName);
131 StatusCode
sc =
evtStore()->retrieve(cchc,containerName);
134 ATH_MSG_ERROR(
"Cannot retrieve calibration hit container " << containerName);
139 v_cchc.push_back(cchc);
145 StatusCode
sc =
evtStore()->retrieve(truthEvent,
"TruthEvent");
146 if (
sc.isFailure()||!truthEvent)
149 return StatusCode::FAILURE;
153 m_mc_eta = gen->momentum().pseudoRapidity();
155 m_mc_e = gen->momentum().e();
156 m_mc_pt = sqrt(
pow(gen->momentum().px(),2)+
pow(gen->momentum().py(),2));
194 Long64_t cell_identifier=0;
195 float cell_energy_reco=0;
196 float cell_energy_active_total_corrected=0;
197 float cell_energy_active_total=0;
198 float cell_energy_inactive_total=0;
204 std::map< Long64_t , cell_info > cell_info_map;
206 for(
int s=0;s<24;s++)
233 double Etot = calibHit->energyTotal();
234 double Eem = calibHit->energyEM();
235 double Enonem = calibHit->energyNonEM();
236 double Einv = calibHit->energyInvisible();
237 double Eesc = calibHit->energyEscaped();
246 if((sampling>=0 && sampling<=11) || (sampling>=21 && sampling<=23)) Efactor=1/fSampl->
FSAMPL(
id);
247 if((sampling>=12 && sampling<=20)) {
249 int channel =
m_tileHWID->channel(channel_id);
250 int drawerIdx =
m_tileHWID->drawerIdx(channel_id);
251 Efactor = tileSamplingFraction->getSamplingFraction(drawerIdx, channel);
259 ATH_MSG_VERBOSE(
"cellID "<<
id<<
" layer "<<sampling<<
" energyTotal "<<Etot<<
" Eem "<<Eem<<
" Enonem "<<Enonem<<
" Einv "<<Einv<<
" Eesc "<<Eesc<<
" Efactor="<<Efactor);
261 if(sampling>=0 && sampling<=23)
264 cell_info_map[
id.get_compact()].cell_identifier=
id.get_compact();
265 cell_info_map[
id.get_compact()].cell_sampling=sampling;
266 cell_info_map[
id.get_compact()].cell_eta=caloDDE->
eta_raw();
267 cell_info_map[
id.get_compact()].cell_phi=caloDDE->
phi_raw();
278 if(
m_docells) cell_info_map[
id.get_compact()].cell_energy_inactive_total+=Etot;
291 cell_info_map[
id.get_compact()].cell_energy_active_total_corrected+=Etot*Efactor;
292 cell_info_map[
id.get_compact()].cell_energy_active_total+=Etot;
305 sc =
evtStore()->retrieve(cellColl,
"AllCalo");
307 if (
sc.isFailure()) {
312 for (
const CaloCell* cell : *cellColl) {
319 if((sampling>=12 && sampling<=20)) {
327 cell_info_map[
id.get_compact()].cell_identifier=
id.get_compact();
328 cell_info_map[
id.get_compact()].cell_sampling=sampling;
329 cell_info_map[
id.get_compact()].cell_eta=caloDDE->
eta_raw();
330 cell_info_map[
id.get_compact()].cell_phi=caloDDE->
phi_raw();
331 cell_info_map[
id.get_compact()].cell_energy_reco+=cell->energy();
338 const std::vector<std::string> lArKeys = {
"LArHitEMB",
"LArHitEMEC",
"LArHitFCAL",
"LArHitHEC"};
339 for (
const std::string& containerName: lArKeys) {
342 if(
evtStore()->retrieve(larContainer,containerName)==StatusCode::SUCCESS) {
344 for (
const LArHit* larHit : *larContainer) {
347 if(!hitElement)
continue;
354 ATH_MSG_DEBUG(
"Read "<<hitnumber<<
" G4Hits from "<<containerName);
362 if (
evtStore()->retrieve(hitVec,
"TileHitVec")==StatusCode::SUCCESS &&
m_tileID ) {
364 for(
const TileHit& hit : *hitVec) {
373 for (
int tilesubhit_i = 0; tilesubhit_i<hit.size(); tilesubhit_i++) {
375 ATH_MSG_DEBUG(
"Tile subhit: "<<tilesubhit_i<<
"/"<<hit.size()<<
" E: "<<hit.energy(tilesubhit_i) );
380 ATH_MSG_DEBUG(
"Read "<<hitnumber<<
" G4Hits from TileHitVec");
383 for(
auto& cell:cell_info_map) {
422 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
AtlasHitsVector< TileHit > TileHitVector
constexpr int pow(int base, int exp) noexcept
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
Class to store calorimeter calibration hit.
Container class for CaloCell.
CaloSampling::CaloSample CaloSample
Data object for each calorimeter readout cell.
This class groups all DetDescr information related to a CaloCell.
float eta_raw() const
cell eta_raw
CaloCell_ID::CaloSample getSampling() const
cell sampling
Identifier identify() const override final
cell identifier
float phi_raw() const
cell phi_raw
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
This class initializes the Calo (LAr and Tile) offline identifiers.
const TileID * getTileID(void) const
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual const float & FSAMPL(const HWIdentifier &id) const =0
Class to store hit energy and time in LAr cell from G4 simulation.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::vector< float > * m_energy_inactive_nonem
std::vector< float > * m_cell_eta
const TileCablingService * m_tileCabling
std::vector< float > * m_energy_active_total
std::vector< float > * m_energy_active_em
std::vector< float > * m_energy_active_inv
ServiceHandle< TileCablingSvc > m_tileCablingSvc
Name of Tile cabling service.
std::vector< float > * m_energy_active_esc
std::vector< int > * m_cell_sampling
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
std::vector< float > * m_cell_energy_active_total
std::vector< float > * m_energy_hit
virtual ~LarEMSamplingFraction()
std::vector< float > * m_energy_inactive_em
LarEMSamplingFraction()
Default constructor:
std::vector< std::string > m_CalibrationHitContainerNames
std::vector< float > * m_energy_inactive_inv
std::vector< float > * m_cell_energy_reco
virtual StatusCode finalize() override
SG::ReadCondHandleKey< TileSamplingFraction > m_tileSamplingFractionKey
Name of TileSamplingFraction in condition store.
virtual StatusCode initialize() override
std::vector< float > * m_cell_phi
std::vector< float > * m_energy_active_nonem
std::vector< float > * m_cell_energy_active_total_corrected
virtual StatusCode execute() override
const TileHWID * m_tileHWID
std::vector< Long64_t > * m_cell_identifier
std::vector< float > * m_energy_inactive_total
const CaloCell_ID * m_calo_id
std::vector< float > * m_energy_reco
std::vector< float > * m_cell_energy_inactive_total
std::vector< float > * m_energy_active_total_corrected
std::vector< float > * m_energy_inactive_esc
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
GenEvent::particle_iterator begin(HepMC::GenEvent &e)