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