![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
25 #include "Identifier/Identifier.h"
41 #include "HepPDT/ParticleDataTable.hh"
42 #include "GaudiKernel/IPartPropSvc.h"
45 #include "GaudiKernel/IToolSvc.h"
48 #include "GaudiKernel/SmartDataPtr.h"
49 #include "GaudiKernel/EventContext.h"
50 #include "GaudiKernel/ThreadLocalContext.h"
62 #include "CLHEP/Random/RandomEngine.h"
63 #include "CLHEP/Random/RandGaussZiggurat.h"
71 const std::string&
name,
131 return StatusCode::FAILURE;
147 IPartPropSvc* p_PartPropSvc(
nullptr);
148 static const bool CREATEIFNOTTHERE(
true);
149 ATH_CHECK(service(
"PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE));
187 return StatusCode::SUCCESS;
197 return StatusCode::SUCCESS;
215 TimedHitCollList hitCollList;
218 bSubEvents, eSubEvents).isSuccess()) &&
219 hitCollList.empty()) {
221 return StatusCode::FAILURE;
223 ATH_MSG_VERBOSE(hitCollList.size() <<
" TRTUncompressedHitCollection with key " <<
230 for( ; iColl != endColl; ++iColl){
233 ATH_MSG_DEBUG(
"TRTUncompressedHitCollection found with " << hitCollPtr->
size() <<
236 <<
" index: " << timeIndex.
index()
237 <<
" type: " << timeIndex.
type());
242 return StatusCode::SUCCESS;
259 ATH_MSG_ERROR (
"Folder holder TRT digitization version exists in condDB, but tag is faulty" );
260 return StatusCode::FAILURE;
262 ATH_MSG_DEBUG (
"Using Digitization version as defined in conditions tag" );
298 noiseThreshRndmEngine,
299 noiseElecResetRndmEngine,
327 pTRTsimdrifttimetool,
339 return StatusCode::SUCCESS;
345 std::set<int>& sim_hitids, std::set<Identifier>& simhitsIdentifiers,
346 CLHEP::HepRandomEngine *rndmEngine,
347 CLHEP::HepRandomEngine *strawRndmEngine,
348 CLHEP::HepRandomEngine *elecProcRndmEngine,
349 CLHEP::HepRandomEngine *elecNoiseRndmEngine,
350 CLHEP::HepRandomEngine *paiRndmEngine) {
363 if (fieldCondObj ==
nullptr) {
365 return StatusCode::FAILURE;
367 fieldCondObj->getInitializedCache (fieldCache);
373 ATH_CHECK(simDataMap.
record(std::make_unique<InDetSimDataCollection>() ));
376 if (not simDataMap.
isValid()) {
378 return StatusCode::FAILURE;
389 std::vector<InDetSimData::Deposit> depositVector(100);
395 int hitID((*i)->GetHitID());
402 sim_hitids.insert(hitID);
405 if ( hitID & 0xc0000000 ) {
406 ATH_MSG_ERROR (
"Hit ID not Valid (" << MSG::hex << hitID <<
")" << MSG::dec );
415 if ( !identifierOK ) {
416 ATH_MSG_ERROR (
"Ignoring simhits with suspicious identifier (1)" );
421 simhitsIdentifiers.insert(idStraw);
425 depositVector.clear();
430 (*hit_iter)->GetEnergyDeposit() );
434 ATH_MSG_VERBOSE (
"Deposit: trackID " << deposit.first <<
" energyDeposit " << deposit.second );
435 depositVector.emplace_back(std::move(deposit));
439 const double bunchCrossingTime(
hitTime(theHit) -
static_cast<double>(theHit->GetGlobalTime()));
442 if ( !depositVector.empty() &&
445 simDataMap->try_emplace(idStraw, std::move(depositVector));
462 bool emulateArFlag =
m_sumTool->getStatusHT(idStraw) == 6;
463 bool emulateKrFlag =
m_sumTool->getStatusHT(idStraw) == 7;
464 const int statusHT =
m_sumTool->getStatusHT(idStraw);
491 return StatusCode::SUCCESS;
499 CLHEP::HepRandomEngine *elecNoiseRndmEngine =
getRandomEngine(
"TRT_ElectronicsNoise", ctx);
500 CLHEP::HepRandomEngine *noiseRndmEngine =
getRandomEngine(
"TRT_NoiseDigitPool", ctx);
501 CLHEP::HepRandomEngine *strawRndmEngine =
getRandomEngine(
"TRT_ProcessStraw", ctx);
502 CLHEP::HepRandomEngine *elecProcRndmEngine =
getRandomEngine(
"TRT_ThresholdFluctuations", ctx);
503 CLHEP::HepRandomEngine *paiRndmEngine =
getRandomEngine(
"TRT_PAI", ctx);
508 return StatusCode::FAILURE;
514 ATH_MSG_DEBUG (
"TRTDigitizationTool::processAllSubEvents()" );
522 return StatusCode::FAILURE;
535 if (!hitCollection.
isValid()) {
536 ATH_MSG_ERROR(
"Could not get TRTUncompressedHitCollection container " << hitCollection.
name() <<
" from store " << hitCollection.
store());
537 return StatusCode::FAILURE;
545 ATH_MSG_DEBUG(
"TRTUncompressedHitCollection found with " << hitCollection->
size() <<
" hits");
548 TimedHitCollList hitCollList;
549 unsigned int numberOfSimHits(0);
550 if ( !(
m_mergeSvc->retrieveSubEvtsData(
m_dataObjectName, hitCollList, numberOfSimHits).isSuccess()) && hitCollList.empty() ) {
552 return StatusCode::FAILURE;
558 thpctrt.
reserve(numberOfSimHits);
565 while ( iColl != endColl ) {
571 thpctrt.
insert(iColl->first, p_collection);
572 ATH_MSG_DEBUG (
"TRTUncompressedHitCollection found with " << p_collection->
size() <<
" hits" );
578 std::set<int> sim_hitids;
579 std::set<Identifier> simhitsIdentifiers;
582 ATH_CHECK(this->
processStraws(ctx, thpctrt, sim_hitids, simhitsIdentifiers, rndmEngine, strawRndmEngine, elecProcRndmEngine, elecNoiseRndmEngine,paiRndmEngine));
588 const int numberOfDigitsBeforeNoise(
m_vDigits.size());
608 return StatusCode::FAILURE;
614 return StatusCode::SUCCESS;
618 const EventContext& ctx)
const
622 rngWrapper->
setSeed( rngName, ctx );
628 const EventContext& ctx)
const
631 rngWrapper->
setSeed(
streamName, ctx.slot(), randomSeedOffset, ctx.eventID().run_number() );
640 ATH_MSG_DEBUG(
"mergeEvent: there are " << ii->first <<
" events in bunch xing " << ii->second );
646 CLHEP::HepRandomEngine *elecNoiseRndmEngine =
getRandomEngine(
"TRT_ElectronicsNoise", ctx);
647 CLHEP::HepRandomEngine *noiseRndmEngine =
getRandomEngine(
"TRT_NoiseDigitPool", ctx);
648 CLHEP::HepRandomEngine *strawRndmEngine =
getRandomEngine(
"TRT_ProcessStraw", ctx);
649 CLHEP::HepRandomEngine *elecProcRndmEngine =
getRandomEngine(
"TRT_ThresholdFluctuations", ctx);
650 CLHEP::HepRandomEngine *paiRndmEngine =
getRandomEngine(
"TRT_PAI", ctx);
655 return StatusCode::FAILURE;
668 return StatusCode::FAILURE;
674 std::set<int> sim_hitids;
675 std::set<Identifier> simhitsIdentifiers;
679 ATH_CHECK(this->
processStraws(ctx, *
m_thpctrt, sim_hitids, simhitsIdentifiers, rndmEngine, strawRndmEngine, elecProcRndmEngine, elecNoiseRndmEngine,paiRndmEngine));
688 const unsigned int numberOfDigitsBeforeNoise(
m_vDigits.size());
708 return StatusCode::FAILURE;
714 return StatusCode::SUCCESS;
721 std::vector<TRTDigit>::const_iterator TRTDigitIter(
m_vDigits.begin());
722 std::vector<TRTDigit>::const_iterator endOfTRTDigits(
m_vDigits.end());
731 while (TRTDigitIter != endOfTRTDigits) {
732 ATH_MSG_DEBUG (
"Digit ID " << TRTDigitIter->GetStrawID() <<
" Digit " << TRTDigitIter->GetDigit() );
735 bool identifierOK(
false);
736 idStraw =
getIdentifier(TRTDigitIter->GetStrawID(), IdHash, layer_id, identifierOK);
738 ATH_MSG_ERROR (
"Ignoring simhits with suspicious identifier (2)" );
751 if (IdHash != IdHashOld) {
753 ATH_MSG_DEBUG (
"New TRT RDO Collection created with IdHash " <<
static_cast<int>(IdHash) );
760 return StatusCode::FAILURE;
771 ATH_MSG_FATAL (
"Failed to create the TRT_RDO_Collection before trying to add an RDO to it! IdHash = " <<
static_cast<int>(IdHash) );
773 return StatusCode::FAILURE;
779 return StatusCode::SUCCESS;
787 bool & statusok )
const
793 const int mask(0x0000001F);
794 const int word_shift(5);
795 int trtID, ringID, moduleID, layerID, strawID;
796 int wheelID, planeID, sectorID;
801 if ( !(hitID & 0x00200000) ) {
802 strawID = hitID &
mask;
803 hitID >>= word_shift;
804 layerID = hitID &
mask;
805 hitID >>= word_shift;
806 moduleID = hitID &
mask;
807 hitID >>= word_shift;
808 ringID = hitID &
mask;
809 trtID = hitID >> word_shift;
812 if ( barrelElement ) {
814 IdLayer = barrelElement->
identify();
817 ATH_MSG_ERROR (
"Could not find detector element for barrel identifier with "
818 <<
"(ipos,iring,imod,ilayer,istraw) = ("
819 << trtID <<
", " << ringID <<
", " << moduleID <<
", "
820 << layerID <<
", " << strawID <<
")" );
824 strawID = hitID &
mask;
825 hitID >>= word_shift;
826 planeID = hitID &
mask;
827 hitID >>= word_shift;
828 sectorID = hitID &
mask;
829 hitID >>= word_shift;
830 wheelID = hitID &
mask;
831 trtID = hitID >> word_shift;
834 if (trtID == 3) { trtID = 0; }
839 if ( endcapElement ) {
841 IdLayer = endcapElement->
identify();
844 ATH_MSG_ERROR (
"Could not find detector element for endcap identifier with "
845 <<
"(ipos,iwheel,isector,iplane,istraw) = ("
846 << trtID <<
", " << wheelID <<
", " << sectorID <<
", "
847 << planeID <<
", " << strawID <<
")" );
848 ATH_MSG_ERROR (
"If this happens very rarely, don't be alarmed (it is a Geant4 'feature')" );
849 ATH_MSG_ERROR (
"If it happens a lot, you probably have misconfigured geometry in the sim. job." );
867 return StatusCode::SUCCESS;
875 int dig_vers_from_condDB = (**digvers)[
"TRT_Dig_Vers"].data<
int>();
877 if (dig_vers_from_condDB!=0) {
880 ATH_MSG_INFO (
"Retrieved TRT_Settings from CondDB with TRT digitization version: digversion = " <<
881 dig_vers_from_condDB );
883 ATH_MSG_WARNING (
"Unknown TRT digitization version: digversion = " << dig_vers_from_condDB <<
884 " read from CondDB. Overriding to use default from Det Desc tag: " <<
889 ATH_MSG_WARNING (
"TRT digitization version: digversion = " << dig_vers_from_condDB <<
890 " read from CondDB. Overriding to use default from Det Desc tag: " <<
894 return StatusCode::SUCCESS;
903 return CLHEP::RandGaussZiggurat::shoot(rndmEngine, 5.48, 8.91);
def retrieve(aClass, aKey=None)
JetConstituentVector::iterator iterator
double pileUpSDOsMinEkin() const
Get minimum Ekin for pileup track to enter MC-truth.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
bool getT0FromData() const
bool doCosmicTimingPit() const
Cosmics timing corresponding to pit setup?
unsigned GetDigit() const
Get digit.
void setIdentifier(Identifier id)
const_pointer_type cptr()
Dereference the pointer.
bool useMagneticFieldMap() const
const std::string & name() const
Return the StoreGate ID for the referenced object.
const TRT_BarrelElement * getBarrelElement(unsigned int positive, unsigned int moduleIndex, unsigned int phiIndex, unsigned int strawLayerIndex) const
Access Barrel Elements:---------------—(Fast)-------------------------—.
static void sortDigits(std::vector< TRTDigit > &digitVect)
size_type straw_layer_hash_max(void) const
void appendCrossTalkNoiseToProperDigits(std::vector< TRTDigit > &digitVect, const std::set< Identifier > &simhitsIdentifiers, const ServiceHandle< ITRT_StrawNeighbourSvc > &m_TRTStrawNeighbourSvc, CLHEP::HepRandomEngine *noiseRndmEngine)
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
void printFlagsForOverrideableParameters(const std::string &front="") const
Print TRT digitization settings overrideable parameters.
void addPropertiesForOverrideableParameters(Algorithm *alg)
Add properties for overrideable parameters.
bool noiseInUnhitStraws() const
Query whether simulation of noise in unhit straws.
index_type index() const
the index of the component event in PileUpEventInfo
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
bool empty() const
Test if the key is blank.
bool nextDetectorElement(const_iterator &b, const_iterator &e)
sets an iterator range with the hits of current detector element returns a bool when done
std::list< value_t > type
type of the collection of timed data object
virtual IdentifierHash identifyHash() const override final
"Fake" straw map until "real" map is known.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Simulate TRT Electronics Noise For description of metod, see Thomas Kittelmanns PhD thesis chapters ...
InDetRawDataCollection< TRT_RDORawData > TRT_RDO_Collection
void appendPureNoiseToProperDigits(std::vector< TRTDigit > &digitVect, const std::set< int > &sim_hitids, CLHEP::HepRandomEngine *noiseRndmEngine)
Append noise digits to list of digits from proper hits.
void insert(const PileUpTimeEventIndex &timeEventIndex, const AtlasHitsVector< HIT > *inputCollection)
void reserve(unsigned int numberOfHits)
reserve a timed vector numberOfHits in size.
::StatusCode StatusCode
StatusCode definition for legacy code.
std::string store() const
Return the name of the store holding the object we are proxying.
Simulation of noise hits in the TRT.
const Version & getVersion() const
Get version information.
int majorNum() const
Major version number.
virtual Identifier identify() const override final
identifier of this detector element:
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual IdentifierHash identifyHash() const override final
identifier hash
bool noiseInSimhits() const
Query whether simulation of noise in hit straws.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TRT Digitization: Processing of a TRT Straws.
void ProcessStraw(MagField::AtlasFieldCache &fieldCache, hitCollConstIter i, hitCollConstIter e, TRTDigit &outdigit, bool &m_alreadyPrintedPDGcodeWarning, double m_cosmicEventPhase, int strawGasType, bool emulationArflag, bool emulationKrflag, CLHEP::HepRandomEngine *rndmEngine, CLHEP::HepRandomEngine *elecProcRndmEngine, CLHEP::HepRandomEngine *elecNoiseRndmEngine, CLHEP::HepRandomEngine *paiRndmEngine)
Process this straw all the way from Geant4 hit to output digit.
const TRT_EndcapElement * getEndcapElement(unsigned int positive, unsigned int wheelIndex, unsigned int strawLayerIndex, unsigned int phiIndex) const
Access Endcap Elements:---------------—(Fast)--------------------------—.
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
virtual bool isValid() override final
Can the handle be successfully dereferenced?
A wrapper class for event-slot-local random engines.
time_type time() const
bunch xing time in ns
value_type push_back(value_type pElem)
Add an element to the end of the collection.
static HepMcParticleLink getRedirectedLink(const HepMcParticleLink &particleLink, uint32_t eventIndex, const EventContext &ctx)
Return a HepMcParticleLink pointing at the same particle, but in a different GenEvent.
StatusCode initialize(bool used=true)
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
StatusCode DigSettingsFromCondDB(int m_dig_vers_from_condDB)
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
#define ATH_MSG_WARNING(x)
unsigned int storeSDO() const
double timeInterval() const
Get time interval covered by each digit.
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
void print(const std::string &front="") const
Printing of TRT digitization settings.
void initialize(const InDetDD::TRT_DetectorManager *detmgr)
Initialize: fill defaults and overwrite by user values where appropriate.
int StrawGasType(int statusHT, int useGasMix, MsgStream *log)
float hitTime(const AFP_SIDSimHit &hit)
Class containing parameters and settings used by TRT digitization.
std::pair< HepMcParticleLink, float > Deposit
Define macros for attributes used to control the static checker.
bool doCrosstalk() const
Switch on crosstalk noise based on Cosmic 08 measurements.
a struct encapsulating the identifier of a pile-up event
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
PileUpType type() const
the pileup type - minbias, cavern, beam halo, signal?
float strawAverageNoiseLevel() const
Get average noise level in straw.
Identifier straw_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer, int straw) const
Three ways of getting id for a single straw:
void initialize(CLHEP::HepRandomEngine *rndmEngine)
AtlasHitsVector< TRTUncompressedHit > TRTUncompressedHitCollection