16 #include "CLHEP/Random/RandomEngine.h"
17 #include "CLHEP/Random/RandFlat.h"
18 #include "CLHEP/Random/RandGaussZiggurat.h"
19 #include "CLHEP/Random/RandPoissonQ.h"
25 #include "Identifier/Identifier.h"
38 #include "CLHEP/Vector/LorentzVector.h"
43 #include "GaudiKernel/ITHistSvc.h"
50 const std::string&
name,
51 const IInterface*
parent) :
53 m_SimHitCollectionName (
"ALFA_HitCollection"),
54 m_SimODHitCollectionName (
"ALFA_ODHitCollection"),
55 m_key_DigitCollection (
"ALFA_DigitCollection"),
56 m_key_ODDigitCollection (
"ALFA_ODDigitCollection"),
57 m_digitCollection (nullptr),
58 m_ODdigitCollection (nullptr),
65 m_AmplitudeCut (0.24),
66 m_mergedALFA_HitList (nullptr),
67 m_mergedALFA_ODHitList (nullptr)
70 declareProperty(
"SimHitCollection",
m_SimHitCollectionName,
"Name of the input ALFA Sim Hit Collection of simulated hits");
71 declareProperty(
"SimODHitCollection",
m_SimODHitCollectionName,
"Name of the input ALFA Sim OD Hit Collection of simulated hits");
73 declareProperty(
"ALFA_DigitCollection",
m_key_DigitCollection,
"Name of the Collection to hold the output from the ALFA main detector digitization");
74 declareProperty(
"ALFA_ODDigitCollection",
m_key_ODDigitCollection,
"Name of the Collection to hold the output from the ALFA OD digitization");
84 declareProperty(
"mean",
m_mean);
108 return StatusCode::SUCCESS;
123 TimedALFAHitCollList tHitCollList;
124 TimedALFAODHitCollList tODHitCollList;
129 ATH_MSG_FATAL (
"Could not fill TimedALFAHitCollList" );
return StatusCode::FAILURE;
138 ATH_MSG_FATAL (
"Could not fill TimedALFAODHitCollList" );
return StatusCode::FAILURE;
140 else {
ATH_MSG_DEBUG (
"Retrieved TimedALFAODHitCollList" ); }
150 while (iHitColl != eHitColl) {
154 tALFAhit.
insert(iHitColl->first, tmpColl);
156 ATH_MSG_DEBUG (
" ALFA_HitCollection found with " << tmpColl->
size() <<
" hits " << iHitColl->first );
166 while (iODHitColl != eODHitColl) {
170 tALFAODhit.
insert(iODHitColl->first, tmpColl);
172 ATH_MSG_DEBUG (
" ALFA_ODHitCollection found with " << tmpColl->
size() <<
" hits " << iODHitColl->first );
181 ATH_MSG_FATAL (
" ALFA_PileUpTool::processAllSubEvents(): Could not record the empty ALFA digit container in StoreGate " );
return StatusCode::FAILURE;
183 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::processAllSubEvents(): ALFA Digit container is recorded in StoreGate " ); }
188 ATH_MSG_FATAL (
" ALFA_PileUpTool::processAllSubEvents(): Could not record the empty ALFA OD digit container in StoreGate " );
return StatusCode::FAILURE;
190 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::processAllSubEvents(): ALFA OD Digit container is recorded in StoreGate " ); }
200 CLHEP::HepRandomEngine* rngEngine = rngWrapper->
getEngine(ctx);
202 if (
sc.isFailure()) {
204 return StatusCode::SUCCESS;
211 if (
sc.isFailure()) {
213 return StatusCode::SUCCESS;
216 return StatusCode::SUCCESS;
224 ATH_MSG_DEBUG (
"ALFA_PileUpTool::prepareEvent() called for " << nInputEvents <<
" input events" );
228 if (
sc.isFailure()) {
ATH_MSG_FATAL (
" ALFA_PileUpTool::prepareEvent(): Could not record the empty digit container in StoreGate " );
return sc; }
229 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::prepareEvent(): Digit container is recorded in StoreGate " ); }
233 if (
sc.isFailure()) {
ATH_MSG_FATAL (
" ALFA_PileUpTool::prepareEvent(): Could not record the empty digit OD container in StoreGate " );
return sc; }
234 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::prepareEvent(): Digit OD container is recorded in StoreGate " ); }
239 return StatusCode::SUCCESS;
246 ATH_MSG_DEBUG (
"ALFA_PileUpTool::processBunchXing() " << bunchXing );
248 for (; iEvt!=eSubEvents; ++iEvt) {
252 <<
" bunch crossing : " << bunchXing
253 <<
" time offset : " << iEvt->time()
254 <<
" event number : " << iEvt->ptr()->eventNumber()
255 <<
" run number : " << iEvt->ptr()->runNumber()
263 ATH_MSG_ERROR (
"SubEvent ALFA_HitCollection not found in StoreGate " << seStore.name() );
265 return StatusCode::FAILURE;
268 ATH_MSG_DEBUG (
"SubEvent, ALFA_HitCollection found with " << tmpHitColl->
size() <<
" hits");
279 ATH_MSG_ERROR (
"SubEvent ALFA_ODHitCollection not found in StoreGate " << seStore.name() );
281 return StatusCode::FAILURE;
284 ATH_MSG_DEBUG (
"ALFA_ODHitCollection found with " << tmpODHitColl->
size() <<
" hits" );
292 return StatusCode::SUCCESS;
306 CLHEP::HepRandomEngine* rngEngine = rngWrapper->
getEngine(ctx);
308 if (
sc.isFailure()) {
310 return StatusCode::SUCCESS;
317 if (
sc.isFailure()) {
319 return StatusCode::SUCCESS;
322 return StatusCode::SUCCESS;
360 for (
int l = 0;
l < 8;
l++ )
362 for (
int i = 0;
i < 20;
i++ )
364 for (
int j = 0; j < 64; j++ )
376 int fiber, plate,
sign, station;
383 station = (*it)->GetStationNumber();
384 plate = (*it)->GetPlateNumber();
385 fiber = (*it)->GetFiberNumber();
386 sign = (*it)->GetSignFiber();
388 ATH_MSG_DEBUG (
"station=" << station <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" << ((*it)->GetEnergyDeposit()));
390 m_E_fib[station-1][2*(plate-1)+(1-
sign)/2][fiber-1] += ((*it)->GetEnergyDeposit());
404 for (
int l = 0;
l < 8;
l++ )
406 for (
int i = 0;
i < 20;
i++ )
408 for (
int j = 0; j < 64; j++ )
421 int fiber, plate,
sign, station;
426 for (;
it != itend; ++
it) {
428 station =
it->GetStationNumber();
429 plate =
it->GetPlateNumber();
430 fiber =
it->GetFiberNumber();
431 sign =
it->GetSignFiber();
433 ATH_MSG_DEBUG (
"station=" << station <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" <<
it->GetEnergyDeposit());
435 m_E_fib[station-1][2*(plate-1)+(1-
sign)/2][fiber-1] +=
it->GetEnergyDeposit();
449 for (
int l = 0;
l < 8;
l++ ){
450 for (
int i = 0;
i < 2;
i++ ){
451 for (
int j = 0; j < 3; j++ ){
452 for (
int k = 0;
k < 30;
k++ ){
463 int fiber, plate,
sign,
side, station;
471 station = (*it)->GetStationNumber();
472 side = (*it)->GetODSide();
473 plate = (*it)->GetPlateNumber();
474 fiber = (*it)->GetFiberNumber();
475 sign = (*it)->GetSignFiber();
478 ATH_MSG_DEBUG (
"station=" << station <<
", side=" <<
side <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" << ((*it)->GetEnergyDeposit()));
480 if (
sign==0)
m_E_ODfib[station-1][
side-1][plate-1][fiber+15] += ((*it)->GetEnergyDeposit());
481 else m_E_ODfib[station-1][
side-1][plate-1][fiber] += ((*it)->GetEnergyDeposit());
495 for (
int l = 0;
l < 8;
l++ ){
496 for (
int i = 0;
i < 2;
i++ ){
497 for (
int j = 0; j < 3; j++ ){
498 for (
int k = 0;
k < 30;
k++ ){
509 int fiber, plate,
sign,
side, station;
515 for (;
it != itend; ++
it) {
518 station =
it->GetStationNumber();
520 plate =
it->GetPlateNumber();
521 fiber =
it->GetFiberNumber();
522 sign =
it->GetSignFiber();
525 ATH_MSG_DEBUG (
"station=" << station <<
", side=" <<
side <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" <<
it->GetEnergyDeposit());
528 else m_E_ODfib[station-1][
side-1][plate-1][fiber] +=
it->GetEnergyDeposit();
538 ATH_MSG_DEBUG(
" ALFA_PileUpTool::fill_MD_DigitCollection()");
543 double amplitude = 0.;
547 for (
int l = 0;
l < 8;
l++ )
549 for (
int i = 0;
i < 20;
i++ )
551 for (
int j = 0; j < 64; j++ )
564 amplitude = CLHEP::RandGaussZiggurat::shoot(rndEngine, N_photo, sqrt(
pow(
m_sigma0,2)+N_photo*
pow(
m_sigma1,2)));
572 ATH_MSG_DEBUG(
" ALFA_Digitization::fillDigitCollection, amplitude " << amplitude);
573 ATH_MSG_DEBUG(
" station = " <<
l <<
", plate= " <<
i <<
", fiber=" << j );
584 for (
int l = 0;
l < 8;
l++ )
586 for (
int i = 0;
i < 20;
i++ )
588 for (
int j = 0; j < 64; j++ )
592 for (
int f = j+1;
f < 64;
f++)
594 rand_fib = CLHEP::RandFlat::shoot(rndEngine,0.,1.);
605 for (
int f = j-1;
f > -1;
f--)
607 rand_fib = CLHEP::RandFlat::shoot(rndEngine,0.,1.);
621 return StatusCode::SUCCESS;
634 double amplitude = 0.;
636 for (
int l = 0;
l < 8;
l++ )
638 for (
int i = 0;
i < 2;
i++ )
640 for (
int j = 0; j < 3; j++ )
642 for (
int k = 0;
k < 30;
k++)
659 ATH_MSG_DEBUG(
" ALFA_Digitization::fill_OD_DigitCollection, amplitude " << amplitude);
660 ATH_MSG_DEBUG(
" station = " <<
l <<
", side = " <<
i <<
", plate = " << j <<
", fiber = " <<
k);
671 return StatusCode::SUCCESS;
677 for (
unsigned int j=0; j<8; j++){
693 throw std::runtime_error(
"FATAL: mapping MD maroc-mapmt not found in Datapath.");
706 for (
unsigned int i=0;
i<127;
i++)
718 return StatusCode::FAILURE;
721 return StatusCode::SUCCESS;