482{
483
485
487 {
489 return StatusCode::FAILURE;
490 }
491
492 SG::ReadCondHandle<ILArfSampl> fSamplHdl(
m_fSamplKey,Gaudi::Hive::currentContext());
493 const ILArfSampl* fSampl=*fSamplHdl;
494
496 ATH_CHECK( tileSamplingFraction.isValid() );
497
498
499
500 TVector3 vectest;
501 vectest.SetPtEtaPhi(1.,1.,1.);
537
538
539 std::map<Long64_t, FCS_cell>
cells;
540 std::map<Long64_t, std::vector<FCS_g4hit> > g4hits;
541 std::map<Long64_t, std::vector<FCS_hit> >
hits;
542
544 g4hits.clear();
546
547 FCS_cell one_cell{};
548 FCS_g4hit one_g4hit{};
549 FCS_hit one_hit{};
550 FCS_matchedcell one_matchedcell;
551
556
581
582
591
592
593
594 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{
m_caloMgrKey,Gaudi::Hive::currentContext()};
596 const CaloDetDescrManager* calo_dd_man = *caloMgrHandle;
597
598
599 const ISF_FCS_Parametrization::FCS_StepInfoCollection* eventStepsES;
601 if (
sc.isFailure()) {
603
604 } else {
607 m_hit_x->push_back( (*it)->x() );
608 m_hit_y->push_back( (*it)->y() );
609 m_hit_z->push_back( (*it)->z() );
612
613
614 bool larbarrel=false;
615 bool larendcap=false;
616 bool larhec=false;
617 bool larfcal=false;
619 int sampling=-1;
620 double sampfrac=0.0;
621
622 Identifier id = (*it)->identify();
623 Identifier cell_id = (*it)->identify();
624
628 } else {
630 }
631
636 int drawerIdx =
m_tileHWID->drawerIdx(channel_id);
637 sampfrac = tileSamplingFraction->getSamplingFraction(drawerIdx, channel);
638 }
640
641 if (
m_larEmID->is_em_barrel(
id)) larbarrel=
true;
642 else if(
m_larEmID->is_em_endcap(
id)) larendcap=
true;
644
645 larhec = true;
647
648 larfcal = true;
649 }
else if (
m_tileID->is_tile_aux(
id)) {
650
653 sampling = CaloCell_ID::TileGap3;
655
658 Int_t tile_sampling = -1;
661 }
662 if(tile_sampling!= -1) sampling = tile_sampling;
663 } else {
665 }
666
669
677
678 }
679 }
680
681
682
684 sc =
evtStore()->retrieve(mcEvent,
"TruthEvent");
687 } else {
688 if(mcEvent) {
689
690 if(!mcEvent->
empty()) {
691 int particleIndex=0;
693 int particles_size=(*mcEvent->
begin())->particles_size();
694 if(loopEnd==-1) {
695 loopEnd = particles_size;
696 }
697#ifdef HEPMC3
698 for (
const auto& part: *(*mcEvent->
begin()))
699#else
700 for (
const auto part: *(*mcEvent->
begin()))
701#endif
702 {
703
704 ATH_MSG_DEBUG(
"Number truth particles="<<particles_size<<
" loopEnd="<<loopEnd);
705 particleIndex++;
706
707 if (particleIndex>loopEnd) break;
708
709
710
711 TFCSTruthState truth(
part->momentum().px(),
part->momentum().py(),
part->momentum().pz(),
part->momentum().e(),
part->pdg_id());
712
713
714 TVector3 moment;
715 moment.SetXYZ(
part->momentum().px(),
part->momentum().py(),
part->momentum().pz());
716 TVector3 direction=moment.Unit();
717
718
719
721
723 } else {
724
726 }
727
728 if((part)->production_vertex()) {
729 truth.set_vertex((part)->production_vertex()->position().
x(), (part)->production_vertex()->position().
y(), (part)->production_vertex()->position().
z());
730 } else {
731 truth.set_vertex(direction.X(),direction.Y(),direction.Z());
732 ATH_MSG_WARNING(
"No particle production vetext, use VERTEX from direction: x "<<direction.X()<<
" y "<<direction.Y()<<
" z "<<direction.Z());
733 }
734
735 if( std::abs(direction.X()-truth.vertex().X())>0.1 || std::abs(direction.Y()-truth.vertex().Y())>0.1 || std::abs(direction.Z()-truth.vertex().Z())>0.1 ) {
736 ATH_MSG_WARNING(
"VERTEX from direction: x "<<direction.X()<<
" y "<<direction.Y()<<
" z "<<direction.Z());
737 ATH_MSG_WARNING(
"but VERTEX from hepmc: x "<<truth.vertex().X()<<
" y "<<truth.vertex().Y()<<
" z "<<truth.vertex().Z());
738 }
739
740 TFCSExtrapolationState
result;
742
743
744
751
758
759 std::vector<float> eta_vec_ENT;
760 std::vector<float> phi_vec_ENT;
761 std::vector<float> r_vec_ENT;
762 std::vector<float> z_vec_ENT;
763 std::vector<float> detaBorder_vec_ENT;
764 std::vector<bool> OK_vec_ENT;
765
766 std::vector<float> eta_vec_EXT;
767 std::vector<float> phi_vec_EXT;
768 std::vector<float> r_vec_EXT;
769 std::vector<float> z_vec_EXT;
770 std::vector<float> detaBorder_vec_EXT;
771 std::vector<bool> OK_vec_EXT;
772
773 std::vector<float> eta_vec_MID;
774 std::vector<float> phi_vec_MID;
775 std::vector<float> r_vec_MID;
776 std::vector<float> z_vec_MID;
777 std::vector<float> detaBorder_vec_MID;
778 std::vector<bool> OK_vec_MID;
779
806 }
807
826
833
834 }
835 }
836 }
837 }
838
839
841 sc =
evtStore()->retrieve(MuonEntry,
"MuonEntryLayer");
843 {
845
846 }
847 else{
848 for ( const TrackRecord &record : *MuonEntry){
857 }
858 }
859
860
861
863 std::string clusterContainerName = "CaloCalTopoClusters";
864 sc =
evtStore()->retrieve(theClusters, clusterContainerName);
865 if (
sc.isFailure()) {
866 ATH_MSG_WARNING(
" Couldn't get cluster container '" << clusterContainerName <<
"'");
867 return StatusCode::SUCCESS;
868 }
871 for ( ; itrClus!=itrLastClus; ++itrClus){
877
878 const CaloClusterCellLink* cellLinks = cluster->
getCellLinks();
879 if (!cellLinks) {
881 continue;
882 }
883
885 if (!cellCont) {
887 continue;
888 }
889 unsigned cellcount = 0;
890 std::vector<Long64_t> cellIDs_in_cluster;
893 for ( ;cellIter !=cellIterEnd;cellIter++) {
894 ++cellcount;
895 const CaloCell*
cell= (*cellIter);
896 cellIDs_in_cluster.push_back(
cell->ID().get_compact());
897 float EnergyCell=
cell->energy();
899 }
902 }
903
904
905 const CaloCellContainer *cellColl = nullptr;
906 sc =
evtStore()->retrieve(cellColl,
"AllCalo");
907
909 {
911 }
912 else
913 {
917 for ( ; itrCell!=itrLastCell; ++itrCell)
918 {
921 if (
m_tileID->is_tile_aux((*itrCell)->ID())) {
922
924 }
925 else if (calo_dd_man->
get_element((*itrCell)->ID()))
926 {
927
930 }
931 else
933 }
934 }
935
936
937 std::string lArKey [4] = {"LArHitEMB", "LArHitEMEC", "LArHitFCAL", "LArHitHEC"};
938 for (
unsigned int i=0;
i<4;
i++)
939 {
943 {
945 int hitnumber = 0;
946 for (hi=(*iter).begin();hi!=(*iter).end();++hi) {
947 hitnumber++;
948 const LArHit* larHit = *hi;
949 const CaloDetDescrElement *hitElement = calo_dd_man->
get_element(larHit->
cellID());
950 if(!hitElement)
951 continue;
952 Identifier larhitid = hitElement->
identify();
955
956 float larsampfrac=fSampl->
FSAMPL(larhitid);
963 }
964 }
965 ATH_MSG_INFO(
"Read "<<hitnumber<<
" G4Hits from "<<lArKey[i]);
966 }
967 else
968 {
970 }
971
972 }
973
976 {
977 int hitnumber = 0;
979 {
980 hitnumber++;
981 Identifier pmt_id = (*i_hit).identify();
982 Identifier cell_id =
m_tileID->cell_id(pmt_id);
983
986
989 int drawerIdx =
m_tileHWID->drawerIdx(channel_id);
990 float tilesampfrac = tileSamplingFraction->getSamplingFraction(drawerIdx, channel);
991
992
993 for (int tilesubhit_i = 0; tilesubhit_i<(*i_hit).size(); tilesubhit_i++)
994 {
1001 }
1002 }
1003 }
1004 ATH_MSG_INFO(
"Read "<<hitnumber<<
" G4Hits from TileHitVec");
1005 }
1006
1007
1008
1010
1011
1015 one_cell.
sampling = (*m_cell_sampling)[cell_i];
1016 one_cell.
energy = (*m_cell_energy)[cell_i];
1021 }
1022 else
1023 {
1024
1026 }
1027 }
1028
1029
1032 {
1034 {
1036 continue;
1037 }
1038
1040 {
1041
1042 one_g4hit.
identifier = (*m_g4hit_identifier)[g4hit_i];
1044 one_g4hit.
sampling = (*m_g4hit_sampling)[g4hit_i];
1045 one_g4hit.
hit_time = (*m_g4hit_time)[g4hit_i];
1046
1048 {
1050 {
1051 one_g4hit.
hit_energy = (*m_g4hit_energy)[g4hit_i] * (*m_g4hit_samplingfraction)[g4hit_i];
1052 }
1054 }
1055 else
1056 {
1057 one_g4hit.
hit_energy = (*m_g4hit_energy)[g4hit_i] / (*m_g4hit_samplingfraction)[g4hit_i];
1058 }
1059 g4hits.insert(std::pair<Long64_t, std::vector<FCS_g4hit> >(one_g4hit.
cell_identifier, std::vector<FCS_g4hit>(1, one_g4hit)));
1060 }
1061 else
1062 {
1063
1064 one_g4hit.
identifier = (*m_g4hit_identifier)[g4hit_i];
1066 one_g4hit.
sampling = (*m_g4hit_sampling)[g4hit_i];
1067 one_g4hit.
hit_time = (*m_g4hit_time)[g4hit_i];
1069 {
1071 {
1072 one_g4hit.
hit_energy = (*m_g4hit_energy)[g4hit_i] * (*m_g4hit_samplingfraction)[g4hit_i];
1073 }
1075 }
1076 else
1077 {
1078 one_g4hit.
hit_energy = (*m_g4hit_energy)[g4hit_i] / (*m_g4hit_samplingfraction)[g4hit_i];
1079 }
1080 g4hits[(*m_g4hit_cellidentifier)[g4hit_i]].push_back(one_g4hit);
1081 }
1082 }
1083 }
1084
1085
1087 {
1089 {
1091 continue;
1092 }
1094 {
1095
1096 one_hit.
identifier = (*m_hit_identifier)[hit_i];
1098 one_hit.
sampling = (*m_hit_sampling)[hit_i];
1099
1101 {
1103 {
1104 one_hit.
hit_energy = (*m_hit_energy)[hit_i] * (*m_hit_samplingfraction)[hit_i];
1105 }
1107 }
1108 else
1109 {
1110 one_hit.
hit_energy = (*m_hit_energy)[hit_i] / (*m_hit_samplingfraction)[hit_i];
1111 }
1112
1113 one_hit.
hit_time = (*m_hit_time)[hit_i];
1114 one_hit.
hit_x = (*m_hit_x)[hit_i];
1115 one_hit.
hit_y = (*m_hit_y)[hit_i];
1116 one_hit.
hit_z = (*m_hit_z)[hit_i];
1117 hits.insert(std::pair<Long64_t, std::vector<FCS_hit> >(one_hit.
cell_identifier, std::vector<FCS_hit>(1, one_hit)));
1118 }
1119 else
1120 {
1121
1122 one_hit.
identifier = (*m_hit_identifier)[hit_i];
1124 one_hit.
sampling = (*m_hit_sampling)[hit_i];
1125
1127 {
1129 {
1130 one_hit.
hit_energy = (*m_hit_energy)[hit_i] * (*m_hit_samplingfraction)[hit_i];
1131 }
1133 }
1134 else
1135 {
1136 one_hit.
hit_energy = (*m_hit_energy)[hit_i] / (*m_hit_samplingfraction)[hit_i];
1137 }
1138
1139 one_hit.
hit_time = (*m_hit_time)[hit_i];
1140 one_hit.
hit_x = (*m_hit_x)[hit_i];
1141 one_hit.
hit_y = (*m_hit_y)[hit_i];
1142 one_hit.
hit_z = (*m_hit_z)[hit_i];
1143 hits[(*m_hit_cellidentifier)[hit_i]].push_back(one_hit);
1144 }
1145 }
1146
1147
1148 for (std::map<Long64_t, FCS_cell>::iterator it =
cells.begin(); it !=
cells.end(); )
1149 {
1150 one_matchedcell.
clear();
1151
1152 one_matchedcell.
cell =
it->second;
1153
1154 std::map<Long64_t, std::vector<FCS_hit> >::iterator it2 =
hits.find(
it->first);
1155 if (it2 !=
hits.end())
1156 {
1157
1158 one_matchedcell.
hit = it2->second;
1160 }
1161 else
1162 {
1163
1164 one_matchedcell.
hit.clear();
1165 }
1166
1167 std::map<Long64_t, std::vector<FCS_g4hit> >::iterator it3 = g4hits.find(
it->first);
1168 if (it3 != g4hits.end())
1169 {
1170 one_matchedcell.
g4hit = it3->second;
1171 g4hits.erase(it3);
1172 }
1173 else
1174 {
1175
1176 one_matchedcell.
g4hit.clear();
1177 }
1179
1181 }
1182
1183
1184
1185 ATH_MSG_DEBUG(
"ISF_HitAnalysis Check after cells: " <<
cells.size() <<
" " << g4hits.size() <<
" " <<
hits.size());
1186
1187 for (std::map<Long64_t, std::vector<FCS_hit> >::iterator it =
hits.begin(); it !=
hits.end();)
1188 {
1189 one_matchedcell.
clear();
1191
1192 if (!
it->second.empty())
1193 {
1195 }
1196 else
1197 {
1199
1201 }
1206 one_matchedcell.
hit =
it->second;
1207 std::map<Long64_t, std::vector<FCS_g4hit> >::iterator it3 = g4hits.find(
it->first);
1208 if (it3 != g4hits.end())
1209 {
1210 one_matchedcell.
g4hit = it3->second;
1211 g4hits.erase(it3);
1212 }
1213 else
1214 {
1215
1216 one_matchedcell.
g4hit.clear();
1217 }
1220
1221 }
1222
1223
1224 ATH_MSG_DEBUG(
"ISF_HitAnalysis Check after hits: " <<
cells.size() <<
" " << g4hits.size() <<
" " <<
hits.size());
1225 for (std::map<Long64_t, std::vector<FCS_g4hit> >::iterator it = g4hits.begin(); it != g4hits.end();)
1226 {
1227 one_matchedcell.
clear();
1229 if (!
it->second.empty())
1230 {
1232 }
1233 else
1234 {
1236
1238 }
1243 one_matchedcell.
g4hit =
it->second;
1244 one_matchedcell.
hit.clear();
1245 g4hits.erase(it++);
1247 }
1248
1249
1253
1255 {
1257 }
1258
1259
1262 {
1266
1267 for (
unsigned int cellindex = 0; cellindex <
m_layercells[
i]->size(); cellindex++)
1268 {
1270 {
1273 }
1274 else
1275 {
1276
1278 }
1279
1280
1281 for (
unsigned int j = 0; j <
m_layercells[
i]->m_vector.at(cellindex).hit.size(); j++)
1282 {
1284 {
1287 }
1288 else
1289 {
1290
1292 }
1293 }
1294
1295
1296 for (
unsigned int j = 0; j <
m_layercells[
i]->m_vector.at(cellindex).g4hit.size(); j++)
1297 {
1299 {
1302 }
1303 else
1304 {
1305
1307 }
1308 }
1309 }
1310 }
1311
1312
1316
1320
1321
1323
1324 return StatusCode::SUCCESS;
1325
1326}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
AtlasHitsVector< TileHit >::const_iterator TileHitVecConstIterator
AtlasHitsVector< TileHit > TileHitVector
AtlasHitsVector< TrackRecord > TrackRecordCollection
ServiceHandle< StoreGateSvc > & evtStore()
boost::transform_iterator< make_const, typename CONT::const_iterator > const_iterator
const_iterator begin() const
const_iterator end() const
CaloSampling::CaloSample CaloSample
const CaloCellContainer * getCellContainer() const
Method to access underlying cell container.
CaloCell_ID::CaloSample getSampling() const
cell sampling
Identifier identify() const override final
cell identifier
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
virtual const float & FSAMPL(const HWIdentifier &id) const =0
std::vector< std::vector< bool > > * m_newTTC_entrance_OK
std::vector< std::vector< float > > * m_newTTC_back_r
std::vector< Float_t > * m_final_hit_energy
std::vector< float > * m_MuonEntryLayer_pz
std::vector< std::vector< float > > * m_newTTC_back_detaBorder
std::vector< std::vector< float > > * m_newTTC_entrance_phi
const LArHEC_ID * m_larHecID
FCS_matchedcellvector * m_oneeventcells
std::vector< std::vector< float > > * m_newTTC_mid_r
std::vector< Long64_t > * m_g4hit_cellidentifier
std::vector< bool > * m_islarhec
std::vector< std::vector< Long64_t > > * m_cluster_cellID
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
std::vector< float > * m_newTTC_IDCaloBoundary_phi
std::vector< float > * m_MuonEntryLayer_py
std::vector< float > * m_cluster_eta
std::vector< int > * m_truth_barcode
std::vector< std::vector< float > > * m_newTTC_back_phi
std::vector< int > * m_truth_pdg
const LArFCAL_ID * m_larFcalID
std::vector< float > * m_truth_py
std::vector< std::vector< float > > * m_newTTC_mid_eta
std::vector< float > * m_MuonEntryLayer_x
std::vector< int > * m_g4hit_sampling
std::vector< float > * m_newTTC_IDCaloBoundary_eta
std::vector< float > * m_newTTC_IDCaloBoundary_z
PublicToolHandle< IFastCaloSimCaloExtrapolation > m_FastCaloSimCaloExtrapolation
The FastCaloSimCaloExtrapolation tool.
std::vector< std::vector< float > > * m_newTTC_mid_detaBorder
std::vector< std::vector< float > > * m_newTTC_entrance_z
SG::ReadCondHandleKey< TileSamplingFraction > m_tileSamplingFractionKey
Name of TileSamplingFraction in condition store.
std::vector< float > * m_hit_y
IntegerProperty m_TimingCut
std::vector< std::vector< float > > * m_newTTC_entrance_eta
std::vector< float > * m_MuonEntryLayer_z
std::vector< float > * m_truth_pz
std::vector< float > * m_cluster_energy
std::vector< std::vector< float > > * m_newTTC_back_eta
std::vector< std::vector< float > > * m_newTTC_mid_z
std::vector< float > * m_hit_z
std::vector< float > * m_newTTC_AngleEta
std::vector< float > * m_truth_px
std::vector< float > * m_hit_x
Simple variables by Ketevi.
std::vector< std::vector< bool > > * m_newTTC_back_OK
const TileHWID * m_tileHWID
std::vector< float > * m_hit_time
BooleanProperty m_doG4Hits
std::vector< float > * m_cluster_phi
std::vector< std::vector< bool > > * m_newTTC_mid_OK
std::vector< float > * m_g4hit_time
std::vector< float > * m_truth_energy
std::vector< float > * m_hit_samplingfraction
std::vector< Long64_t > * m_cell_identifier
std::vector< bool > * m_islarbarrel
std::vector< int > * m_truth_vtxbarcode
std::vector< float > * m_newTTC_Angle3D
std::vector< Long64_t > * m_hit_identifier
std::vector< float > * m_MuonEntryLayer_E
std::vector< std::vector< float > > * m_newTTC_entrance_r
std::vector< float > * m_hit_energy
DoubleProperty m_CaloBoundaryR
std::vector< int > * m_MuonEntryLayer_pdg
const TileDetDescrManager * m_tileMgr
DoubleProperty m_CaloBoundaryZ
std::vector< unsigned > * m_cluster_size
std::vector< float > * m_MuonEntryLayer_y
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::vector< bool > * m_islarendcap
std::vector< std::vector< float > > * m_newTTC_mid_phi
std::vector< int > * m_cell_sampling
std::vector< Long64_t > * m_hit_cellidentifier
std::vector< float > * m_g4hit_samplingfraction
std::vector< float > * m_newTTC_IDCaloBoundary_r
std::vector< float > * m_cell_energy
FCS_matchedcellvector * m_layercells[MAX_LAYER]
std::vector< bool > * m_istile
std::vector< std::vector< float > > * m_newTTC_entrance_detaBorder
static const int MAX_LAYER
std::vector< std::vector< float > > * m_newTTC_back_z
const LArEM_ID * m_larEmID
std::vector< int > * m_hit_sampling
std::vector< float > * m_g4hit_energy
std::vector< Float_t > * m_final_cell_energy
std::vector< Long64_t > * m_g4hit_identifier
std::vector< float > * m_MuonEntryLayer_px
IntegerProperty m_NtruthParticles
std::vector< bool > * m_islarfcal
std::vector< Float_t > * m_final_g4hit_energy
const TileCablingService * m_tileCabling
value_type get_compact() const
Get the compact id.
Identifier cellID() const
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
CaloClusterCellLink::const_iterator const_cell_iterator
Iterator of the underlying CaloClusterCellLink (explicitly const version)
const_cell_iterator cell_end() const
virtual double phi() const
The azimuthal angle ( ) of the particle.
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
::StatusCode StatusCode
StatusCode definition for legacy code.
retrieve(aClass, aKey=None)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
std::vector< FCS_g4hit > g4hit
std::vector< FCS_hit > hit