|
ATLAS Offline Software
|
Go to the documentation of this file.
24 #include "CLHEP/Random/RandGaussZiggurat.h"
25 #include "CLHEP/Random/RandomEngine.h"
26 #include "GaudiKernel/ServiceHandle.h"
42 #include "Gaudi/Property.h"
43 #include "GaudiKernel/IChronoStatSvc.h"
44 #include "GaudiKernel/IIncidentSvc.h"
45 #include "GaudiKernel/IService.h"
46 #include "GaudiKernel/IToolSvc.h"
47 #include "GaudiKernel/TypeNameString.h"
48 #include "GaudiKernel/MsgStream.h"
57 using CLHEP::RandGaussZiggurat;
63 m_scidtool(
"CaloSuperCellIDTool"),
65 m_OnlSCHelper(nullptr),
66 m_incSvc(
"IncidentSvc",
name) {
104 "Specify to save hits");
127 ATH_MSG_INFO(
"***********************************************");
128 ATH_MSG_INFO(
"* Steering options for LArSCL1Maker algorithm *");
129 ATH_MSG_INFO(
"***********************************************");
136 "Electronic noise will be added in each SC for selected "
163 " In case of pileup, the trigger time subtraction is done in "
165 ATH_MSG_INFO(
" => LArSCL1Maker will not apply Trigger Time ");
193 ATH_MSG_ERROR(
"Could not access CaloCell_SuperCell_ID helper");
194 return StatusCode::FAILURE;
196 ATH_MSG_DEBUG(
"Successfully accessed CaloCell_SuperCell_ID helper");
219 return StatusCode::SUCCESS;
234 std::map<HWIdentifier, size_t> IDtoIndexMap;
238 bkgDigitsPtr = bkgDigits.
cptr();
239 unsigned int digitCount(0);
240 for (
const auto*
const bkgDigit : *bkgDigitsPtr) {
241 IDtoIndexMap.insert({bkgDigit->channelID(), digitCount});
245 if ((
unsigned int)bkgDigitsPtr->at(0)->nsamples() !=
m_nSamples) {
248 "Uncompatible background and signal LArDigit size : Overlay "
249 "requested but will not be performed");
271 auto scContainer = std::make_unique<LArDigitContainer>();
274 scContainer->reserve(nbSC);
281 return StatusCode::FAILURE;
297 std::vector<std::vector<float> >
299 std::vector<std::vector<float> >
301 sumEnergy.resize(nbSC);
302 sumTime.resize(nbSC);
303 std::vector<float> scSumE;
304 int scSumEvecSize = 5;
306 scSumE.reserve(scSumEvecSize);
307 std::vector<std::vector<float> > scFloatContainerTmp;
311 scContainer->reserve(nbSC);
312 const std::vector<float> base_vec(0);
313 scFloatContainerTmp.assign(nbSC, base_vec);
314 std::vector<bool> alreadyThere;
315 alreadyThere.resize(nbSC);
316 alreadyThere.assign(nbSC,
false);
318 std::vector<float> truthE;
320 truthE.assign(nbSC, 0);
322 std::vector<HWIdentifier> hwid;
330 std::vector<float> samples;
332 std::vector<short> samplesInt;
336 for (;
it != it_end; ++
it) {
338 const std::vector<std::pair<float, float> >& timeE = hitlist.
getData();
339 if (!timeE.empty()) {
343 if (scHash.
value() == 999999)
348 hwid[scHWHash] = hwSC;
351 if ((adc2mev->ADC2MEV(hwSC, scGain)).size() < 2) {
354 factor = (adc2mev->ADC2MEV(hwSC, scGain))[1];
355 factor = 1.0 / fracS->FSAMPL(hwSC) / factor;
359 std::vector<float>&
vec = scFloatContainerTmp.at(scHWHash);
360 if (!alreadyThere[scHWHash]) {
361 alreadyThere[scHWHash] =
true;
362 for (
unsigned int i = 0;
i < samples.size();
i++) {
363 vec.push_back(factor * samples[
i]);
366 for (
unsigned int i = 0;
i < samples.size();
i++) {
367 vec[
i] += (factor * samples[
i]);
378 std::vector<float> zeroSamp;
387 CLHEP::HepRandomEngine* rndmEngine = rngWrapper->
getEngine(context);
388 for (;
it != it_end; ++
it) {
389 std::vector<float>* vecPtr = &zeroSamp;
390 if (alreadyThere[
it])
391 vecPtr = &(scFloatContainerTmp.at(
it));
392 std::vector<float>&
vec = *vecPtr;
400 size_t backGroundIdx = 999999;
401 if (addBkg && (IDtoIndexMap.find(
id) != IDtoIndexMap.end()))
402 backGroundIdx = IDtoIndexMap.find(
id)->second;
409 float SigmaNoise = (larnoise->noise(
id, 0));
411 const std::vector<float>& CorrGen = (autoCorrNoise->autoCorrSqrt(
id, 0));
413 RandGaussZiggurat::shootArray(rndmEngine,
static_cast<int>(
m_nSamples),
418 for (
int j = 0; j <=
i; j++) {
426 if (backGroundIdx < 999999) {
428 const std::vector<short>& bkgSamples =
429 bkgDigitsPtr->
at(backGroundIdx)->
samples();
430 samplesInt.assign(bkgSamples.begin(), bkgSamples.end());
432 int ped = pedestal->pedestal(
id, 0);
435 for (
unsigned int i = 0;
i <
vec.size();
i++) {
439 if (samplesInt[
i] < 0)
443 scContainer->push_back(dig);
449 IDtoIndexMap.clear();
452 m_chronSvc->chronoStop(
"LArSCL1Mk hit loop ");
453 m_chronSvc->chronoPrint(
"LArSCL1Mk hit loop ");
454 m_chronSvc->chronoStart(
"LArSCL1Mk SC loop ");
457 return StatusCode::SUCCESS;
462 ATH_MSG_INFO(
" LArSCL1Maker finalize completed successfully");
463 m_chronSvc->chronoPrint(
"LArSCL1Mk hit loop ");
464 m_chronSvc->chronoPrint(
"LArSCL1Mk TT loop ");
466 return StatusCode::SUCCESS;
476 const std::vector<std::pair<float, float> >& TimeE,
477 std::vector<float>& samples)
const {
495 nsamples_der = ShapeDer.size();
498 std::cout <<
" No samples for cell = " << hwSC << std::endl;
502 std::vector<std::pair<float, float> >::const_iterator
first = TimeE.begin();
503 std::vector<std::pair<float, float> >::const_iterator last = TimeE.end();
508 while (
first != last) {
510 time = (*first).second;
515 int ishift = (
int)(rint(
time * (1. / 25)));
516 double dtime =
time - 25. * ((
double)(ishift));
521 if (j < nsamples_der && std::fabs(ShapeDer[j]) < 10.)
522 samples[
i] += (Shape[j] - ShapeDer[j] * dtime) *
energy;
524 samples[
i] += Shape[j] *
energy;
StatusCode initialize()
Read ascii files for auxiliary data (puslse shapes, noise, etc...)
void printConditions(const HWIdentifier &hwSC)
Method to print SuperCell Conditions.
SeedingOptionType
Options for seeding option=0 is setSeed as in MC20 option=1 is setSeedLegacy as in MC16 option=2 is s...
unsigned int m_nSamples
output number of samples
bool m_useTriggerTime
Alorithm property: use trigger time or not.
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
const_pointer_type cptr()
Dereference the pointer.
bool m_NoiseOnOff
algorithm property: noise (in all sub-detectors) is on if true
unsigned int value() const
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
void setSeedLegacy(const std::string &algName, size_t slot, uint64_t ev, uint64_t run, uint64_t offset, SeedingOptionType seeding, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT)
Set the random seed using a string (e.g.
LArSCL1Maker(const std::string &name, ISvcLocator *pSvcLocator)
constructor
const std::vector< short > & samples() const
const LArOnline_SuperCellID * m_OnlSCHelper
pointer to the online LAr helper
bool m_noHadCalibMode
algorithm property: no calibration mode for had towers
SG::ReadHandleKey< LArDigitContainer > m_bkgDigitsKey
Background Digit Overlay, default key is Bkg_LArDigitSCL2.
std::string m_saveHitsContainer
StatusCode execute(const EventContext &context) const
Create LArSCL1 object save in TES (2 containers: 1 EM, 1 hadronic)
std::vector< size_t > vec
bool empty() const
Test if the key is blank.
const CaloCell_SuperCell_ID * m_scHelper
pointer to the offline TT helper
bool m_noEmCalibMode
algorithm property: no calibration mode for EM towers
bool m_PileUp
algorithm property: pile up or not
const LArHitList & GetCell(const unsigned int index) const
const T * retrieve(const EventContext &context, SG::ReadCondHandleKey< T > handleKey) const
~LArSCL1Maker()
destructor
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadCondHandleKey< LArAutoCorrNoise > m_autoCorrNoiseSCKey
Property: AutoCorr Noise (conditions input).
Gaudi::Property< std::string > m_randomStreamName
const LARLIST & getData() const
This class initializes the Calo (LAr and Tile) offline identifiers.
Liquid Argon digit base class.
SG::ReadCondHandleKey< ILArNoise > m_noiseSCKey
Property: Electronics Noise (conditions input).
::StatusCode StatusCode
StatusCode definition for legacy code.
SG::ReadCondHandleKey< ILArPedestal > m_pedestalSCKey
Property: Pedestal offset (conditions input).
void ConvertHits2Samples(const EventContext &context, const HWIdentifier &hwSC, CaloGain::CaloGain igain, const std::vector< std::pair< float, float > > &TimeE, std::vector< float > &samples) const
Method for converting Hits from samples (simplified version of the same method in LarPileUpTool)
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Helper class for offline supercell identifiers.
SG::ReadCondHandleKey< ILArfSampl > m_fracSKey
Property: Fraction of Energy Sampled (conditions input).
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
int m_BeginRunPriority
pointer to the TriggerTimeTool
IChronoStatSvc * m_chronSvc
bool m_chronoTest
algorithm property: switch chrono on
A wrapper class for event-slot-local random engines.
size_type channelHashMax(void) const
Define channel hash tables max size.
ServiceHandle< IAthRNGSvc > m_atRndmGenSvc
StatusCode initialize(bool used=true)
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
ToolHandle< ICaloSuperCellIDTool > m_scidtool
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
def time(flags, cells_name, *args, **kw)
Gaudi::Property< bool > m_useLegacyRandomSeeds
unsigned int m_firstSample
output first samples
Gaudi::Property< uint32_t > m_randomSeedOffset
const CaloCell_SuperCell_ID * getCaloCell_SuperCell_ID(void) const
Container class for LArDigit.
std::string m_SubDetectors
algorithm property: sub-detectors to be simulated
SG::ReadCondHandleKey< ILArShape > m_shapesKey
Property: Pulse shape (conditions input).
SG::WriteHandleKey< LArDigitContainer > m_sLArDigitsContainerKey
output Lar Digits SC container
int GetNbCells(void) const
const T * at(size_type n) const
Access an element, as an rvalue.
SG::ReadHandleKey< LArHitEMap > m_hitMapKey
hit map
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
const CaloCell_ID * m_OflHelper
pointer to the offline id helper
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevSCKey
Property: ADC2MeV conversion (conditions input).
interface to a tool that returns the time offset of the current trigger. Used by PileUpMergeSvc
Proxy for accessing a range of float values like a vector.
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size