diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/CMakeLists.txt b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/CMakeLists.txt index 75734daf699659fa60c839d4b60eef3b530626a8..f465479606064fa6002363592b6033a0aec7adb4 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/CMakeLists.txt +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/CMakeLists.txt @@ -30,13 +30,13 @@ atlas_add_library( ISF_FastCaloSimParametrizationLib INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${HEPPDT_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPPDT_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps AthenaKernel AtlasHepMCLib BarcodeEventLib CaloDetDescrLib CaloInterfaceLib GaudiKernel ISF_FastCaloSimEvent ISF_InterfacesLib LArElecCalib LArReadoutGeometry StoreGateLib TrkEventPrimitives TrkExInterfaces TrkParameters - PRIVATE_LINK_LIBRARIES CaloGeoHelpers ) + PRIVATE_LINK_LIBRARIES CaloGeoHelpers xAODCaloEvent ) atlas_add_component( ISF_FastCaloSimParametrization src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${HEPPDT_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} ${GEANT4_LIBRARIES} ${HEPPDT_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps AthenaPoolUtilities AtlasHepMCLib CaloDetDescrLib CaloEvent CaloGeoHelpers CaloIdentifier EventInfo GaudiKernel GeneratorObjects GeoAdaptors GeoModelInterfaces GeoPrimitives ISF_Event ISF_FastCaloSimEvent ISF_FastCaloSimInterfaces ISF_FastCaloSimParametrizationLib ISF_InterfacesLib LArSimEvent NavFourMom StoreGateLib TileConditionsLib TileDetDescr TileSimEvent TrackRecordLib TrkExInterfaces TrkGeometry TrkMaterialOnTrack TrkParameters TrkSurfaces ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} ${GEANT4_LIBRARIES} ${HEPPDT_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps AthenaPoolUtilities AtlasHepMCLib CaloDetDescrLib CaloEvent CaloGeoHelpers CaloIdentifier EventInfo GaudiKernel GeneratorObjects GeoAdaptors GeoModelInterfaces GeoPrimitives ISF_Event ISF_FastCaloSimEvent ISF_FastCaloSimInterfaces ISF_FastCaloSimParametrizationLib ISF_InterfacesLib LArSimEvent NavFourMom StoreGateLib TileConditionsLib TileDetDescr TileSimEvent TrackRecordLib TrkExInterfaces TrkGeometry TrkMaterialOnTrack TrkParameters TrkSurfaces xAODCaloEvent ) # Code in this file makes heavy use of eigen and runs orders of magnitude # more slowly without optimization. So force this to be optimized even @@ -51,7 +51,6 @@ if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) COMPILE_DEFINITIONS "FLATTEN" ) endif() - # Install files from the package: atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_joboptions( share/*.py ) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/ISF_HitAnalysis.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/ISF_HitAnalysis.h index 8b3a212ba61c628e355c9267003c0945b4d18035..30a998e344912c94d2fbdf43982762cc987f99fa 100755 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/ISF_HitAnalysis.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/ISF_HitAnalysis.h @@ -118,6 +118,13 @@ class ISF_HitAnalysis : public AthAlgorithm { std::vector<int>* m_truth_barcode; std::vector<int>* m_truth_vtxbarcode; //production vertex barcode + std::vector<float>* m_cluster_energy; + std::vector<float>* m_cluster_eta; + std::vector<float>* m_cluster_phi; + std::vector<unsigned>* m_cluster_size; + std::vector<std::vector<Long64_t >>* m_cluster_cellID; + + std::vector<Long64_t>* m_cell_identifier; std::vector<float>* m_cell_energy; std::vector<int>* m_cell_sampling; @@ -264,6 +271,7 @@ class ISF_HitAnalysis : public AthAlgorithm { double m_calomargin; bool m_saveAllBranches; bool m_doAllCells; + bool m_doClusterInfo; bool m_doLayers; bool m_doLayerSums; bool m_doG4Hits; diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/Root/LinkDef.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/Root/LinkDef.h index ecefea902167a55b600cdb53a73f6755cacb37a9..5edfb24e7bd168a5c353f83b857dcdfa522aad2f 100755 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/Root/LinkDef.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/Root/LinkDef.h @@ -17,6 +17,7 @@ #pragma link C++ struct FCS_matchedcellvector+; #pragma link C++ class std::vector<Float_t>+; #pragma link C++ class std::vector<std::vector<float> >+; +#pragma link C++ class std::vector<std::vector<Long64_t> >+; #ifndef CaloGeometryFromFile_h #pragma link C++ class CaloGeometryLookup; #pragma link C++ class CaloGeometry; diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/fcsTrfArgs.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/fcsTrfArgs.py index 88d243aabfb69aac6d69b36d3519c1b7e27968be..4c7f8a1a50a8615d212221d38b2115dd50ea2103 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/fcsTrfArgs.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/python/fcsTrfArgs.py @@ -26,3 +26,6 @@ def addFCS_NtupArgs(parser): parser.add_argument('--NTruthParticles', type=argFactory(argInt), help='Option to select number of truth particles copied to ntuples', group='FCS_Ntup_tf') + parser.add_argument('--doClusterInfo', + type=argFactory(argBool), + help='Flag to turn on extra branches for clusters', group='FCS_Ntup_tf') diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_ntuple_core.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_ntuple_core.py index 7c21248a6021e829d869ed1878e5fe00a7935a9d..d0a846616ef392fe2a3d886d941392bc308becf8 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_ntuple_core.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_ntuple_core.py @@ -47,6 +47,7 @@ ISF_HitAnalysis.DoAllCells = False ISF_HitAnalysis.DoLayers = True ISF_HitAnalysis.DoLayerSums = True ISF_HitAnalysis.DoG4Hits = doG4Hits +ISF_HitAnalysis.DoClusterInfo = doClusterInfo ISF_HitAnalysis.TimingCut = 999999 ISF_HitAnalysis.OutputLevel = ERROR diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/skeleton.ESDtoNTUP_FCS.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/skeleton.ESDtoNTUP_FCS.py index 1bd9e55073d836115e75be035438eac6aa2a104e..0f38dd84a893b5e4f8f9c2000ba22d4c66eddac9 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/skeleton.ESDtoNTUP_FCS.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/skeleton.ESDtoNTUP_FCS.py @@ -53,6 +53,12 @@ if hasattr(runArgs,"doG4Hits"): else: doG4Hits = False +## Flag for doClusterInfo +if hasattr(runArgs,"doClusterInfo"): + doClusterInfo = runArgs.doClusterInfo +else: + doClusterInfo = False + ## Flag for saveAllBranches if hasattr(runArgs, "saveAllBranches"): saveAllBranches = runArgs.saveAllBranches diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/ISF_HitAnalysis.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/ISF_HitAnalysis.cxx index 42882f7170e65f827c74147740dd5dd67b97fadd..de2fd53fc82e479fdadeb8b12988c0a20d1eff50 100755 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/ISF_HitAnalysis.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/ISF_HitAnalysis.cxx @@ -31,6 +31,9 @@ //CaloCell #include "CaloEvent/CaloCellContainer.h" +#include "CaloEvent/CaloClusterCellLinkContainer.h" +#include "xAODCaloEvent/CaloClusterContainer.h" +#include "xAODCaloEvent/CaloCluster.h" #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/IToolSvc.h" @@ -102,6 +105,11 @@ ISF_HitAnalysis::ISF_HitAnalysis(const std::string& name, ISvcLocator* pSvcLocat , m_truth_pdg(0) , m_truth_barcode(0) , m_truth_vtxbarcode(0) + , m_cluster_energy(0) + , m_cluster_eta(0) + , m_cluster_phi(0) + , m_cluster_size(0) + , m_cluster_cellID(0) , m_cell_identifier(0) , m_cell_energy(0) , m_cell_sampling(0) @@ -213,6 +221,7 @@ ISF_HitAnalysis::ISF_HitAnalysis(const std::string& name, ISvcLocator* pSvcLocat declareProperty("SaveAllBranches", m_saveAllBranches = false); declareProperty("DoAllCells", m_doAllCells = false); + declareProperty("DoClusterInfo", m_doClusterInfo = false); declareProperty("DoLayers", m_doLayers = true); declareProperty("DoLayerSums", m_doLayerSums = true); declareProperty("DoG4Hits", m_doG4Hits = false); @@ -479,6 +488,18 @@ StatusCode ISF_HitAnalysis::initialize() return StatusCode::FAILURE; } + if(m_doClusterInfo){ + m_tree->Branch("ClusterE", &m_cluster_energy); + m_tree->Branch("ClusterEta", &m_cluster_eta); + m_tree->Branch("ClusterPhi", &m_cluster_phi); + m_tree->Branch("ClusterSize", &m_cluster_size); + m_tree->Branch("ClusterCellID", &m_cluster_cellID); + } + m_oneeventcells = new FCS_matchedcellvector; + if(m_doAllCells){ + m_tree->Branch("AllCells", &m_oneeventcells); + } + //######################### IPartPropSvc* p_PartPropSvc=0; if (service("PartPropSvc",p_PartPropSvc).isFailure() || p_PartPropSvc == 0) @@ -532,6 +553,12 @@ StatusCode ISF_HitAnalysis::initialize() m_truth_barcode = new std::vector<int>; m_truth_vtxbarcode = new std::vector<int>; + m_cluster_energy = new std::vector<float>; + m_cluster_eta = new std::vector<float>; + m_cluster_phi = new std::vector<float>; + m_cluster_size = new std::vector<unsigned>; + m_cluster_cellID = new std::vector<std::vector<Long64_t > >; + m_cell_identifier = new std::vector<Long64_t>; m_cell_energy = new std::vector<float>; m_cell_sampling = new std::vector<int>; @@ -820,6 +847,11 @@ StatusCode ISF_HitAnalysis::execute() m_truth_pdg->clear(); m_truth_barcode->clear(); m_truth_vtxbarcode->clear(); + m_cluster_energy->clear(); + m_cluster_eta->clear(); + m_cluster_phi->clear(); + m_cluster_size->clear(); + m_cluster_cellID->clear(); m_cell_identifier->clear(); m_cell_energy->clear(); m_cell_sampling->clear(); @@ -917,7 +949,7 @@ StatusCode ISF_HitAnalysis::execute() sampling = layer; //use CaloCell layer immediately } else { ATH_MSG_WARNING( "Warning no sampling info for "<<id.getString()); - } + } if(m_larEmID->is_lar_em(id) || m_larHecID->is_lar_hec(id) || m_larFcalID->is_lar_fcal(id)) sampfrac=fSampl->FSAMPL(id); @@ -949,7 +981,7 @@ StatusCode ISF_HitAnalysis::execute() if(tile_sampling!= -1) sampling = tile_sampling; //m_calo_dd_man needs to be called with cell_id not pmt_id!! } else { ATH_MSG_WARNING( "This hit is somewhere. Please check!"); - } + } m_hit_identifier->push_back(id.get_compact()); m_hit_cellidentifier->push_back(cell_id.get_compact()); @@ -1137,8 +1169,6 @@ StatusCode ISF_HitAnalysis::execute() } //mcEvent }//truth event - - //Retrieve and save MuonEntryLayer information const TrackRecordCollection *MuonEntry = nullptr; sc = evtStore()->retrieve(MuonEntry, "MuonEntryLayer"); @@ -1160,6 +1190,49 @@ StatusCode ISF_HitAnalysis::execute() } } + // Get the reco clusters if available +// retreiving cluster container + const DataHandle<xAOD::CaloClusterContainer > theClusters; + std::string clusterContainerName = "CaloCalTopoClusters"; + sc = evtStore()->retrieve(theClusters, clusterContainerName); + if (sc.isFailure()) { + ATH_MSG_WARNING(" Couldn't get cluster container '" << clusterContainerName << "'"); + return StatusCode::SUCCESS; + } + xAOD::CaloClusterContainer::const_iterator itrClus = theClusters->begin(); + xAOD::CaloClusterContainer::const_iterator itrLastClus = theClusters->end(); + for ( ; itrClus!=itrLastClus; ++itrClus){ + const xAOD::CaloCluster *cluster =(*itrClus); + m_cluster_energy->push_back(cluster->e()); + m_cluster_eta->push_back(cluster->eta()); + m_cluster_phi->push_back(cluster->phi()); + ATH_MSG_VERBOSE("Cluster energy: " << cluster->e() << " cells: " << " links: " << cluster->getCellLinks()); + //cluster->getCellLinks(); + const CaloClusterCellLink* cellLinks = cluster->getCellLinks(); + if (!cellLinks) { + ATH_MSG_DEBUG( "No cell links for this cluster" ); + continue; + } + + const CaloCellContainer* cellCont=cellLinks->getCellContainer(); + if (!cellCont) { + ATH_MSG_DEBUG( "DataLink to cell container is broken" ); + continue; + } + unsigned cellcount = 0; + std::vector<Long64_t> cellIDs_in_cluster; + xAOD::CaloCluster::const_cell_iterator cellIter =cluster->cell_begin(); + xAOD::CaloCluster::const_cell_iterator cellIterEnd =cluster->cell_end(); + for ( ;cellIter !=cellIterEnd;cellIter++) { + ++cellcount; + const CaloCell* cell= (*cellIter); + cellIDs_in_cluster.push_back(cell->ID().get_compact()); + float EnergyCell=cell->energy(); //ID, time, phi, eta + ATH_MSG_DEBUG(" Cell energy: " << EnergyCell); + }// end of cells inside cluster loop + m_cluster_size->push_back(cellcount); + m_cluster_cellID->push_back(cellIDs_in_cluster); + } //Get reco cells if available const CaloCellContainer *cellColl = 0;