BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
tofcalgsec Class Reference

#include <tofcalgsec.h>

+ Inheritance diagram for tofcalgsec:

Public Member Functions

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

Protected Member Functions

bool testbit (unsigned int n)
 

Detailed Description

Definition at line 9 of file tofcalgsec.h.

Constructor & Destructor Documentation

◆ tofcalgsec()

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

Definition at line 63 of file tofcalgsec.cxx.

63 :Algorithm(name,pSvcLocator){
64 //set default values
65 m_calibItem="111111111";
66 //declares
67 declareProperty("Online", m_online );
68 declareProperty("Calibration", m_calibration );
69 declareProperty("WorkDir", m_workdir );
70 declareProperty("InputDataDir", m_datafile_dir );
71 declareProperty("InputDataFiles_Barrel", m_datafile_barrel );
72 declareProperty("InputDataFiles_Endcap", m_datafile_endcap );
73 declareProperty("CalibItem", m_calibItem );
74 declareProperty("TimeCorrelationZBin", m_tcorrzbin = 23 );
75 declareProperty("BarrelSigmaZBin", m_barrelzbin = 5 );
76 declareProperty("EndcapSigmaRBin", m_endcaprbin = 5 );
77 declareProperty("EndcapQRBin", m_endcapQrbin = 5 );
78}

◆ ~tofcalgsec()

tofcalgsec::~tofcalgsec ( )

Definition at line 363 of file tofcalgsec.cxx.

363{}

Member Function Documentation

◆ beginRun()

StatusCode tofcalgsec::beginRun ( )

Definition at line 198 of file tofcalgsec.cxx.

198 {
199 MsgStream log(msgSvc(), name());
200 log << MSG::INFO << "tofcalgsec::beginRun()" << endreq;
201 return StatusCode::SUCCESS;
202}
IMessageSvc * msgSvc()

◆ endRun()

StatusCode tofcalgsec::endRun ( )

Definition at line 241 of file tofcalgsec.cxx.

241 {
242 MsgStream log(msgSvc(), name());
243 log << MSG::INFO << "tofcalgsec::endRun()" << endreq;
244 return StatusCode::SUCCESS;
245}

◆ execute()

StatusCode tofcalgsec::execute ( )

Definition at line 205 of file tofcalgsec.cxx.

205 {
206 MsgStream log(msgSvc(), name());
207 log << MSG::INFO << "start "<<"tofcalgsec::execute()" << endreq;
208
209 if( m_online ) {
210 SmartDataPtr<RecBTofCalHitCol> bhitcol(eventSvc(),"/Event/Recon/RecBTofCalHitCol");
211 if( bhitcol ) {
212 m_checkbarrel->FillCol( bhitcol );
213 if( m_calibration ) {
215 manager->dataSet()->setBarrelData( bhitcol );
216 }
217 }
218 else{
219 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" << endreq;
220 // return StatusCode::SUCCESS;
221 }
222
223 SmartDataPtr<RecETofCalHitCol> ehitcol(eventSvc(),"/Event/Recon/RecETofCalHitCol");
224 if( ehitcol ) {
225 m_checkendcap->FillCol( ehitcol );
226 if( m_calibration ) {
228 }
229 }
230 else{
231 // log << MSG::ERROR << " Can't get /Event/Recon/RecETofCalHitCol in TDS!" <<endreq;
232 // return StatusCode::SUCCESS;
233 }
234 }
235
236 log << MSG::INFO << "end "<<"tofcalgsec::execute()" << endreq;
237 return StatusCode::SUCCESS;
238}
void FillCol(RecBTofCalHitCol &)
static TofCalibManager * getManager()
TofDataSet * dataSet()
void setBarrelData(RecBTofCalHitCol &)
Definition: TofDataSet.cxx:219
void setEndcapData(RecETofCalHitCol &)
Definition: TofDataSet.cxx:237

◆ finalize()

StatusCode tofcalgsec::finalize ( )

Definition at line 248 of file tofcalgsec.cxx.

248 {
249
250 MsgStream log(msgSvc(), name());
251 log << MSG::INFO << "tofcalgsec::finalize()" << endreq;
252
253 if( m_online && !m_calibration ) {
254 if( m_checkbarrel ) { delete m_checkbarrel; }
255 if( m_checkendcap ) { delete m_checkendcap; }
256 return StatusCode::SUCCESS;
257 }
258
260 if( !m_online ) {
261 if( m_barrelfile.empty() ) {
262 std::cout << " No barrle data files are valid, exit " << std::endl;
263 exit(0);
264 }
265 else {
266 manager->dataSet()->setBarrelDataFiles( m_barrelfile );
267 }
268 if( m_endcapfile.empty() ) {
269 std::cout << " No endcap data files are valid, exit " << std::endl;
270 exit(0);
271 }
272 else {
273 manager->dataSet()->setEndcapDataFiles( m_endcapfile );
274 }
275 }
276
277 // barrel attenuation length calibration
278 if( testbit(5) ) {
279 manager->addCalib( new calib_barrel_atten(), true );
280 manager->addCalib( new calib_barrel_q0(), true );
281 }
282 // barrel effective velocity calibration
283 if( testbit(4) ) {
284 manager->addCalib( new calib_barrel_veff(), true );
285 }
286 // barrel time calibration
287 if( testbit(7) ) {
288 manager->addCalib( new calib_barrel_left(), true );
289 if (testbit(8)){
290 manager->addCalib( new calib_barrel_left_offset1_bunch0_4(), true );
291 manager->addCalib( new calib_barrel_left_offset1_bunch1_4(), true );
292 manager->addCalib( new calib_barrel_left_offset1_bunch2_4(), true );
293 manager->addCalib( new calib_barrel_left_offset1_bunch3_4(), true );
294 manager->addCalib( new calib_barrel_left_offset2_bunch0_4(), true );
295 manager->addCalib( new calib_barrel_left_offset2_bunch1_4(), true );
296 manager->addCalib( new calib_barrel_left_offset2_bunch2_4(), true );
297 manager->addCalib( new calib_barrel_left_offset2_bunch3_4(), true );
298 }
299 if (!testbit(8)){
300 manager->addCalib( new calib_barrel_left_offset1_bunch0_3(), true );
301 manager->addCalib( new calib_barrel_left_offset1_bunch1_3(), true );
302 manager->addCalib( new calib_barrel_left_offset1_bunch2_3(), true );
303 manager->addCalib( new calib_barrel_left_offset1_bunch3_3(), true );
304 manager->addCalib( new calib_barrel_left_offset2_bunch0_3(), true );
305 manager->addCalib( new calib_barrel_left_offset2_bunch1_3(), true );
306 manager->addCalib( new calib_barrel_left_offset2_bunch2_3(), true );
307 manager->addCalib( new calib_barrel_left_offset2_bunch3_3(), true );
308 }
309 manager->addCalib( new calib_barrel_right(), true );
310 if (testbit(8)){
311 manager->addCalib( new calib_barrel_right_offset1_bunch0_4(), true );
312 manager->addCalib( new calib_barrel_right_offset1_bunch1_4(), true );
313 manager->addCalib( new calib_barrel_right_offset1_bunch2_4(), true );
314 manager->addCalib( new calib_barrel_right_offset1_bunch3_4(), true );
315 manager->addCalib( new calib_barrel_right_offset2_bunch0_4(), true );
316 manager->addCalib( new calib_barrel_right_offset2_bunch1_4(), true );
317 manager->addCalib( new calib_barrel_right_offset2_bunch2_4(), true );
318 manager->addCalib( new calib_barrel_right_offset2_bunch3_4(), true );
319 }
320 if (!testbit(8)){
321 manager->addCalib( new calib_barrel_right_offset1_bunch0_3(), true );
322 manager->addCalib( new calib_barrel_right_offset1_bunch1_3(), true );
323 manager->addCalib( new calib_barrel_right_offset1_bunch2_3(), true );
324 manager->addCalib( new calib_barrel_right_offset1_bunch3_3(), true );
325 manager->addCalib( new calib_barrel_right_offset2_bunch0_3(), true );
326 manager->addCalib( new calib_barrel_right_offset2_bunch1_3(), true );
327 manager->addCalib( new calib_barrel_right_offset2_bunch2_3(), true );
328 manager->addCalib( new calib_barrel_right_offset2_bunch3_3(), true );
329 }
330 }
331 // barrel sigma calibration
332 if( testbit(6) ) {
333 manager->addCalib( new calib_barrel_common(m_tcorrzbin), true );
334 manager->addCalib( new calib_barrel_sigma(m_barrelzbin), true );
335 }
336
337 // endcap attenuation length calibration
338 if( testbit(1) ) {
339 manager->addCalib( new calib_endcap_atten(m_endcapQrbin),false );
340 }
341 // endcap effective velocity calibration
342 if( testbit(0) ) {
343 manager->addCalib( new calib_endcap_veff(),false );
344 }
345 // endcap time calibration
346 if( testbit(3) ) {
347 manager->addCalib( new calib_endcap_left(), false );
348 }
349 // endcap sigma calibration
350 if( testbit(2) ) {
351 manager->addCalib( new calib_endcap_sigma(m_endcaprbin), false );
352 }
353
354 manager->doCalibration();
355
356 manager->fillTxt( m_workdir );
357 manager->fillRoot( m_workdir );
358
359 return StatusCode::SUCCESS;
360}
void addCalib(TofCalib *cal_item1, bool isbarrel)
void fillRoot(string &dir)
void fillTxt(string &dir)
void setEndcapDataFiles(std::vector< std::string > &)
Definition: TofDataSet.cxx:196
void setBarrelDataFiles(std::vector< std::string > &)
Definition: TofDataSet.cxx:173
bool testbit(unsigned int n)
Definition: tofcalgsec.h:21

◆ initialize()

StatusCode tofcalgsec::initialize ( )

Definition at line 81 of file tofcalgsec.cxx.

81 {
82
83 MsgStream log(msgSvc(), name());
84 log<<MSG::INFO<< "tofcalgsec::initialize()!" <<endreq;
85
86 if( m_online ) {
87 NTuplePtr nt1(ntupleSvc(),"TofCalib/btrk");
88 NTuplePtr nt2(ntupleSvc(),"TofCalib/etrk");
89 if ( nt1 || nt2 ) {
90 mtuple_barrel = nt1;
91 mtuple_endcap = nt2;
92 }
93 else {
94 mtuple_barrel = ntupleSvc()->book("TofCalib/btrk",CLID_ColumnWiseTuple,"TofCalib");
95 mtuple_endcap = ntupleSvc()->book("TofCalib/etrk",CLID_ColumnWiseTuple,"TofCalib");
96
97 if( mtuple_barrel ) {
98 m_checkbarrel = new TofCalibCheck( mtuple_barrel );
99 }
100 else{
101 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_barrel) <<endmsg;
102 return StatusCode::FAILURE;
103 }
104 if( mtuple_endcap ) {
105 m_checkendcap = new TofCalibCheck( mtuple_endcap );
106 }
107 else{
108 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_endcap) <<endmsg;
109 return StatusCode::FAILURE;
110 }
111 }
112 }
113 else {
114 m_calibration = true; // offline
115 }
116
117 if( !m_online || m_calibration ) {
118 // check workdir
119 std::cout<<" tofcalgsec checks your configurations ..."<<std::endl;
120 void *pdir=0;
121 if((pdir=gSystem->OpenDirectory(m_workdir.c_str()))==0){//dir exists?
122 std::cerr<<"WorkDir "<<m_workdir<<" doesn't exist "<<std::endl;
123 if(gSystem->MakeDirectory(m_workdir.c_str())==-1){//mkdir,fail to create?
124 std::cerr<<" Fail to create directory : "<<m_workdir
125 <<" Specify ./ as current work directory"<<std::endl;
126 m_workdir="./";
127 }
128 }
129 else{
130 gSystem->FreeDirectory(pdir);
131 pdir=0;
132 }
133 }
134
135 if( !m_online ) {
136 void *pdir=0;
137 if( (pdir=gSystem->OpenDirectory(m_datafile_dir.c_str())) ) {
138 FileStat_t fs;
139 std::vector<string>::iterator it = m_datafile_barrel.begin();
140 for( ; it!=m_datafile_barrel.end(); it++ ) {
141 if( (*it).size()>0 ) {
142 std::string thefile = (m_datafile_dir+"/"+(*it));
143 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) {
144 m_barrelfile.push_back(thefile);
145 }
146 else{
147 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl;
148 }
149 }
150 }
151 it = m_datafile_endcap.begin();
152 for( ; it!=m_datafile_endcap.end(); it++ ) {
153 if( (*it).size()>0 ) {
154 std::string thefile=(m_datafile_dir+"/"+(*it));
155 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) {
156 m_endcapfile.push_back(thefile);
157 }
158 else{
159 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl;
160 }
161 }
162 }
163 gSystem->FreeDirectory(pdir);
164 pdir=0;
165 }
166 else {
167 std::cerr<<" Error : Please specify the InputDataDir which contains input data files for calibration "<<std::endl;
168 exit(0);
169 }
170 }
171
172 if( !m_online || m_calibration ) {
173 std::cout<<"******************* Report of before Calibration ********************"<<std::endl
174 <<"* WorkDir = "<<m_workdir<<" [ results are save in this directory ] "<<std::endl
175 <<"* WorkMode = "<<(m_online?"OnLine":"OffLine")<<" [ run alone or with other algorithms ] "<<std::endl
176 <<"* CalibItem = "<<m_calibItem<<" [ which calibraions you perform ]"<<std::endl;
177 }
178
179 if( !m_online ) {
180 std::cout <<"* ==> InputDataDir : "<<m_datafile_dir<<std::endl
181 <<"* ===>Files of Barrel : ";
182 for( std::vector<std::string>::iterator it=m_barrelfile.begin(); it!=m_barrelfile.end(); it++ ) {
183 std::cout << "'" << (*it) << "' ";
184 }
185 std::cout << std::endl
186 <<"* ===>Files of Endcap : ";
187 for( std::vector<std::string>::iterator it=m_endcapfile.begin(); it!=m_endcapfile.end(); it++ ) {
188 std::cout << "'" << (*it) << "' ";
189 }
190 std::cout << std::endl;
191 }
192 std::cout<<"*********************************************************************"<<std::endl;
193
194 return StatusCode::SUCCESS;
195}
INTupleSvc * ntupleSvc()

◆ testbit()

bool tofcalgsec::testbit ( unsigned int  n)
inlineprotected

Definition at line 21 of file tofcalgsec.h.

21 {
22 if( n>m_calibItem.size() ) return false;
23 return m_calibItem[n]=='0'?false:true;
24 }
const Int_t n

Referenced by finalize().


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