ATLAS Offline Software
TBMWPCRec.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "TBMWPCRec.h"
7 
8 
9 TBMWPCRec::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 
29 { }
30 
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 
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  TBMWPCCont * mwpcCont = new 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  TBMWPC * mwpc = new TBMWPC(name);
73 
74  std::vector<int> cwireno = mwpcraw->getCwireno();
75  std::vector<int> nwires = mwpcraw->getNwires();
76 
77  std::vector<float> cluspos;
78  std::vector<float> clussize;
79 
80  cluspos.clear(); clussize.clear();
81 
82  unsigned int nclus = cwireno.size();
83  if(nclus!=nwires.size()) {
84  ATH_MSG_INFO ( " Problem with cluster number in MWPC plane "<<ind);
85  continue;
86  }
87  for(unsigned int clus=0;clus<nclus;clus++){
88 
89  // Cluster center (cm) (from 2002 code)
90  float coor = -m_mwpc_halfsize[ind]+m_mwpc_wirestep[ind]*cwireno[clus];
91  coor += (nwires[clus]%2==0) ? 0.5*m_mwpc_wirestep[ind] : 0;
92  if (mwpcraw->isX())
93  coor *= m_mwpc_invX[ind];
94  else
95  coor *= m_mwpc_invY[ind];
96 
97  // Halfsize of cluster (cm) (from 2002 code)
98  float hwidth = 0.5*nwires[clus]*m_mwpc_wirestep[ind];
99 
100  ATH_MSG_DEBUG ( " coor= "<<coor<<"cm , w="<<hwidth<<"cm");
101 
102  cluspos.push_back(coor);
103  clussize.push_back(hwidth);
104 
105  }
106 
107  mwpc->setCPos(cluspos);
108  mwpc->setClusterSizeC(clussize);
109  mwpc->setXchambers(mwpcraw->isX());
110 
111  mwpc->setOverflow(mwpcraw->isOverflow());
112 
113  mwpcCont->push_back(mwpc);
114  }
115 
116  ATH_MSG_DEBUG ( " recording "<<m_SGrecordkey);
117  sc = evtStore()->record(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 
133 StatusCode
135 {
136  return StatusCode::SUCCESS;
137 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TBMWPC::setXchambers
void setXchambers(bool isX)
Definition: TBMWPC.h:54
TBMWPCRawCont
Definition: TBMWPCRawCont.h:18
TBMWPCRec::m_mwpc_invY
std::vector< int > m_mwpc_invY
Definition: TBMWPCRec.h:53
TBMWPCRaw
Definition: TBMWPCRaw.h:23
TBMWPCRec::m_mwpc_invX
std::vector< int > m_mwpc_invX
Definition: TBMWPCRec.h:52
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TBBeamDetector::setOverflow
virtual void setOverflow()
Definition: TBBeamDetector.h:51
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TBMWPCRec::m_mwpc_names
std::string m_mwpc_names[8]
Definition: TBMWPCRec.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TBMWPC::setClusterSizeC
void setClusterSizeC(const std::vector< float > &clsize_c)
Set cluster size for c-direction.
Definition: TBMWPC.h:57
TBMWPCRec::finalize
virtual StatusCode finalize() override
Definition: TBMWPCRec.cxx:134
TBMWPCRec::m_SGrecordkey
std::string m_SGrecordkey
Definition: TBMWPCRec.h:41
TBMWPCCont
Definition: TBMWPCCont.h:17
TBMWPCRec::~TBMWPCRec
virtual ~TBMWPCRec()
Definition: TBMWPCRec.cxx:28
AthAlgorithm
Definition: AthAlgorithm.h:47
TBMWPCRec::TBMWPCRec
TBMWPCRec(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TBMWPCRec.cxx:9
TBMWPCRec::initialize
virtual StatusCode initialize() override
Definition: TBMWPCRec.cxx:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TBMWPCRec.h
TBMWPC
Definition: TBMWPC.h:30
TBMWPCRec::m_mwpc_halfsize
std::vector< float > m_mwpc_halfsize
Definition: TBMWPCRec.h:50
TBMWPC::setCPos
void setCPos(const std::vector< float > &signals)
Definition: TBMWPC.h:49
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
checkFileSG.ind
list ind
Definition: checkFileSG.py:118
TBMWPCRec::m_mwpc_wirestep
std::vector< float > m_mwpc_wirestep
Definition: TBMWPCRec.h:49
TBMWPCRec::execute
virtual StatusCode execute() override
Definition: TBMWPCRec.cxx:41
TBMWPCRec::m_SGkey
std::string m_SGkey
Definition: TBMWPCRec.h:41