#include <tofcalgsec.h>
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) |
Private Attributes | |
bool | m_online |
bool | m_calibration |
std::string | m_workdir |
std::string | m_datafile_dir |
std::vector< std::string > | m_datafile_barrel |
std::vector< std::string > | m_datafile_endcap |
std::vector< std::string > | m_datafile_etf |
std::vector< std::string > | m_barrelfile |
std::vector< std::string > | m_endcapfile |
std::vector< std::string > | m_etffile |
std::string | m_calibItem |
unsigned int | m_tcorrzbin |
unsigned int | m_barrelzbin |
unsigned int | m_endcaprbin |
unsigned int | m_endcapQrbin |
bool | FILE_HAS_BEEN_READ |
TofCalibCheck * | m_checkbarrel |
NTuple::Tuple * | mtuple_barrel |
TofCalibCheck * | m_checkendcap |
NTuple::Tuple * | mtuple_endcap |
TofCalibCheck * | m_checketf |
NTuple::Tuple * | mtuple_etf |
Definition at line 9 of file tofcalgsec.h.
tofcalgsec::tofcalgsec | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 71 of file tofcalgsec.cxx.
References m_barrelzbin, m_calibItem, m_calibration, m_datafile_barrel, m_datafile_dir, m_datafile_endcap, m_datafile_etf, m_endcapQrbin, m_endcaprbin, m_online, m_tcorrzbin, and m_workdir.
00071 :Algorithm(name,pSvcLocator){ 00072 //set default values 00073 m_calibItem="111111111"; 00074 //declares 00075 declareProperty("Online", m_online ); 00076 declareProperty("Calibration", m_calibration ); 00077 declareProperty("WorkDir", m_workdir ); 00078 declareProperty("InputDataDir", m_datafile_dir ); 00079 declareProperty("InputDataFiles_Barrel", m_datafile_barrel ); 00080 declareProperty("InputDataFiles_Endcap", m_datafile_endcap ); 00081 declareProperty("InputDataFiles_Etf", m_datafile_etf ); 00082 declareProperty("CalibItem", m_calibItem ); 00083 declareProperty("TimeCorrelationZBin", m_tcorrzbin = 23 ); 00084 declareProperty("BarrelSigmaZBin", m_barrelzbin = 5 ); 00085 declareProperty("EndcapSigmaRBin", m_endcaprbin = 5 ); 00086 declareProperty("EndcapQRBin", m_endcapQrbin = 5 ); 00087 }
tofcalgsec::~tofcalgsec | ( | ) |
StatusCode tofcalgsec::beginRun | ( | ) |
Definition at line 234 of file tofcalgsec.cxx.
References Bes_Common::INFO, and msgSvc().
00234 { 00235 MsgStream log(msgSvc(), name()); 00236 log << MSG::INFO << "tofcalgsec::beginRun()" << endreq; 00237 return StatusCode::SUCCESS; 00238 }
StatusCode tofcalgsec::endRun | ( | ) |
Definition at line 289 of file tofcalgsec.cxx.
References Bes_Common::INFO, and msgSvc().
00289 { 00290 MsgStream log(msgSvc(), name()); 00291 log << MSG::INFO << "tofcalgsec::endRun()" << endreq; 00292 return StatusCode::SUCCESS; 00293 }
StatusCode tofcalgsec::execute | ( | ) |
Definition at line 241 of file tofcalgsec.cxx.
References TofCalibManager::dataSet(), TofCalibCheck::FillBarrelCol(), TofCalibCheck::FillEndcapCol(), TofCalibCheck::FillEtfCol(), TofCalibManager::getManager(), Bes_Common::INFO, m_calibration, m_checkbarrel, m_checkendcap, m_checketf, m_online, msgSvc(), TofDataSet::setBarrelData(), TofDataSet::setEndcapData(), and TofDataSet::setEtfData().
00241 { 00242 MsgStream log(msgSvc(), name()); 00243 log << MSG::INFO << "start "<<"tofcalgsec::execute()" << endreq; 00244 00245 if( m_online ) { 00246 SmartDataPtr<RecBTofCalHitCol> bhitcol(eventSvc(),"/Event/Recon/RecBTofCalHitCol"); 00247 if( bhitcol ) { 00248 m_checkbarrel->FillBarrelCol( bhitcol ); 00249 if( m_calibration ) { 00250 TofCalibManager* manager = TofCalibManager::getManager(); 00251 manager->dataSet()->setBarrelData( bhitcol ); 00252 } 00253 } 00254 else{ 00255 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" << endreq; 00256 // return StatusCode::SUCCESS; 00257 } 00258 00259 SmartDataPtr<RecETofCalHitCol> ehitcol(eventSvc(),"/Event/Recon/RecETofCalHitCol"); 00260 if( ehitcol ) { 00261 m_checkendcap->FillEndcapCol( ehitcol ); 00262 if( m_calibration ) { 00263 TofCalibManager::getManager()->dataSet()->setEndcapData( ehitcol ); 00264 } 00265 } 00266 else{ 00267 // log << MSG::ERROR << " Can't get /Event/Recon/RecETofCalHitCol in TDS!" <<endreq; 00268 // return StatusCode::SUCCESS; 00269 } 00270 00271 if( bhitcol ) { 00272 m_checketf->FillEtfCol( bhitcol ); 00273 if( m_calibration ) { 00274 TofCalibManager::getManager()->dataSet()->setEtfData( bhitcol ); 00275 } 00276 } 00277 else{ 00278 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" << endreq; 00279 // return StatusCode::SUCCESS; 00280 } 00281 00282 } 00283 00284 log << MSG::INFO << "end "<<"tofcalgsec::execute()" << endreq; 00285 return StatusCode::SUCCESS; 00286 }
StatusCode tofcalgsec::finalize | ( | ) |
Definition at line 296 of file tofcalgsec.cxx.
References TofCalibManager::addCalib(), TofCalibManager::dataSet(), TofCalibManager::doCalibration(), TofCalibManager::fillRoot(), TofCalibManager::fillTxt(), TofCalibManager::getManager(), Bes_Common::INFO, m_barrelfile, m_barrelzbin, m_calibration, m_checkbarrel, m_checkendcap, m_checketf, m_endcapfile, m_endcapQrbin, m_endcaprbin, m_etffile, m_online, m_tcorrzbin, m_workdir, msgSvc(), TofDataSet::setBarrelDataFiles(), TofDataSet::setEndcapDataFiles(), TofDataSet::setEtfDataFiles(), and testbit().
00296 { 00297 00298 MsgStream log(msgSvc(), name()); 00299 log << MSG::INFO << "tofcalgsec::finalize()" << endreq; 00300 00301 if( m_online && !m_calibration ) { 00302 if( m_checkbarrel ) { delete m_checkbarrel; } 00303 if( m_checkendcap ) { delete m_checkendcap; } 00304 if( m_checketf ) { delete m_checketf; } 00305 return StatusCode::SUCCESS; 00306 } 00307 00308 TofCalibManager* manager = TofCalibManager::getManager(); 00309 if( !m_online ) { 00310 if( m_barrelfile.empty() ) { 00311 std::cout << " No barrle data files are valid, exit " << std::endl; 00312 exit(0); 00313 } 00314 else { 00315 manager->dataSet()->setBarrelDataFiles( m_barrelfile ); 00316 } 00317 if( m_endcapfile.empty() ) { 00318 std::cout << " No endcap data files are valid, exit " << std::endl; 00319 exit(0); 00320 } 00321 else { 00322 manager->dataSet()->setEndcapDataFiles( m_endcapfile ); 00323 } 00324 if( m_etffile.empty() ) { 00325 std::cout << " No etf data files are valid, exit " << std::endl; 00326 exit(0); 00327 } 00328 else { 00329 manager->dataSet()->setEtfDataFiles( m_etffile ); 00330 } 00331 } 00332 00333 // barrel attenuation length calibration 00334 if( testbit(5) ) { 00335 manager->addCalib( new calib_barrel_atten(), 1 ); 00336 manager->addCalib( new calib_barrel_q0(), 1 ); 00337 } 00338 // barrel effective velocity calibration 00339 if( testbit(4) ) { 00340 manager->addCalib( new calib_barrel_veff(), 1 ); 00341 } 00342 // barrel time calibration 00343 if( testbit(7) ) { 00344 manager->addCalib( new calib_barrel_left(), 1 ); 00345 if (testbit(8)){ 00346 manager->addCalib( new calib_barrel_left_offset1_bunch0_4(), true ); 00347 manager->addCalib( new calib_barrel_left_offset1_bunch1_4(), true ); 00348 manager->addCalib( new calib_barrel_left_offset1_bunch2_4(), true ); 00349 manager->addCalib( new calib_barrel_left_offset1_bunch3_4(), true ); 00350 manager->addCalib( new calib_barrel_left_offset2_bunch0_4(), true ); 00351 manager->addCalib( new calib_barrel_left_offset2_bunch1_4(), true ); 00352 manager->addCalib( new calib_barrel_left_offset2_bunch2_4(), true ); 00353 manager->addCalib( new calib_barrel_left_offset2_bunch3_4(), true ); 00354 } 00355 if( !testbit(8) ) { 00356 manager->addCalib( new calib_barrel_left_offset1_bunch0_3(), true ); 00357 manager->addCalib( new calib_barrel_left_offset1_bunch1_3(), true ); 00358 manager->addCalib( new calib_barrel_left_offset1_bunch2_3(), true ); 00359 manager->addCalib( new calib_barrel_left_offset1_bunch3_3(), true ); 00360 manager->addCalib( new calib_barrel_left_offset2_bunch0_3(), true ); 00361 manager->addCalib( new calib_barrel_left_offset2_bunch1_3(), true ); 00362 manager->addCalib( new calib_barrel_left_offset2_bunch2_3(), true ); 00363 manager->addCalib( new calib_barrel_left_offset2_bunch3_3(), true ); 00364 } 00365 manager->addCalib( new calib_barrel_right(), 1 ); 00366 if( testbit(8) ) { 00367 manager->addCalib( new calib_barrel_right_offset1_bunch0_4(), true ); 00368 manager->addCalib( new calib_barrel_right_offset1_bunch1_4(), true ); 00369 manager->addCalib( new calib_barrel_right_offset1_bunch2_4(), true ); 00370 manager->addCalib( new calib_barrel_right_offset1_bunch3_4(), true ); 00371 manager->addCalib( new calib_barrel_right_offset2_bunch0_4(), true ); 00372 manager->addCalib( new calib_barrel_right_offset2_bunch1_4(), true ); 00373 manager->addCalib( new calib_barrel_right_offset2_bunch2_4(), true ); 00374 manager->addCalib( new calib_barrel_right_offset2_bunch3_4(), true ); 00375 } 00376 if( !testbit(8) ) { 00377 manager->addCalib( new calib_barrel_right_offset1_bunch0_3(), true ); 00378 manager->addCalib( new calib_barrel_right_offset1_bunch1_3(), true ); 00379 manager->addCalib( new calib_barrel_right_offset1_bunch2_3(), true ); 00380 manager->addCalib( new calib_barrel_right_offset1_bunch3_3(), true ); 00381 manager->addCalib( new calib_barrel_right_offset2_bunch0_3(), true ); 00382 manager->addCalib( new calib_barrel_right_offset2_bunch1_3(), true ); 00383 manager->addCalib( new calib_barrel_right_offset2_bunch2_3(), true ); 00384 manager->addCalib( new calib_barrel_right_offset2_bunch3_3(), true ); 00385 } 00386 } 00387 // barrel sigma calibration 00388 if( testbit(6) ) { 00389 manager->addCalib( new calib_barrel_common(m_tcorrzbin), true ); 00390 manager->addCalib( new calib_barrel_sigma(m_barrelzbin), true ); 00391 } 00392 00393 // endcap attenuation length calibration 00394 if( testbit(1) ) { 00395 manager->addCalib( new calib_endcap_atten(m_endcapQrbin), false ); 00396 } 00397 // endcap effective velocity calibration 00398 if( testbit(0) ) { 00399 manager->addCalib( new calib_endcap_veff(), false ); 00400 } 00401 // endcap time calibration 00402 if( testbit(3) ) { 00403 manager->addCalib( new calib_endcap_left(), 0 ); 00404 } 00405 // endcap sigma calibration 00406 if( testbit(2) ) { 00407 manager->addCalib( new calib_endcap_sigma(m_endcaprbin), false ); 00408 } 00409 // etf effective velocity calibration 00410 if( testbit(9) ) { 00411 manager->addCalib( new calib_etf_veff(), 2 ); 00412 } 00413 // monte carlo etf time calibration 00414 if( testbit(11) ) { 00415 manager->addCalib( new calib_mc_etf_combine(), 2 ); 00416 manager->addCalib( new calib_mc_etf_left(), 2 ); 00417 manager->addCalib( new calib_mc_etf_right(), 2 ); 00418 } 00419 // etf time calibration 00420 if( testbit(10) ) { 00421 manager->addCalib( new calib_etf_combine(), 2 ); 00422 manager->addCalib( new calib_etf_left(), 2 ); 00423 manager->addCalib( new calib_etf_right(), 2 ); 00424 } 00425 // etf bunch offset 00426 if( testbit(12) ) { 00427 manager->addCalib( new calib_etf_bunch(4), false ); 00428 } 00429 00430 manager->doCalibration(); 00431 00432 manager->fillTxt( m_workdir ); 00433 manager->fillRoot( m_workdir ); 00434 00435 return StatusCode::SUCCESS; 00436 }
StatusCode tofcalgsec::initialize | ( | ) |
Definition at line 90 of file tofcalgsec.cxx.
References calibUtil::ERROR, Bes_Common::INFO, m_barrelfile, m_calibItem, m_calibration, m_checkbarrel, m_checkendcap, m_checketf, m_datafile_barrel, m_datafile_dir, m_datafile_endcap, m_datafile_etf, m_endcapfile, m_etffile, m_online, m_workdir, msgSvc(), mtuple_barrel, mtuple_endcap, mtuple_etf, ntupleSvc(), and deljobs::string.
00090 { 00091 00092 MsgStream log(msgSvc(), name()); 00093 log<<MSG::INFO<< "tofcalgsec::initialize()!" <<endreq; 00094 00095 if( m_online ) { 00096 NTuplePtr nt1(ntupleSvc(),"TofCalib/btrk"); 00097 NTuplePtr nt2(ntupleSvc(),"TofCalib/etrk"); 00098 NTuplePtr nt3(ntupleSvc(),"TofCalib/etf"); 00099 if ( nt1 || nt2 || nt3 ) { 00100 mtuple_barrel = nt1; 00101 mtuple_endcap = nt2; 00102 mtuple_etf = nt3; 00103 } 00104 else { 00105 mtuple_barrel = ntupleSvc()->book("TofCalib/btrk",CLID_ColumnWiseTuple,"TofCalib"); 00106 mtuple_endcap = ntupleSvc()->book("TofCalib/etrk",CLID_ColumnWiseTuple,"TofCalib"); 00107 mtuple_etf = ntupleSvc()->book("TofCalib/etf", CLID_ColumnWiseTuple,"TofCalib"); 00108 00109 if( mtuple_barrel ) { 00110 m_checkbarrel = new TofCalibCheck( mtuple_barrel ); 00111 } 00112 else{ 00113 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_barrel) <<endmsg; 00114 return StatusCode::FAILURE; 00115 } 00116 if( mtuple_endcap ) { 00117 m_checkendcap = new TofCalibCheck( mtuple_endcap ); 00118 } 00119 else{ 00120 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_endcap) <<endmsg; 00121 return StatusCode::FAILURE; 00122 } 00123 if( mtuple_etf ) { 00124 m_checketf = new TofCalibCheck( mtuple_etf ); 00125 } 00126 else{ 00127 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_etf) <<endmsg; 00128 return StatusCode::FAILURE; 00129 } 00130 } 00131 } 00132 else { 00133 m_calibration = true; // offline 00134 } 00135 00136 if( !m_online || m_calibration ) { 00137 // check workdir 00138 std::cout<<" tofcalgsec checks your configurations ..."<<std::endl; 00139 void *pdir=0; 00140 if((pdir=gSystem->OpenDirectory(m_workdir.c_str()))==0){//dir exists? 00141 std::cerr<<"WorkDir "<<m_workdir<<" doesn't exist "<<std::endl; 00142 if(gSystem->MakeDirectory(m_workdir.c_str())==-1){//mkdir,fail to create? 00143 std::cerr<<" Fail to create directory : "<<m_workdir 00144 <<" Specify ./ as current work directory"<<std::endl; 00145 m_workdir="./"; 00146 } 00147 } 00148 else{ 00149 gSystem->FreeDirectory(pdir); 00150 pdir=0; 00151 } 00152 } 00153 00154 if( !m_online ) { 00155 void *pdir=0; 00156 if( (pdir=gSystem->OpenDirectory(m_datafile_dir.c_str())) ) { 00157 FileStat_t fs; 00158 std::vector<string>::iterator it = m_datafile_barrel.begin(); 00159 for( ; it!=m_datafile_barrel.end(); it++ ) { 00160 if( (*it).size()>0 ) { 00161 std::string thefile = (m_datafile_dir+"/"+(*it)); 00162 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) { 00163 m_barrelfile.push_back(thefile); 00164 } 00165 else{ 00166 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl; 00167 } 00168 } 00169 } 00170 it = m_datafile_endcap.begin(); 00171 for( ; it!=m_datafile_endcap.end(); it++ ) { 00172 if( (*it).size()>0 ) { 00173 std::string thefile=(m_datafile_dir+"/"+(*it)); 00174 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) { 00175 m_endcapfile.push_back(thefile); 00176 } 00177 else{ 00178 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl; 00179 } 00180 } 00181 } 00182 it = m_datafile_etf.begin(); 00183 for( ; it!=m_datafile_etf.end(); it++ ) { 00184 if( (*it).size()>0 ) { 00185 std::string thefile=(m_datafile_dir+"/"+(*it)); 00186 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) { 00187 m_etffile.push_back(thefile); 00188 } 00189 else{ 00190 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl; 00191 } 00192 } 00193 } 00194 gSystem->FreeDirectory(pdir); 00195 pdir=0; 00196 } 00197 else { 00198 std::cerr<<" Error : Please specify the InputDataDir which contains input data files for calibration "<<std::endl; 00199 exit(0); 00200 } 00201 } 00202 00203 if( !m_online || m_calibration ) { 00204 std::cout<<"******************* Report of before Calibration ********************"<<std::endl 00205 <<"* WorkDir = "<<m_workdir<<" [ results are save in this directory ] "<<std::endl 00206 <<"* WorkMode = "<<(m_online?"OnLine":"OffLine")<<" [ run alone or with other algorithms ] "<<std::endl 00207 <<"* CalibItem = "<<m_calibItem<<" [ which calibraions you perform ]"<<std::endl; 00208 } 00209 00210 if( !m_online ) { 00211 std::cout <<"* ==> InputDataDir : "<<m_datafile_dir<<std::endl 00212 <<"* ===>Files of Barrel : "; 00213 for( std::vector<std::string>::iterator it=m_barrelfile.begin(); it!=m_barrelfile.end(); it++ ) { 00214 std::cout << "'" << (*it) << "' "; 00215 } 00216 std::cout << std::endl 00217 <<"* ===>Files of Endcap : "; 00218 for( std::vector<std::string>::iterator it=m_endcapfile.begin(); it!=m_endcapfile.end(); it++ ) { 00219 std::cout << "'" << (*it) << "' "; 00220 } 00221 std::cout << std::endl 00222 <<"* ===>Files of Etf : "; 00223 for( std::vector<std::string>::iterator it=m_etffile.begin(); it!=m_etffile.end(); it++ ) { 00224 std::cout << "'" << (*it) << "' "; 00225 } 00226 std::cout << std::endl; 00227 } 00228 std::cout<<"*********************************************************************"<<std::endl; 00229 00230 return StatusCode::SUCCESS; 00231 }
bool tofcalgsec::testbit | ( | unsigned int | n | ) | [inline, protected] |
Definition at line 21 of file tofcalgsec.h.
References m_calibItem.
Referenced by finalize().
00021 { 00022 if( n>m_calibItem.size() ) return false; 00023 return m_calibItem[n]=='0'?false:true; 00024 }
bool tofcalgsec::FILE_HAS_BEEN_READ [private] |
Definition at line 46 of file tofcalgsec.h.
std::vector<std::string> tofcalgsec::m_barrelfile [private] |
unsigned int tofcalgsec::m_barrelzbin [private] |
std::string tofcalgsec::m_calibItem [private] |
Definition at line 38 of file tofcalgsec.h.
Referenced by initialize(), testbit(), and tofcalgsec().
bool tofcalgsec::m_calibration [private] |
Definition at line 29 of file tofcalgsec.h.
Referenced by execute(), finalize(), initialize(), and tofcalgsec().
TofCalibCheck* tofcalgsec::m_checkbarrel [private] |
TofCalibCheck* tofcalgsec::m_checkendcap [private] |
TofCalibCheck* tofcalgsec::m_checketf [private] |
std::vector<std::string> tofcalgsec::m_datafile_barrel [private] |
std::string tofcalgsec::m_datafile_dir [private] |
std::vector<std::string> tofcalgsec::m_datafile_endcap [private] |
std::vector<std::string> tofcalgsec::m_datafile_etf [private] |
std::vector<std::string> tofcalgsec::m_endcapfile [private] |
unsigned int tofcalgsec::m_endcapQrbin [private] |
unsigned int tofcalgsec::m_endcaprbin [private] |
std::vector<std::string> tofcalgsec::m_etffile [private] |
bool tofcalgsec::m_online [private] |
Definition at line 28 of file tofcalgsec.h.
Referenced by execute(), finalize(), initialize(), and tofcalgsec().
unsigned int tofcalgsec::m_tcorrzbin [private] |
std::string tofcalgsec::m_workdir [private] |
Definition at line 30 of file tofcalgsec.h.
Referenced by finalize(), initialize(), and tofcalgsec().
NTuple::Tuple* tofcalgsec::mtuple_barrel [private] |
NTuple::Tuple* tofcalgsec::mtuple_endcap [private] |
NTuple::Tuple* tofcalgsec::mtuple_etf [private] |