154 {
155 MsgStream log(
msgSvc(), name() );
156 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc, "/Event/EventHeader" );
157 int run = eventHeader->runNumber();
158
159
160 char stmt1[400];
161 StatusCode st1;
162
163
164 int runfrm, runfrm1;
165 int runto, runto1;
166std:
167 string cType;
168
169 if ( run < 0 )
170 {
171 cout << "This data is the MC sample with the Run Number: " << run << endl;
172 run = -run;
173 }
174
175 if ( m_bossRelease == "default" ) m_bossRelease = getenv( "BES_RELEASE" );
176 if ( m_isData == "default" )
177 {
178 cout << "Please set the type of TofEnergy" << endl;
179 exit( 1 );
180 }
181 if ( m_isData == "Data" ) cType = "TofEnergyData";
182 if ( m_isData == "MC" ) cType = "TofEnergyMC";
183 st1 =
getSftParVer( m_bossVer, m_calPar, runfrm1, runto1, run, m_bossRelease, cType );
184 if ( cType == "TofEnergyData" )
185 {
187 "select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergyCalib where "
188 "BossVer = '%s' and RunFrom <= "
189 "%d and RunTo >= %d and isData = '%s'",
190 m_bossVer.c_str(), run, run, m_isData.c_str() );
191 }
192 else if ( cType == "TofEnergyMC" )
193 {
195 "select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergySim where BossVer "
196 "= '%s' and RunFrom <= %d "
197 "and RunTo >= %d and isData = '%s'",
198 m_bossVer.c_str(), run, run, m_isData.c_str() );
199 }
200
201 DatabaseRecordVector res;
202 int row_no =
m_dbsvc->query(
"offlinedb", stmt1, res );
203 if ( row_no > 0 )
204 {
205 DatabaseRecord& dbrec = *res[row_no - 1];
206 m_CalibConst = dbrec.
GetDouble(
"CalibConst" );
212 cout << stmt1 << endl;
213 cout << "BossReleaseVer=" << m_bossRelease.c_str() << "\t"
214 << "TofEnergyBossVer=" << m_bossVer.c_str() << endl;
215 cout << "m_CalibConst is:" << m_CalibConst << endl;
216 cout << "Para1=" << m_Para1 << "\t"
217 << "Para2=" << m_Para2 << "\t"
218 << "Para3=" << m_Para3 << "\t"
219 << "Para4=" << m_Para4 << "\t"
220 << "Para5=" << m_Para5 << endl;
221 cout << "Successfully fetch TofEnergyCalibSvc information for run: " << run << endl;
222 return true;
223 }
224 else if ( row_no <= 0 )
225 {
226 cout << " TofEnergyCalibSvc:: can not found TofEnergyCalibSvc information of run:" << run
227 << ", boss version " << m_bossRelease << endl;
228 exit( 1 );
229 return false;
230 }
231 return true;
232}
double GetDouble(std::string key)
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)