ATLAS Offline Software
Loading...
Searching...
No Matches
ISF::FastCaloSimV2ParamSvc Class Reference

#include <FastCaloSimV2ParamSvc.h>

Inheritance diagram for ISF::FastCaloSimV2ParamSvc:
Collaboration diagram for ISF::FastCaloSimV2ParamSvc:

Public Member Functions

 FastCaloSimV2ParamSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters.
virtual ~FastCaloSimV2ParamSvc ()=default
 Destructor.
virtual StatusCode initialize () override final
 Athena algorithm's interface methods.
virtual StatusCode simulate (TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override final
 Simulation Call.

Private Member Functions

const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Private Attributes

ServiceHandle< StoreGateSvcm_detStore
 Pointer to StoreGate (detector store by default)
std::string m_paramsFilename {"TFCSparam.root"}
std::string m_paramsObject {"SelPDGID"}
TFCSParametrizationBasem_param {}
std::unique_ptr< CaloGeometryFromCaloDDMm_caloGeo {}
bool m_printParametrization {false}
bool m_CompressMemory {true}
bool m_runOnGPU {false}

Detailed Description

Definition at line 22 of file FastCaloSimV2ParamSvc.h.

Constructor & Destructor Documentation

◆ FastCaloSimV2ParamSvc()

ISF::FastCaloSimV2ParamSvc::FastCaloSimV2ParamSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters.

Constructor.

Definition at line 44 of file FastCaloSimV2ParamSvc.cxx.

45 : base_class(name, svc)
46 , m_detStore( "StoreGateSvc/DetectorStore", name )
47
48{
49 declareProperty( "DetStore",
51 "Handle to a StoreGateSvc/DetectorStore instance: it will be used to "
52 "retrieve data during the course of the job" );
53 declareProperty("ParamsInputFilename" , m_paramsFilename);
54 declareProperty("ParamsInputObject" , m_paramsObject);
55 declareProperty("PrintParametrization" , m_printParametrization);
56 declareProperty("CompressMemory" , m_CompressMemory);
57 declareProperty("RunOnGPU" , m_runOnGPU);
58}
ServiceHandle< StoreGateSvc > m_detStore
Pointer to StoreGate (detector store by default)

◆ ~FastCaloSimV2ParamSvc()

virtual ISF::FastCaloSimV2ParamSvc::~FastCaloSimV2ParamSvc ( )
virtualdefault

Destructor.

Member Function Documentation

◆ detStore()

const ServiceHandle< StoreGateSvc > & ISF::FastCaloSimV2ParamSvc::detStore ( ) const
inlineprivate

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 74 of file FastCaloSimV2ParamSvc.h.

75{ return m_detStore; }

◆ initialize()

StatusCode ISF::FastCaloSimV2ParamSvc::initialize ( )
finaloverridevirtual

Athena algorithm's interface methods.

framework methods

does not take ownership

Definition at line 61 of file FastCaloSimV2ParamSvc.cxx.

62{
63 const FCALDetectorManager *fcalManager{};
64 ATH_CHECK(detStore()->retrieve(fcalManager));
65
66 m_caloGeo = std::make_unique<CaloGeometryFromCaloDDM>();
67
68 const CaloDetDescrManager* caloMgr = detStore()->tryConstRetrieve<CaloDetDescrManager>(caloMgrStaticKey);
69 if(caloMgr) {
70 m_caloGeo->LoadGeometryFromCaloDDM(caloMgr);
71 }
72 else {
73 std::unique_ptr<CaloDetDescrManager> caloMgrPtr = buildCaloDetDescrNoAlign(serviceLocator()
75 m_caloGeo->LoadGeometryFromCaloDDM(caloMgrPtr.get());
76 ATH_CHECK(detStore()->record(std::move(caloMgrPtr), caloMgrStaticKey));
77 }
78
79 if (!m_caloGeo->LoadFCalChannelMapFromFCalDDM(fcalManager)) {
80 ATH_MSG_FATAL("Found inconsistency between FCal_Channel map and GEO file. Please, check if they are configured properly.");
81 return StatusCode::FAILURE;
82 }
83
84 const std::string fileName = m_paramsFilename; //?
85 std::string inputFile=PathResolverFindCalibFile(fileName);
86 std::unique_ptr<TFile> paramsFile(TFile::Open( inputFile.c_str(), "READ" ));
87 if (paramsFile == nullptr) {
88 ATH_MSG_ERROR("file = "<<m_paramsFilename<< " not found");
89 return StatusCode::FAILURE;
90 }
91 ATH_MSG_INFO("Opened parametrization file = "<<m_paramsFilename);
92 paramsFile->ls();
93 m_param=static_cast<TFCSParametrizationBase*>(paramsFile->Get(m_paramsObject.c_str()));
94 if (!m_param) {
95 ATH_MSG_WARNING("file = "<<m_paramsFilename<< ", object "<< m_paramsObject<<" not found");
96 return StatusCode::FAILURE;
97 }
98
99 paramsFile->Close();
100
101 if(m_CompressMemory) m_param->RemoveDuplicates();
102 m_param->set_geometry(m_caloGeo.get());
103 m_param->setLevel(msg().level());
105 m_param->Print("short");
106 }
107 if(m_CompressMemory) m_param->RemoveNameTitle();
108
109#ifdef USE_GPU
110
111 // if no GPU is found then run on CPU
112 if( !m_runOnGPU )
113 return StatusCode::SUCCESS;
114 if( AthCUDA::Info::instance().nDevices() == 0 ) {
115 ATH_MSG_WARNING( "no GPU device is found, will run everything on the CPU." );
116 m_runOnGPU=false;
117 return StatusCode::SUCCESS;
118 }
119
120 // FCS-GPU
121 // copy the geometry and parameterization files to GPU
122 ATH_MSG_INFO("start copying all parametrization files to GPU");
123 m_param->Copy2GPU();
124 //random seed for curand in GPU
125 unsigned long long seed=23424352;
126 m_rd4h = CaloGpuGeneral::Rand4Hits_init( MAXHITS, MAXBINS, seed, true );
127 //construct and load Geometry in GPU
128 ATH_MSG_INFO("start loading Geometry in GPU");
129 m_gl = new GeoLoadGpu();
130 CaloGeometry* calogeo=m_caloGeo.get();
131 m_gl->set_ncells( calogeo->get_cells()->size() );
132
133 if(calogeo->get_cells()->size() ==0 ) return StatusCode::SUCCESS;
134
135 m_gl->set_max_sample( CaloGeometry::MAX_SAMPLING);
136 int nrgns= calogeo->get_tot_regions();
137 m_gl->set_nregions( nrgns);
138
139
140 if(!convert_cellmap(calogeo->get_cells(),&m_cellmap_gpu)){
141 ATH_MSG_ERROR("can not convert the CaloDetDescrElement to CaloDetDescrElement_GPU ");
142 }
143 m_gl->set_cellmap( &m_cellmap_gpu);
144 GeoRegion* GR_ptr = (GeoRegion*)malloc( nrgns *sizeof( GeoRegion ));
145 m_gl->set_regions( GR_ptr );
146
147 Rg_Sample_Index* si = (Rg_Sample_Index*)malloc(CaloGeometry::MAX_SAMPLING * sizeof( Rg_Sample_Index ) ) ;
148
149 m_gl->set_sample_index_h( si );
150 //set regions
151 int i = 0;
152 for ( int is = 0; is < CaloGeometry::MAX_SAMPLING; ++is ) {
153 si[is].index = i;
154 int nr = calogeo->get_n_regions( is );
155 si[is].size = nr;
156 for ( int ir = 0; ir < nr; ++ir ) region_data_cpy( calogeo->get_region( is, ir), &GR_ptr[i++] );
157 }
158
159 if(m_gl->LoadGpu())
160 ATH_MSG_INFO("calo geometry loaded successfully in GPU");
161 else
162 ATH_MSG_ERROR("can not load calo geoemtry in GPU");
163#endif
164
165 return StatusCode::SUCCESS;
166}
#define MAXHITS
Definition Args.h:11
#define MAXBINS
Definition Args.h:12
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
std::unique_ptr< CaloDetDescrManager > buildCaloDetDescrNoAlign(ISvcLocator *svcLocator, IMessageSvc *msgSvc)
static constexpr const char * caloMgrStaticKey
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
static const Info & instance()
Singleton accessor function.
static const int MAX_SAMPLING
std::unique_ptr< CaloGeometryFromCaloDDM > m_caloGeo
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
TFCSParametrizationBase * m_param
int ir
counter of the current depth
Definition fastadd.cxx:49
IMessageSvc * getMessageSvc(bool quiet=false)
void * Rand4Hits_init(long long, unsigned short, unsigned long long, bool)
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
MsgStream & msg
Definition testRead.cxx:32

◆ simulate()

StatusCode ISF::FastCaloSimV2ParamSvc::simulate ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
finaloverridevirtual

Simulation Call.

Definition at line 169 of file FastCaloSimV2ParamSvc.cxx.

170{
171#ifdef USE_GPU
172 if( m_runOnGPU ) {
173 simulstate.set_gpu_rand (m_rd4h );
174 simulstate.set_geold( m_gl );
175 }
176 else
177 simulstate.set_geold( nullptr );
178#endif
179
180 FCSReturnCode status = m_param->simulate(simulstate, truth, extrapol);
181 if (status != FCSSuccess) {
182 return StatusCode::FAILURE;
183 }
184
185 return StatusCode::SUCCESS;
186}
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
status
Definition merge.py:16

Member Data Documentation

◆ m_caloGeo

std::unique_ptr<CaloGeometryFromCaloDDM> ISF::FastCaloSimV2ParamSvc::m_caloGeo {}
private

Definition at line 61 of file FastCaloSimV2ParamSvc.h.

61{};

◆ m_CompressMemory

bool ISF::FastCaloSimV2ParamSvc::m_CompressMemory {true}
private

Definition at line 64 of file FastCaloSimV2ParamSvc.h.

64{true};

◆ m_detStore

ServiceHandle<StoreGateSvc> ISF::FastCaloSimV2ParamSvc::m_detStore
private

Pointer to StoreGate (detector store by default)

Definition at line 54 of file FastCaloSimV2ParamSvc.h.

◆ m_param

TFCSParametrizationBase* ISF::FastCaloSimV2ParamSvc::m_param {}
private

Definition at line 59 of file FastCaloSimV2ParamSvc.h.

59{};

◆ m_paramsFilename

std::string ISF::FastCaloSimV2ParamSvc::m_paramsFilename {"TFCSparam.root"}
private

Definition at line 56 of file FastCaloSimV2ParamSvc.h.

56{"TFCSparam.root"};

◆ m_paramsObject

std::string ISF::FastCaloSimV2ParamSvc::m_paramsObject {"SelPDGID"}
private

Definition at line 57 of file FastCaloSimV2ParamSvc.h.

57{"SelPDGID"};

◆ m_printParametrization

bool ISF::FastCaloSimV2ParamSvc::m_printParametrization {false}
private

Definition at line 63 of file FastCaloSimV2ParamSvc.h.

63{false};

◆ m_runOnGPU

bool ISF::FastCaloSimV2ParamSvc::m_runOnGPU {false}
private

Definition at line 65 of file FastCaloSimV2ParamSvc.h.

65{false};

The documentation for this class was generated from the following files: