ATLAS Offline Software
Loading...
Searching...
No Matches
TBMWPCRec.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "TBMWPCRec.h"
7
8
9TBMWPCRec::TBMWPCRec(const std::string& name,
10 ISvcLocator* pSvcLocator) :
11 AthAlgorithm(name,pSvcLocator)
12 {
13 // job options
14
15 declareProperty("SGkey", m_SGkey="MWPCRawCont");
16 declareProperty("SGrecordkey", m_SGrecordkey="MWPCCont");
17
18
19
20 declareProperty("MWPCwirestep", m_mwpc_wirestep);
21 declareProperty("MWPChalfsize", m_mwpc_halfsize);
22
23 declareProperty("MWPCinvX", m_mwpc_invX);
24 declareProperty("MWPCinvY", m_mwpc_invY);
25
26 }
27
30
31StatusCode
33{
34 m_mwpc_names[0]="X2"; m_mwpc_names[1]="Y2";m_mwpc_names[2]="X3";m_mwpc_names[3]="Y3";m_mwpc_names[4]="X4";
35 m_mwpc_names[5]="Y4";m_mwpc_names[6]="X5";m_mwpc_names[7]="Y5";
36
37 return StatusCode::SUCCESS;
38}
39
40StatusCode
42{
43 ATH_MSG_DEBUG ( "In execute()" );
44
45 // Reconstruct MWPC :
46 TBMWPCRawCont * mwpcrawCont;
47 StatusCode sc = evtStore()->retrieve(mwpcrawCont, m_SGkey);
48 if (sc.isFailure()){
49 ATH_MSG_INFO ( "TBObjectReco: Retrieval of "<<m_SGkey<<" failed" );
50
51 }else {
52 ATH_MSG_DEBUG ( "TBMWPCRec : Retrieval of "<<m_SGkey<<" succeed : cont size=" << mwpcrawCont->size());
53
54 auto mwpcCont = std::make_unique<TBMWPCCont>();
55
56 // Loop over MWPC
57 for (const TBMWPCRaw* mwpcraw : *mwpcrawCont) {
58 std::string name = mwpcraw->getDetectorName();
59 unsigned int ind=0;
60 // Find calibration index for this MWPC
61 while(ind<8)
62 {
63 if(name==m_mwpc_names[ind]) break;
64 else ind++;
65 }
66 if(ind==8) {
67 ATH_MSG_ERROR( "No calibrations for MWPC" <<name);
68 continue;
69 }
70
71 // build new MWPC
72
73 std::vector<int> cwireno = mwpcraw->getCwireno();
74 std::vector<int> nwires = mwpcraw->getNwires();
75
76 std::vector<float> cluspos;
77 std::vector<float> clussize;
78
79 cluspos.clear(); clussize.clear();
80
81 unsigned int nclus = cwireno.size();
82 if(nclus!=nwires.size()) {
83 ATH_MSG_INFO ( " Problem with cluster number in MWPC plane "<<ind);
84 continue;
85 }
86 for(unsigned int clus=0;clus<nclus;clus++){
87
88 // Cluster center (cm) (from 2002 code)
89 float coor = -m_mwpc_halfsize[ind]+m_mwpc_wirestep[ind]*cwireno[clus];
90 coor += (nwires[clus]%2==0) ? 0.5*m_mwpc_wirestep[ind] : 0;
91 if (mwpcraw->isX())
92 coor *= m_mwpc_invX[ind];
93 else
94 coor *= m_mwpc_invY[ind];
95
96 // Halfsize of cluster (cm) (from 2002 code)
97 float hwidth = 0.5*nwires[clus]*m_mwpc_wirestep[ind];
98
99 ATH_MSG_DEBUG ( " coor= "<<coor<<"cm , w="<<hwidth<<"cm");
100
101 cluspos.push_back(coor);
102 clussize.push_back(hwidth);
103
104 }
105
106 auto mwpc = std::make_unique<TBMWPC>(name);
107 mwpc->setCPos(cluspos);
108 mwpc->setClusterSizeC(clussize);
109 mwpc->setXchambers(mwpcraw->isX());
110
111 mwpc->setOverflow(mwpcraw->isOverflow());
112
113 mwpcCont->push_back(std::move(mwpc));
114 }
115
116 ATH_MSG_DEBUG ( " recording "<<m_SGrecordkey);
117 sc = evtStore()->record(std::move(mwpcCont),m_SGrecordkey);
118 if ( sc.isFailure( ) ) {
119 ATH_MSG_FATAL ( "Cannot record MWPCCont" );
120 }
121 }
122
123 if ( sc.isFailure( ) ) {
124 setFilterPassed(false);
125 } else {
126 setFilterPassed(true);
127 }
128 return StatusCode::SUCCESS;
129
130}
131
132
133StatusCode
135{
136 return StatusCode::SUCCESS;
137}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
size_type size() const noexcept
Returns the number of elements in the collection.
"TBEvent/TBMWPCRawCont.h"
std::vector< int > m_mwpc_invY
Definition TBMWPCRec.h:53
virtual ~TBMWPCRec()
Definition TBMWPCRec.cxx:28
std::vector< float > m_mwpc_wirestep
Definition TBMWPCRec.h:49
TBMWPCRec(const std::string &name, ISvcLocator *pSvcLocator)
Definition TBMWPCRec.cxx:9
virtual StatusCode finalize() override
std::string m_SGkey
Definition TBMWPCRec.h:41
virtual StatusCode execute() override
Definition TBMWPCRec.cxx:41
std::vector< float > m_mwpc_halfsize
Definition TBMWPCRec.h:50
virtual StatusCode initialize() override
Definition TBMWPCRec.cxx:32
std::string m_SGrecordkey
Definition TBMWPCRec.h:41
std::string m_mwpc_names[8]
Definition TBMWPCRec.h:47
std::vector< int > m_mwpc_invX
Definition TBMWPCRec.h:52