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