CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcAlignAlg Class Reference

#include <MdcAlignAlg.h>

+ Inheritance diagram for MdcAlignAlg:

Public Member Functions

 MdcAlignAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
 MdcAlignAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Constructor & Destructor Documentation

◆ MdcAlignAlg() [1/2]

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

Definition at line 21 of file MdcAlignAlg.cxx.

21 :
22 Algorithm(name, pSvcLocator), m_alignMeth(0), m_flgKalFit(0){
23
24 m_distAlign = false;
25 m_configFile = "MdcCalibConfig.txt";
26 m_fixMomLab = "fixMom_lab.txt";
27 m_nEvt = 0;
28 m_mag = 1.0;
29
30 //declare properties
31 declareProperty("DistAlign", m_distAlign);
32 declareProperty("MdcAlignMeth", m_alignMeth);
33 declareProperty("UseKalFit", m_flgKalFit);
34 declareProperty("MagneticField", m_mag);
35 declareProperty("AlignFile", m_alignFile);
36 declareProperty("HistFile", m_histname);
37 declareProperty("ConfigFile", m_configFile);
38 declareProperty("FixMomLab", m_fixMomLab);
39 declareProperty("NumEvtDisplay", m_nEvtDisp);
40}

◆ MdcAlignAlg() [2/2]

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

Member Function Documentation

◆ execute() [1/2]

StatusCode MdcAlignAlg::execute ( )

Definition at line 155 of file MdcAlignAlg.cxx.

155 {
156 MsgStream log(msgSvc(), name());
157 log << MSG::DEBUG << "MdcAlignAlg execute()" << endreq;
158
159 // display event number for debug
160 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
161 if (!eventHeader) {
162 log << MSG::FATAL << "Could not find Event Header" << endreq;
163 return( StatusCode::FAILURE);
164 }
165 int iEvt = eventHeader->eventNumber();
166 if(0 == (m_nEvt % m_nEvtDisp)) std::cout << "Event " << m_nEvt << ", Event number online " << iEvt << endl;
167 m_nEvt++;
168
169 // get reconstruction result
170 if(m_flgKalFit) m_mdcevt -> setKalEvent();
171 else m_mdcevt -> setRecEvent();
172
173 if (!(m_pAlign->fillHist(m_mdcevt))) {
174 m_mdcevt->clear();
175 return(StatusCode::SUCCESS);
176 }
177 m_mdcevt->clear();
178
179 return StatusCode::SUCCESS;
180}
virtual bool fillHist(MdcAliEvent *event)=0
Definition: MdcAlign.cxx:16

◆ execute() [2/2]

StatusCode MdcAlignAlg::execute ( )

◆ finalize() [1/2]

StatusCode MdcAlignAlg::finalize ( )

Definition at line 183 of file MdcAlignAlg.cxx.

183 {
184 MsgStream log(msgSvc(), name());
185 log << MSG::INFO << "MdcAlignAlg finalize()" << endreq;
186
187 if( ! m_distAlign ){
188 // execute calibration and write new calibration data file
189 m_pAlign -> updateConst(m_alignPar);
190 m_alignPar -> wrtAlignPar();
191 }
192
193 TFile* fhist = new TFile(m_histname.c_str(), "recreate");
194 m_hlist -> Write();
195
196 m_pAlign -> clear();
197 delete m_pAlign;
198 std::cout << "m_pAlign deleted" << std::endl;
199
200 delete m_alignPar;
201 std::cout << "m_alignPar deleted" << std::endl;
202
203 delete m_mdcevt;
204 std::cout << "m_mdcevt deleted" << std::endl;
205
206 delete m_hlist;
207 std::cout << "m_hlist deleted" << std::endl;
208
209 fhist->Close();
210 delete fhist;
211 cout << m_histname << " was written" << endl;
212
213 if( ! m_distAlign ){
214 std::ofstream fend("endalign.out");
215 fend << "MdcAlign end." << std::endl;
216 fend.close();
217 }
218
219 std::cout << "MdcAlignAlg End." << std::endl;
220
221 return StatusCode::SUCCESS;
222}

◆ finalize() [2/2]

StatusCode MdcAlignAlg::finalize ( )

◆ initialize() [1/2]

StatusCode MdcAlignAlg::initialize ( )

Definition at line 44 of file MdcAlignAlg.cxx.

44 {
45 MsgStream log( msgSvc(), name() );
46 log << MSG::INFO << "MdcAlignAlg initialze() ..." << endreq;
47 log << MSG::INFO << "MdcAlignFlg = " << m_alignMeth << endreq;
48
49 StatusCode sc = service("MdcGeomSvc", m_mdcGeomSvc);
50 if(sc != StatusCode::SUCCESS){
51 log << MSG::ERROR << "can not use MdcGeomSvc" << endreq;
52 }
53
54 sc = service("MdcCalibFunSvc", m_mdcFunSvc);
55 if( sc != StatusCode::SUCCESS ){
56 log << MSG::FATAL << "can not use MdcCalibFunSvc" << endreq;
57 }
58
59 // initialize m_param
60 initParam();
61
62 // read mdc config parameters
63 int i;
64 std::string strconfig;
65 std::string strcomment;
66 std::string strTes;
67 int fgTes[50];
68 for(i=0; i<50; i++) fgTes[i] = -999;
69 ifstream fconfig( m_configFile.c_str() );
70 if( ! fconfig.is_open() ){
71 log << MSG::WARNING << "can not open config file " << m_configFile
72 << ". Use defalt config parameters" << endreq;
73 } else {
74 log << MSG::INFO << "Open config file " << m_configFile << endreq;
75 while( fconfig >> strconfig ){
76 if('#' == strconfig[0]){
77 getline(fconfig, strcomment);
78 } else if("EsTimeFlag" == strconfig){
79 getline(fconfig, strTes);
80 int n = sscanf(strTes.c_str(), "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d",
81 fgTes+0, fgTes+1, fgTes+2, fgTes+3, fgTes+4,
82 fgTes+5, fgTes+6, fgTes+7, fgTes+8, fgTes+9,
83 fgTes+10, fgTes+11, fgTes+12, fgTes+13, fgTes+14,
84 fgTes+15, fgTes+16, fgTes+17, fgTes+18, fgTes+19);
85 for(i=0; i<n; i++) m_param.esFlag[i] = fgTes[i];
86 m_param.nEsFlag = n;
87 } else if("TesMin" == strconfig){
88 fconfig >> m_param.tesMin;
89 } else if("TesMax" == strconfig){
90 fconfig >> m_param.tesMax;
91 } else if("ResidualType" == strconfig){
92 fconfig >> m_param.resiType;
93 } else if("FlagAdjacLayerCut" == strconfig){
94 fconfig >> m_param.fgAdjacLayerCut;
95 } else if("FlagBoundLayerCut" == strconfig){
96 fconfig >> m_param.fgBoundLayerCut;
97 } else if("hitStatCut" == strconfig){
98 fconfig >> m_param.hitStatCut;
99 } else if("nTrkCut" == strconfig){
100 fconfig >> m_param.nTrkCut[0] >> m_param.nTrkCut[1];
101 } else if("nHitLayCut" == strconfig){
102 fconfig >> m_param.nHitLayCut;
103 } else if("nHitCut" == strconfig){
104 fconfig >> m_param.nHitCut;
105 } else if("ptCut" == strconfig){
106 fconfig >> m_param.ptCut[0] >> m_param.ptCut[1];
107 } else if("cosThetaCut" == strconfig){
108 fconfig >> m_param.costheCut[0] >> m_param.costheCut[1];
109 } else if("DrCut" == strconfig){
110 fconfig >> m_param.drCut;
111 } else if("DzCut" == strconfig){
112 fconfig >> m_param.dzCut;
113 } else if("MaximalDocaInner" == strconfig){
114 fconfig >> m_param.maxDocaInner;
115 }else if("MaximalDocaOuter" == strconfig){
116 fconfig >> m_param.maxDocaOuter;
117 }else if("MaximalResidual" == strconfig){
118 fconfig >> m_param.maxResi;
119 }
120 }
121 fconfig.close();
122 }
123
124 // set event type
125 m_param.particle = m_evtType;
126
127 cout << "EsFlag for Mdc Alignment: ";
128 for(int iEs=0; iEs<m_param.nEsFlag; iEs++) cout << setw(6) << m_param.esFlag[iEs];
129 cout << endl;
130
131 if(fabs(m_mag) > 0.01) Alignment::gFlagMag = true;
132 else Alignment::gFlagMag = false;
133
134 m_alignPar = new MdcAlignPar();
135 m_alignPar -> rdAlignPar(m_alignFile);
136
137 m_mdcevt = new MdcAliEvent();
138 m_mdcevt -> setParam(m_param);
139
140 m_hlist = new TObjArray();
141
142 if( 0 == m_alignMeth ){
143 m_pAlign = new ResiAlign();
144 } else if( 1 == m_alignMeth ){
145 m_pAlign = new MilleAlign();
146 m_pAlign->fixMomLab = m_fixMomLab;
147 }
148 m_pAlign->setParam(m_param);
149 m_pAlign -> initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc);
150
151 return StatusCode::SUCCESS;
152}
const Int_t n
StatusCode initialize()
Definition: MdcAlignAlg.cxx:44
virtual void setParam(MdcAliParams &param)=0

Referenced by initialize().

◆ initialize() [2/2]

StatusCode MdcAlignAlg::initialize ( )

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