16 #include "CLHEP/Random/RandomEngine.h"
17 #include "CLHEP/Random/RandFlat.h"
18 #include "CLHEP/Random/RandGaussZiggurat.h"
19 #include "CLHEP/Random/RandPoissonQ.h"
23 #include "Identifier/Identifier.h"
34 #include "CLHEP/Vector/LorentzVector.h"
39 #include "GaudiKernel/ITHistSvc.h"
51 const std::string&
name,
52 const IInterface*
parent) :
54 m_SimHitCollectionName (
"ALFA_HitCollection"),
55 m_SimODHitCollectionName (
"ALFA_ODHitCollection"),
56 m_key_DigitCollection (
"ALFA_DigitCollection"),
57 m_key_ODDigitCollection (
"ALFA_ODDigitCollection"),
58 m_digitCollection (nullptr),
59 m_ODdigitCollection (nullptr),
66 m_AmplitudeCut (0.24),
67 m_mergedALFA_HitList (nullptr),
68 m_mergedALFA_ODHitList (nullptr)
71 declareProperty(
"SimHitCollection",
m_SimHitCollectionName,
"Name of the input ALFA Sim Hit Collection of simulated hits");
72 declareProperty(
"SimODHitCollection",
m_SimODHitCollectionName,
"Name of the input ALFA Sim OD Hit Collection of simulated hits");
74 declareProperty(
"ALFA_DigitCollection",
m_key_DigitCollection,
"Name of the Collection to hold the output from the ALFA main detector digitization");
75 declareProperty(
"ALFA_ODDigitCollection",
m_key_ODDigitCollection,
"Name of the Collection to hold the output from the ALFA OD digitization");
85 declareProperty(
"mean",
m_mean);
109 return StatusCode::SUCCESS;
124 TimedALFAHitCollList tHitCollList;
125 TimedALFAODHitCollList tODHitCollList;
130 ATH_MSG_FATAL (
"Could not fill TimedALFAHitCollList" );
return StatusCode::FAILURE;
139 ATH_MSG_FATAL (
"Could not fill TimedALFAODHitCollList" );
return StatusCode::FAILURE;
141 else {
ATH_MSG_DEBUG (
"Retrieved TimedALFAODHitCollList" ); }
151 while (iHitColl != eHitColl) {
155 tALFAhit.
insert(iHitColl->first, tmpColl);
157 ATH_MSG_DEBUG (
" ALFA_HitCollection found with " << tmpColl->
size() <<
" hits " << iHitColl->first );
167 while (iODHitColl != eODHitColl) {
171 tALFAODhit.
insert(iODHitColl->first, tmpColl);
173 ATH_MSG_DEBUG (
" ALFA_ODHitCollection found with " << tmpColl->
size() <<
" hits " << iODHitColl->first );
182 ATH_MSG_FATAL (
" ALFA_PileUpTool::processAllSubEvents(): Could not record the empty ALFA digit container in StoreGate " );
return StatusCode::FAILURE;
184 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::processAllSubEvents(): ALFA Digit container is recorded in StoreGate " ); }
189 ATH_MSG_FATAL (
" ALFA_PileUpTool::processAllSubEvents(): Could not record the empty ALFA OD digit container in StoreGate " );
return StatusCode::FAILURE;
191 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::processAllSubEvents(): ALFA OD Digit container is recorded in StoreGate " ); }
201 CLHEP::HepRandomEngine* rngEngine = rngWrapper->
getEngine(ctx);
203 if (
sc.isFailure()) {
205 return StatusCode::SUCCESS;
212 if (
sc.isFailure()) {
214 return StatusCode::SUCCESS;
217 return StatusCode::SUCCESS;
225 ATH_MSG_DEBUG (
"ALFA_PileUpTool::prepareEvent() called for " << nInputEvents <<
" input events" );
229 if (
sc.isFailure()) {
ATH_MSG_FATAL (
" ALFA_PileUpTool::prepareEvent(): Could not record the empty digit container in StoreGate " );
return sc; }
230 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::prepareEvent(): Digit container is recorded in StoreGate " ); }
234 if (
sc.isFailure()) {
ATH_MSG_FATAL (
" ALFA_PileUpTool::prepareEvent(): Could not record the empty digit OD container in StoreGate " );
return sc; }
235 else {
ATH_MSG_DEBUG (
" ALFA_PileUpTool::prepareEvent(): Digit OD container is recorded in StoreGate " ); }
240 return StatusCode::SUCCESS;
247 ATH_MSG_DEBUG (
"ALFA_PileUpTool::processBunchXing() " << bunchXing );
249 for (; iEvt!=eSubEvents; ++iEvt) {
253 <<
" bunch crossing : " << bunchXing
254 <<
" time offset : " << iEvt->time()
255 <<
" event number : " << iEvt->ptr()->eventNumber()
256 <<
" run number : " << iEvt->ptr()->runNumber()
264 ATH_MSG_ERROR (
"SubEvent ALFA_HitCollection not found in StoreGate " << seStore.name() );
266 return StatusCode::FAILURE;
269 ATH_MSG_DEBUG (
"SubEvent, ALFA_HitCollection found with " << tmpHitColl->
size() <<
" hits");
280 ATH_MSG_ERROR (
"SubEvent ALFA_ODHitCollection not found in StoreGate " << seStore.name() );
282 return StatusCode::FAILURE;
285 ATH_MSG_DEBUG (
"ALFA_ODHitCollection found with " << tmpODHitColl->
size() <<
" hits" );
293 return StatusCode::SUCCESS;
307 CLHEP::HepRandomEngine* rngEngine = rngWrapper->
getEngine(ctx);
309 if (
sc.isFailure()) {
311 return StatusCode::SUCCESS;
318 if (
sc.isFailure()) {
320 return StatusCode::SUCCESS;
323 return StatusCode::SUCCESS;
361 for (
int l = 0;
l < 8;
l++ )
363 for (
int i = 0;
i < 20;
i++ )
365 for (
int j = 0; j < 64; j++ )
377 int fiber, plate,
sign, station;
384 station = (*it)->GetStationNumber();
385 plate = (*it)->GetPlateNumber();
386 fiber = (*it)->GetFiberNumber();
387 sign = (*it)->GetSignFiber();
389 ATH_MSG_DEBUG (
"station=" << station <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" << ((*it)->GetEnergyDeposit()));
391 m_E_fib[station-1][2*(plate-1)+(1-
sign)/2][fiber-1] += ((*it)->GetEnergyDeposit());
405 for (
int l = 0;
l < 8;
l++ )
407 for (
int i = 0;
i < 20;
i++ )
409 for (
int j = 0; j < 64; j++ )
422 int fiber, plate,
sign, station;
427 for (;
it != itend; ++
it) {
429 station =
it->GetStationNumber();
430 plate =
it->GetPlateNumber();
431 fiber =
it->GetFiberNumber();
432 sign =
it->GetSignFiber();
434 ATH_MSG_DEBUG (
"station=" << station <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" <<
it->GetEnergyDeposit());
436 m_E_fib[station-1][2*(plate-1)+(1-
sign)/2][fiber-1] +=
it->GetEnergyDeposit();
450 for (
int l = 0;
l < 8;
l++ ){
451 for (
int i = 0;
i < 2;
i++ ){
452 for (
int j = 0; j < 3; j++ ){
453 for (
int k = 0;
k < 30;
k++ ){
464 int fiber, plate,
sign,
side, station;
472 station = (*it)->GetStationNumber();
473 side = (*it)->GetODSide();
474 plate = (*it)->GetPlateNumber();
475 fiber = (*it)->GetFiberNumber();
476 sign = (*it)->GetSignFiber();
479 ATH_MSG_DEBUG (
"station=" << station <<
", side=" <<
side <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" << ((*it)->GetEnergyDeposit()));
481 if (
sign==0)
m_E_ODfib[station-1][
side-1][plate-1][fiber+15] += ((*it)->GetEnergyDeposit());
482 else m_E_ODfib[station-1][
side-1][plate-1][fiber] += ((*it)->GetEnergyDeposit());
496 for (
int l = 0;
l < 8;
l++ ){
497 for (
int i = 0;
i < 2;
i++ ){
498 for (
int j = 0; j < 3; j++ ){
499 for (
int k = 0;
k < 30;
k++ ){
510 int fiber, plate,
sign,
side, station;
516 for (;
it != itend; ++
it) {
519 station =
it->GetStationNumber();
521 plate =
it->GetPlateNumber();
522 fiber =
it->GetFiberNumber();
523 sign =
it->GetSignFiber();
526 ATH_MSG_DEBUG (
"station=" << station <<
", side=" <<
side <<
", plate= "<< plate <<
", fiber=" << fiber <<
", sign=" <<
sign <<
", dep energy=" <<
it->GetEnergyDeposit());
529 else m_E_ODfib[station-1][
side-1][plate-1][fiber] +=
it->GetEnergyDeposit();
539 ATH_MSG_DEBUG(
" ALFA_PileUpTool::fill_MD_DigitCollection()");
544 double amplitude = 0.;
548 for (
int l = 0;
l < 8;
l++ )
550 for (
int i = 0;
i < 20;
i++ )
552 for (
int j = 0; j < 64; j++ )
565 amplitude = CLHEP::RandGaussZiggurat::shoot(rndEngine, N_photo, sqrt(
pow(
m_sigma0,2)+N_photo*
pow(
m_sigma1,2)));
573 ATH_MSG_DEBUG(
" ALFA_Digitization::fillDigitCollection, amplitude " << amplitude);
574 ATH_MSG_DEBUG(
" station = " <<
l <<
", plate= " <<
i <<
", fiber=" << j );
585 for (
int l = 0;
l < 8;
l++ )
587 for (
int i = 0;
i < 20;
i++ )
589 for (
int j = 0; j < 64; j++ )
593 for (
int f = j+1;
f < 64;
f++)
595 rand_fib = CLHEP::RandFlat::shoot(rndEngine,0.,1.);
606 for (
int f = j-1;
f > -1;
f--)
608 rand_fib = CLHEP::RandFlat::shoot(rndEngine,0.,1.);
622 return StatusCode::SUCCESS;
635 double amplitude = 0.;
637 for (
int l = 0;
l < 8;
l++ )
639 for (
int i = 0;
i < 2;
i++ )
641 for (
int j = 0; j < 3; j++ )
643 for (
int k = 0;
k < 30;
k++)
660 ATH_MSG_DEBUG(
" ALFA_Digitization::fill_OD_DigitCollection, amplitude " << amplitude);
661 ATH_MSG_DEBUG(
" station = " <<
l <<
", side = " <<
i <<
", plate = " << j <<
", fiber = " <<
k);
672 return StatusCode::SUCCESS;
678 std::ifstream fXTalk;
679 std::stringstream
ss;
681 for (
unsigned int j=0; j<8; j++){
685 fname =
"Xtalk_station";
697 throw std::runtime_error(
"FATAL: mapping MD maroc-mapmt not found in Datapath.");
708 if (fXTalk.is_open())
710 for (
unsigned int i=0;
i<127;
i++)
722 return StatusCode::FAILURE;
725 return StatusCode::SUCCESS;