17#include "GaudiKernel/IToolSvc.h"
18#include "GaudiKernel/ITHistSvc.h"
21#include "CaloDetDescr/CaloDetDescrElement.h"
25#include "Identifier/Identifier.h"
44#include "CLHEP/Vector/LorentzVector.h"
45#include "CLHEP/Vector/ThreeVector.h"
46#include "CLHEP/Geometry/Point3D.h"
79 CHECK(histSvc.retrieve());
89 throw GaudiException(
"Invalid LAr FCAL ID helper",
"LArHitAnalysis", StatusCode::FAILURE);
95 throw GaudiException(
"Invalid Calo Cell ID helper",
"LArHitAnalysis", StatusCode::FAILURE);
123 m_tree_AS =
new TTree(
"tree_AS",
"TTree of AnalysisSkleton");
202 throw GaudiException(
"Invalid Calo DM ID helper",
"LArFCalTB_MC_CBNT_AA", StatusCode::FAILURE);
260 return StatusCode::SUCCESS;
270 return StatusCode::SUCCESS;
406 return StatusCode::SUCCESS;
429 double energy = hit->energy();
431 int module_index = caloDDE->
getLayer();
433 double x = caloDDE->
x();
434 double y = caloDDE->
y();
437 if (module_index == 1) {
445 else if (module_index == 2) {
453 else if (module_index == 3) {
472 float xNumer1 = 0.0, xNumer2 = 0.0, xNumer3 = 0.0;
473 float yNumer1 = 0.0, yNumer2 = 0.0, yNumer3 = 0.0;
474 float Denom1 = 0.0, Denom2 = 0.0, Denom3 = 0.0;
476 double subClusterSize = 30.0;
477 double thisCG_R = 0.0;
488 double energy = hit->energy();
490 int module_index = caloDDE->
getLayer();
492 double x = caloDDE->
x();
493 double y = caloDDE->
y();
497 if (module_index == 1) {
499 double x_subcheck1 =
m_cx1 -
x;
500 double y_subcheck1 =
m_cy1 -
y;
501 thisCG_R = sqrt(x_subcheck1 * x_subcheck1 + y_subcheck1 * y_subcheck1);
503 if (thisCG_R <= subClusterSize) {
504 xNumer1 +=
x * energy;
505 yNumer1 +=
y * energy;
509 else if (module_index == 2) {
511 double x_subcheck2 =
m_cx2 -
x;
512 double y_subcheck2 =
m_cy2 -
y;
513 thisCG_R = sqrt(x_subcheck2 * x_subcheck2 + y_subcheck2 * y_subcheck2);
515 if (thisCG_R <= subClusterSize) {
516 xNumer2 +=
x * energy;
517 yNumer2 +=
y * energy;
521 else if (module_index == 3) {
523 double x_subcheck3 =
m_cx3 -
x;
524 double y_subcheck3 =
m_cy3 -
y;
525 thisCG_R = sqrt(x_subcheck3 * x_subcheck3 + y_subcheck3 * y_subcheck3);
527 if (thisCG_R <= subClusterSize) {
528 xNumer3 +=
x * energy;
529 yNumer3 +=
y * energy;
536 if (fabs(Denom1) > 0.0) {
541 if (fabs(Denom2) > 0.0) {
546 if (fabs(Denom3) > 0.0) {
565 std::string name = kv.first;
576 return StatusCode::FAILURE;
579 ATH_MSG_DEBUG(
"CaloCalibrationHit container successfully retrieved");
614 std::string name = kv.first;
625 double energy = calibhit->energyTotal();
636 if (name ==
"LArCalibrationHitActive")
639 if (name ==
"LArCalibrationHitInactive")
642 if (name ==
"LArCalibrationHitDeadMaterial") {
703 if (name ==
"LArCalibrationHitActive") {
720 if (name ==
"LArCalibrationHitInactive") {
740 for (
const auto& theParticle: *e)
745 const HepMC::FourVector& HMCmom = theParticle->momentum();
746 CLHEP::HepLorentzVector momentum(CLHEP::Hep3Vector(HMCmom.px(), HMCmom.py(), HMCmom.pz()), HMCmom.e());
748 HepMC::FourVector HMC3vec(0.0,0.0,0.0,0.0);
749 if (theParticle->production_vertex()) HMC3vec = theParticle->production_vertex()->position();
750 HepGeom::Point3D<double> origin = HepGeom::Point3D<double>(HMC3vec.x(), HMC3vec.y(), HMC3vec.z());
759 m_pt = momentum.vect().perp();
761 m_px = momentum.px();
762 m_py = momentum.py();
763 m_pz = momentum.pz();
767 m_vertx = theParticle->production_vertex()->position().x();
768 m_verty = theParticle->production_vertex()->position().y();
769 m_vertz = theParticle->production_vertex()->position().z();
776 std::string nickname;
780 const double z1 = -32668.5 * CLHEP::mm;
781 const double z2 = -33128.3 * CLHEP::mm;
782 const double z3 = -33602.8 * CLHEP::mm;
784 double shift2 = sinangle * (5128.3 - 4668.5) * CLHEP::mm;
785 double shift3 = sinangle * (5602.8 - 4668.5) * CLHEP::mm;
824 sc =
evtStore()->retrieve(mcEventCollection,
"TruthEvent");
826 if (
sc.isSuccess()) {
829 for (
const HepMC::GenEvent * mcEvent : *mcEventCollection) {
835 <<
": could not fetch MC event collection");
840 std::string FCalContainerName =
"LArHitFCAL";
847 return StatusCode::FAILURE;
850 ATH_MSG_DEBUG(
"LArHitFCAL container successfully retrieved");
872 sc =
evtStore()->retrieve(mcEventCollection,
"TruthEvent");
874 if (
sc.isSuccess()) {
878 for (
const HepMC::GenEvent * mcEvent : *mcEventCollection)
881 for (
auto theParticle: *mcEvent)
883 m_pdg_id->push_back(theParticle->pdg_id());
895 double energy = hit->energy();
896 int module_index = caloDDE->
getLayer();
899 if (module_index == 1) {
903 else if (module_index == 2) {
907 else if (module_index == 3) {
919 return StatusCode::SUCCESS;
927 std::vector<double> *hit_x, std::vector<double> *hit_y,
928 std::vector<double> *hit_ieta, std::vector<double> *hit_iphi,
931 const double hitx = caloDDE->
x();
932 const double hity = caloDDE->
y();
933 const double hiteta = 7;
934 const double hitphi = 7;
939 for (
int icell = 0; icell < NCell; icell++) {
940 if ((hitx == hit_x->at(icell)) && (hity == hit_y->at(icell))) {
942 cell_E->at(icell) += energy;
949 cell_E->push_back(energy);
950 hit_x->push_back(hitx);
951 hit_y->push_back(hity);
952 hit_ieta->push_back(hiteta);
953 hit_iphi->push_back(hitphi);
978 if (
sc.isFailure()) {
980 return StatusCode::SUCCESS;
985 return StatusCode::SUCCESS;
1006 m_bCID = eventInfo->bcid();
1009 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
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.
double energyNonEM() const
Identifier cellID() const
double energyEscaped() const
double energyInvisible() const
double energyTotal() const
This class groups all DetDescr information related to a CaloCell.
virtual int getLayer() const
cell layer
bool is_lar_fcal() const
cell belongs to FCAL
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 CaloDM_ID * getDM_ID(void) const
const CaloCell_ID * getCaloCell_ID(void) const
Access to IdHelper.
const LArFCAL_ID * getFCAL_ID(void) const
DataModel_detail::const_iterator< DataVector > const_iterator
virtual StatusCode initEvent()
Init event.
LArFCalSamplingFraction(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
double m_FCalActiveInvisible
std::vector< double > * m_hit_x1
StatusCode doFCal()
The main FCal analysis method.
StatusCode addEventInfo()
methods called by execute()
virtual StatusCode execute() override
Execute (event by event)
std::vector< double > * m_hit_iphi2
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
const CaloCell_ID * m_caloCellID
double m_totalFCal1CalibrationEnergy
const CaloDM_ID * m_caloDmID
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
TTree * m_tree_AS
Athena-Aware Ntuple (AAN) variables - branches of the AAN TTree.
std::vector< double > * m_cell2_E
double m_totalFCal2CalibrationEnergy
std::vector< double > * m_hit_y2
std::vector< double > * m_hit_ieta1
void FCalCalibAnalysis(const std::string &name, const CaloCalibrationHit *CalibHit)
FCal Analysis with Calibration Hits on Added by JPA, June 2005.
void FCalHitCenter(const LArHitContainer *container, const CaloDetDescrManager *caloMgr)
Calculate FCal hit center.
std::vector< double > * m_hit_ieta2
StatusCode doCalib()
Calibration hit analysis.
double m_totalInvisibleEnergy
double m_totalNonEmEnergy
std::vector< double > * m_cell3_E
std::vector< double > * m_hit_iphi3
double m_totalFCal3CalibrationEnergy
double m_FCalActiveEscaped
double m_totalActiveEnergy
double m_totalInactiveEnergy
std::vector< double > * m_hit_ieta3
m_calibHitMap_t m_calibHitMap
double m_totalEscapedEnergy
std::vector< double > * m_cell1_E
virtual StatusCode finalize() override
Finalize.
double m_totalCalibrationEnergy
~LArFCalSamplingFraction()
Destructor.
void FillCellInfo(const CaloDetDescrElement *caloDDE, double energy, std::vector< double > *cell_E, std::vector< double > *hit_x, std::vector< double > *hit_y, std::vector< double > *hit_ieta, std::vector< double > *hit_iphi, int &NCell)
Fill FCal cell information.
void FCalClusterCenter(const LArHitContainer *container, const CaloDetDescrManager *caloMgr)
Calculate FCal cluster center.
void TruthImpactPosition(const HepMC::GenEvent *e)
Calculate truth impact position.
std::vector< int > * m_pdg_id
std::vector< double > * m_hit_iphi1
unsigned int m_eventNumber
double m_totalDeadMaterialEnergy
const LArFCAL_ID * m_larFCalID
virtual StatusCode initialize() override
Initialize.
std::vector< double > * m_hit_y1
std::vector< double > * m_hit_x3
std::vector< double > * m_hit_x2
double m_totalFCalCalibrationEnergy
std::vector< double > * m_hit_y3
Class to store hit energy and time in LAr cell from G4 simulation.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
virtual bool isValid() override final
Can the handle be successfully dereferenced?