#include <tofcalgsec.h>
Public Member Functions | |
StatusCode | beginRun () |
StatusCode | beginRun () |
StatusCode | endRun () |
StatusCode | endRun () |
StatusCode | execute () |
StatusCode | execute () |
StatusCode | finalize () |
StatusCode | finalize () |
StatusCode | initialize () |
StatusCode | initialize () |
tofcalgsec (const std::string &name, ISvcLocator *pSvcLocator) | |
tofcalgsec (const std::string &name, ISvcLocator *pSvcLocator) | |
~tofcalgsec () | |
~tofcalgsec () | |
Protected Member Functions | |
bool | testbit (unsigned int n) |
bool | testbit (unsigned int n) |
Private Attributes | |
bool | FILE_HAS_BEEN_READ |
std::vector< std::string > | m_barrelfile |
std::vector< std::string > | m_barrelfile |
unsigned int | m_barrelzbin |
std::string | m_calibItem |
bool | m_calibration |
TofCalibCheck * | m_checkbarrel |
TofCalibCheck * | m_checkbarrel |
TofCalibCheck * | m_checkendcap |
TofCalibCheck * | m_checkendcap |
std::vector< std::string > | m_datafile_barrel |
std::vector< std::string > | m_datafile_barrel |
std::string | m_datafile_dir |
std::vector< std::string > | m_datafile_endcap |
std::vector< std::string > | m_datafile_endcap |
std::vector< std::string > | m_endcapfile |
std::vector< std::string > | m_endcapfile |
unsigned int | m_endcapQrbin |
unsigned int | m_endcaprbin |
bool | m_online |
unsigned int | m_tcorrzbin |
std::string | m_workdir |
NTuple::Tuple * | mtuple_barrel |
NTuple::Tuple * | mtuple_barrel |
NTuple::Tuple * | mtuple_endcap |
NTuple::Tuple * | mtuple_endcap |
|
00035 :Algorithm(name,pSvcLocator){ 00036 //set default values 00037 m_calibItem="11111111"; 00038 //declares 00039 declareProperty("Online", m_online ); 00040 declareProperty("Calibration", m_calibration ); 00041 declareProperty("WorkDir", m_workdir ); 00042 declareProperty("InputDataDir", m_datafile_dir ); 00043 declareProperty("InputDataFiles_Barrel", m_datafile_barrel ); 00044 declareProperty("InputDataFiles_Endcap", m_datafile_endcap ); 00045 declareProperty("CalibItem", m_calibItem ); 00046 declareProperty("TimeCorrelationZBin", m_tcorrzbin = 23 ); 00047 declareProperty("BarrelSigmaZBin", m_barrelzbin = 5 ); 00048 declareProperty("EndcapSigmaRBin", m_endcaprbin = 5 ); 00049 declareProperty("EndcapQRBin", m_endcapQrbin = 5 ); 00050 }
|
|
00299 {}
|
|
|
|
|
|
|
|
00170 { 00171 MsgStream log(msgSvc(), name()); 00172 log << MSG::INFO << "tofcalgsec::beginRun()" << endreq; 00173 return StatusCode::SUCCESS; 00174 }
|
|
|
|
00213 { 00214 MsgStream log(msgSvc(), name()); 00215 log << MSG::INFO << "tofcalgsec::endRun()" << endreq; 00216 return StatusCode::SUCCESS; 00217 }
|
|
|
|
00177 { 00178 MsgStream log(msgSvc(), name()); 00179 log << MSG::INFO << "start "<<"tofcalgsec::execute()" << endreq; 00180 00181 if( m_online ) { 00182 SmartDataPtr<RecBTofCalHitCol> bhitcol(eventSvc(),"/Event/Recon/RecBTofCalHitCol"); 00183 if( bhitcol ) { 00184 m_checkbarrel->FillCol( bhitcol ); 00185 if( m_calibration ) { 00186 TofCalibManager* manager = TofCalibManager::getManager(); 00187 manager->dataSet()->setBarrelData( bhitcol ); 00188 } 00189 } 00190 else{ 00191 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" << endreq; 00192 // return StatusCode::SUCCESS; 00193 } 00194 00195 SmartDataPtr<RecETofCalHitCol> ehitcol(eventSvc(),"/Event/Recon/RecETofCalHitCol"); 00196 if( ehitcol ) { 00197 m_checkendcap->FillCol( ehitcol ); 00198 if( m_calibration ) { 00199 TofCalibManager::getManager()->dataSet()->setEndcapData( ehitcol ); 00200 } 00201 } 00202 else{ 00203 // log << MSG::ERROR << " Can't get /Event/Recon/RecETofCalHitCol in TDS!" <<endreq; 00204 // return StatusCode::SUCCESS; 00205 } 00206 } 00207 00208 log << MSG::INFO << "end "<<"tofcalgsec::execute()" << endreq; 00209 return StatusCode::SUCCESS; 00210 }
|
|
|
|
00220 { 00221 00222 MsgStream log(msgSvc(), name()); 00223 log << MSG::INFO << "tofcalgsec::finalize()" << endreq; 00224 00225 if( m_online && !m_calibration ) { 00226 if( m_checkbarrel ) { delete m_checkbarrel; } 00227 if( m_checkendcap ) { delete m_checkendcap; } 00228 return StatusCode::SUCCESS; 00229 } 00230 00231 TofCalibManager* manager = TofCalibManager::getManager(); 00232 if( !m_online ) { 00233 if( m_barrelfile.empty() ) { 00234 std::cout << " No barrle data files are valid, exit " << std::endl; 00235 exit(0); 00236 } 00237 else { 00238 manager->dataSet()->setBarrelDataFiles( m_barrelfile ); 00239 } 00240 if( m_endcapfile.empty() ) { 00241 std::cout << " No endcap data files are valid, exit " << std::endl; 00242 exit(0); 00243 } 00244 else { 00245 manager->dataSet()->setEndcapDataFiles( m_endcapfile ); 00246 } 00247 } 00248 00249 // barrel attenuation length calibration 00250 if( testbit(5) ) { 00251 manager->addCalib( new calib_barrel_atten(), true ); 00252 manager->addCalib( new calib_barrel_q0(), true ); 00253 } 00254 // barrel effective velocity calibration 00255 if( testbit(4) ) { 00256 manager->addCalib( new calib_barrel_veff(), true ); 00257 } 00258 // barrel time calibration 00259 if( testbit(7) ) { 00260 manager->addCalib( new calib_barrel_left(), true ); 00261 manager->addCalib( new calib_barrel_left_offset1(), true ); 00262 manager->addCalib( new calib_barrel_left_offset2(), true ); 00263 manager->addCalib( new calib_barrel_right(), true ); 00264 manager->addCalib( new calib_barrel_right_offset1(), true ); 00265 manager->addCalib( new calib_barrel_right_offset2(), true ); 00266 } 00267 // barrel sigma calibration 00268 if( testbit(6) ) { 00269 manager->addCalib( new calib_barrel_common(m_tcorrzbin), true ); 00270 manager->addCalib( new calib_barrel_sigma(m_barrelzbin), true ); 00271 } 00272 00273 // endcap attenuation length calibration 00274 if( testbit(1) ) { 00275 manager->addCalib( new calib_endcap_atten(m_endcapQrbin),false ); 00276 } 00277 // endcap effective velocity calibration 00278 if( testbit(0) ) { 00279 manager->addCalib( new calib_endcap_veff(),false ); 00280 } 00281 // endcap time calibration 00282 if( testbit(3) ) { 00283 manager->addCalib( new calib_endcap_left(), false ); 00284 } 00285 // endcap sigma calibration 00286 if( testbit(2) ) { 00287 manager->addCalib( new calib_endcap_sigma(m_endcaprbin), false ); 00288 } 00289 00290 manager->doCalibration(); 00291 00292 manager->fillTxt( m_workdir ); 00293 manager->fillRoot( m_workdir ); 00294 00295 return StatusCode::SUCCESS; 00296 }
|
|
|
|
00053 { 00054 00055 MsgStream log(msgSvc(), name()); 00056 log<<MSG::INFO<< "tofcalgsec::initialize()!" <<endreq; 00057 00058 if( m_online ) { 00059 NTuplePtr nt1(ntupleSvc(),"TofCalib/btrk"); 00060 NTuplePtr nt2(ntupleSvc(),"TofCalib/etrk"); 00061 if ( nt1 || nt2 ) { 00062 mtuple_barrel = nt1; 00063 mtuple_endcap = nt2; 00064 } 00065 else { 00066 mtuple_barrel = ntupleSvc()->book("TofCalib/btrk",CLID_ColumnWiseTuple,"TofCalib"); 00067 mtuple_endcap = ntupleSvc()->book("TofCalib/etrk",CLID_ColumnWiseTuple,"TofCalib"); 00068 00069 if( mtuple_barrel ) { 00070 m_checkbarrel = new TofCalibCheck( mtuple_barrel ); 00071 } 00072 else{ 00073 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_barrel) <<endmsg; 00074 return StatusCode::FAILURE; 00075 } 00076 if( mtuple_endcap ) { 00077 m_checkendcap = new TofCalibCheck( mtuple_endcap ); 00078 } 00079 else{ 00080 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_endcap) <<endmsg; 00081 return StatusCode::FAILURE; 00082 } 00083 } 00084 } 00085 else { 00086 m_calibration = true; // offline 00087 } 00088 00089 if( !m_online || m_calibration ) { 00090 // check workdir 00091 std::cout<<" tofcalgsec checks your configurations ..."<<std::endl; 00092 void *pdir=0; 00093 if((pdir=gSystem->OpenDirectory(m_workdir.c_str()))==0){//dir exists? 00094 std::cerr<<"WorkDir "<<m_workdir<<" doesn't exist "<<std::endl; 00095 if(gSystem->MakeDirectory(m_workdir.c_str())==-1){//mkdir,fail to create? 00096 std::cerr<<" Fail to create directory : "<<m_workdir 00097 <<" Specify ./ as current work directory"<<std::endl; 00098 m_workdir="./"; 00099 } 00100 } 00101 else{ 00102 gSystem->FreeDirectory(pdir); 00103 pdir=0; 00104 } 00105 } 00106 00107 if( !m_online ) { 00108 void *pdir=0; 00109 if( (pdir=gSystem->OpenDirectory(m_datafile_dir.c_str())) ) { 00110 FileStat_t fs; 00111 std::vector<string>::iterator it = m_datafile_barrel.begin(); 00112 for( ; it!=m_datafile_barrel.end(); it++ ) { 00113 if( (*it).size()>0 ) { 00114 std::string thefile = (m_datafile_dir+"/"+(*it)); 00115 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) { 00116 m_barrelfile.push_back(thefile); 00117 } 00118 else{ 00119 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl; 00120 } 00121 } 00122 } 00123 it = m_datafile_endcap.begin(); 00124 for( ; it!=m_datafile_endcap.end(); it++ ) { 00125 if( (*it).size()>0 ) { 00126 std::string thefile=(m_datafile_dir+"/"+(*it)); 00127 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) { 00128 m_endcapfile.push_back(thefile); 00129 } 00130 else{ 00131 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl; 00132 } 00133 } 00134 } 00135 gSystem->FreeDirectory(pdir); 00136 pdir=0; 00137 } 00138 else { 00139 std::cerr<<" Error : Please specify the InputDataDir which contains input data files for calibration "<<std::endl; 00140 exit(0); 00141 } 00142 } 00143 00144 if( !m_online || m_calibration ) { 00145 std::cout<<"******************* Report of before Calibration ********************"<<std::endl 00146 <<"* WorkDir = "<<m_workdir<<" [ results are save in this directory ] "<<std::endl 00147 <<"* WorkMode = "<<(m_online?"OnLine":"OffLine")<<" [ run alone or with other algorithms ] "<<std::endl 00148 <<"* CalibItem = "<<m_calibItem<<" [ which calibraions you perform ]"<<std::endl; 00149 } 00150 00151 if( !m_online ) { 00152 std::cout <<"* ==> InputDataDir : "<<m_datafile_dir<<std::endl 00153 <<"* ===>Files of Barrel : "; 00154 for( std::vector<std::string>::iterator it=m_barrelfile.begin(); it!=m_barrelfile.end(); it++ ) { 00155 std::cout << "'" << (*it) << "' "; 00156 } 00157 std::cout << std::endl 00158 <<"* ===>Files of Endcap : "; 00159 for( std::vector<std::string>::iterator it=m_endcapfile.begin(); it!=m_endcapfile.end(); it++ ) { 00160 std::cout << "'" << (*it) << "' "; 00161 } 00162 std::cout << std::endl; 00163 } 00164 std::cout<<"*********************************************************************"<<std::endl; 00165 00166 return StatusCode::SUCCESS; 00167 }
|
|
00021 { 00022 if( n>m_calibItem.size() ) return false; 00023 return m_calibItem[n]=='0'?false:true; 00024 }
|
|
00021 { 00022 if( n>m_calibItem.size() ) return false; 00023 return m_calibItem[n]=='0'?false:true; 00024 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|