18#include "CLHEP/Geometry/Vector3D.h"
42 declareInterface<IMuidCaloEnergyMeas>(
this);
77 return StatusCode::SUCCESS;
85 return StatusCode::SUCCESS;
88 double phiHad)
const {
110 std::unique_ptr<CaloMeas> caloMeas = std::make_unique<CaloMeas>();
123 <<
" Tile energy (GeV) :" << std::setw(8) << std::setprecision(3) << caloMeas->Tile_EnergyMeasured() / Units::GeV
124 <<
" Material percent:" << std::setw(4) << std::setprecision(0) << 100. * caloMeas->Tile_SamplingFraction()
125 <<
" ISO :" << std::setw(8) << std::setprecision(3) << caloMeas->Tile_Isolation() / Units::GeV <<
endmsg
126 <<
" LArHEC energy (GeV):" << std::setw(8) << std::setprecision(3) << caloMeas->LArHEC_EnergyMeasured() / Units::GeV
127 <<
" Material percent:" << std::setw(4) << std::setprecision(0) << 100. * caloMeas->LArHEC_SamplingFraction()
128 <<
" ISO :" << std::setw(8) << std::setprecision(3) << caloMeas->LArHEC_Isolation() / Units::GeV <<
endmsg
129 <<
" EM energy :" << std::setw(8) << std::setprecision(3) << caloMeas->LArEM_EnergyMeasured() / Units::GeV
130 <<
" first compartment:" << std::setw(8) << std::setprecision(3)
131 << caloMeas->LArEM_FirstCompartmentEnergy() / Units::GeV <<
" Material percent:" << std::setw(4)
132 << std::setprecision(0) << 100. * caloMeas->LArEM_SamplingFraction() <<
" ISO :" << std::setw(8)
133 << std::setprecision(3) << caloMeas->LArEM_Isolation() / Units::GeV);
141 const CaloNoise* noiseCDO,
double mu_eta,
double mu_phi)
const {
143 constexpr double lowest_threshold = 4 * 50.;
147 myList.
select(mu_eta, mu_phi, 0.2, 0.2);
150 for (
const CaloCell* cell : myList) {
151 const double cellEnergy = cell->energy();
152 const double noise_rms = noiseCDO->
getNoise(cell->ID(), cell->gain());
164 return m_tileID->sample(cell->ID());
166 return m_hecID->sampling(cell->ID());
168 return m_emID->sampling(cell->ID());
175 const CaloNoise* noiseCDO,
double muEta,
double muPhi,
int isubcalo)
const {
200 double totalEnergy = 0.;
201 double leadingEnergy = 0.;
202 std::unique_ptr<CaloCellList> myList =
nullptr;
206 myList = std::make_unique<CaloCellList>(detMgr,cellContainer, iCalo);
210 myList = std::make_unique<CaloCellList>(detMgr,cellContainer, iCalo);
214 myList = std::make_unique<CaloCellList>(detMgr,cellContainer, iCalo);
218 int countCoreCells = 0;
219 int countSelected = 0;
220 bool compartment[4] = {
false,
false,
false,
false};
221 double measuredSamplings = 0.;
223 if (myList && myList->ncells()) {
225 const CaloCell* lastCell = *(myList->end() - 1);
228 for (
int coreSampling = 0; coreSampling != 4; ++coreSampling) {
230 double coreRadius = 0.;
231 for (
const CaloCell* cell : *myList) {
234 if (cell != lastCell && sampling != coreSampling)
continue;
236 const double deltaEta = cell->eta() - muEta;
240 if (sampling == coreSampling) {
241 if (!coreCell || radius < coreRadius) {
247 if (cell != lastCell || !coreCell)
continue;
249 for (
const CaloCell* cell2 : *myList) {
251 if (sampling != coreSampling)
continue;
253 double cellEnergy = cell2->energy();
254 double noiseRms = noiseCDO->
getNoise(cell2->ID(), cell2->gain());
262 totalEnergy += cellEnergy;
263 compartment[coreSampling] =
true;
264 if (coreSampling < 2) leadingEnergy += cellEnergy;
266 if (cell2 == coreCell) {
280 std::string info =
"";
281 std::string
type =
" Tile ";
287 if (cellSelected && cell2 == coreCell) {
288 info =
" selected core cell# ";
289 }
else if (cellSelected) {
290 info =
" selected cell# ";
291 }
else if (cell2 == coreCell) {
292 info =
" cell in core NOT selected";
297 <<
type <<
" Sampling: " << std::setw(1) << coreSampling <<
" Radius :" << std::setw(6)
298 << std::setprecision(0) << cell2->caloDDE()->r() <<
" Eta : " << std::setw(6)
299 << std::setprecision(2) << cell2->eta() <<
" Phi : " << std::setw(6) << std::setprecision(2)
300 << cell2->phi() <<
" Noise level : " << std::setw(6) << std::setprecision(0) << noiseRms
301 <<
" Energy : " << std::setw(7) << std::setprecision(0) << cell2->energy() << info);
302 }
else if (cellSelected) {
304 <<
type <<
" Sampling: " << std::setw(1) << coreSampling <<
" Radius :" << std::setw(6)
305 << std::setprecision(0) << cell2->caloDDE()->r() <<
" Eta : " << std::setw(6)
306 << std::setprecision(2) << cell2->eta() <<
" Phi : " << std::setw(6) << std::setprecision(2)
307 << cell2->phi() <<
" Noise level : " << std::setw(6) << std::setprecision(0) << noiseRms
308 <<
" Energy : " << std::setw(7) << std::setprecision(0) << cell2->energy() << info
312 <<
type <<
" Sampling: " << std::setw(1) << coreSampling <<
" Radius :" << std::setw(6)
313 << std::setprecision(0) << cell2->caloDDE()->r() <<
" Eta : " << std::setw(6)
314 << std::setprecision(2) << cell2->eta() <<
" Phi : " << std::setw(6) << std::setprecision(2)
315 << cell2->phi() <<
" Noise level : " << std::setw(6) << std::setprecision(0) << noiseRms
316 <<
" Energy : " << std::setw(7) << std::setprecision(0) << cell2->energy() << info);
324 std::string info =
"";
325 std::string
type =
" Tile ";
332 ATH_MSG_DEBUG(
type <<
" at eta = " << muEta <<
" : selected " << countSelected <<
" from measured cone with "
333 << countCoreCells <<
" cells forming core");
336 for (
int i = 0; i < 4; ++i)
337 if (compartment[i]) measuredSamplings +=
m_caloParamTool->caloCompartmentDepth(isubcalo, i);
355 const CaloNoise* noiseCDO,
double muEta,
double muPhi,
int isubcalo)
const {
356 double totalEnergy = 0.;
361 std::unique_ptr<CaloCellList> myList;
365 myList = std::make_unique<CaloCellList>(detMgr,cellContainer, iCalo);
369 myList = std::make_unique<CaloCellList>(detMgr,cellContainer, iCalo);
373 myList = std::make_unique<CaloCellList>(detMgr,cellContainer, iCalo);
377 if (myList && myList->ncells()) {
379 const CaloCell* lastCell = *(myList->end() - 1);
382 for (
int coreSampling = 0; coreSampling != 4; ++coreSampling) {
384 double coreRadius = 0.;
385 for (
const CaloCell* cell : *myList) {
388 if (cell != lastCell && sampling != coreSampling)
continue;
390 const double deltaEta = cell->eta() - muEta;
394 if (sampling == coreSampling) {
395 if (!coreCell || radius < coreRadius) {
401 if (cell != lastCell || !coreCell)
continue;
403 for (
const CaloCell* cell2 : *myList) {
405 if (sampling != coreSampling)
continue;
407 double cellEnergy = cell2->energy();
408 double noiseRms = noiseCDO->
getNoise(cell2->ID(), cell2->gain());
413 if (cellSelected) totalEnergy += cellEnergy;
430 const CaloNoise* noiseCDO,
double mu_eta,
double mu_phi,
int sample,
int cone)
const {
440 double tileTotalEnergy = 0.;
441 double tileTestEnergy = 0.;
446 myList.
select(mu_eta, mu_phi, 0.15, 0.15);
448 myList.
select(mu_eta, mu_phi, 0.3, 0.3);
450 myList.
select(mu_eta, mu_phi, 0., 0.);
454 double lowest_threshold = 0.;
455 for (
const CaloCell* cell : myList) {
456 double cellEnergy = cell->energy();
457 double noise_rms = noiseCDO->
getNoise(cell->ID(), cell->gain());
463 <<
" Radius :" << cell->caloDDE()->r() <<
" Eta : " << cell->eta() <<
" Phi : " << cell->phi()
464 <<
" Noise Level : " << noise_rms);
466 tileTotalEnergy += cellEnergy;
468 tileTestEnergy += cellEnergy;
474 return tileTotalEnergy;
478 const CaloNoise* noiseCDO,
double mu_eta,
double mu_phi,
int sample,
int cone)
const {
492 double larhecTotal = 0.;
497 myList.
select(mu_eta, mu_phi, 0.15, 0.15);
499 myList.
select(mu_eta, mu_phi, 0.3, 0.3);
501 myList.
select(mu_eta, mu_phi, 0., 0.);
505 constexpr double lowest_threshold = 4. * 150.;
507 for (
const CaloCell* cell : myList) {
508 double cellEnergy = cell->energy();
509 const double noise_rms = noiseCDO->
getNoise(cell->ID(), cell->gain());
510 if (cellEnergy > lowest_threshold && cellEnergy > noise_rms *
m_sigmasAboveNoise &&
m_hecID->sampling(cell->ID()) == sample) {
515 <<
" z :" << cell->caloDDE()->z() <<
" Eta : " << cell->eta() <<
" Phi : " << cell->phi()
516 <<
" Noise Level : " << noise_rms);
518 larhecTotal += cell->energy();
528 const CaloNoise* noiseCDO,
double mu_eta,
double mu_phi,
int sample,
int cone)
const {
540 double emTotalEnergy = 0.;
545 myList.
select(mu_eta, mu_phi, 0.075, 0.075);
547 myList.
select(mu_eta, mu_phi, 0.15, 0.15);
549 myList.
select(mu_eta, mu_phi, 0., 0.);
555 double lowest_threshold = 4. * 50.;
557 for (
const CaloCell* cell : myList) {
558 double cellEnergy = cell->energy();
559 const double noise_rms = noiseCDO->
getNoise(cell->ID(), cell->gain());
561 if (cellEnergy > lowest_threshold && cellEnergy > noise_rms *
m_sigmasAboveNoise &&
m_emID->sampling(cell->ID()) == sample) {
565 ATH_MSG_DEBUG(
"Energy : " << cell->energy() <<
" Sampling: " <<
m_emID->sampling(cell->ID())
566 <<
" Radius :" << cell->caloDDE()->r() <<
" z :" << cell->caloDDE()->z()
567 <<
" Eta : " << cell->eta() <<
" Phi : " << cell->phi() <<
" Noise Level : " << noise_rms);
569 emTotalEnergy += cell->energy();
575 return emTotalEnergy;
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Wrapper to avoid constant divisions when using units.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
Container class for CaloCell.
void select(double eta, double phi, double deta, double dphi)
CaloCell_Base_ID::SUBCALO SUBCALO
Data object for each calorimeter readout cell.
This class provides the client interface for accessing the detector description information common to...
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
double LArHEC_Isolation(void) const
double LArEM_Isolation(void) const
double LArEM_SamplingFraction(void) const
double LArEM_EnergyMeasured(void) const
double Tile_SamplingFraction(void) const
double Tile_Isolation(void) const
double LArHEC_SamplingFraction(void) const
double Tile_EnergyMeasured(void) const
double LArHEC_EnergyMeasured(void) const
double LArEM_FirstCompartmentEnergy(void) const
std::atomic_int m_totalCoreCellsEM
std::atomic_int m_totalSelectedTile
std::unique_ptr< CaloMeas > energyMeasurement(const EventContext &ctx, double etaEM, double phiEM, double etaHad, double phiHad) const override
IMuidCaloEnergyMeas interface: get the muon energy loss measurement from the calorimeter,...
double m_sigmasAboveNoise
double m_isolationConeLArEM
MuidCaloEnergyMeas(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::atomic_int m_totalCoreCellsHEC
virtual ~MuidCaloEnergyMeas()
double m_measurementConeTile
double energyInLArEM(const CaloCellContainer *cellContainer, const CaloDetDescrManager *detMgr, const CaloNoise *noiseCDO, double eta, double phi, int, int) const
const LArHEC_ID * m_hecID
SG::ReadHandleKey< CaloCellContainer > m_cellContainerLocation
std::atomic_int m_totalCoreCellsTile
double m_measurementConeLArHEC
double m_isolationConeLArHEC
void energyInCalo(CaloMeas &caloMeas, const CaloCellContainer *cellContainer, const CaloDetDescrManager *detMgr, const CaloNoise *noiseCDO, double eta, double phi, int iSubCalo) const
std::atomic_int m_totalSelectedEM
StatusCode finalize() override
double energyInTile(const CaloCellContainer *cellContainer, const CaloDetDescrManager *detMgr, const CaloNoise *noiseCDO, double eta, double phi, int, int) const
double m_sigmasAboveNoiseCore
double energyInLArHEC(const CaloCellContainer *cellContainer, const CaloDetDescrManager *detMgr, const CaloNoise *noiseCDO, double eta, double phi, int, int) const
std::atomic_int m_totalSelectedHEC
ToolHandle< IMuidCaloEnergyParam > m_caloParamTool
StatusCode initialize() override
double m_measurementConeLArEM
int cellCounting(const CaloCellContainer *cellContainer, const CaloDetDescrManager *detMgr, const CaloNoise *noiseCDO, double eta, double phi) const
int samplingID(const CaloCell *cell, int iSubCalo) const
double m_isolationConeTile
void isolationEnergy(CaloMeas &caloMeas, const CaloCellContainer *cellContainer, const CaloDetDescrManager *detMgr, const CaloNoise *noiseCDO, double eta, double phi, int iSubCalo) const
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
bool isPresent() const
Is the referenced object present in SG?
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[