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 ) {
99 }
100 else{
101 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_barrel) <<endmsg;
102 return StatusCode::FAILURE;
103 }
104 if( 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;
115 }
116
117 if( !m_online || m_calibration ) {
118
119 std::cout<<" tofcalgsec checks your configurations ..."<<std::endl;
120 void *pdir=0;
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;
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}