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

#include <LArTBH6BeamInfo.h>

Inheritance diagram for LArTBH6BeamInfo:
Collaboration diagram for LArTBH6BeamInfo:

Public Member Functions

 LArTBH6BeamInfo (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~LArTBH6BeamInfo ()=default
virtual StatusCode initialize () override
virtual StatusCode execute () override
virtual StatusCode finalize () 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 std::vector< double > dVect
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

bool fitVect (const dVect &vec_x, const dVect &vec_xz, const dVect &vec_ex, double &a1, double &a2, double &chi2, dVect &residual)
 Fit data to the function u = a1 + a2*w.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< std::vector< std::string > > m_HitsCollNames {this, "HitsContainer"}
Gaudi::Property< bool > m_Primary {this, "PrimaryTrackOnly", true}
Gaudi::Property< int > m_pcode {this, "PrimaryParticle", 999}
float m_cryoX {0.f}
int m_numEv {0}
SG::ReadHandle< TBEventInfom_theEventInfo
SG::WriteHandle< TBTrackm_track
std::vector< SG::ReadHandle< AthenaHitsVector< LArG4H6FrontHit > > > m_hitcoll
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 21 of file LArTBH6BeamInfo.h.

Member Typedef Documentation

◆ dVect

typedef std::vector<double> LArTBH6BeamInfo::dVect
private

Definition at line 37 of file LArTBH6BeamInfo.h.

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ LArTBH6BeamInfo()

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

Definition at line 15 of file LArTBH6BeamInfo.cxx.

16 : AthAlgorithm(name, pSvcLocator)
17 , m_theEventInfo("TBEventInfo")
18{
19 for (const auto &it : m_HitsCollNames){
20 m_hitcoll.push_back( SG::ReadHandle< AthenaHitsVector<LArG4H6FrontHit> >( it ) );
21 }
22}
AthAlgorithm()
Default constructor:
std::vector< SG::ReadHandle< AthenaHitsVector< LArG4H6FrontHit > > > m_hitcoll
SG::ReadHandle< TBEventInfo > m_theEventInfo
Gaudi::Property< std::vector< std::string > > m_HitsCollNames

◆ ~LArTBH6BeamInfo()

virtual LArTBH6BeamInfo::~LArTBH6BeamInfo ( )
virtualdefault

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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ 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 LArTBH6BeamInfo::execute ( )
overridevirtual

Definition at line 45 of file LArTBH6BeamInfo.cxx.

46{
47 ATH_MSG_INFO ( "LArTBH6BeamInfo in execute" );
48 CLHEP::Hep3Vector pos;
49
50 if ( m_numEv == 0 ){
51 m_cryoX = m_theEventInfo->getCryoX();
52 }
53
54 dVect v_x;
55 dVect v_y;
56 dVect v_xz;
57 dVect v_yz;
58 dVect v_ex;
59 dVect v_ey;
60
61// loop hit containers
62 for (auto &it : m_hitcoll) {
63
64 ATH_MSG_INFO (" hit container: "<< it->Name() <<" size: "<<it->size() );
65
66 for (const LArG4H6FrontHit* hit : *it){
67 // loop over hits, find track==0 and make a fit, store a TBTrack to StoreGate
68 if(hit->GetSC() > 0) continue; // scintilator hit
69 if(m_Primary) {
70 if(hit->GetTrackID() != 1) continue; // not a primary particle
71 } else {
72 if(hit->GetPcode() != m_pcode) continue; // not a beam particle
73 }
74 pos = hit->GetPos();
75 if(hit->GetX() > 0) { // X-coordinate
76 v_x.push_back(pos.x());
77 v_xz.push_back(pos.z()+21600.*mm);
78 v_ex.push_back(0.01); // take the error from somewhere !!!
79 } else {
80 v_y.push_back(pos.y());
81 v_yz.push_back(pos.z()+21600.*mm);
82 v_ey.push_back(0.01); // take the error from somewhere !!!
83 }
84 }
85
86 }
87
88 if(v_x.size() < 2 || v_y.size() < 2) { // Could not fit
89 ATH_MSG_DEBUG ( "Could not fit, setting zero. "<<v_x.size()<<"/"<<v_y.size() );
90 m_track = std::make_unique<TBTrack>(0,0);
91 m_track->setUintercept(0.);
92 m_track->setVintercept(0.);
93 m_track->setUslope(0.);
94 m_track->setVslope(0.);
95// m_track->setResidualu(0, 0);
96// m_track->setResidualv(0, 0);
97 m_track->setChi2_u(1000.);
98 m_track->setChi2_v(1000.);
99 m_track->setCryoHitu(0.);
100 m_track->setCryoHitv(0.);
101 m_track->setCryoHitw(30000.);
102 return StatusCode::FAILURE;
103 }
104 // Now fit somehow
105 double chi2_x = 0;
106 double chi2_y = 0;
107 std::vector<double> residual_x, residual_y;
108 double a1_x = 0;
109 double a2_x = 0;
110 double a1_y = 0;
111 double a2_y = 0;
112 bool check = true;
113
114 check = fitVect(v_x, v_xz, v_ex, a1_x, a2_x, chi2_x, residual_x);
115
116 if(!check){
117 ATH_MSG_ERROR ( "Fit in X-coordinate failure." );
118 return StatusCode::FAILURE;
119 }
120
121 check = fitVect(v_y, v_yz, v_ey, a1_y, a2_y, chi2_y, residual_y);
122 if(!check){
123 ATH_MSG_ERROR ( "Fit in Y-coordinate failure." );
124 return StatusCode::FAILURE;
125 }
126
127 // Setting the slopes & intercepts for each track //
128 ATH_MSG_DEBUG ( "Setting fit parameters of track." );
129 ATH_MSG_DEBUG ( "Intercepts: "<<a1_x<<" "<<a1_y );
130 ATH_MSG_DEBUG ( "Slopes: "<<a2_x<<" "<<a2_y );
131
132 m_track = std::make_unique<TBTrack>(v_x.size(), v_y.size());
133
134 m_track->setUintercept(a1_x);
135 m_track->setVintercept(a1_y);
136 m_track->setUslope(a2_x);
137 m_track->setVslope(a2_y);
138
139 // Setting the residual for plane u //
140 for(size_t i = 0; i < v_x.size(); ++i){
141 m_track->setResidualu(i, residual_x[i]);
142 }
143
144 // Setting the residual for plane v //
145 for(size_t i = 0; i < v_y.size(); ++i){
146 m_track->setResidualv(i, residual_y[i]);
147 }
148
149 ATH_MSG_DEBUG ( "chi2 in X: " << chi2_x );
150 ATH_MSG_DEBUG ( "chi2 in Y: " << chi2_y );
151 ATH_MSG_DEBUG ( "Setting chi2s of track." );
152
153 m_track->setChi2_u(chi2_x);
154 m_track->setChi2_v(chi2_y);
155
156 // Setting the cryo plane (30000 mm in TB coordinate)
157 m_track->setCryoHitu(a2_x*30000.+a1_x+m_cryoX);
158 m_track->setCryoHitv(a2_y*30000.+a1_y);
159 m_track->setCryoHitw(30000.);
160
161 return StatusCode::SUCCESS;
162}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< int > m_pcode
Gaudi::Property< bool > m_Primary
bool fitVect(const dVect &vec_x, const dVect &vec_xz, const dVect &vec_ex, double &a1, double &a2, double &chi2, dVect &residual)
Fit data to the function u = a1 + a2*w.
SG::WriteHandle< TBTrack > m_track
std::vector< double > dVect

◆ 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

◆ finalize()

StatusCode LArTBH6BeamInfo::finalize ( )
overridevirtual

Definition at line 168 of file LArTBH6BeamInfo.cxx.

169{
170 ATH_MSG_INFO ( "LArTBH6BeamInfo::finalize()" );
171 return StatusCode::SUCCESS;
172}

◆ fitVect()

bool LArTBH6BeamInfo::fitVect ( const dVect & vec_x,
const dVect & vec_xz,
const dVect & vec_ex,
double & a1,
double & a2,
double & chi2,
dVect & residual )
private

Fit data to the function u = a1 + a2*w.

and determines intercept, slope, residual for each BPC, and chi2 on fit

Definition at line 175 of file LArTBH6BeamInfo.cxx.

178{
179 // v_u = vector of u data points
180 // v_w = vector of w data points
181 // v_eu = vector of errors in u data points
182 // v_ew = vector of errors in w data points
183 // a1 and a2 = fit parameters: u = a1 + a2*w
184
185 // *** note that the fit algorithm used (given in 'Numerical Methods
186 // in C' section 15.2) assumes that the w data points are known exactly
187 // i.e. that v_ew[i]=0 for all i
188
189 // 'Numerical Methods' notes that the task of fitting a straight
190 // line model with errors in both coordinates is "considerably harder"
191 // (section 15.3) - but clearly it could be done
192
193 int i;
194 double s = 0;
195 double su = 0;
196 double sww = 0;
197 double sw = 0;
198 double suw = 0;
199
200 int hitNum = vec.size();
201 for(i = 0; i < hitNum; ++i){
202
203 ATH_MSG_DEBUG ( "Position in X: " << vec[i] );
204 ATH_MSG_DEBUG ( "Position in Z: " << vec_z[i] );
205 ATH_MSG_DEBUG ( "Error in X: " << vec_e[i] );
206
207 s += 1 / (vec_e[i]*vec_e[i]);
208 su += vec[i] / (vec_e[i]*vec_e[i]);
209 sww += vec_z[i]*vec_z[i] / (vec_e[i]*vec_e[i]);
210 sw += vec_z[i] / (vec_e[i]*vec_e[i]);
211 suw += vec[i]*vec_z[i] / (vec_e[i]*vec_e[i]);
212 }
213
214 const double denom = (s*sww-sw*sw);
215 if(denom == 0){
216 ATH_MSG_ERROR ( " Invalid denominator" );
217 return false;
218 }
219
220 // coverity[divide_by_zero] // false positive
221 const double inv_denom = 1. / denom;
222 a1 = (su*sww - sw*suw) * inv_denom;
223 a2 = (s*suw - su*sw) * inv_denom;
224 ATH_MSG_DEBUG ( "Fit results:" << " intercept = " << a1 << " and slope = " << a2 );
225
226 // Fill residual
227 residual.clear();
228 for (i = 0; i < hitNum; ++i) {
229 residual.push_back(vec[i] - a1 - a2*vec_z[i]);
230 }
231 // Fill Chi2
232 chi2 = 0;
233 for(i = 0; i < hitNum; ++i){
234 chi2 += (vec[i] - a1 - a2*vec_z[i])*(vec[i] - a1 - a2*vec_z[i])/(vec_e[i]*vec_e[i]);
235 }
236
237 return true;
238}
std::vector< size_t > vec
double chi2(TH1 *h0, TH1 *h1)

◆ initialize()

StatusCode LArTBH6BeamInfo::initialize ( )
overridevirtual

Definition at line 28 of file LArTBH6BeamInfo.cxx.

29{
30
31 if((!m_Primary) && (m_pcode == 999)) {
32 ATH_MSG_ERROR ( "Pcode should be in jO, if not PrimaryTrackOnly !" );
33 return StatusCode::FAILURE;
34 }
35
36// End of Initialization
37 ATH_MSG_INFO ( "LArTBH6BeamInfo initialisation completed" );
38 return StatusCode::SUCCESS;
39}

◆ 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}
#define ATH_MSG_WARNING(x)
static Double_t sc
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_cryoX

float LArTBH6BeamInfo::m_cryoX {0.f}
private

Definition at line 50 of file LArTBH6BeamInfo.h.

50{0.f};

◆ 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_hitcoll

std::vector< SG::ReadHandle< AthenaHitsVector<LArG4H6FrontHit> > > LArTBH6BeamInfo::m_hitcoll
private

Definition at line 55 of file LArTBH6BeamInfo.h.

◆ m_HitsCollNames

Gaudi::Property<std::vector<std::string> > LArTBH6BeamInfo::m_HitsCollNames {this, "HitsContainer"}
private

Definition at line 46 of file LArTBH6BeamInfo.h.

46{this, "HitsContainer"};

◆ m_numEv

int LArTBH6BeamInfo::m_numEv {0}
private

Definition at line 51 of file LArTBH6BeamInfo.h.

51{0};

◆ m_pcode

Gaudi::Property<int> LArTBH6BeamInfo::m_pcode {this, "PrimaryParticle", 999}
private

Definition at line 48 of file LArTBH6BeamInfo.h.

48{this, "PrimaryParticle", 999};

◆ m_Primary

Gaudi::Property<bool> LArTBH6BeamInfo::m_Primary {this, "PrimaryTrackOnly", true}
private

Definition at line 47 of file LArTBH6BeamInfo.h.

47{this, "PrimaryTrackOnly", true};

◆ m_theEventInfo

SG::ReadHandle<TBEventInfo> LArTBH6BeamInfo::m_theEventInfo
private

Definition at line 53 of file LArTBH6BeamInfo.h.

◆ m_track

SG::WriteHandle<TBTrack> LArTBH6BeamInfo::m_track
private

Definition at line 54 of file LArTBH6BeamInfo.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.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: