ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
virtual ~FastCaloSimV2ParamSvc ()=default
 Destructor. More...
 
virtual StatusCode initialize () override final
 Athena algorithm's interface methods. More...
 
virtual StatusCode simulate (TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override final
 Simulation Call. More...
 

Private Member Functions

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

Private Attributes

ServiceHandle< StoreGateSvcm_detStore
 Pointer to StoreGate (detector store by default) More...
 
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",
50  m_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 }

◆ ~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; //?
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 
102  m_param->set_geometry(m_caloGeo.get());
103  m_param->setLevel(msg().level());
105  m_param->Print("short");
106  }
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 
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 }

◆ 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 }

Member Data Documentation

◆ m_caloGeo

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

Definition at line 61 of file FastCaloSimV2ParamSvc.h.

◆ m_CompressMemory

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

Definition at line 64 of file FastCaloSimV2ParamSvc.h.

◆ 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.

◆ m_paramsFilename

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

Definition at line 56 of file FastCaloSimV2ParamSvc.h.

◆ m_paramsObject

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

Definition at line 57 of file FastCaloSimV2ParamSvc.h.

◆ m_printParametrization

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

Definition at line 63 of file FastCaloSimV2ParamSvc.h.

◆ m_runOnGPU

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

Definition at line 65 of file FastCaloSimV2ParamSvc.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
FCSReturnCode
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Definition: TFCSParametrizationBase.h:41
AthCUDA::Info::instance
static const Info & instance()
Singleton accessor function.
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
FCALDetectorManager
A manager class providing access to readout geometry information for the forward calorimeter.
Definition: FCALDetectorManager.h:29
CaloGeometry::MAX_SAMPLING
static const int MAX_SAMPLING
Definition: CaloGeometry.h:29
ISF::FastCaloSimV2ParamSvc::m_runOnGPU
bool m_runOnGPU
Definition: FastCaloSimV2ParamSvc.h:65
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ISF::FastCaloSimV2ParamSvc::m_CompressMemory
bool m_CompressMemory
Definition: FastCaloSimV2ParamSvc.h:64
LArNewCalib_Delay_OFC_Cali.paramsFile
paramsFile
Definition: LArNewCalib_Delay_OFC_Cali.py:183
ISF::FastCaloSimV2ParamSvc::m_param
TFCSParametrizationBase * m_param
Definition: FastCaloSimV2ParamSvc.h:59
ISF::FastCaloSimV2ParamSvc::m_paramsObject
std::string m_paramsObject
Definition: FastCaloSimV2ParamSvc.h:57
ISF::FastCaloSimV2ParamSvc::m_printParametrization
bool m_printParametrization
Definition: FastCaloSimV2ParamSvc.h:63
TFCSParametrizationBase::simulate
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
Method in all derived classes to do some simulation.
Definition: TFCSParametrizationBase.cxx:32
CaloGpuGeneral::Rand4Hits_init
void * Rand4Hits_init(long long, unsigned short, unsigned long long, bool)
Definition: CaloGpuGeneral.cxx:8
RunActsMaterialValidation.extrapol
extrapol
Definition: RunActsMaterialValidation.py:90
ISF::FastCaloSimV2ParamSvc::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: FastCaloSimV2ParamSvc.h:74
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
CaloGeometry
Definition: CaloGeometry.h:27
TFCSParametrizationBase
Definition: TFCSParametrizationBase.h:46
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
Generate_dsid_ranseed.seed
seed
Definition: Generate_dsid_ranseed.py:10
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
lumiFormat.i
int i
Definition: lumiFormat.py:85
ISF::FastCaloSimV2ParamSvc::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Pointer to StoreGate (detector store by default)
Definition: FastCaloSimV2ParamSvc.h:54
ISF::FastCaloSimV2ParamSvc::m_caloGeo
std::unique_ptr< CaloGeometryFromCaloDDM > m_caloGeo
Definition: FastCaloSimV2ParamSvc.h:61
TFCSParametrizationBase::set_geometry
virtual void set_geometry(ICaloGeometry *geo)
Method to set the geometry access pointer.
Definition: TFCSParametrizationBase.cxx:24
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TFCSParametrizationBase::Print
void Print(Option_t *option="") const
Print object information.
Definition: TFCSParametrizationBase.cxx:52
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:132
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
FCSSuccess
@ FCSSuccess
Definition: TFCSParametrizationBase.h:41
TFCSParametrizationBase::RemoveNameTitle
void RemoveNameTitle()
Definition: TFCSParametrizationBase.cxx:200
ISF::FastCaloSimV2ParamSvc::m_paramsFilename
std::string m_paramsFilename
Definition: FastCaloSimV2ParamSvc.h:56
Rg_Sample_Index::index
int index
Definition: GeoGpu_structs.h:12
TFCSParametrizationBase::RemoveDuplicates
void RemoveDuplicates()
Definition: TFCSParametrizationBase.cxx:142
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ISF_FCS::MLogging::setLevel
virtual void setLevel(MSG::Level lvl)
Update outputlevel.
Definition: MLogging.cxx:105
Rg_Sample_Index
Definition: GeoGpu_structs.h:10
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
GeoLoadGpu
Definition: GeoLoadGpu.h:17
MAXBINS
#define MAXBINS
Definition: Args.h:12
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
GeoRegion
Definition: GeoRegion.h:18
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MAXHITS
#define MAXHITS
Definition: Args.h:11
merge.status
status
Definition: merge.py:17
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
buildCaloDetDescrNoAlign
std::unique_ptr< CaloDetDescrManager > buildCaloDetDescrNoAlign(ISvcLocator *svcLocator, IMessageSvc *msgSvc)
Definition: CaloDetDescrBuilder.cxx:791
Rg_Sample_Index::size
int size
Definition: GeoGpu_structs.h:11