diff --git a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/MuonTrackingGeometry/MuonStationBuilder.h b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/MuonTrackingGeometry/MuonStationBuilder.h index b902f9a68d3652996c9142e9f96cbd113ba35e06..8092d6cd21e7f644ec43657fa8540d7eb20eb820 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/MuonTrackingGeometry/MuonStationBuilder.h +++ b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/MuonTrackingGeometry/MuonStationBuilder.h @@ -5,12 +5,12 @@ #ifndef MUONTRACKINGGEOMETRY_MUONSTATIONBUILDER_H #define MUONTRACKINGGEOMETRY_MUONSTATIONBUILDER_H -#include "MuonTrackingGeometry/MuonStationTypeBuilder.h" #include "TrkDetDescrInterfaces/IDetachedTrackingVolumeBuilder.h" #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" +#include "MuonTrackingGeometry/MuonStationTypeBuilder.h" #include "TrkDetDescrInterfaces/ITrackingVolumeHelper.h" #include "TrkGeometry/DetachedTrackingVolume.h" #include "TrkGeometry/TrackingVolume.h" @@ -57,20 +57,19 @@ namespace Muon { void identifyPrototype(const Trk::TrackingVolume*, int, int, Amg::Transform3D ) const; void getNSWStationsForTranslation(const GeoVPhysVol* pv, std::string name, Amg::Transform3D , std::vector<std::pair<std::pair<const GeoLogVol*,Trk::MaterialProperties*>,std::vector<Amg::Transform3D> > >& vols, std::vector<std::string>& volNames ) const; - const MuonGM::MuonDetectorManager* m_muonMgr; //!< the MuonDetectorManager + const MuonGM::MuonDetectorManager* m_muonMgr; Gaudi::Property<std::string> m_muonMgrLocation{this,"MuonDetManagerLocation","MuonMgr"}; //!< the location of the Muon Manager - ToolHandle<Muon::MuonStationTypeBuilder> m_muonStationTypeBuilder - {this,"StationTypeBuilder","Muon::MuonStationTypeBuilder/MuonStationTypeBuilder"}; //!< Helper Tool to create TrackingVolume Arrays - ToolHandle<Trk::ITrackingVolumeHelper> m_trackingVolumeHelper{this,"TrackingVolumeHelper","Trk::TrackingVolumeHelper/TrackingVolumeHelper"}; //!< Helper Tool to create TrackingVolumes - - Trk::Material m_muonMaterial; //!< the material - std::unique_ptr<Trk::GeoShapeConverter> m_geoShapeConverter; //!< shape converter - std::unique_ptr<Trk::GeoMaterialConverter> m_materialConverter; //!< material converter - Gaudi::Property<bool> m_buildBarrel{this,"BuildBarrelStations",true}; - Gaudi::Property<bool> m_buildEndcap{this,"BuildEndcapStations",true}; - Gaudi::Property<bool> m_buildCsc{this,"BuildCSCStations",true}; - Gaudi::Property<bool> m_buildTgc{this,"BuildTGCStations",true}; + ToolHandle<Muon::MuonStationTypeBuilder> m_muonStationTypeBuilder{this,"StationTypeBuilder","Muon::MuonStationTypeBuilder/MuonStationTypeBuilder"}; //!< Helper Tool to create TrackingVolume Arrays + ToolHandle<Trk::ITrackingVolumeHelper> m_trackingVolumeHelper{this,"TrackingVolumeHelper","Trk::TrackingVolumeHelper/TrackingVolumeHelper"}; //!< Helper Tool to create TrackingVolumes + + Trk::Material m_muonMaterial; //!< the material + std::unique_ptr<Trk::GeoShapeConverter> m_geoShapeConverter; //!< shape converter + std::unique_ptr<Trk::GeoMaterialConverter> m_materialConverter; //!< material converter + Gaudi::Property<bool> m_buildBarrel{this,"BuildBarrelStations",true}; + Gaudi::Property<bool> m_buildEndcap{this,"BuildEndcapStations",true}; + Gaudi::Property<bool> m_buildCsc{this,"BuildCSCStations",true}; + Gaudi::Property<bool> m_buildTgc{this,"BuildTGCStations",true}; }; diff --git a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonStationBuilder.cxx b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonStationBuilder.cxx index 6beaf1c1adff2d53860c07a0130c750cb7ae02d2..e526e3f628b864f6ab8271e681a3648de1484fd8 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonStationBuilder.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonStationBuilder.cxx @@ -12,9 +12,7 @@ #include "MuonReadoutGeometry/TgcReadoutElement.h" #include "MuonReadoutGeometry/sTgcReadoutElement.h" #include "MuonReadoutGeometry/MMReadoutElement.h" -// Amg #include "GeoPrimitives/GeoPrimitives.h" -// Trk #include "TrkDetDescrInterfaces/ITrackingVolumeArrayCreator.h" #include "TrkDetDescrInterfaces/IDetachedTrackingVolumeBuilder.h" #include "TrkDetDescrUtils/BinUtility.h" diff --git a/MuonSpectrometer/MuonDigitization/MDT_Digitization/MDT_Digitization/RT_Relation_DB_DigiTool.h b/MuonSpectrometer/MuonDigitization/MDT_Digitization/MDT_Digitization/RT_Relation_DB_DigiTool.h index b384bfdc4e3fb9c47f3a91af69be5b9ff4869a93..dd8a1d889168bd42074364d04b8600ff856d5d4a 100644 --- a/MuonSpectrometer/MuonDigitization/MDT_Digitization/MDT_Digitization/RT_Relation_DB_DigiTool.h +++ b/MuonSpectrometer/MuonDigitization/MDT_Digitization/MDT_Digitization/RT_Relation_DB_DigiTool.h @@ -46,13 +46,11 @@ class RT_Relation_DB_DigiTool : public AthAlgTool, virtual public IMDT_Digitizat bool isTubeEfficient(double radius,CLHEP::HepRandomEngine *rndmEngine) const; //Data members - double m_effRadius; double m_maxRadius; const MuonGM::MuonDetectorManager* m_muonGeoMgr; - protected: - ToolHandle<MdtCalibrationDbTool> m_calibrationDbTool; - + ToolHandle<MdtCalibrationDbTool> m_calibrationDbTool{this,"CalibrationDbTool","MdtCalibrationDbTool"}; + Gaudi::Property<double> m_effRadius{this,"EffectiveRadius",14.4275}; }; diff --git a/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx index b5642a287e4b65e1dc26df8cdc4aaadfe56f2569..dec24ade6428a6284e259901cf1208815df7f33c 100644 --- a/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx +++ b/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx @@ -824,8 +824,8 @@ bool MdtDigitizationTool::createDigits(MdtDigitContainer* digitContainer, MuonSi } //-ForCosmics } - if(digitCollection==NULL) { - ATH_MSG_ERROR( "Trying to use NULL pointer digitCollection" ); + if(!digitCollection) { + ATH_MSG_ERROR( "Trying to use nullptr digitCollection" ); return false; } diff --git a/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/RT_Relation_DB_DigiTool.cxx b/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/RT_Relation_DB_DigiTool.cxx index 1b528fc3a141f41427c0f4414de75735ba3d545c..d00ece3e844001deb8f9d61b410f085ffd42673d 100644 --- a/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/RT_Relation_DB_DigiTool.cxx +++ b/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/RT_Relation_DB_DigiTool.cxx @@ -2,27 +2,22 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -#include "MDT_Digitization/MdtDigiToolInput.h" #include "MDT_Digitization/RT_Relation_DB_DigiTool.h" + +#include "MDT_Digitization/MdtDigiToolInput.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" #include <iostream> using namespace MuonGM; -RT_Relation_DB_DigiTool::RT_Relation_DB_DigiTool( const std::string& type, const std::string& name, const IInterface* parent ) -: AthAlgTool(type,name,parent) -, m_maxRadius(0) -, m_muonGeoMgr(0) -, m_calibrationDbTool("MdtCalibrationDbTool",this) -{ +RT_Relation_DB_DigiTool::RT_Relation_DB_DigiTool( const std::string& type, const std::string& name, const IInterface* parent) : + AthAlgTool(type,name,parent), + m_maxRadius(0), + m_muonGeoMgr(nullptr) { declareInterface<IMDT_DigitizationTool>(this); - declareProperty("EffectiveRadius", m_effRadius = 14.4275); - declareProperty("CalibrationDbTool",m_calibrationDbTool); } - - StatusCode RT_Relation_DB_DigiTool::initialize() { ATH_MSG_INFO ("Initializing RT_Relation_DB_DigiTool"); @@ -38,10 +33,6 @@ StatusCode RT_Relation_DB_DigiTool::initialize() else { ATH_MSG_DEBUG("MuonGeoModelDetectorManager retrieved from StoreGate"); - //initialize the MdtIdHelper -// m_idHelper = m_muonGeoMgr->mdtIdHelper(); -// ATH_MSG_DEBUG("MdtIdHelper: " << m_idHelper ); -// if(!m_idHelper) return status; } } diff --git a/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_DigitizationTool.h b/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_DigitizationTool.h index 7f81668030166f963b476362b91069210c6d0932..a6d28573eeb238952c264d89bd12680678cee393 100644 --- a/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_DigitizationTool.h +++ b/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_DigitizationTool.h @@ -4,6 +4,7 @@ #ifndef MM_DIGITIZATIONTOOL_H #define MM_DIGITIZATIONTOOL_H + /** @class MM_DigitizationTool @section MM_DigitizerDetails Class methods and properties @@ -33,38 +34,31 @@ In the execute() method... */ +#include "PileUpTools/PileUpToolBase.h" #include "GaudiKernel/AlgTool.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "HitManagement/TimedHitCollection.h" #include "MuonSimEvent/MMSimHitCollection.h" #include "MuonSimEvent/MMSimHit.h" -#include "PileUpTools/PileUpToolBase.h" #include "MuonSimData/MuonSimDataCollection.h" #include "MuonDigitContainer/MmDigitContainer.h" - #include "MM_Digitization/MM_SortedHitVector.h" - #include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Geometry/Point3D.h" #include "CLHEP/Vector/ThreeVector.h" -#include "AthenaKernel/IAtRndmGenSvc.h" - -#include "MuonDigToolInterfaces/IMuonDigitizationTool.h" #include "MM_Digitization/MM_StripsResponseSimulation.h" #include "MM_Digitization/MM_ElectronicsResponseSimulation.h" #include "MM_Digitization/MM_StripVmmMappingTool.h" - #include "xAODEventInfo/EventInfo.h" // SubEventIterator #include "xAODEventInfo/EventAuxInfo.h"// SubEventIterator - #include "NSWCalibTools/INSWCalibSmearingTool.h" #include "NSWCalibTools/INSWCalibTool.h" - #include "MagFieldConditions/AtlasFieldCacheCondObj.h" #include "MagFieldElements/AtlasFieldCache.h" +#include "MM_Digitization/IMM_DigitizationTool.h" #include <string> #include <sstream> @@ -76,20 +70,16 @@ namespace MuonGM{ class MuonDetectorManager; } -namespace CLHEP{ - class HepRandomEngine; -} + class PileUpMergeSvc; class MicromegasHitIdHelper; -class IAtRndmGenSvc; -class IMM_DigitizationTool; class StoreGateSvc; class TTree; class TFile; /*******************************************************************************/ -class MM_DigitizationTool : virtual public IMuonDigitizationTool, public PileUpToolBase { +class MM_DigitizationTool : public PileUpToolBase { public: MM_DigitizationTool(const std::string& type, const std::string& name, const IInterface* parent); @@ -116,19 +106,12 @@ class MM_DigitizationTool : virtual public IMuonDigitizationTool, public PileUpT /** Just calls processAllSubEvents - leaving for back-compatibility (IMuonDigitizationTool) */ - StatusCode digitize(const EventContext& ctx) override; + StatusCode digitize(const EventContext& ctx); /** Finalize */ StatusCode finalize() override final; - /** accessors */ - ServiceHandle<IAtRndmGenSvc> getRndmSvc() const { return m_rndmSvc; } // Random number service - CLHEP::HepRandomEngine *getRndmEngine() const { return m_rndmEngine; } // Random number engine used - - - private: - /** Record MmDigitContainer and MuonSimDataCollection */ StatusCode getNextEvent(); StatusCode doDigitization(const EventContext& ctx); @@ -136,70 +119,65 @@ class MM_DigitizationTool : virtual public IMuonDigitizationTool, public PileUpT bool checkMMSimHit(const MMSimHit& /* hit */ ) const; MM_ElectronicsToolInput combinedStripResponseAllHits(const std::vector< MM_ElectronicsToolInput > & v_stripDigitOutput); - // Services - ServiceHandle<StoreGateSvc> m_storeGateService; - PileUpMergeSvc *m_mergeSvc; // Pile up service - ServiceHandle <IAtRndmGenSvc> m_rndmSvc; // Random number service - CLHEP::HepRandomEngine *m_rndmEngine; // Random nu - std::string m_rndmEngineName;// name of random enginember engine used - not init in SiDigitization - - SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj"}; - - // Tools - ToolHandle <IMM_DigitizationTool> m_digitTool; - TFile *m_file; - TTree *m_ntuple; - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - MicromegasHitIdHelper* m_muonHelper; - const MuonGM::MuonDetectorManager* m_MuonGeoMgr; - std::list<MMSimHitCollection*> m_MMHitCollList; + ToolHandle<Muon::INSWCalibSmearingTool> m_smearingTool{this,"SmearingTool","Muon::NSWCalibSmearingTool/MMCalibSmearingTool"}; + ToolHandle<Muon::INSWCalibTool> m_calibrationTool{this,"CalibrationTool","Muon::NSWCalibTool/NSWCalibTool"}; + ToolHandle<IMM_DigitizationTool> m_digitTool{this,"DigitizationTool","MM_Response_DigitTool","Tool which handles the digitization process"}; - // Settings - double m_energyThreshold; - int m_maskMultiplet; - bool m_writeOutputFile; - TimedHitCollection<MMSimHit>* m_timedHitCollection_MM; // the pileup hits + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj"}; - SG::WriteHandleKey<MmDigitContainer> m_outputDigitCollectionKey{this,"OutputObjectName","MM_DIGITS","WriteHandleKey for Output MmigitContainer"}; // name of the output digits - SG::WriteHandleKey<MuonSimDataCollection> m_outputSDO_CollectionKey{this,"OutputSDOName","MM_SDO","WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs + Gaudi::Property<std::string> m_inputObjectName{this,"InputObjectName","MicromegasSensitiveDetector","name of the input objects"}; + Gaudi::Property<std::string> m_vmmReadoutMode{this,"vmmReadoutMode","peak","For readout (DAQ) path. Can be peak or threshold"}; + Gaudi::Property<std::string> m_vmmARTMode{this,"vmmARTMode","threshold","For ART (trigger) path. Can be peak or threshold"}; - std::string m_inputObjectName; // name of the input objects - bool m_needsMcEventCollHelper; + Gaudi::Property<double> m_energyThreshold{this,"EnergyThreshold",50,"Minimal energy to produce a PRD"}; + Gaudi::Property<double> m_timeWindowLowerOffset{this,"WindowLowerOffset",-300,"processBunchXing between -250 and 150 ns (look at config file)"}; + Gaudi::Property<double> m_timeWindowUpperOffset{this,"WindowUpperOffset",300}; + Gaudi::Property<double> m_DiffMagSecondMuonHit{this,"DiffMagSecondMuonHit",0.1}; - bool m_checkMMSimHits; + Gaudi::Property<int> m_maskMultiplet{this,"MaskMultiplet",0,"0: all, 1: first, 2: second, 3: both"}; + Gaudi::Property<bool> m_writeOutputFile{this,"SaveInternalHistos",true}; + Gaudi::Property<bool> m_needsMcEventCollHelper{this,"UseMcEventCollectionHelper",false}; + Gaudi::Property<bool> m_checkMMSimHits{this,"CheckSimHits",true,"Control on the hit validity"}; + Gaudi::Property<bool> m_useTimeWindow{this,"UseTimeWindow",true}; + Gaudi::Property<bool> m_vmmNeighborLogic{this,"VMMNeighborLogic",true}; + Gaudi::Property<bool> m_doSmearing{this,"doSmearing",false,"set the usage or not of the smearing tool for realistic detector performance"}; - //TIMING SCHEME - bool m_useTimeWindow; + // Constants vars for the MM_StripsResponseSimulation class + // qThreshold=2e, we accept a good strip if the charge is >=2e - double m_timeWindowLowerOffset; - double m_timeWindowUpperOffset; - double m_DiffMagSecondMuonHit; + //Three gas mixture mode, Ar/CO2=93/7, Ar/CO2=80/20, Ar/CO2/Iso=93/5/2 + //each mode have different transverseDiffusionSigma/longitudinalDiffusionSigma/driftVelocity/avalancheGain/interactionDensityMean/interactionDensitySigma/lorentzAngle + Gaudi::Property<float> m_qThreshold{this,"qThreshold",0.001,"Charge Threshold"}; + Gaudi::Property<float> m_driftGapWidth{this,"DriftGapWidth",5.168,"Drift Gap Width of 5.04 mm + 0.128 mm (the amplification gap)"}; + Gaudi::Property<float> m_crossTalk1{this,"crossTalk1",0.1,"Strip Cross Talk with Nearest Neighbor"}; + Gaudi::Property<float> m_crossTalk2{this,"crossTalk2",0.03,"Strip Cross Talk with 2nd Nearest Neighbor"}; - // StripsResponse stuff... - MM_StripsResponseSimulation *m_StripsResponseSimulation; + Gaudi::Property<float> m_avalancheGain{this,"AvalancheGain",8.0e3,"avalanche Gain for rach gas mixture"}; - float m_qThreshold; - float m_driftGapWidth; - float m_driftVelocity; - float m_crossTalk1; - float m_crossTalk2; + // Constants vars for the MM_ElectronicsResponseSimulation + Gaudi::Property<float> m_peakTime{this,"peakTime",100,"The VMM peak time setting"}; + Gaudi::Property<float> m_electronicsThreshold{this,"electronicsThreshold",15000,"threshold Voltage for histoBNL, 2*(Intrinsic noise ~3k e)"}; + Gaudi::Property<float> m_stripdeadtime{this,"StripDeadTime",200,"dead-time for strip, default value 200 ns = 8 BCs"}; + Gaudi::Property<float> m_ARTdeadtime{this,"ARTDeadTime",200,"dead-time for ART, default value 200 ns = 8 BCs"}; - float m_avalancheGain; + SG::WriteHandleKey<MmDigitContainer> m_outputDigitCollectionKey{this,"OutputObjectName","MM_DIGITS","WriteHandleKey for Output MmigitContainer"}; // name of the output digits + SG::WriteHandleKey<MuonSimDataCollection> m_outputSDO_CollectionKey{this,"OutputSDOName","MM_SDO","WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs - // ElectronicsResponse stuff... - MM_ElectronicsResponseSimulation *m_ElectronicsResponseSimulation; - float m_peakTime; // VMM setting - float m_electronicsThreshold; // threshold "Voltage" for histoBNL - float m_stripdeadtime; // dead-time for strip - float m_ARTdeadtime; // dead-time for ART + PileUpMergeSvc *m_mergeSvc; // Pile up service - bool m_vmmNeighborLogic; // switch for the usage of the vmm neighbor logic + TFile *m_file; + TTree *m_ntuple; - std::string m_vmmReadoutMode; - std::string m_vmmARTMode; + MicromegasHitIdHelper* m_muonHelper; + const MuonGM::MuonDetectorManager* m_MuonGeoMgr; + std::list<MMSimHitCollection*> m_MMHitCollList; + TimedHitCollection<MMSimHit>* m_timedHitCollection_MM; // the pileup hits + MM_StripsResponseSimulation* m_StripsResponseSimulation; + MM_ElectronicsResponseSimulation* m_ElectronicsResponseSimulation; + float m_driftVelocity; int m_n_Station_side; int m_n_Station_eta; int m_n_Station_phi; @@ -214,27 +192,21 @@ class MM_DigitizationTool : virtual public IMuonDigitizationTool, public PileUpT double m_n_hitOnSurface_x; double m_n_hitOnSurface_y; double m_n_hitDistToChannel; - double m_n_hitIncomingAngle,m_n_StrRespTrg_Time; + double m_n_hitIncomingAngle; + double m_n_StrRespTrg_Time; double m_n_hitIncomingAngleRads; double m_n_hitKineticEnergy; double m_n_hitDepositEnergy; int m_exitcode; - float m_tofCorrection; + float m_tofCorrection; float m_bunchTime; float m_globalHitTime; float m_eventTime; std::vector<int> m_n_StrRespID; std::vector<float> m_n_StrRespCharge; std::vector<float> m_n_StrRespTime; - - /// tool handle for the smearing - bool m_doSmearing; - ToolHandle<Muon::INSWCalibSmearingTool> m_smearingTool; - - ToolHandle<Muon::INSWCalibTool> m_calibrationTool; - }; #endif // MM_DigitizationTool diff --git a/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_Digitizer.h b/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_Digitizer.h index 27278270fd83e0dd4e7802894089f465d073f7bb..63229ba42dc4199253fdd97d821198079b1ff9dc 100644 --- a/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_Digitizer.h +++ b/MuonSpectrometer/MuonDigitization/MM_Digitization/MM_Digitization/MM_Digitizer.h @@ -1,34 +1,27 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONDIGITIZATION_MM_DIGITIZER_H #define MUONDIGITIZATION_MM_DIGITIZER_H -/// Gaudi External #include "AthenaBaseComps/AthAlgorithm.h" #include "GaudiKernel/ToolHandle.h" -class IMuonDigitizationTool; +class IPileUpTool; -/*******************************************************************************/ class MM_Digitizer : public AthAlgorithm { public: - MM_Digitizer(const std::string& name, ISvcLocator* pSvcLocator); - ~MM_Digitizer(); + ~MM_Digitizer()=default; StatusCode initialize(); StatusCode execute(); - StatusCode finalize(); - private: - - ToolHandle<IMuonDigitizationTool> m_digTool{this, "DigitizationTool", "MM_DigitizationTool", "MMDigitizationTool name"}; + ToolHandle<IPileUpTool> m_digTool{this, "DigitizationTool", "MM_DigitizationTool", "MMDigitizationTool name"}; }; -/*******************************************************************************/ #endif // MUONDIGITIZATION_MM_DIGITIZER_H diff --git a/MuonSpectrometer/MuonDigitization/MM_Digitization/python/MM_DigitizationConfig.py b/MuonSpectrometer/MuonDigitization/MM_Digitization/python/MM_DigitizationConfig.py index a2c6ad27372a626e61f5c48b959d9352c46fb755..990cc63f393a3dda67eb82da3f6fad187d9cfb29 100644 --- a/MuonSpectrometer/MuonDigitization/MM_Digitization/python/MM_DigitizationConfig.py +++ b/MuonSpectrometer/MuonDigitization/MM_Digitization/python/MM_DigitizationConfig.py @@ -19,10 +19,6 @@ def MM_LastXing(): return 200 def MM_DigitizationTool(name="MM_DigitizationTool",**kwargs): - kwargs.setdefault("RndmSvc", jobproperties.Digitization.rndmSvc() ) - # set rndm seeds - mmRndm = kwargs.setdefault("RndmEngine","MM_Digitization") - jobproperties.Digitization.rndmSeedList.addSeed(mmRndm, 49261510, 105132394 ) if jobproperties.Digitization.doXingByXingPileUp(): kwargs.setdefault("FirstXing", MM_FirstXing() ) # this should match the range for the MM in Digitization/share/MuonDigitization.py kwargs.setdefault("LastXing", MM_LastXing() ) # this should match the range for the MM in Digitization/share/MuonDigitization.py diff --git a/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx index 0c2f03e6344539a7afc3e14be1f39d8694bdf332..31e0802bcacdde18c7528acf0d9b24600808d708 100644 --- a/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx +++ b/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx @@ -26,7 +26,6 @@ //MM digitization includes #include "MM_Digitization/MM_DigitizationTool.h" -#include "MM_Digitization/IMM_DigitizationTool.h" #include "MM_Digitization/MM_DigitToolInput.h" #include "MuonSimEvent/MM_SimIdToOfflineId.h" @@ -38,14 +37,8 @@ #include "TrkDetDescrUtils/GeometryStatics.h" #include "TrkEventPrimitives/LocalDirection.h" #include "TrkSurfaces/Surface.h" - -//Gaudi - Core -#include "GaudiKernel/MsgStream.h" -#include "StoreGate/StoreGateSvc.h" #include "PathResolver/PathResolver.h" #include "AIDA/IHistogram1D.h" - -//Geometry #include "MuonReadoutGeometry/MuonDetectorManager.h" #include "MuonReadoutGeometry/MMReadoutElement.h" #include "MuonReadoutGeometry/MuonChannelDesign.h" @@ -62,8 +55,7 @@ #include "GeneratorObjects/HepMcParticleLink.h" #include "AtlasHepMC/GenParticle.h" -//Random Numbers -#include "AthenaKernel/IAtRndmGenSvc.h" +#include "AthenaKernel/RNGWrapper.h" #include "MuonAGDDDescription/MMDetectorDescription.h" #include "MuonAGDDDescription/MMDetectorHelper.h" @@ -72,7 +64,6 @@ #include "MM_Digitization/MM_StripVmmMappingTool.h" //ROOT -// #include "TH1.h" #include "TTree.h" #include "TFile.h" #include "TString.h" @@ -88,138 +79,44 @@ using namespace MuonGM; /*******************************************************************************/ MM_DigitizationTool::MM_DigitizationTool(const std::string& type, const std::string& name, const IInterface* parent): PileUpToolBase(type, name, parent), - - // Services - m_storeGateService("StoreGateSvc", name), m_mergeSvc(nullptr), - m_rndmSvc("AtRndmGenSvc", name ), - m_rndmEngine(nullptr), - m_rndmEngineName("MuonDigitization"), - - // Tools - m_digitTool("MM_Response_DigitTool", this), m_file(nullptr), m_ntuple(nullptr), - - // Settings - m_energyThreshold(50.), - m_maskMultiplet(0), - m_writeOutputFile(false), + m_muonHelper(nullptr), + m_MuonGeoMgr(nullptr), + m_MMHitCollList(), m_timedHitCollection_MM(nullptr), - - m_inputObjectName(""), - - m_checkMMSimHits(true), - m_useTimeWindow(true), - - m_timeWindowLowerOffset(0), - m_timeWindowUpperOffset(0), - m_DiffMagSecondMuonHit (0), - - // Strip Response - m_StripsResponseSimulation(0), - m_qThreshold(0), // Strips Charge Threshold - m_crossTalk1(0), // Cross talk with nearest strip - m_crossTalk2(0), // Cross talk with 2nd nearest strip - - m_avalancheGain(0), - - // Electronics Response - m_ElectronicsResponseSimulation(0), - m_peakTime(0), - m_electronicsThreshold(0), - m_stripdeadtime(0), - m_ARTdeadtime(0), - - m_vmmNeighborLogic(true), - - m_vmmReadoutMode(""), - m_vmmARTMode(""), - + m_StripsResponseSimulation(nullptr), + m_ElectronicsResponseSimulation(nullptr), + m_driftVelocity(0), // Tree Branches... - m_n_Station_side(-999), - m_n_Station_eta(-999), - m_n_Station_phi(-999), - m_n_Station_multilayer(-999), - m_n_Station_layer(-999), - m_n_hitStripID(-999), - m_n_StrRespTrg_ID(-999), - m_n_strip_multiplicity(-999), - m_n_strip_multiplicity_2(-999), - m_n_hitPDGId(-99999999.), - m_n_hitOnSurface_x(-99999999.), - m_n_hitOnSurface_y(-99999999.), - m_n_hitDistToChannel(-99999999.), - m_n_hitIncomingAngle(-99999999.), - m_n_StrRespTrg_Time(-99999999.), - m_n_hitIncomingAngleRads(-99999999.), - m_n_hitKineticEnergy(-99999999.), - m_n_hitDepositEnergy(-99999999.), + m_n_Station_side(-INT_MAX), + m_n_Station_eta(-INT_MAX), + m_n_Station_phi(-INT_MAX), + m_n_Station_multilayer(-INT_MAX), + m_n_Station_layer(-INT_MAX), + m_n_hitStripID(-INT_MAX), + m_n_StrRespTrg_ID(-INT_MAX), + m_n_strip_multiplicity(-INT_MAX), + m_n_strip_multiplicity_2(-INT_MAX), + m_n_hitPDGId(-INT_MAX), + m_n_hitOnSurface_x(-DBL_MAX), + m_n_hitOnSurface_y(-DBL_MAX), + m_n_hitDistToChannel(-DBL_MAX), + m_n_hitIncomingAngle(-DBL_MAX), + m_n_StrRespTrg_Time(-DBL_MAX), + m_n_hitIncomingAngleRads(-DBL_MAX), + m_n_hitKineticEnergy(-DBL_MAX), + m_n_hitDepositEnergy(-DBL_MAX), m_exitcode(0), - // Timings - m_tofCorrection(-99999999.), - m_bunchTime(-99999999.), - m_globalHitTime(-99999999.), - m_eventTime(-99999999.), - m_doSmearing(false), - m_smearingTool("Muon::NSWCalibSmearingTool/MMCalibSmearingTool",this), - m_calibrationTool("Muon::NSWCalibTool/NSWCalibTool",this) -{ - - declareInterface<IMuonDigitizationTool>(this); - - declareProperty("MCStore", m_storeGateService); - declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in Muon digitization"); - declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); - - declareProperty("DigitizationTool", m_digitTool, "Tool which handle the digitization process"); - declareProperty("EnergyThreshold", m_energyThreshold = 50., "Minimal energy to produce a PRD" ); - declareProperty("MaskMultiplet", m_maskMultiplet = 0, "0: all, 1: first, 2: second, 3: both" ); - - declareProperty("SaveInternalHistos", m_writeOutputFile = true ); - - //Object names - declareProperty("InputObjectName", m_inputObjectName = "MicromegasSensitiveDetector"); - declareProperty("UseMcEventCollectionHelper", m_needsMcEventCollHelper = false); - - //Configurations - declareProperty("CheckSimHits", m_checkMMSimHits = true, "Control on the hit validity"); // Currently deprecated - - //Timing scheme - declareProperty("UseTimeWindow", m_useTimeWindow = true); - declareProperty("WindowLowerOffset", m_timeWindowLowerOffset = -300.); // processBunchXing between -250 and 150 ns (look at config file) - declareProperty("WindowUpperOffset", m_timeWindowUpperOffset = +300.); - declareProperty("DiffMagSecondMuonHit",m_DiffMagSecondMuonHit = 0.1); - - // Constants vars for the MM_StripsResponseSimulation class - // qThreshold=2e, we accept a good strip if the charge is >=2e - - //Three gas mixture mode, Ar/CO2=93/7, Ar/CO2=80/20, Ar/CO2/Iso=93/5/2 - //each mode have different transverseDiffusionSigma/longitudinalDiffusionSigma/driftVelocity/avalancheGain/interactionDensityMean/interactionDensitySigma/lorentzAngle - declareProperty("qThreshold", m_qThreshold = 0.001); // Charge Threshold - declareProperty("DriftGapWidth", m_driftGapWidth = 5.168); // Drift Gap Width of 5.04 mm + 0.128 mm (the amplification gap) - declareProperty("crossTalk1", m_crossTalk1 = 0.1); // Strip Cross Talk with Nearest Neighbor - declareProperty("crossTalk2", m_crossTalk2 = 0.03); // Strip Cross Talk with 2nd Nearest Neighbor - - declareProperty("AvalancheGain", m_avalancheGain = 8.0e3); //avalanche Gain for rach gas mixture - - declareProperty("vmmReadoutMode", m_vmmReadoutMode = "peak" ); // For readout (DAQ) path. Can be "peak" or "threshold" - declareProperty("vmmARTMode", m_vmmARTMode = "threshold" ); // For ART (trigger) path. Can be "peak" or "threshold" - - // Constants vars for the MM_ElectronicsResponseSimulation - declareProperty("peakTime", m_peakTime = 100.); // The VMM peak time setting. - declareProperty("electronicsThreshold", m_electronicsThreshold = 15000.0); // 2*(Intrinsic noise ~3k e) - declareProperty("StripDeadTime", m_stripdeadtime = 200.0); // default value 200 ns = 8 BCs - declareProperty("ARTDeadTime", m_ARTdeadtime = 200.0); // default value 200 ns = 8 BCs - declareProperty("VMMNeighborLogic", m_vmmNeighborLogic = true); // default vmm neighbor logic on - - declareProperty("doSmearing", m_doSmearing=false); // set the usage or not of the smearing tool for realistic detector performance - declareProperty("SmearingTool",m_smearingTool); - - declareProperty("CalibrationTool", m_calibrationTool); - -} + m_tofCorrection(-FLT_MAX), + m_bunchTime(-FLT_MAX), + m_globalHitTime(-FLT_MAX), + m_eventTime(-FLT_MAX), + m_n_StrRespID(), + m_n_StrRespCharge(), + m_n_StrRespTime() {} /*******************************************************************************/ // member function implementation @@ -228,12 +125,8 @@ StatusCode MM_DigitizationTool::initialize() { ATH_MSG_DEBUG ("MM_DigitizationTool:: in initialize()") ; - // Initialize transient event store - ATH_CHECK(m_storeGateService.retrieve()); - // Initialize transient detector store and MuonGeoModel OR MuonDetDescrManager StoreGateSvc* detStore=nullptr; - m_MuonGeoMgr=nullptr; ATH_CHECK( serviceLocator()->service("DetectorStore", detStore) ); if(detStore->contains<MuonGM::MuonDetectorManager>( "Muon" )){ ATH_CHECK( detStore->retrieve(m_MuonGeoMgr) ); @@ -243,19 +136,7 @@ StatusCode MM_DigitizationTool::initialize() { ATH_CHECK(m_idHelperSvc.retrieve()); // Digit tools - ATH_CHECK( m_digitTool.retrieve() ); - - // Random Service - ATH_CHECK( m_rndmSvc.retrieve() ); - - // Random Engine from Random Service - ATH_MSG_DEBUG ( "Getting random number engine : <" << m_rndmEngineName << ">" ); - m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (m_rndmEngine == nullptr) { - ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName ); - return StatusCode::FAILURE; - } - + ATH_CHECK(m_digitTool.retrieve()); //initialize the output WriteHandleKeys if(m_outputDigitCollectionKey.key()=="") { @@ -352,30 +233,26 @@ StatusCode MM_DigitizationTool::initialize() { // Configuring various VMM modes of signal readout // - if( TString(m_vmmReadoutMode).Contains("peak", TString::kIgnoreCase) ) m_vmmReadoutMode = "peak"; - else if( TString(m_vmmReadoutMode).Contains("threshold",TString::kIgnoreCase) ) m_vmmReadoutMode = "threshold"; - else { - ATH_MSG_ERROR("MM_DigitizationTool can't interperet vmmReadoutMode option! (Should be 'peak' or 'threshold'.) Contains: " - << m_vmmReadoutMode); - } - if( TString(m_vmmARTMode).Contains("peak", TString::kIgnoreCase) ) m_vmmARTMode = "peak"; - else if( TString(m_vmmARTMode).Contains("threshold",TString::kIgnoreCase) ) m_vmmARTMode = "threshold"; - else { - ATH_MSG_ERROR("MM_DigitizationTool can't interperet vmmReadoutMode option! (Should be 'peak' or 'threshold'.) Contains: " - << m_vmmARTMode); - } - - if ( m_doSmearing ) { - - ATH_MSG_INFO("Running in smeared mode!"); - - } - + std::string vmmReadoutMode = m_vmmReadoutMode; + // convert vmmReadoutMode to lower case + std::for_each(vmmReadoutMode.begin(), vmmReadoutMode.end(), [](char & c) { + c = ::tolower(c); + }); + if (vmmReadoutMode.find("peak")!=std::string::npos) m_vmmReadoutMode = "peak"; + else if (vmmReadoutMode.find("threshold")!=std::string::npos) m_vmmReadoutMode = "threshold"; + else ATH_MSG_ERROR("MM_DigitizationTool can't interperet vmmReadoutMode option! (Should be 'peak' or 'threshold'.) Contains: " << m_vmmReadoutMode); + std::string vmmARTMode = m_vmmARTMode; + // convert vmmARTMode to lower case + std::for_each(vmmARTMode.begin(), vmmARTMode.end(), [](char & c) { + c = ::tolower(c); + }); + if (vmmARTMode.find("peak")!=std::string::npos) m_vmmARTMode = "peak"; + else if (vmmARTMode.find("threshold")!=std::string::npos) m_vmmARTMode = "threshold"; + else ATH_MSG_ERROR("MM_DigitizationTool can't interperet vmmARTMode option! (Should be 'peak' or 'threshold'.) Contains: " << m_vmmARTMode); + + if (m_doSmearing) ATH_MSG_INFO("Running in smeared mode!"); ATH_MSG_DEBUG ( "Configuration MM_DigitizationTool " ); - ATH_MSG_DEBUG ( "RndmSvc " << m_rndmSvc ); - ATH_MSG_DEBUG ( "RndmEngine " << m_rndmEngineName ); - ATH_MSG_DEBUG ( "MCStore " << m_storeGateService ); ATH_MSG_DEBUG ( "DigitizationTool " << m_digitTool ); ATH_MSG_DEBUG ( "InputObjectName " << m_inputObjectName ); ATH_MSG_DEBUG ( "OutputObjectName " << m_outputDigitCollectionKey.key()); @@ -1338,3 +1215,4 @@ MM_ElectronicsToolInput MM_DigitizationTool::combinedStripResponseAllHits(const bool MM_DigitizationTool::checkMMSimHit( const MMSimHit& /*hit*/ ) const { return true; } + diff --git a/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_Digitizer.cxx b/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_Digitizer.cxx index 5dd158d4b001ac4876d5f8484ab9f0884f2fb09f..405a034083680c6b951b05e21714b5d583e7abb4 100644 --- a/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_Digitizer.cxx +++ b/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_Digitizer.cxx @@ -1,39 +1,25 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -/// Gaudi External -#include "AthenaBaseComps/AthMsgStreamMacros.h" -#include "AthenaKernel/errorcheck.h" - -#include "MuonDigToolInterfaces/IMuonDigitizationTool.h" #include "MM_Digitization/MM_Digitizer.h" -/*******************************************************************************/ -MM_Digitizer::MM_Digitizer(const std::string& name, ISvcLocator* pSvcLocator) - : AthAlgorithm(name, pSvcLocator) -{ -} +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include "AthenaKernel/errorcheck.h" +#include "PileUpTools/IPileUpTool.h" /*******************************************************************************/ -MM_Digitizer::~MM_Digitizer() {} +MM_Digitizer::MM_Digitizer(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name, pSvcLocator) {} /*******************************************************************************/ StatusCode MM_Digitizer::initialize() { // intitialize store gate active store ATH_CHECK( m_digTool.retrieve() ); ATH_MSG_DEBUG ("MM_Digitizer::Retrieved MM Digitization Tool."); return StatusCode::SUCCESS; - } /*******************************************************************************/ StatusCode MM_Digitizer::execute() { ATH_MSG_DEBUG ("MM_Digitizer::in execute()"); - return m_digTool->digitize(Gaudi::Hive::currentContext()); -} -/*******************************************************************************/ -StatusCode MM_Digitizer::finalize() { - ATH_MSG_INFO ("MM_Digitizer::finalize"); - return StatusCode::SUCCESS; + return m_digTool->processAllSubEvents(Gaudi::Hive::currentContext()); } -/*******************************************************************************/ - diff --git a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.cxx b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.cxx index 886f33742324ab2dd96180f38efb4b61031bc765..b87c3a99bd4d6c10b7aa5d53f700317368acdee9 100644 --- a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.cxx +++ b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.cxx @@ -17,6 +17,7 @@ #include "TrkEventPrimitives/LocalDirection.h" #include "MuonAGDDDescription/MMDetectorDescription.h" #include "MuonAGDDDescription/MMDetectorHelper.h" +#include "AthenaKernel/RNGWrapper.h" #include <sstream> #include <iostream> @@ -85,14 +86,11 @@ MM_FastDigitizer::MM_FastDigitizer(const std::string& name, ISvcLocator* pSvcLoc m_surfcentx(0.), m_surfcenty(0.), m_surfcentz(0.), - m_muonClusterCreator("Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator"), - m_rndmSvc("AtRndmGenSvc", name ), - m_rndmEngine(0),m_inputObjectName("MicromegasSensitiveDetector"), + m_inputObjectName("MicromegasSensitiveDetector"), m_sdoName("MMfast_SDO") { declareProperty("InputObjectName", m_inputObjectName = "MicromegasSensitiveDetector", "name of the input object"); declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); - declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in Muon digitization"); declareProperty("UseTimeShift", m_useTimeShift = true, "Use time shift"); declareProperty("EnergyThreshold", m_energyThreshold = 50, "Minimal energy to produce a PRD" ); declareProperty("CheckIds", m_checkIds = false, "Turn on validity checking of Identifiers" ); @@ -126,13 +124,7 @@ StatusCode MM_FastDigitizer::initialize() { // getting our random numbers stream ATH_MSG_DEBUG ( "Getting random number engine : <" << m_rndmEngineName << ">" ); - ATH_CHECK( m_rndmSvc.retrieve() ); - m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (m_rndmEngine==0) { - ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName ); - return StatusCode::FAILURE; - } - + ATH_CHECK(m_rndmSvc.retrieve()); m_file = new TFile("MM_plots.root","RECREATE"); m_ntuple = new TTree("a","a"); @@ -197,6 +189,8 @@ StatusCode MM_FastDigitizer::execute() { SG::WriteHandle<MuonSimDataCollection> h_sdoContainer(m_sdoName); ATH_CHECK( h_sdoContainer.record ( std::make_unique<MuonSimDataCollection>() ) ); + CLHEP::HepRandomEngine* rndmEngine = getRandomEngine(m_rndmEngineName, Gaudi::Hive::currentContextEvt()); + MMPrepDataContainer* prdContainer = new MMPrepDataContainer(m_idHelperSvc->mmIdHelper().module_hash_max()); std::string key = "MM_Measurements"; ATH_MSG_DEBUG(" Done! Total number of MM chambers with PRDS: " << prdContainer->numberOfCollections() << " key " << key); @@ -341,7 +335,7 @@ StatusCode MM_FastDigitizer::execute() { resolution = .07; else resolution = ( -.001/3.*fabs(inAngle_XZ) ) + .28/3.; - double sp = CLHEP::RandGauss::shoot(m_rndmEngine, 0, resolution); + double sp = CLHEP::RandGauss::shoot(rndmEngine, 0, resolution); ATH_MSG_VERBOSE("slpos.z " << slpos.z() << ", ldir " << ldir.z() << ", scale " << scale << ", hitOnSurface.z " << hitOnSurface.z() ); @@ -350,15 +344,12 @@ StatusCode MM_FastDigitizer::execute() { // smeared local position Amg::Vector2D posOnSurf(hitOnSurface.x()+sp,hitOnSurface.y()); -// int digiMode = 0; // for large angles project perpendicular to surface if( fabs(inAngle_XZ) > 70 ){ posOnSurf[0]=(slpos.x()+sp); -// digiMode = 1; // if using timing information use hit position after shift }else if( m_useTimeShift && !m_microTPC ){ posOnSurf[0]=(hitAfterTimeShiftOnSurface.x()+sp); -// digiMode = 2; } ////// fill first part of ntuple @@ -511,7 +502,7 @@ StatusCode MM_FastDigitizer::execute() { cov->setIdentity(); (*cov.get())(0,0) = resolution*resolution; - tdrift = CurrentHitInDriftGap.z() / vdrift + CLHEP::RandGauss::shoot(m_rndmEngine, 0., 5.); + tdrift = CurrentHitInDriftGap.z() / vdrift + CLHEP::RandGauss::shoot(rndmEngine, 0., 5.); Amg::Vector2D CurrenPosOnSurf(CurrentHitInDriftGap.x(),CurrentHitInDriftGap.y()); stripNumber = detEl->stripNumber(CurrenPosOnSurf,layid); @@ -580,3 +571,12 @@ float MM_FastDigitizer::RadsToDegrees(float Radians) float Degrees = Radians * (180.) / M_PI; return Degrees; } + +CLHEP::HepRandomEngine* MM_FastDigitizer::getRandomEngine(const std::string& streamName, const EventContext& ctx) const +{ + ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName); + std::string rngName = name()+streamName; + rngWrapper->setSeed( rngName, ctx ); + return rngWrapper->getEngine(ctx); +} + diff --git a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.h b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.h index bc09af3b4ec57b5baa8f8c2b7d55d25d7a4b7bd6..7fc92b32b7ebc1816a0b02fcf5a52e8e0120f3c5 100644 --- a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.h +++ b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/MM_FastDigitizer.h @@ -12,27 +12,24 @@ #include "StoreGate/StoreGateSvc.h" #include "StoreGate/WriteHandleKey.h" #include "CLHEP/Random/RandomEngine.h" -#include "AthenaKernel/IAtRndmGenSvc.h" #include "CLHEP/Random/RandGauss.h" #include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonRecToolInterfaces/IMuonClusterOnTrackCreator.h" +#include "AthenaKernel/IAthRNGSvc.h" #include <string> -class TTree; -class TFile; - namespace MuonGM { class MuonDetectorManager; } - -//Random -namespace CLHEP{ +namespace CLHEP { class HepRandomEngine; } class ActiveStoreSvc; class MuonSimDataCollection; +class TTree; +class TFile; class MM_FastDigitizer : public AthAlgorithm { @@ -45,13 +42,11 @@ class MM_FastDigitizer : public AthAlgorithm { StatusCode execute(); StatusCode finalize(); - ServiceHandle<IAtRndmGenSvc> getRndmSvc() const { return m_rndmSvc; } // Random number service - CLHEP::HepRandomEngine *getRndmEngine() const { return m_rndmEngine; } // Random number engine used - float RadsToDegrees(float Radians); private: - ActiveStoreSvc* m_activeStore; + CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, const EventContext& ctx) const; + ActiveStoreSvc* m_activeStore; const MuonGM::MuonDetectorManager* m_detManager; TFile* m_file; @@ -111,9 +106,9 @@ class MM_FastDigitizer : public AthAlgorithm { protected: ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - ToolHandle <Muon::IMuonClusterOnTrackCreator> m_muonClusterCreator; - ServiceHandle <IAtRndmGenSvc> m_rndmSvc; // Random number service - CLHEP::HepRandomEngine *m_rndmEngine; // Random number engine used - not init in SiDigitization + ToolHandle<Muon::IMuonClusterOnTrackCreator> m_muonClusterCreator{this,"ClusterCreator","Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator"}; + ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", "Random Number Service used in Muon digitization"}; + std::string m_rndmEngineName;// name of random engine std::string m_inputObjectName; // name of the input objects SG::WriteHandleKey<MuonSimDataCollection> m_sdoName; // name of the output SDO collection diff --git a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.cxx b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.cxx index 4b7f43c8c13cf0e5074697baa4da95283eb5ab7a..59d8b7745c6a9562acd54cd557efa5a658bee245 100644 --- a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.cxx +++ b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.cxx @@ -17,6 +17,7 @@ #include "TrkSurfaces/Surface.h" #include "CLHEP/Random/RandFlat.h" #include "PathResolver/PathResolver.h" +#include "AthenaKernel/RNGWrapper.h" #include "TTree.h" #include "TFile.h" @@ -25,10 +26,10 @@ using namespace Muon; sTgcFastDigitizer::sTgcFastDigitizer(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator), - m_detManager(NULL), + m_detManager(nullptr), m_channelTypes(0), - m_file(NULL), - m_ntuple(NULL), + m_file(nullptr), + m_ntuple(nullptr), m_dlx(0.), m_dly(0.), m_dlz(0.), @@ -84,9 +85,6 @@ sTgcFastDigitizer::sTgcFastDigitizer(const std::string& name, ISvcLocator* pSvcL m_surfcentx(0.), m_surfcenty(0.), m_surfcentz(0.), - m_muonClusterCreator("Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator"), - m_rndmSvc("AtRndmGenSvc", name ), - m_rndmEngine(0), m_sdoName("STGCfast_SDO"), m_timeWindowOffsetWire(0.), m_timeWindowOffsetStrip(0.), @@ -94,10 +92,8 @@ sTgcFastDigitizer::sTgcFastDigitizer(const std::string& name, ISvcLocator* pSvcL m_timeWindowStrip(24.95), // TGC 40.94; // 40.94 ns = 26 ns + 18 * 0.83 ns m_bunchCrossingTime(24.95) // 24.95 ns =(40.08 MHz)^(-1) { - declareProperty("ClusterCreator", m_muonClusterCreator); declareProperty("ChannelTypes", m_channelTypes = 3); declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); - declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in Muon digitization"); declareProperty("EnergyThreshold", m_energyThreshold = 50, "Minimal energy of incoming particle to produce a PRD" ); declareProperty("EnergyDepositThreshold", m_energyDepositThreshold = 0.00052, "Minimal energy deposit to produce a PRD" ); declareProperty("CheckIds", m_checkIds = false, "Turn on validity checking of Identifiers" ); @@ -107,11 +103,7 @@ sTgcFastDigitizer::sTgcFastDigitizer(const std::string& name, ISvcLocator* pSvcL StatusCode sTgcFastDigitizer::initialize() { ATH_CHECK(detStore()->retrieve(m_detManager)); - m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (m_rndmEngine==0) { - ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); - return StatusCode::FAILURE; - } + ATH_CHECK(m_rndmSvc.retrieve()); ATH_CHECK(m_idHelperSvc.retrieve()); ATH_CHECK(m_muonClusterCreator.retrieve()); ATH_CHECK(m_sdoName.initialize()); @@ -185,6 +177,8 @@ StatusCode sTgcFastDigitizer::execute() { SG::WriteHandle<MuonSimDataCollection> h_sdoContainer(m_sdoName); ATH_CHECK( h_sdoContainer.record ( std::make_unique<MuonSimDataCollection>() ) ); + CLHEP::HepRandomEngine* rndmEngine = getRandomEngine(m_rndmEngineName, Gaudi::Hive::currentContextEvt()); + sTgcPrepDataContainer* prdContainer = new sTgcPrepDataContainer(m_idHelperSvc->stgcIdHelper().module_hash_max()); // as the sTgcPrepDataContainer only allows const accesss, need a local vector as well. @@ -357,12 +351,6 @@ StatusCode sTgcFastDigitizer::execute() { Identifier parentId = m_idHelperSvc->stgcIdHelper().parentID(layid); - // SimHits without energy loss are not recorded. - // not needed because of already done in sensitive detector - // https://svnweb.cern.ch/trac/atlasoff/browser/MuonSpectrometer/MuonG4/MuonG4SD/trunk/src/sTGCSensitiveDetector.cxx?rev=542333#L66 - // if(hit.depositEnergy()==0.) continue; - - // select whether to produce only strips or strips + wires or strips + wires + pads int ftype = m_channelTypes == 3 ? 0 : 1; int ltype = m_channelTypes == 1 ? 1 : 2; @@ -398,8 +386,6 @@ StatusCode sTgcFastDigitizer::execute() { if(inAngle_time > 90) inAngle_time = inAngle_time -90.; if(inAngle_space > 90) inAngle_space = inAngle_space -90.; - - // bctagging float jitter = 0;//jitterInitial; // calculated m_at central strip but also used in all the strips fired by the same hit @@ -417,7 +403,7 @@ StatusCode sTgcFastDigitizer::execute() { double resolution = 0; if( type == 1 ){ resolution = getResolution(inAngle_time); - sp = CLHEP::RandGauss::shoot(m_rndmEngine, hitOnSurface.x(), resolution); + sp = CLHEP::RandGauss::shoot(rndmEngine, hitOnSurface.x(), resolution); } @@ -484,7 +470,6 @@ StatusCode sTgcFastDigitizer::execute() { m_surfcenty = surf.center().y(); m_surfcentz = surf.center().z(); - // cut on depositEnergy(0.52KeV) to simulation the detector efficiency(95% for strips) if( type ==1 && hit.depositEnergy()<m_energyDepositThreshold) { ATH_MSG_VERBOSE("Drop SimHit with depositEnergy = " << m_edep << " in the strip response!"); @@ -721,38 +706,6 @@ uint16_t sTgcFastDigitizer::bcTagging(float digitTime, int channelType) const { return bctag; } - -//+++++++++++++++++++++++++++++++++++++++++++++++ -float sTgcFastDigitizer::timeJitter(float inAngle_time) const -{ - - int ithAngle = static_cast<int>(inAngle_time/5.); - float wAngle = inAngle_time/5. - static_cast<float>(ithAngle); - int jthAngle; - if (ithAngle > 11) { - ithAngle = 12; - jthAngle = 12; - } - else { - jthAngle = ithAngle+1; - } - - float jitter = 0.; - float prob = 1.; - float probRef = 0.; - - while (prob > probRef) { - prob = CLHEP::RandFlat::shoot(m_rndmEngine, 0.0, 1.0); - jitter = CLHEP::RandFlat::shoot(m_rndmEngine, 0.0, 1.0)*40.; // trial time jitter in nsec - int ithJitter = static_cast<int>(jitter); - // probability distribution calculated from weighted sum between neighboring bins of angles - probRef = (1.-wAngle)*m_vecAngle_Time[ithAngle][ithJitter] - + wAngle *m_vecAngle_Time[jthAngle][ithJitter]; - } - return jitter; -} - - //+++++++++++++++++++++++++++++++++++++++++++++++ bool sTgcFastDigitizer::readFileOfTimeJitter() { @@ -797,3 +750,12 @@ bool sTgcFastDigitizer::readFileOfTimeJitter() ifs.close(); return true; } + +CLHEP::HepRandomEngine* sTgcFastDigitizer::getRandomEngine(const std::string& streamName, const EventContext& ctx) const +{ + ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName); + std::string rngName = name()+streamName; + rngWrapper->setSeed( rngName, ctx ); + return rngWrapper->getEngine(ctx); +} + diff --git a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.h b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.h index ef8c6fa591aff5d8b15f30d6629e0fa89afe30f8..ae8f31d2b40f2818466347a5e0a9b72a8d6e9a35 100644 --- a/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.h +++ b/MuonSpectrometer/MuonDigitization/MuonFastDigitization/src/sTgcFastDigitizer.h @@ -12,19 +12,21 @@ #include "StoreGate/StoreGateSvc.h" #include "StoreGate/WriteHandleKey.h" #include "CLHEP/Random/RandomEngine.h" -#include "AthenaKernel/IAtRndmGenSvc.h" #include "CLHEP/Random/RandGauss.h" #include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonRecToolInterfaces/IMuonClusterOnTrackCreator.h" - -class TTree; -class TFile; +#include "AthenaKernel/IAthRNGSvc.h" namespace MuonGM { class MuonDetectorManager; } +namespace CLHEP { + class HepRandomEngine; +} class MuonSimDataCollection; +class TTree; +class TFile; class sTgcFastDigitizer : public AthAlgorithm { @@ -37,10 +39,8 @@ class sTgcFastDigitizer : public AthAlgorithm { StatusCode execute(); StatusCode finalize(); - ServiceHandle<IAtRndmGenSvc> getRndmSvc() const { return m_rndmSvc; } // Random number service - CLHEP::HepRandomEngine *getRndmEngine() const { return m_rndmEngine; } // Random number engine used - private: + CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, const EventContext& ctx) const; const MuonGM::MuonDetectorManager* m_detManager; int m_channelTypes; // 1 -> strips, 2 -> strips+wires, 3 -> strips/wires/pads @@ -105,7 +105,6 @@ class sTgcFastDigitizer : public AthAlgorithm { double getResolution(float inAngle_space) const; uint16_t bcTagging(float digittime, int channelType) const; - float timeJitter(float inAngle_time) const; /** Reads parameters for intrinsic time response from timejitter.dat. @@ -115,9 +114,9 @@ class sTgcFastDigitizer : public AthAlgorithm { protected: ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - ToolHandle <Muon::IMuonClusterOnTrackCreator> m_muonClusterCreator; - ServiceHandle <IAtRndmGenSvc> m_rndmSvc; // Random number service - CLHEP::HepRandomEngine *m_rndmEngine; // Random number engine used - not init in SiDigitization + ToolHandle<Muon::IMuonClusterOnTrackCreator> m_muonClusterCreator{this,"ClusterCreator","Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator"}; + ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", "Random Number Service used in Muon digitization"}; + std::string m_rndmEngineName;// name of random engine std::string m_inputObjectName; // name of the input objects SG::WriteHandleKey<MuonSimDataCollection> m_sdoName; // name of the output SDO collection diff --git a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/python/sTGC_DigitizationConfig.py b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/python/sTGC_DigitizationConfig.py index c989d2fcb7313439884039e35e8fe03dceb8e223..bf6f79651b32c922dbc8b17058a7097f10ac019e 100644 --- a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/python/sTGC_DigitizationConfig.py +++ b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/python/sTGC_DigitizationConfig.py @@ -19,10 +19,6 @@ def sTGC_LastXing(): return 175 def sTgcDigitizationTool(name="sTgcDigitizationTool",**kwargs): - kwargs.setdefault("RndmSvc", jobproperties.Digitization.rndmSvc() ) - # set rndm seeds - sTgcRndm = kwargs.setdefault("RndmEngine","sTGC_Digitization") - jobproperties.Digitization.rndmSeedList.addSeed(sTgcRndm, 49261510, 105132394 ) if jobproperties.Digitization.doXingByXingPileUp(): kwargs.setdefault("FirstXing", sTGC_FirstXing() ) # this should match the range for the sTGC in Digitization/share/MuonDigitization.py kwargs.setdefault("LastXing", sTGC_LastXing() ) # this should match the range for the sTGC in Digitization/share/MuonDigitization.py diff --git a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTGC_Digitizer.h b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTGC_Digitizer.h index bd44b5f2cb1e30991feee75968635b9047617db0..078fa603a54a1d53d21fb4d0837f017e405e5f96 100644 --- a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTGC_Digitizer.h +++ b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTGC_Digitizer.h @@ -1,29 +1,26 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONDIGITIZATION_STGC_DIGITIZER_H #define MUONDIGITIZATION_STGC_DIGITIZER_H -/// Gaudi External #include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" -/*******************************************************************************/ -class IMuonDigitizationTool; -/*******************************************************************************/ +#include "GaudiKernel/ToolHandle.h" + +class IPileUpTool; + class sTGC_Digitizer : public AthAlgorithm { public: - sTGC_Digitizer(const std::string& name, ISvcLocator* pSvcLocator); - ~sTGC_Digitizer(); + ~sTGC_Digitizer()=default; StatusCode initialize(); StatusCode execute(); - StatusCode finalize(); private: - ToolHandle<IMuonDigitizationTool> m_digTool{this, "DigitizationTool", "sTgcDigitizationTool", "sTgcDigitizationTool name"}; + ToolHandle<IPileUpTool> m_digTool{this, "DigitizationTool", "sTgcDigitizationTool", "sTgcDigitizationTool name"}; }; /*******************************************************************************/ #endif // MUONDIGITIZATION_STGC_DIGITIZER_H diff --git a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTgcDigitizationTool.h b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTgcDigitizationTool.h index 978fbcf5196cc856fc6e4fc0c3ae0fc4392e1c18..16afe2b8fa624eab41a6e46e504bb64fd368374e 100644 --- a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTgcDigitizationTool.h +++ b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/sTGC_Digitization/sTgcDigitizationTool.h @@ -4,6 +4,7 @@ #ifndef MUONDIGITIZATION_STGC_DIGITIZATIONTOOL_H #define MUONDIGITIZATION_STGC_DIGITIZATIONTOOL_H + /** @class sTgcDigitizationTool @section sTGC_DigitizerDetails Class methods and properties @@ -14,11 +15,11 @@ */ -#include "MuonDigToolInterfaces/IMuonDigitizationTool.h" #include "PileUpTools/PileUpToolBase.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" -#include "AthenaKernel/IAtRndmGenSvc.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "HitManagement/TimedHitCollection.h" #include "MuonSimEvent/sTGCSimHitCollection.h" #include "MuonSimEvent/sTGCSimHit.h" @@ -26,16 +27,13 @@ #include "xAODEventInfo/EventAuxInfo.h" #include "MuonSimData/MuonSimDataCollection.h" #include "MuonDigitContainer/sTgcDigitContainer.h" - #include "NSWCalibTools/INSWCalibSmearingTool.h" - #include "CLHEP/Random/RandGaussZiggurat.h" #include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Geometry/Point3D.h" #include "CLHEP/Vector/ThreeVector.h" - -#include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/ToolHandle.h" +#include "AthenaKernel/IAthRNGSvc.h" +#include "CLHEP/Units/PhysicalConstants.h" #include <string> #include <sstream> @@ -46,15 +44,16 @@ namespace MuonGM{ class MuonDetectorManager; } -namespace CLHEP{ +namespace CLHEP { class HepRandomEngine; } + class PileUpMergeSvc; class sTgcHitIdHelper; class sTgcDigitMaker; /*******************************************************************************/ -class sTgcDigitizationTool : virtual public IMuonDigitizationTool, public PileUpToolBase { +class sTgcDigitizationTool : public PileUpToolBase { public: sTgcDigitizationTool(const std::string& type, const std::string& name, const IInterface* parent); @@ -96,65 +95,64 @@ public: /** Finalize */ StatusCode finalize(); - /** accessors */ - ServiceHandle<IAtRndmGenSvc> getRndmSvc() const { return m_rndmSvc; } // Random number service - CLHEP::HepRandomEngine *getRndmEngine() const { return m_rndmEngine; } // Random number engine used +protected: + PileUpMergeSvc *m_mergeSvc; // Pile up service private: + CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, const EventContext& ctx) const; + /** Get next event and extract collection of hit collections */ StatusCode getNextEvent(); /** Core part of digitization use by mergeEvent (IPileUpTool) and digitize (IMuonDigitizationTool) */ StatusCode doDigitization(const EventContext& ctx); -protected: - PileUpMergeSvc *m_mergeSvc; // Pile up service - CLHEP::HepRandomEngine *m_rndmEngine; // Random number engine used - not init in SiDigitization - ServiceHandle<IAtRndmGenSvc> m_rndmSvc; // Random number service - std::string m_rndmEngineName;// name of random engine - -private: - - sTgcHitIdHelper* m_hitIdHelper; + ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", "Random Number Service used in Muon digitization"}; + sTgcHitIdHelper* m_hitIdHelper; ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - const MuonGM::MuonDetectorManager* m_mdManager; - sTgcDigitMaker* m_digitizer; - TimedHitCollection<sTGCSimHit>* m_thpcsTGC; - std::list<sTGCSimHitCollection*> m_STGCHitCollList; + const MuonGM::MuonDetectorManager* m_mdManager; + sTgcDigitMaker* m_digitizer; + TimedHitCollection<sTGCSimHit>* m_thpcsTGC; + std::list<sTGCSimHitCollection*> m_STGCHitCollList; - ToolHandle<Muon::INSWCalibSmearingTool> m_smearingTool; - BooleanProperty m_doSmearing; + ToolHandle<Muon::INSWCalibSmearingTool> m_smearingTool{this,"SmearingTool","Muon::NSWCalibSmearingTool/STgcCalibSmearingTool"}; - std::string m_inputHitCollectionName; // name of the input objects SG::WriteHandleKey<sTgcDigitContainer> m_outputDigitCollectionKey{this,"OutputObjectName","sTGC_DIGITS","WriteHandleKey for Output sTgcDigitContainer"}; // name of the output digits SG::WriteHandleKey<MuonSimDataCollection> m_outputSDO_CollectionKey{this,"OutputSDOName","sTGC_SDO","WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs - bool m_needsMcEventCollHelper; + + Gaudi::Property<bool> m_doSmearing{this,"doSmearing",false}; + Gaudi::Property<bool> m_needsMcEventCollHelper{this,"UseMcEventCollectionHelper",false}; + Gaudi::Property<bool> m_doToFCorrection{this,"doToFCorrection",false}; + + Gaudi::Property<std::string> m_rndmEngineName{this,"RndmEngine","MuonDigitization","Random engine name"}; + Gaudi::Property<std::string> m_inputHitCollectionName{this,"InputObjectName","sTGCSensitiveDetector","name of the input object"}; + + Gaudi::Property<int> m_doChannelTypes{this,"doChannelTypes",3}; + + Gaudi::Property<float> m_deadtimeStrip{this,"DeadtimeElectronicsStrip",50}; + Gaudi::Property<float> m_deadtimePad{this,"DeadtimeElectronicsPad",5}; + Gaudi::Property<float> m_timeWindowPad{this,"timeWindowPad",30}; + Gaudi::Property<float> m_timeWindowStrip{this,"timeWindowStrip",30}; + + Gaudi::Property<double> m_energyDepositThreshold{this,"energyDepositThreshold",300.0*CLHEP::eV,"Minimum energy deposit for hit to be digitized"}; - bool m_doToFCorrection; - int m_doChannelTypes; float m_readoutThreshold; float m_neighborOnThreshold; float m_saturation; - bool m_deadtimeON; - bool m_produceDeadDigits; - float m_deadtimeStrip; - float m_deadtimePad; + bool m_deadtimeON; + bool m_produceDeadDigits; + float m_deadtimeWire; float m_readtimeStrip; float m_readtimePad; float m_readtimeWire; float m_timeWindowOffsetPad; float m_timeWindowOffsetStrip; - float m_timeWindowPad; - float m_timeWindowStrip; float m_bunchCrossingTime; float m_timeJitterElectronicsStrip; float m_timeJitterElectronicsPad; float m_hitTimeMergeThreshold; - // Minimum energy deposit for hit to be digitized - double m_energyDepositThreshold; - std::map< Identifier, int > m_hitSourceVec; void readDeadtimeConfig(); diff --git a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTGC_Digitizer.cxx b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTGC_Digitizer.cxx index 27b924cfddf9d462160d0dd8fe783f66bb0ec8dc..82e8ca87373bfbb9d7193cb04ed0b9768f8b7a61 100644 --- a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTGC_Digitizer.cxx +++ b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTGC_Digitizer.cxx @@ -1,39 +1,25 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -/// Gaudi External +#include "sTGC_Digitization/sTGC_Digitizer.h" + #include "AthenaBaseComps/AthMsgStreamMacros.h" #include "AthenaKernel/errorcheck.h" -#include "sTGC_Digitization/sTGC_Digitizer.h" -#include "MuonDigToolInterfaces/IMuonDigitizationTool.h" +#include "PileUpTools/IPileUpTool.h" /*******************************************************************************/ -sTGC_Digitizer::sTGC_Digitizer(const std::string& name, ISvcLocator* pSvcLocator) - : AthAlgorithm(name, pSvcLocator) -{ -} -/*******************************************************************************/ -sTGC_Digitizer::~sTGC_Digitizer() {} +sTGC_Digitizer::sTGC_Digitizer(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name, pSvcLocator) {} /*******************************************************************************/ StatusCode sTGC_Digitizer::initialize() { // intitialize store gate active store - if (m_digTool.retrieve().isFailure()) { - ATH_MSG_FATAL (" Could not retrieve sTGC Digitization Tool!" ); - return StatusCode::FAILURE; - } + ATH_CHECK(m_digTool.retrieve()); ATH_MSG_DEBUG ("Retrieved sTGC Digitization Tool." ); return StatusCode::SUCCESS; } /*******************************************************************************/ StatusCode sTGC_Digitizer::execute() { ATH_MSG_DEBUG ("sTGC_Digitizer::in execute()"); - return m_digTool->digitize(Gaudi::Hive::currentContext()); + return m_digTool->processAllSubEvents(Gaudi::Hive::currentContext()); } -/*******************************************************************************/ -StatusCode sTGC_Digitizer::finalize() { - ATH_MSG_INFO (" sTGC_Digitizer::finalize "); - return StatusCode::SUCCESS; -} -/*******************************************************************************/ - diff --git a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTgcDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTgcDigitizationTool.cxx index ab7c01b86386dae168175ce88c20520d0c31f25f..9d8405158413df584ceb5f895d06099fa63011fb 100644 --- a/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTgcDigitizationTool.cxx +++ b/MuonSpectrometer/MuonDigitization/sTGC_Digitization/src/sTgcDigitizationTool.cxx @@ -35,14 +35,10 @@ #include "PileUpTools/PileUpMergeSvc.h" //Truth -#include "CLHEP/Units/PhysicalConstants.h" #include "GeneratorObjects/HepMcParticleLink.h" #include "AtlasHepMC/GenParticle.h" -//Random Numbers -#include "AthenaKernel/IAtRndmGenSvc.h" -#include "CLHEP/Random/RandFlat.h" -#include "CLHEP/Random/RandGauss.h" +#include "AthenaKernel/RNGWrapper.h" #include <sstream> #include <iostream> @@ -91,56 +87,31 @@ inline bool sort_digitsEarlyToLate(sTgcSimDigitData a, sTgcSimDigitData b){ } /*******************************************************************************/ -sTgcDigitizationTool::sTgcDigitizationTool(const std::string& type, const std::string& name, const IInterface* parent) - : PileUpToolBase(type, name, parent), - m_mergeSvc(0), - m_rndmEngine(0), - m_rndmSvc("AtRndmGenSvc", name), - m_rndmEngineName("MuonDigitization"), - m_hitIdHelper(0), - m_mdManager(0), - m_digitizer(0), - m_thpcsTGC(0), - m_smearingTool("Muon::NSWCalibSmearingTool/STgcCalibSmearingTool",this), - m_inputHitCollectionName("sTGCSensitiveDetector"), - m_doToFCorrection(0), - m_doChannelTypes(3), +sTgcDigitizationTool::sTgcDigitizationTool(const std::string& type, const std::string& name, const IInterface* parent) : + PileUpToolBase(type, name, parent), + m_mergeSvc(nullptr), + m_hitIdHelper(nullptr), + m_mdManager(nullptr), + m_digitizer(nullptr), + m_thpcsTGC(nullptr), + m_STGCHitCollList(), m_readoutThreshold(0), m_neighborOnThreshold(0), m_saturation(0), - m_deadtimeON(1), - m_produceDeadDigits(0), - m_deadtimeStrip(50.), - m_deadtimePad(5.), + m_deadtimeON(true), + m_produceDeadDigits(false), m_deadtimeWire(5.), m_readtimeStrip(6.25), m_readtimePad(6.25), m_readtimeWire(6.25), m_timeWindowOffsetPad(0), m_timeWindowOffsetStrip(0), - m_timeWindowPad(30.), - m_timeWindowStrip(30.), m_bunchCrossingTime(0), m_timeJitterElectronicsStrip(0), m_timeJitterElectronicsPad(0), m_hitTimeMergeThreshold(0), - m_energyDepositThreshold(300.0*CLHEP::eV) -{ - declareInterface<IMuonDigitizationTool>(this); - declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in Muon digitization"); - declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); - declareProperty("InputObjectName", m_inputHitCollectionName = "sTGCSensitiveDetector", "name of the input object"); - declareProperty("UseMcEventCollectionHelper", m_needsMcEventCollHelper = false); - declareProperty("doToFCorrection", m_doToFCorrection); - declareProperty("doChannelTypes", m_doChannelTypes); - declareProperty("DeadtimeElectronicsStrip",m_deadtimeStrip); - declareProperty("DeadtimeElectronicsPad", m_deadtimePad); - declareProperty("timeWindowPad", m_timeWindowPad); - declareProperty("timeWindowStrip", m_timeWindowStrip); - declareProperty("energyDepositThreshold", m_energyDepositThreshold, "Minimum energy deposit considered for digitization"); - declareProperty("doSmearing", m_doSmearing=false); - declareProperty("SmearingTool",m_smearingTool); -} + m_hitSourceVec() {} + /*******************************************************************************/ // member function implementation //-------------------------------------------- @@ -188,28 +159,16 @@ StatusCode sTgcDigitizationTool::initialize() { // getting our random numbers stream ATH_MSG_DEBUG("Getting random number engine : <" << m_rndmEngineName << ">"); - m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if(m_rndmEngine==0) { - ATH_MSG_FATAL("Could not find RndmEngine : " << m_rndmEngineName); - return StatusCode::FAILURE; - } - - ATH_CHECK(m_digitizer->initialize(m_rndmEngine, m_doChannelTypes)); readDeadtimeConfig(); // initialize digit parameters - //m_noiseFactor = 0.09; m_readoutThreshold = 0.05; m_neighborOnThreshold = 0.01; m_saturation = 1.75; // = 3500. / 2000.; m_hitTimeMergeThreshold = 30; //30ns = resolution of peak finding descriminator - //m_deadtimeStrip = 50.; // 50ns deadtime of electronics after peak found (for strip readout) - //m_deadtimePad = 5.; // 50ns deadtime of electronics after peak found (for strip readout) m_timeWindowOffsetPad = 0.; m_timeWindowOffsetStrip = 25.; - //m_timeWindowPad = 30.; // TGC 29.32; // 29.32 ns = 26 ns + 4 * 0.83 ns - //m_timeWindowStrip = 30.; // TGC 40.94; // 40.94 ns = 26 ns + 18 * 0.83 ns m_bunchCrossingTime = 24.95; // 24.95 ns =(40.08 MHz)^(-1) m_timeJitterElectronicsPad = 2.; //ns m_timeJitterElectronicsStrip= 2.; //ns @@ -328,7 +287,6 @@ StatusCode sTgcDigitizationTool::mergeEvent(const EventContext& ctx) { status = doDigitization(ctx); if (status.isFailure()) { ATH_MSG_ERROR ( "doDigitization Failed" ); - //return StatusCode::FAILURE; } // reset the pointer (delete null pointer should be safe) @@ -387,6 +345,10 @@ StatusCode sTgcDigitizationTool::doDigitization(const EventContext& ctx) { ATH_MSG_DEBUG ("sTgcDigitizationTool::doDigitization()" ); + CLHEP::HepRandomEngine* rndmEngine = getRandomEngine(m_rndmEngineName, ctx); + + ATH_CHECK(m_digitizer->initialize(rndmEngine, m_doChannelTypes)); + // create and record the Digit container in StoreGate SG::WriteHandle<sTgcDigitContainer> digitContainer(m_outputDigitCollectionKey, ctx); ATH_CHECK(digitContainer.record(std::make_unique<sTgcDigitContainer>(m_idHelperSvc->stgcIdHelper().module_hash_max()))); @@ -557,8 +519,8 @@ StatusCode sTgcDigitizationTool::doDigitization(const EventContext& ctx) { float newTime = (*it_digiHits)->time(); int newChannelType = m_idHelperSvc->stgcIdHelper().channelType((*it_digiHits)->identify()); - float timeJitterElectronicsStrip = CLHEP::RandGauss::shoot(m_rndmEngine, 0, m_timeJitterElectronicsStrip); - float timeJitterElectronicsPad = CLHEP::RandGauss::shoot(m_rndmEngine, 0, m_timeJitterElectronicsPad); + float timeJitterElectronicsStrip = CLHEP::RandGauss::shoot(rndmEngine, 0, m_timeJitterElectronicsStrip); + float timeJitterElectronicsPad = CLHEP::RandGauss::shoot(rndmEngine, 0, m_timeJitterElectronicsPad); if(newChannelType==1) newTime += timeJitterElectronicsStrip; else @@ -1121,13 +1083,9 @@ uint16_t sTgcDigitizationTool::bcTagging(const float digitTime, const int channe ATH_MSG_VERBOSE("Determining BC tag for pad channel"); } else if(channelType == 1) { //strips - //offset = m_timeWindowOffsetStrip; - //window = m_timeWindowStrip; ATH_MSG_VERBOSE("Determining BC tag for strip channel"); } else if (channelType == 2) { // wire groups - //offset = m_timeWindowOffsetPad; - //window = m_timeWindowPad; ATH_MSG_VERBOSE("Determining BC tag for wiregroup channel"); } @@ -1144,3 +1102,13 @@ int sTgcDigitizationTool::humanBC(uint16_t bctag) { if(bctag << 15 == 1) return ~bctag; else return bctag; } + +CLHEP::HepRandomEngine* sTgcDigitizationTool::getRandomEngine(const std::string& streamName, const EventContext& ctx) const +{ + ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName); + std::string rngName = name()+streamName; + rngWrapper->setSeed( rngName, ctx ); + return rngWrapper->getEngine(ctx); +} + + diff --git a/MuonSpectrometer/MuonGeoModelTest/MuonGeoModelTest/MuonGMCheck.h b/MuonSpectrometer/MuonGeoModelTest/MuonGeoModelTest/MuonGMCheck.h index f2183343329f7b6b8f79d8f753104837b41696b0..ea36c321064a40a09120a74953ca4d78bd803ef3 100644 --- a/MuonSpectrometer/MuonGeoModelTest/MuonGeoModelTest/MuonGMCheck.h +++ b/MuonSpectrometer/MuonGeoModelTest/MuonGeoModelTest/MuonGMCheck.h @@ -13,6 +13,7 @@ #include "AthenaBaseComps/AthAlgorithm.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" + #include "MuonCalibITools/IIdToFixedIdTool.h" #include "MuonIdHelpers/IMuonIdHelperSvc.h" @@ -32,8 +33,8 @@ public: MuonGMCheck(const std::string& name, ISvcLocator* pSvcLocator); ~MuonGMCheck()=default; - StatusCode initialize(); - StatusCode execute(); + StatusCode initialize(); + StatusCode execute(); void clearCache() const; private: @@ -70,16 +71,14 @@ private: int m_check_surfaces; int m_check_surfaces_details; int m_check_rpc_distToReadout; - int m_print_level; - int m_tgcgood; - int m_rpcgood; - int m_mdtgood; - - + int m_print_level; + int m_tgcgood; + int m_rpcgood; + int m_mdtgood; - MuonGM::MuonDetectorManager* p_MuonMgr; + MuonGM::MuonDetectorManager* p_MuonMgr; - ToolHandle<MuonCalib::IIdToFixedIdTool> m_fixedIdTool; + ToolHandle<MuonCalib::IIdToFixedIdTool> m_fixedIdTool{this,"idTool","MuonCalib::IdToFixedIdTool"}; ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; int m_mem; //<! counter for memory allocated VmSize values read from /proc/<pid>/status @@ -136,10 +135,6 @@ private: void checkParentStation(); void checkreadouttgcgeo(); void checkRegionSelectorMap(); -// void showPointComparison(HepGeom::Point3D<double> gmP, HepGeom::Point3D<double> ddP, const MuonGM::MuonReadoutElement* rpc, Identifier id); -// void showMdtPointComparison(HepGeom::Point3D<double> gmP, HepGeom::Point3D<double> ddP, const MuonGM::MuonReadoutElement* rpc); -// void showTgcPointComparison(HepGeom::Point3D<double> gmP, HepGeom::Point3D<double> ddP, const MuonGM::MuonReadoutElement* rpc); - void testMdtDetectorElementHash(); void testRpcDetectorElementHash(); void testTgcDetectorElementHash(); diff --git a/MuonSpectrometer/MuonGeoModelTest/src/MuonGMCheck.cxx b/MuonSpectrometer/MuonGeoModelTest/src/MuonGMCheck.cxx index d07a9c428528995cb4e53612a0a46bb741352d5f..84093eefaa0d665a6b6d9209ffbe4b5c2095d55f 100644 --- a/MuonSpectrometer/MuonGeoModelTest/src/MuonGMCheck.cxx +++ b/MuonSpectrometer/MuonGeoModelTest/src/MuonGMCheck.cxx @@ -7,7 +7,6 @@ ----------------------------------------- ***************************************************************************/ -#include "MuonGeoModelTest/PerfUtils.h" #include "MuonGeoModelTest/MuonGMCheck.h" #include "MuonDigitContainer/RpcDigitContainer.h" @@ -32,6 +31,7 @@ #include "TrkSurfaces/Surface.h" #include "RegionSelector/IRegSelSvc.h" #include "GeoPrimitives/CLHEPtoEigenConverter.h" +#include "MuonGeoModelTest/PerfUtils.h" #include <boost/format.hpp> @@ -48,8 +48,7 @@ using namespace MuonGM; MuonGMCheck::MuonGMCheck(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator), - p_MuonMgr(nullptr), - m_fixedIdTool("MuonCalib::IdToFixedIdTool") + p_MuonMgr(nullptr) { m_mem = 0; m_cpu[0] = 0; @@ -105,9 +104,6 @@ MuonGMCheck::MuonGMCheck(const std::string& name, ISvcLocator* pSvcLocator) : declareProperty("testTgcDetectorElementHash",m_testTgcDetectorElementHash=0); declareProperty("testCscDetectorElementHash",m_testCscDetectorElementHash=0); - - declareProperty("idTool", m_fixedIdTool); - m_print_level = 0; declareProperty("print_level", m_print_level); m_mdtgood = 0; @@ -128,7 +124,8 @@ MuonGMCheck::initialize() // first get helpers ATH_MSG_DEBUG("Get Muon Id Helpers from the det store (through their converters)" ); - ATH_CHECK( m_idHelperSvc.retrieve() ); + ATH_CHECK(m_idHelperSvc.retrieve()); + ATH_CHECK(m_fixedIdTool.retrieve()); ATH_MSG_DEBUG( " Muon Id Helper retrieved from handle " ); showVmemCpu("initialize (IDHELPER retrieved from handle)");