1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/Property.h"
3#include "GaudiKernel/SmartRef.h"
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/SmartDataLocator.h"
65 m_calibItem=
"111111111";
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 );
83 MsgStream log(
msgSvc(), name());
84 log<<MSG::INFO<<
"tofcalgsec::initialize()!" <<endreq;
87 NTuplePtr nt1(
ntupleSvc(),
"TofCalib/btrk");
88 NTuplePtr nt2(
ntupleSvc(),
"TofCalib/etrk");
94 mtuple_barrel =
ntupleSvc()->book(
"TofCalib/btrk",CLID_ColumnWiseTuple,
"TofCalib");
95 mtuple_endcap =
ntupleSvc()->book(
"TofCalib/etrk",CLID_ColumnWiseTuple,
"TofCalib");
101 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(mtuple_barrel) <<endmsg;
102 return StatusCode::FAILURE;
104 if( mtuple_endcap ) {
108 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(mtuple_endcap) <<endmsg;
109 return StatusCode::FAILURE;
114 m_calibration =
true;
117 if( !m_online || m_calibration ) {
119 std::cout<<
" tofcalgsec checks your configurations ..."<<std::endl;
121 if((pdir=gSystem->OpenDirectory(m_workdir.c_str()))==0){
122 std::cerr<<
"WorkDir "<<m_workdir<<
" doesn't exist "<<std::endl;
123 if(gSystem->MakeDirectory(m_workdir.c_str())==-1){
124 std::cerr<<
" Fail to create directory : "<<m_workdir
125 <<
" Specify ./ as current work directory"<<std::endl;
130 gSystem->FreeDirectory(pdir);
137 if( (pdir=gSystem->OpenDirectory(m_datafile_dir.c_str())) ) {
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);
147 std::cerr<<
" File "<<thefile<<
" doesn't exist! "<<std::endl;
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);
159 std::cerr<<
" File "<<thefile<<
" doesn't exist! "<<std::endl;
163 gSystem->FreeDirectory(pdir);
167 std::cerr<<
" Error : Please specify the InputDataDir which contains input data files for calibration "<<std::endl;
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;
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) <<
"' ";
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) <<
"' ";
190 std::cout << std::endl;
192 std::cout<<
"*********************************************************************"<<std::endl;
194 return StatusCode::SUCCESS;
199 MsgStream log(
msgSvc(), name());
200 log << MSG::INFO <<
"tofcalgsec::beginRun()" << endreq;
201 return StatusCode::SUCCESS;
206 MsgStream log(
msgSvc(), name());
207 log << MSG::INFO <<
"start "<<
"tofcalgsec::execute()" << endreq;
210 SmartDataPtr<RecBTofCalHitCol> bhitcol(eventSvc(),
"/Event/Recon/RecBTofCalHitCol");
212 m_checkbarrel->
FillCol( bhitcol );
213 if( m_calibration ) {
223 SmartDataPtr<RecETofCalHitCol> ehitcol(eventSvc(),
"/Event/Recon/RecETofCalHitCol");
225 m_checkendcap->
FillCol( ehitcol );
226 if( m_calibration ) {
236 log << MSG::INFO <<
"end "<<
"tofcalgsec::execute()" << endreq;
237 return StatusCode::SUCCESS;
242 MsgStream log(
msgSvc(), name());
243 log << MSG::INFO <<
"tofcalgsec::endRun()" << endreq;
244 return StatusCode::SUCCESS;
250 MsgStream log(
msgSvc(), name());
251 log << MSG::INFO <<
"tofcalgsec::finalize()" << endreq;
253 if( m_online && !m_calibration ) {
254 if( m_checkbarrel ) {
delete m_checkbarrel; }
255 if( m_checkendcap ) {
delete m_checkendcap; }
256 return StatusCode::SUCCESS;
261 if( m_barrelfile.empty() ) {
262 std::cout <<
" No barrle data files are valid, exit " << std::endl;
268 if( m_endcapfile.empty() ) {
269 std::cout <<
" No endcap data files are valid, exit " << std::endl;
359 return StatusCode::SUCCESS;
void FillCol(RecBTofCalHitCol &)
void addCalib(TofCalib *cal_item1, bool isbarrel)
static TofCalibManager * getManager()
void fillRoot(string &dir)
void fillTxt(string &dir)
void setEndcapDataFiles(std::vector< std::string > &)
void setBarrelData(RecBTofCalHitCol &)
void setBarrelDataFiles(std::vector< std::string > &)
void setEndcapData(RecETofCalHitCol &)
tofcalgsec(const std::string &name, ISvcLocator *pSvcLocator)
bool testbit(unsigned int n)