54 |
ret1=(float)ret; |
ret1=(float)ret; |
55 |
return ret1; |
return ret1; |
56 |
} |
} |
57 |
|
|
58 |
|
/** |
59 |
|
* Static method to open a DB connection. |
60 |
|
* HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST, |
61 |
|
* $PAM_DBUSER and $PAM_DBPSW |
62 |
|
* NB! The method create a new connection, which has to be closed by the user. |
63 |
|
*/ |
64 |
|
TSQLServer* TrkParams::SetDBConnection(){ |
65 |
|
|
66 |
|
TString host = "mysql://localhost/pamelaprod"; |
67 |
|
TString user = "anonymous"; |
68 |
|
TString psw = ""; |
69 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
70 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
71 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
72 |
|
if ( !pamdbhost ) pamdbhost = ""; |
73 |
|
if ( !pamdbuser ) pamdbuser = ""; |
74 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
75 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
76 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
77 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
78 |
|
if(TrkParams::VerboseMode()){ |
79 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
80 |
|
cout<<"Connecting to DB"<<endl; |
81 |
|
cout<<"HOST "<<host<<endl; |
82 |
|
cout<<"USER "<<user<<endl; |
83 |
|
cout<<"PSW "<<psw<<endl; |
84 |
|
} |
85 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
86 |
|
if( !dbc )return NULL; |
87 |
|
if( !dbc->IsConnected() )return NULL; |
88 |
|
stringstream myquery; // EMILIANO |
89 |
|
myquery.str(""); // EMILIANO |
90 |
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
91 |
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
92 |
|
if(TrkParams::VerboseMode()){ |
93 |
|
cout << " ...done"<<endl; |
94 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
95 |
|
} |
96 |
|
|
97 |
|
return dbc; |
98 |
|
} |
99 |
/** |
/** |
100 |
* \brief Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
101 |
|
|
115 |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
116 |
false ){ |
false ){ |
117 |
|
|
|
// cout <<">>> isloaded? "<< CalibIsLoaded() << endl; |
|
|
// cout <<">>> trk_calib_used "<< glrun->TRK_CALIB_USED<<endl; |
|
|
// cout <<">>> 104 loaded? "<< calib104 <<endl; |
|
|
// cout <<">>> from time "<< calib.FROM_TIME<<endl; |
|
|
// cout <<">>> to time "<< calib.TO_TIME<<endl; |
|
|
// if( !dbc || (dbc && !dbc->IsConnected()) ){ |
|
|
|
|
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
|
|
// TString host = "mysql://localhost/pamelaprod"; |
|
|
// TString user = "anonymous"; |
|
|
// TString psw = ""; |
|
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
// if ( !pamdbhost ) pamdbhost = ""; |
|
|
// if ( !pamdbuser ) pamdbuser = ""; |
|
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
// if(TrkParams::VerboseMode()){ |
|
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
// cout<<"Connecting to DB"<<endl; |
|
|
// cout<<"HOST "<<host<<endl; |
|
|
// cout<<"USER "<<user<<endl; |
|
|
// cout<<"PSW "<<psw<<endl; |
|
|
// } |
|
|
// dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
// if( !dbc )return false; |
|
|
// if( !dbc->IsConnected() )return false; |
|
|
// if(TrkParams::VerboseMode()){ |
|
|
// cout << " ...done"<<endl; |
|
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
// } |
|
|
// } |
|
118 |
|
|
119 |
GL_TRK_CALIB q2; |
GL_TRK_CALIB q2; |
120 |
GL_ROOT q3; |
GL_ROOT q3; |
121 |
GL_PARAM q4; |
GL_PARAM q4; |
122 |
|
|
123 |
|
|
124 |
|
bool LOCAL_CONNECTION = false; |
125 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
126 |
|
|
127 |
|
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
128 |
|
dbc = TrkParams::SetDBConnection(); |
129 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
130 |
|
|
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
if(TrkParams::VerboseMode()){ |
if(TrkParams::VerboseMode()){ |
135 |
cout << "--------------------------------------"<<endl; |
cout << "--------------------------------------"<<endl; |
156 |
calibpatht = q4.PATH + q4.NAME; |
calibpatht = q4.PATH + q4.NAME; |
157 |
} |
} |
158 |
|
|
159 |
|
if(LOCAL_CONNECTION){ |
160 |
|
dbc->Close(); |
161 |
|
delete dbc; |
162 |
|
} |
163 |
|
|
164 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
165 |
return true; |
return true; |
638 |
* @param dbc Database |
* @param dbc Database |
639 |
* @param type Parameter type |
* @param type Parameter type |
640 |
* @return FALSE if parameter set fails. |
* @return FALSE if parameter set fails. |
641 |
* If glrun==NULL the last parameter entry from GL_PARAM table is set. |
* If glrun==NULL the first parameter entry from GL_PARAM table is set. |
642 |
* If dbc==NULL, try to open a connection taking DB-connection |
* If dbc==NULL, try to open a connection taking DB-connection |
643 |
* parameters from PAMELA environment variables. |
* parameters from PAMELA environment variables. |
644 |
*/ |
*/ |
665 |
runheadtime > gl[index].TO_TIME || |
runheadtime > gl[index].TO_TIME || |
666 |
false ){ |
false ){ |
667 |
|
|
668 |
|
bool LOCAL_CONNECTION = false; |
669 |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
670 |
|
|
671 |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
672 |
TString host = "mysql://localhost/pamelaprod"; |
dbc = TrkParams::SetDBConnection(); |
673 |
TString user = "anonymous"; |
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
674 |
TString psw = ""; |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
if(TrkParams::VerboseMode()){ |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
cout<<"Connecting to DB"<<endl; |
|
|
cout<<"HOST "<<host<<endl; |
|
|
cout<<"USER "<<user<<endl; |
|
|
cout<<"PSW "<<psw<<endl; |
|
|
} |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if( !dbc )return false; |
|
|
if( !dbc->IsConnected() )return false; |
|
|
stringstream myquery; // EMILIANO |
|
|
myquery.str(""); // EMILIANO |
|
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
|
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
|
|
if(TrkParams::VerboseMode()){ |
|
|
cout << " ...done"<<endl; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
} |
|
675 |
} |
} |
676 |
|
|
677 |
GL_PARAM q4; |
GL_PARAM q4; |
678 |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
679 |
|
if(LOCAL_CONNECTION){ |
680 |
|
dbc->Close(); |
681 |
|
delete dbc; |
682 |
|
} |
683 |
gl[index] = q4; |
gl[index] = q4; |
684 |
glpath[index] = q4.PATH+q4.NAME; |
glpath[index] = q4.PATH+q4.NAME; |
685 |
glload[index] = false; |
glload[index] = false; |
723 |
|
|
724 |
return Set(0,0,type); |
return Set(0,0,type); |
725 |
|
|
|
// UInt_t index = TrkParams::GetIndex( type ); |
|
|
// if(index < 0)return false; |
|
|
|
|
|
// gl[index].TYPE= type; |
|
|
// glload[index] = false; |
|
|
|
|
|
// // ----------------------------------------- |
|
|
// // check if enviroment variables are defined |
|
|
// // ----------------------------------------- |
|
|
// glpath[index] = gSystem->Getenv("PAM_CALIB"); |
|
|
|
|
|
// if( !glpath[index].IsNull() ){ |
|
|
|
|
|
// switch(type){ |
|
|
// case 1: |
|
|
// glpath[index].Append("/trk-param/field_param-0/"); |
|
|
// break; |
|
|
// case 2: |
|
|
// glpath[index].Append("/trk-param/mip_param-0/"); |
|
|
// break; |
|
|
// case 3: |
|
|
// glpath[index].Append("/trk-param/charge_param-1/"); |
|
|
// break; |
|
|
// case 4: |
|
|
// glpath[index].Append("/trk-param/eta_param-2/"); |
|
|
// break; |
|
|
// case 5: |
|
|
// glpath[index].Append("/trk-param/align_param-Q.A/"); |
|
|
// break; |
|
|
// case 6: |
|
|
// glpath[index].Append("/trk-param/mask_param-1/"); |
|
|
// break; |
|
|
// case 7: |
|
|
// glpath[index].Append("/trk-param/default_calib/"); |
|
|
// break; |
|
|
// } |
|
|
|
|
|
// }else{ |
|
|
// cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl; |
|
|
// return false; |
|
|
|
|
|
// } |
|
|
|
|
|
// // if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >>"<<endl; |
|
|
// cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >> **WARNING** does not use DB info !!!!"<<endl; |
|
|
|
|
|
// // return TrkParams::Load(type); |
|
|
// return true; |
|
726 |
|
|
727 |
}; |
}; |
728 |
/** |
/** |
733 |
*/ |
*/ |
734 |
Bool_t TrkParams::Set( ){ |
Bool_t TrkParams::Set( ){ |
735 |
|
|
|
// Bool_t connected = false; |
|
|
// cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
|
|
// TString host = "mysql://localhost/pamelaprod"; |
|
|
// TString user = "anonymous"; |
|
|
// TString psw = ""; |
|
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
// if ( !pamdbhost ) pamdbhost = ""; |
|
|
// if ( !pamdbuser ) pamdbuser = ""; |
|
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
// if(TrkParams::VerboseMode()){ |
|
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
// cout<<"Connecting to DB"<<endl; |
|
|
// cout<<"HOST "<<host<<endl; |
|
|
// cout<<"USER "<<user<<endl; |
|
|
// cout<<"PSW "<<psw<<endl; |
|
|
// } |
|
|
// TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
// if( dbc || dbc->IsConnected() )connected = true; |
|
|
// else cout << " >> DB connection FAILED!!!"<<endl; |
|
|
// if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
|
|
|
// if(connected){ |
|
|
// if ( !TrkParams::Set(0,dbc) )return false; |
|
|
// dbc->Close(); |
|
|
// }else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
|
736 |
|
|
737 |
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
738 |
|
|