601 |
if (dbc) { |
if (dbc) { |
602 |
dbc->Close(); |
dbc->Close(); |
603 |
delete dbc; |
delete dbc; |
604 |
|
dbc=0; |
605 |
} |
} |
606 |
|
|
607 |
if (gltsync) |
if (gltsync) |
2884 |
if (!dbc || (dbc && !dbc->IsConnected())) |
if (!dbc || (dbc && !dbc->IsConnected())) |
2885 |
SetDBConnection(); //Emiliano |
SetDBConnection(); //Emiliano |
2886 |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here) |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here) |
2887 |
if (dbc) |
if (dbc){ |
2888 |
dbc->Close();// Emiliano |
dbc->Close();// Emiliano |
2889 |
|
dbc=0; |
2890 |
|
}; |
2891 |
}; |
}; |
2892 |
// --------------------------------------------------------------- |
// --------------------------------------------------------------- |
2893 |
// retrieve OBT and absolute time of the event |
// retrieve OBT and absolute time of the event |
3032 |
if (!dbc || (dbc && !dbc->IsConnected())) |
if (!dbc || (dbc && !dbc->IsConnected())) |
3033 |
SetDBConnection(); //Emiliano |
SetDBConnection(); //Emiliano |
3034 |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano |
3035 |
if (dbc) |
if (dbc){ |
3036 |
dbc->Close(); // Emiliano |
dbc->Close(); // Emiliano |
3037 |
|
dbc=0; |
3038 |
|
}; |
3039 |
if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano |
if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano |
3040 |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun |
3041 |
<< " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; |
<< " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; |
3073 |
if (!dbc || (dbc && !dbc->IsConnected())) |
if (!dbc || (dbc && !dbc->IsConnected())) |
3074 |
SetDBConnection(); |
SetDBConnection(); |
3075 |
TrkParams::Set(GetRunInfo(), dbc); |
TrkParams::Set(GetRunInfo(), dbc); |
3076 |
if (dbc) |
if (dbc){ |
3077 |
dbc->Close(); |
dbc->Close(); |
3078 |
|
dbc=0; |
3079 |
|
}; |
3080 |
|
|
3081 |
// ---------------------------------------------------- |
// ---------------------------------------------------- |
3082 |
// then check if the run has a fragment |
// then check if the run has a fragment |
3168 |
if (!dbc || (dbc && !dbc->IsConnected())) |
if (!dbc || (dbc && !dbc->IsConnected())) |
3169 |
SetDBConnection(); |
SetDBConnection(); |
3170 |
TrkParams::Set(GetRunInfo(), dbc); |
TrkParams::Set(GetRunInfo(), dbc); |
3171 |
if (dbc) |
if (dbc){ |
3172 |
dbc->Close(); |
dbc->Close(); |
3173 |
|
dbc=0; |
3174 |
|
}; |
3175 |
// cout << endl; |
// cout << endl; |
3176 |
prevshift = 0; |
prevshift = 0; |
3177 |
return true; |
return true; |
4350 |
} |
} |
4351 |
|
|
4352 |
dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
4353 |
|
dbc=0; |
4354 |
|
|
4355 |
}; |
}; |
4356 |
|
|
4363 |
// if( !TrkParams::IsLoaded(6) ){ |
// if( !TrkParams::IsLoaded(6) ){ |
4364 |
// cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; |
// cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; |
4365 |
// }; |
// }; |
4366 |
// if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection(); |
if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection(); // PERCHE` ERA COMMENTATA QUESTA RIGA? |
4367 |
TrkParams::SetCalib(run_obj, dbc); |
TrkParams::SetCalib(run_obj, dbc); |
4368 |
TrkParams::LoadCalib(); |
TrkParams::LoadCalib(); |
4369 |
if (!TrkParams::CalibIsLoaded()) { |
if (!TrkParams::CalibIsLoaded()) { |
4370 |
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded" << endl; |
cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded" << endl; |
4371 |
}; |
}; |
4372 |
// if(dbc)dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
if(dbc){ |
4373 |
|
dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
4374 |
|
dbc=0; |
4375 |
|
}; |
4376 |
} |
} |
4377 |
|
|
4378 |
// cout << l0_tree << endl; |
// cout << l0_tree << endl; |
4503 |
cout << "USER " << user << endl; |
cout << "USER " << user << endl; |
4504 |
cout << "PSW " << psw << endl; |
cout << "PSW " << psw << endl; |
4505 |
} |
} |
4506 |
dbc = TSQLServer::Connect(host.Data(), user.Data(), psw.Data()); |
Bool_t notconn = true; |
4507 |
if (!dbc) |
Int_t trials = 0; |
4508 |
return false; |
while ( notconn && trials < 10 ){ |
4509 |
if (!dbc->IsConnected()) |
// gSystem->Sleep(500); |
4510 |
return false; |
dbc = TSQLServer::Connect(host.Data(), user.Data(), psw.Data()); |
4511 |
|
//dbc->Connect(host.Data(), user.Data(), psw.Data()); |
4512 |
|
if ( dbc ) notconn = false; |
4513 |
|
if (DBG) printf("<%i> test connection...\n ",trials); |
4514 |
|
if (!dbc){ |
4515 |
|
if (DBG) printf(" :( failed, no pointer \n"); |
4516 |
|
notconn = true; |
4517 |
|
// return false; |
4518 |
|
}; |
4519 |
|
if (dbc && !dbc->IsConnected()){ |
4520 |
|
if (DBG) printf(" :( failed, no connection \n"); |
4521 |
|
notconn = true; |
4522 |
|
// return false; |
4523 |
|
}; |
4524 |
|
trials++; |
4525 |
|
}; |
4526 |
|
if ( notconn ) return false; |
4527 |
|
// |
4528 |
|
if (DBG) printf("=connected!\n"); |
4529 |
stringstream myquery; // EMILIANO |
stringstream myquery; // EMILIANO |
4530 |
myquery.str(""); // EMILIANO |
myquery.str(""); // EMILIANO |
4531 |
myquery << "SET time_zone='+0:00'"; // EMILIANO |
myquery << "SET time_zone='+0:00'"; // EMILIANO |
4532 |
dbc->Query(myquery.str().c_str()); // EMILIANO |
dbc->Query(myquery.str().c_str()); // EMILIANO |
4533 |
if (DBG) |
if ( DBG ) printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); |
|
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl; |
|
4534 |
return true; |
return true; |
4535 |
|
|
4536 |
} |
} |