ATLAS Offline Software
Loading...
Searching...
No Matches
ComTimeRec Class Reference

#include <ComTimeRec.h>

Inheritance diagram for ComTimeRec:
Collaboration diagram for ComTimeRec:

Public Member Functions

 ComTimeRec (const std::string &name, ISvcLocator *pSvcLocator)
 ~ComTimeRec ()
virtual StatusCode initialize () override
virtual StatusCode execute () override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::string m_comTimeKey
std::string m_mode
std::string m_method
std::string m_TTRKey
double m_samplingPeriod
double m_velocity
CosmicTriggerTimeToolm_triggerTimeTool
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 12 of file ComTimeRec.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ComTimeRec()

ComTimeRec::ComTimeRec ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 20 of file ComTimeRec.cxx.

21 :
22 AthAlgorithm(name,pSvcLocator),m_triggerTimeTool(0)
23{
24 declareProperty("ComTimeKey",m_comTimeKey="ComTime");
25 declareProperty("Mode",m_mode="TTRCavern");
26 declareProperty("Method",m_method="YZero"); // or "ZZero" or "Origin"
27 declareProperty("TTRKey",m_TTRKey="CosmicRecord");
28 declareProperty("SamplingPeriod",m_samplingPeriod=1./(40.08*CLHEP::megahertz));
29 declareProperty("Velocity", m_velocity=299.792458*CLHEP::millimeter/CLHEP::nanosecond);
30}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_method
Definition ComTimeRec.h:27
double m_samplingPeriod
Definition ComTimeRec.h:29
double m_velocity
Definition ComTimeRec.h:30
std::string m_comTimeKey
Definition ComTimeRec.h:25
CosmicTriggerTimeTool * m_triggerTimeTool
Definition ComTimeRec.h:31
std::string m_TTRKey
Definition ComTimeRec.h:28
std::string m_mode
Definition ComTimeRec.h:26

◆ ~ComTimeRec()

ComTimeRec::~ComTimeRec ( )

Definition at line 34 of file ComTimeRec.cxx.

35{
36}

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode ComTimeRec::execute ( )
overridevirtual

Definition at line 65 of file ComTimeRec.cxx.

66{
67
68 ATH_MSG_DEBUG( "In execute()" );
69
70 // Pick method of calculating trigger point.
71 if(m_mode == "TTRCavern" ) {
72
73 // Use the Timed Track Record of the muon entering the cavern.
74
76 ATH_MSG_ERROR( " can not retrieve TrackRecordCollection with key " << m_TTRKey );
77 // Put default ComTime into SG for.
78 ComTime *theComTime = new ComTime();
79 CHECK( evtStore()->record(theComTime, m_comTimeKey) );
80 return StatusCode::SUCCESS;
81 }
82 // const TimedTrackRecordCollection* coll;
83 const TrackRecordCollection *coll(NULL);
84 CHECK( evtStore()->retrieve(coll, m_TTRKey) );
85 int nMuons = 0;
86 double earliestMuonTime = -1.;
87 const TrackRecord *earliestMuon=nullptr;
88
89 for(const TrackRecord& r : *coll) {
90
91 if(abs(r.GetPDGCode()) == 13 ) {
92 nMuons++;
93 if( (nMuons==1) or (r.GetTime() < earliestMuonTime) ) {
94 earliestMuon = &r;
95 earliestMuonTime = r.GetTime();
96 }
97 }
98 }
99
100 if( nMuons>=1 ) { // use the earliest muon if more than 1
101 CLHEP::Hep3Vector pos = earliestMuon->GetPosition();
102 CLHEP::Hep3Vector mom = earliestMuon->GetMomentum();
103 double energy = sqrt(mom.x()*mom.x() + mom.y()*mom.y() + mom.z()*mom.z());
104
105 CLHEP::Hep3Vector cosThetaDir = CLHEP::Hep3Vector(mom.x()/energy, mom.y()/energy, mom.z()/energy);
106
107 double time = earliestMuon->GetTime();
108
109 ATH_MSG_DEBUG( " Earliest Muon xyz position " << pos.x()<<" "
110 << pos.y() << " " << pos.z() );
111 ATH_MSG_DEBUG( " cosThetaDir " << cosThetaDir.x() << " "
112 << cosThetaDir.y() << " " << cosThetaDir.z() );
113 ATH_MSG_DEBUG( " time " << time );
114
115 // Three different methods of definining the virtrual trigger point
116 // 1) m_method = YZero : extrapolate to Y=0 plane (default)
117 // 2) m_method = ZZero : extrapolate to Z=0 plane
118 // 3) m_method = Origin : extrapolate to closest approach to (0,0,0)
119
120
121 double PathCritical;
122 CLHEP::Hep3Vector PointCritical;
123
124 if( m_method == "YZero" ) { // Extrapolate to Y=0 plane. Good for cosmics.
125 double dXdY = cosThetaDir.x()/cosThetaDir.y();
126 double dZdY = cosThetaDir.z()/cosThetaDir.y();
127
128 double XCritical = pos.x()-dXdY*pos.y();
129 double YCritical = 0.0;
130 double ZCritical = pos.z()-dZdY*pos.y();
131
132 PointCritical = CLHEP::Hep3Vector(XCritical,YCritical,ZCritical);
133
134 PathCritical = sqrt(pow(XCritical-pos.x(),2) + pow(YCritical-pos.y(),2) +
135 pow(ZCritical-pos.z(),2));
136 if( (YCritical-pos.y())*cosThetaDir.y() < 0 ) { // backwards extrapolation??
137 ATH_MSG_WARNING( "Backwards extrapolation?? pos.y(),cosThetaDir.y() = "
138 << pos.y()<<"," << cosThetaDir.y() );
139 PathCritical = -1.0 * PathCritical;
140 }
141 }
142 else if (m_method == "ZZero") { // Extrapolate to Z=0 plane. Good for halo.
143 double dXdZ = cosThetaDir.x()/cosThetaDir.z();
144 double dYdZ = cosThetaDir.y()/cosThetaDir.z();
145
146 double XCritical = pos.x()-dXdZ*pos.z();
147 double YCritical = pos.y()-dYdZ*pos.z();
148 double ZCritical = 0.0;
149
150 PointCritical = CLHEP::Hep3Vector(XCritical,YCritical,ZCritical);
151
152 PathCritical = sqrt(pow(XCritical-pos.x(),2) + pow(YCritical-pos.y(),2) +
153 pow(ZCritical-pos.z(),2));
154 if( (ZCritical-pos.z())*cosThetaDir.z() < 0 ) { // backwards extrapolation??
155 ATH_MSG_WARNING( "Backwards extrapolation?? pos.z(),cosThetaDir.z() = "
156 << pos.z()<<"," << cosThetaDir.z() );
157 PathCritical = -1.0 * PathCritical;
158 }
159 }
160 else if (m_method == "Origin") { // Extrapolate to closest approach to (0,0,0)
161 // See arithmetic in RMcP logbook 28 Feb 2006
162 PathCritical = -1.*(pos.x()*cosThetaDir.x() + pos.y()*cosThetaDir.y() +
163 pos.z()*cosThetaDir.z());
164 PointCritical = CLHEP::Hep3Vector( pos.x() + PathCritical*cosThetaDir.x(),
165 pos.y() + PathCritical*cosThetaDir.y(),
166 pos.z() + PathCritical*cosThetaDir.z());
167 }
168 else { // This is bad ... invalid method requested
169 ATH_MSG_FATAL( "Invalid method = " << m_method );
170 return StatusCode::FAILURE;
171 }
172
173 double TimeCritical = time + PathCritical/m_velocity;
174 double TTCTime = m_samplingPeriod * floor(TimeCritical/m_samplingPeriod);
175
176 ATH_MSG_DEBUG( " Extrapolated muon xyz position " << PointCritical.x()<<" "
177 << PointCritical.y()<<" " << PointCritical.z());
178 ATH_MSG_DEBUG( " path " << PathCritical );
179 ATH_MSG_DEBUG( " time " << TimeCritical );
180 ATH_MSG_DEBUG( " TTCTime " << TTCTime );
181
182 ComTime* theComTime = new ComTime(TTCTime,TimeCritical,PointCritical,cosThetaDir);
183 CHECK( evtStore()->record(theComTime, m_comTimeKey) );
184
185 m_triggerTimeTool->setComTime(theComTime);
186
187 } else { // no muons entering cavern found.
188 ATH_MSG_DEBUG( " No muons entered cavern." );
189 ComTime *theComTime = new ComTime();
190 CHECK( evtStore()->record(theComTime, m_comTimeKey) );
191 }
192 } else if(m_mode == "CollisionMode" ) {
193 // Using cosmic reco during collisions. Fire on BCIDs.
194 // Just provide a default ComTime object.
195 ComTime *theComTime = new ComTime();
196 CHECK( evtStore()->record(theComTime, m_comTimeKey) );
197 return StatusCode::SUCCESS;
198 } else {
199 ATH_MSG_FATAL( "Invalid mode = " << m_mode );
200 return StatusCode::SUCCESS;
201 }
202 return StatusCode::SUCCESS;
203}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AtlasHitsVector< TrackRecord > TrackRecordCollection
constexpr int pow(int base, int exp) noexcept
CLHEP::Hep3Vector GetPosition() const
Position.
Definition TrackRecord.h:88
CLHEP::Hep3Vector GetMomentum() const
Momentum.
Definition TrackRecord.h:94
double GetTime() const
Time.
int r
Definition globals.cxx:22
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
time(flags, cells_name, *args, **kw)
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ initialize()

StatusCode ComTimeRec::initialize ( )
overridevirtual

Definition at line 40 of file ComTimeRec.cxx.

41{
42
43 ATH_MSG_INFO( "In initialize()" );
44
45 // This level of obfuscation is necessary because ITriggerTime, the interface class for
46 // the timing tool, does not provide the method that is needed here (which is bad design).
47 // The right thing to do is to fix the interface, at which point this is a simple retrieve.
48 // Until then, we are stuck with the old way.
49
50 IAlgTool *trigTool(0);
51 CHECK( toolSvc()->retrieveTool("CosmicTriggerTimeTool",trigTool) );
52
53 m_triggerTimeTool = dynamic_cast<CosmicTriggerTimeTool*>(trigTool);
54 if(0==m_triggerTimeTool){
55 ATH_MSG_ERROR( " Failed to dynamic cast CosmicTriggerTimeTool " );
56 return StatusCode::FAILURE;
57 }
58
59 return StatusCode::SUCCESS;
60
61}
#define ATH_MSG_INFO(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_comTimeKey

std::string ComTimeRec::m_comTimeKey
private

Definition at line 25 of file ComTimeRec.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_method

std::string ComTimeRec::m_method
private

Definition at line 27 of file ComTimeRec.h.

◆ m_mode

std::string ComTimeRec::m_mode
private

Definition at line 26 of file ComTimeRec.h.

◆ m_samplingPeriod

double ComTimeRec::m_samplingPeriod
private

Definition at line 29 of file ComTimeRec.h.

◆ m_triggerTimeTool

CosmicTriggerTimeTool* ComTimeRec::m_triggerTimeTool
private

Definition at line 31 of file ComTimeRec.h.

◆ m_TTRKey

std::string ComTimeRec::m_TTRKey
private

Definition at line 28 of file ComTimeRec.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_velocity

double ComTimeRec::m_velocity
private

Definition at line 30 of file ComTimeRec.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: