BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcCalibAlg Class Reference

#include <MdcCalibAlg.h>

+ Inheritance diagram for MdcCalibAlg:

Public Member Functions

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

Detailed Description

Definition at line 39 of file MdcCalibAlg.h.

Constructor & Destructor Documentation

◆ MdcCalibAlg()

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

Definition at line 20 of file MdcCalibAlg.cxx.

20 :
21 Algorithm(name, pSvcLocator), m_mdcCalFlg(0), m_flgKalFit(0), m_evtType(0){
22
23 m_histname = "NULL";
24 m_configFile = "NULL";
25 m_nEvtDisp = 1000;
26 m_distCalib = false;
27 m_nEvt = 0;
28
29 // declare properties
30 declareProperty("MdcCalFlg", m_mdcCalFlg);
31 declareProperty("MdcKalmanFlg", m_flgKalFit);
32 declareProperty("Event", m_evtType);
33 declareProperty("HistOutput", m_histname);
34 declareProperty("ConfigFile", m_configFile);
35 declareProperty("WirePosCorFile", m_wpcFile);
36 declareProperty("NumEvtDisplay", m_nEvtDisp);
37 declareProperty("DistCalib", m_distCalib);
38 declareProperty("Ecm", m_ecm = 3.686);
39
40 m_initCalConstFlg = false;
41}

◆ ~MdcCalibAlg()

MdcCalibAlg::~MdcCalibAlg ( )

Definition at line 43 of file MdcCalibAlg.cxx.

43 {
44 delete m_constmgr;
45 std::cout << "m_constmgr deleted" << std::endl;
46
47 delete m_mdccalib;
48 std::cout << "delete m_mdccalib" << std::endl;
49
50 delete m_mdcevt;
51 std::cout << "m_mdcevt deleted" << std::endl;
52
53 delete m_hlist;
54 std::cout << "m_hlist deleted" << std::endl;
55
56 delete m_calconst;
57 std::cout << "m_calconst deleted" << std::endl;
58
59 if(!m_distCalib){
60 std::ofstream fend("endcal.out");
61 fend << "MdcCalib end." << std::endl;
62 fend.close();
63 }
64
65 std::cout << "MdcCalibAlg End." << std::endl;
66}

Member Function Documentation

◆ execute()

StatusCode MdcCalibAlg::execute ( )

Definition at line 264 of file MdcCalibAlg.cxx.

264 {
265 MsgStream log(msgSvc(), name());
266 log << MSG::DEBUG << "MdcCalibAlg execute()" << endreq;
267
268 // display event number for debug
269 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
270 if (!eventHeader) {
271 log << MSG::FATAL << "Could not find Event Header" << endreq;
272 return( StatusCode::FAILURE);
273 }
274 int iRun = eventHeader->runNumber();
275 int iEvt = eventHeader->eventNumber();
276 if(0 == (m_nEvt % m_nEvtDisp))
277 std::cout << "Run " << iRun << ", Event " << iEvt << ", Total Event number " << m_nEvt << endl;
278
279 m_mdcevt->setEvtNoOnline(iEvt);
280 m_mdcevt->setEvtNoOffline(m_nEvt);
281
282 if( ! m_initCalConstFlg ){
283// if((0 == m_mdcCalFlg) && (0 == m_param.fgIniCalConst)){
284// m_calconst->initCalibConst();
285// } else{
286// m_constmgr -> rdConstTcds(m_calconst);
287// }
288 m_constmgr -> rdConstTcds(m_calconst);
289 m_initCalConstFlg = true;
290 }
291
292 if(m_mdcCalFlg > 1){
293 if(m_flgKalFit) m_mdcevt -> setKalEvent();
294 else m_mdcevt -> setRecEvent();
295 }
296
297 // fill histograms
298 m_mdccalib -> fillHist(m_mdcevt);
299 m_mdcevt -> clear();
300 m_nEvt++;
301
302 return StatusCode::SUCCESS;
303}
IMessageSvc * msgSvc()
void setEvtNoOffline(int evtNo)
Definition: MdcCalEvent.h:39
void setEvtNoOnline(int evtNo)
Definition: MdcCalEvent.h:36

◆ finalize()

StatusCode MdcCalibAlg::finalize ( )

Definition at line 306 of file MdcCalibAlg.cxx.

306 {
307 MsgStream log(msgSvc(), name());
308 log << MSG::INFO << "MdcCalibAlg finalize()" << endreq;
309
310 gStyle -> SetCanvasBorderMode(0);
311 gStyle -> SetCanvasColor(10);
312 gStyle -> SetOptFit(0011);
313 gStyle -> SetStatColor(10);
314 gStyle -> SetStatBorderSize(1);
315 gStyle -> SetStatFont(42);
316 gStyle -> SetStatFontSize(0.04);
317 gStyle -> SetStatX(0.9);
318 gStyle -> SetStatY(0.9);
319 gStyle -> SetPadColor(10);
320 gStyle -> SetFuncColor(2);
321
322 // execute calibration and write new calibration data file
323 if(!m_distCalib){
324 m_mdccalib -> updateConst(m_calconst);
325 m_constmgr -> wrtConst( m_calconst );
326 }
327
328 // write histogram file
329 TFile fhist(m_histname.c_str(), "recreate");
330 m_hlist -> Write();
331 fhist.Close();
332 std::cout << m_histname << " was written" << std::endl;
333
334 m_mdccalib->clear();
335
336 return StatusCode::SUCCESS;
337}
curve Write()
gStyle SetCanvasColor(0)
virtual void clear()=0
Definition: MdcCalib.cxx:76

◆ initialize()

StatusCode MdcCalibAlg::initialize ( )

Definition at line 69 of file MdcCalibAlg.cxx.

69 {
70 MsgStream log( msgSvc(), name() );
71 log << MSG::INFO << "MdcCalibAlg initialze() ..." << endreq;
72 log << MSG::INFO << "MdcCalFlg = " << m_mdcCalFlg << endreq;
73
74 if("NULL"==m_histname){
75 log << MSG::ERROR << "not defined histogram file." << endreq;
76 return StatusCode::FAILURE;
77 }
78 if("NULL"==m_configFile){
79 log << MSG::ERROR << "not defined MdcCalibConfig file." << endreq;
80 return StatusCode::FAILURE;
81 }
82
83 StatusCode sc = service("MdcGeomSvc", m_mdcGeomSvc);
84 if(sc != StatusCode::SUCCESS){
85 log << MSG::ERROR << "can not use MdcGeomSvc" << endreq;
86 }
87
88 sc = service("MdcCalibFunSvc", m_mdcFunSvc);
89 if( sc != StatusCode::SUCCESS ){
90 log << MSG::FATAL << "can not use MdcCalibFunSvc" << endreq;
91 }
92
93 sc = service ("MdcUtilitySvc", m_mdcUtilitySvc);
94 if ( sc.isFailure() ){
95 log << MSG::FATAL << "Could not load MdcUtilitySvc!" << endreq;
96 }
97
98 string estver = getenv("ESTIMEALGROOT");
99 cout << "EsTimeAlg_ver: "<< estver << endl;
100
101 // initialize m_param
102 initParam();
103
104 // read mdc config parameters
105 int i;
106 int lay;
107 std::string strconfig;
108 std::string strcomment;
109 std::string strtmp;
110 std::string strTes;
111 int fgTes[50];
112 for(i=0; i<50; i++) fgTes[i] = -999;
113 ifstream fconfig( m_configFile.c_str() );
114 if( ! fconfig.is_open() ){
115 log << MSG::ERROR << "can not open config file " << m_configFile
116 << ". Use defalt config parameters" << endreq;
117 return StatusCode::FAILURE;
118 } else {
119 log << MSG::INFO << "Open config file " << m_configFile << endreq;
120 while( fconfig >> strconfig ){
121 if('#' == strconfig[0]){
122 getline(fconfig, strcomment);
123 } else if("FillNtuple" == strconfig){
124 fconfig >> m_param.fillNtuple;
125 } else if("nEvtNtuple" == strconfig){
126 fconfig >> m_param.nEvtNtuple;
127 }else if("FlagCalDetEffi" == strconfig){
128 fconfig >> m_param.fgCalDetEffi;
129 }else if("BoostPar" == strconfig){
130 fconfig >> m_param.boostPar[0] >> m_param.boostPar[1] >> m_param.boostPar[2];
131 } else if("EsTimeFlag" == strconfig){
132 getline(fconfig, strTes);
133 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",
134 fgTes+0, fgTes+1, fgTes+2, fgTes+3, fgTes+4,
135 fgTes+5, fgTes+6, fgTes+7, fgTes+8, fgTes+9,
136 fgTes+10, fgTes+11, fgTes+12, fgTes+13, fgTes+14,
137 fgTes+15, fgTes+16, fgTes+17, fgTes+18, fgTes+19);
138 for(i=0; i<n; i++) m_param.esFlag[i] = fgTes[i];
139 m_param.nEsFlag = n;
140 } else if("TimeShift" == strconfig){
141 fconfig >> m_param.timeShift;
142 } else if("TesMin" == strconfig){
143 fconfig >> m_param.tesMin;
144 } else if("TesMax" == strconfig){
145 fconfig >> m_param.tesMax;
146 } else if("FlagIniCalConst" == strconfig){
147 fconfig >> m_param.fgIniCalConst;
148 } else if("FlagUpdateTmInPreT0" == strconfig){
149 fconfig >> m_param.preT0SetTm;
150 } else if("InitT0" == strconfig){
151 fconfig >> m_param.initT0;
152 } else if("T0Shift" == strconfig){
153 fconfig >> m_param.t0Shift;
154 } else if("TminFitChindf" == strconfig){
155 fconfig >> m_param.tminFitChindf;
156 } else if("TmaxFitChindf" == strconfig){
157 fconfig >> m_param.tmaxFitChindf;
158 } else if("InitSigma" == strconfig){
159 fconfig >> m_param.initSigma;
160 } else if("UpdateSigma" == strconfig){
161 fconfig >> m_param.calSigma;
162 } else if("ResidualType" == strconfig){
163 fconfig >> m_param.resiType;
164 } else if("FixXtC0" == strconfig){
165 fconfig >> m_param.fixXtC0;
166 } else if("FixXtEdge" == strconfig){
167 fconfig >> m_param.fixXtEdge;
168 } else if("FlagAdjacLayerCut" == strconfig){
169 fconfig >> m_param.fgAdjacLayerCut;
170 } else if("FlagBoundLayerCut" == strconfig){
171 fconfig >> m_param.fgBoundLayerCut;
172 } else if("hitStatCut" == strconfig){
173 fconfig >> m_param.hitStatCut;
174 } else if("nTrkCut" == strconfig){
175 fconfig >> m_param.nTrkCut[0] >> m_param.nTrkCut[1];
176 } else if("nHitLayCut" == strconfig){
177 fconfig >> m_param.nHitLayCut;
178 } else if("nHitCut" == strconfig){
179 fconfig >> m_param.nHitCut;
180 } else if("noiseCut" == strconfig){
181 fconfig >> m_param.noiseCut;
182 } else if("cosThetaCut" == strconfig){
183 fconfig >> m_param.costheCut[0] >> m_param.costheCut[1];
184 } else if("DrCut" == strconfig){
185 fconfig >> m_param.drCut;
186 } else if("DzCut" == strconfig){
187 fconfig >> m_param.dzCut;
188 }else if("MaximalDocaInner" == strconfig){
189 fconfig >> m_param.maxDocaInner;
190 }else if("MaximalDocaOuter" == strconfig){
191 fconfig >> m_param.maxDocaOuter;
192 } else if("RawTimeFitRange" == strconfig){
193 for(lay=0; lay<MdcCalNLayer; lay++){
194 fconfig >> strtmp
195 >> m_param.fgCalib[lay]
196 >> m_param.tminFitRange[lay][0]
197 >> m_param.tminFitRange[lay][1]
198 >> m_param.tmaxFitRange[lay][0]
199 >> m_param.tmaxFitRange[lay][1]
200 >> m_param.initTm[lay]
201 >> m_param.resiCut[lay]
202 >> m_param.qmin[lay]
203 >> m_param.qmax[lay];
204 }
205 }
206 }
207 fconfig.close();
208 }
209 // set single wire position calibration file
210 m_param.wpcFile = m_wpcFile;
211
212 // set event type
213 m_param.particle = m_evtType;
214
215 // set Ecm
216 m_param.ecm = m_ecm;
217
218 cout << "EsFlag for Mdc Calibration: ";
219 for(int iEs=0; iEs<m_param.nEsFlag; iEs++) cout << setw(6) << m_param.esFlag[iEs];
220 cout << endl;
221
222 m_hlist = new TObjArray(0);
223 m_constmgr = new MdcCalConstMgr();
224 m_calconst = new MdcCalibConst();
225
226 m_mdcevt = new MdcCalEvent();
227 m_mdcevt -> setParam(m_param);
228 m_mdcevt -> setGeomSvc(m_mdcGeomSvc);
229 m_mdcevt -> setUtilSvc(m_mdcUtilitySvc);
230
231 if( 0 == m_mdcCalFlg ){
232 m_mdccalib = new IniMdcCalib();
233 }else if( 1 == m_mdcCalFlg ){
234 m_mdccalib = new PreXtMdcCalib();
235 }else if( 2 == m_mdcCalFlg ){
236 m_mdccalib = new PreT0MdcCalib();
237 }else if( 3 == m_mdcCalFlg ){
238 m_mdccalib = new XtMdcCalib();
239 }else if( 4 == m_mdcCalFlg ){
240 m_mdccalib = new GrXtMdcCalib();
241 }else if( 9 == m_mdcCalFlg ){
242 m_mdccalib = new XtInteMdcCalib();
243 }else if( 5 == m_mdcCalFlg ){
244 m_mdccalib = new T0MdcCalib();
245 }else if( 6 == m_mdcCalFlg ){
246 m_mdccalib = new WrMdcCalib();
247 }else if( 7 == m_mdcCalFlg ){
248 m_mdccalib = new Wr2dMdcCalib();
249 }else if( 8 == m_mdcCalFlg ){
250 m_mdccalib = new QtMdcCalib();
251 }
252 // initialize and read the calibraion data from TCDS
253 m_constmgr -> init(m_mdcGeomSvc, m_mdcFunSvc);
254
255 m_mdccalib -> setParam(m_param);
256 m_mdccalib -> initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc);
257
258// if(0 == m_mdcCalFlg) m_calconst->initCalibConst();
259
260 return StatusCode::SUCCESS;
261}
const Int_t n
const int MdcCalNLayer
Definition: MdcCalParams.h:6
int fgAdjacLayerCut
Definition: MdcCalParams.h:61
double maxDocaOuter
Definition: MdcCalParams.h:73
double initTm[MdcCalNLayer]
Definition: MdcCalParams.h:78
double costheCut[2]
Definition: MdcCalParams.h:69
int fgBoundLayerCut
Definition: MdcCalParams.h:62
int nTrkCut[2]
Definition: MdcCalParams.h:63
int fgCalib[MdcCalNLayer]
Definition: MdcCalParams.h:75
double t0Shift
Definition: MdcCalParams.h:50
std::string wpcFile
Definition: MdcCalParams.h:83
double initT0
Definition: MdcCalParams.h:49
double tminFitRange[MdcCalNLayer][2]
Definition: MdcCalParams.h:76
double initSigma
Definition: MdcCalParams.h:53
double maxDocaInner
Definition: MdcCalParams.h:72
double boostPar[3]
Definition: MdcCalParams.h:37
double qmax[MdcCalNLayer]
Definition: MdcCalParams.h:81
double dzCut
Definition: MdcCalParams.h:71
double tminFitChindf
Definition: MdcCalParams.h:51
double timeShift
Definition: MdcCalParams.h:42
double tesMax
Definition: MdcCalParams.h:44
int esFlag[50]
Definition: MdcCalParams.h:41
double qmin[MdcCalNLayer]
Definition: MdcCalParams.h:80
double tmaxFitChindf
Definition: MdcCalParams.h:52
double drCut
Definition: MdcCalParams.h:70
double resiCut[MdcCalNLayer]
Definition: MdcCalParams.h:79
double tmaxFitRange[MdcCalNLayer][2]
Definition: MdcCalParams.h:77
double tesMin
Definition: MdcCalParams.h:43
StatusCode initialize()
Definition: MdcCalibAlg.cxx:69
InputRawInit init
Definition: JobInputRaw.cxx:29
std::ifstream ifstream
Definition: bpkt_streams.h:44

Referenced by initialize().


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