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