BOSS 7.1.0
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 40 of file MdcCalibAlg.h.

Constructor & Destructor Documentation

◆ MdcCalibAlg()

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

Definition at line 27 of file MdcCalibAlg.cxx.

27 :
28 Algorithm(name, pSvcLocator), m_mdcCalFlg(0), m_flgKalFit(0), m_evtType(0){
29
30 m_histname = "NULL";
31 m_configFile = "NULL";
32 m_nEvtDisp = 1000;
33 m_distCalib = false;
34 m_nEvt = 0;
35
36 // declare properties
37 declareProperty("MdcCalFlg", m_mdcCalFlg);
38 declareProperty("MdcKalmanFlg", m_flgKalFit);
39 declareProperty("Event", m_evtType);
40 declareProperty("HistOutput", m_histname);
41 declareProperty("ConfigFile", m_configFile);
42 declareProperty("WirePosCorFile", m_wpcFile);
43 declareProperty("WireNoCal", m_fileWireNoCal);
44 declareProperty("NumEvtDisplay", m_nEvtDisp);
45 declareProperty("DistCalib", m_distCalib);
46 declareProperty("Ecm", m_ecm = 3.686);
47 declareProperty("CombinePlusMinus", m_combPM = false);
48
49 m_initCalConstFlg = false;
50}

◆ ~MdcCalibAlg()

MdcCalibAlg::~MdcCalibAlg ( )

Definition at line 52 of file MdcCalibAlg.cxx.

52 {
53 delete m_constmgr;
54 std::cout << "m_constmgr deleted" << std::endl;
55
56 delete m_mdccalib;
57 std::cout << "delete m_mdccalib" << std::endl;
58
59 delete m_mdcevt;
60 std::cout << "m_mdcevt deleted" << std::endl;
61
62 delete m_hlist;
63 std::cout << "m_hlist deleted" << std::endl;
64
65 delete m_calconst;
66 std::cout << "m_calconst deleted" << std::endl;
67
68 std::ofstream fend("endcal.out");
69 fend << "MdcCalib end." << std::endl;
70 fend.close();
71
72 std::cout << "MdcCalibAlg End." << std::endl;
73}

Member Function Documentation

◆ execute()

StatusCode MdcCalibAlg::execute ( )

Definition at line 294 of file MdcCalibAlg.cxx.

294 {
295 MsgStream log(msgSvc(), name());
296 log << MSG::DEBUG << "MdcCalibAlg execute()" << endreq;
297
298 // display event number for debug
299 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
300 if (!eventHeader) {
301 log << MSG::FATAL << "Could not find Event Header" << endreq;
302 return( StatusCode::FAILURE);
303 }
304 int iRun = eventHeader->runNumber();
305 int iEvt = eventHeader->eventNumber();
306 if(0 == (m_nEvt % m_nEvtDisp)){
307 std::cout << "Run " << iRun << ", Event " << iEvt << ", Total Event number " << m_nEvt << endl;
308 }
309
310 if(m_nEvt<=1){
311 IDataProviderSvc* pCalibDataSvc;
312 StatusCode sc = service("CalibDataSvc", pCalibDataSvc, true);
313 if ( !sc.isSuccess() ) {
314 log << MSG::ERROR
315 << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
316 << endreq;
317 return sc;
318 }
319
320 std::string fullPath = "/Calib/EsTimeCal";
321 SmartDataPtr<CalibData::EsTimeCalibData> TEst(pCalibDataSvc, fullPath);
322 if(!TEst){ cout<<"ERROR EsTimeCalibData"<<endl;}
323 else{
324 int no = TEst->getTestCalibConstNo();
325 cout <<"offset barrel t0="<< TEst->getToffsetb()
326 <<" , offset endcap t0="<< TEst->getToffsete()
327 <<" , bunch time ="<<TEst->getBunchTime()
328 <<endl;
329 // double t0offset_b=TEst->getToffsetb();
330 // double t0offset_e=TEst->getToffsete();
331 // double bunchtime=TEst->getBunchTime();
332 }
333 }
334
335 m_mdcevt->setEvtNoOnline(iEvt);
336 m_mdcevt->setEvtNoOffline(m_nEvt);
337
338 if( ! m_initCalConstFlg ){
339// if((0 == m_mdcCalFlg) && (0 == m_param.fgIniCalConst)){
340// m_calconst->initCalibConst();
341// } else{
342// m_constmgr -> rdConstTcds(m_calconst);
343// }
344 m_constmgr -> rdConstTcds(m_calconst);
345 m_initCalConstFlg = true;
346 }
347
348 if(m_mdcCalFlg > 1){
349 if(m_flgKalFit) m_mdcevt -> setKalEvent();
350 else m_mdcevt -> setRecEvent();
351 }
352
353 // fill histograms
354 m_mdccalib -> fillHist(m_mdcevt);
355 m_mdcevt -> clear();
356 m_nEvt++;
357
358 return StatusCode::SUCCESS;
359}
const int no
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 362 of file MdcCalibAlg.cxx.

362 {
363 MsgStream log(msgSvc(), name());
364 log << MSG::INFO << "MdcCalibAlg finalize()" << endreq;
365
366 gStyle -> SetCanvasBorderMode(0);
367 gStyle -> SetCanvasColor(10);
368 gStyle -> SetOptFit(0011);
369 gStyle -> SetStatColor(10);
370 gStyle -> SetStatBorderSize(1);
371 gStyle -> SetStatFont(42);
372 gStyle -> SetStatFontSize(0.04);
373 gStyle -> SetStatX(0.9);
374 gStyle -> SetStatY(0.9);
375 gStyle -> SetPadColor(10);
376 gStyle -> SetFuncColor(2);
377
378 // execute calibration and write new calibration data file
379 m_mdccalib -> printCut();
380 if(!m_distCalib){
381 m_mdccalib -> updateConst(m_calconst);
382 m_constmgr -> wrtConst( m_calconst );
383 }
384
385 // write histogram file
386 TFile fhist(m_histname.c_str(), "recreate");
387 m_hlist -> Write();
388 fhist.Close();
389 std::cout << m_histname << " was written" << std::endl;
390
391 // m_mdccalib->clear();
392
393 return StatusCode::SUCCESS;
394}
curve Write()
gStyle SetCanvasColor(0)

◆ initialize()

StatusCode MdcCalibAlg::initialize ( )

Definition at line 76 of file MdcCalibAlg.cxx.

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