35 |
double TrkParams::init__mini_fact = 1.e4; //100.; |
double TrkParams::init__mini_fact = 1.e4; //100.; |
36 |
float TrkParams::init__pfa_e234ax[] = {0.,10.,10.,15.,15.,90.}; |
float TrkParams::init__pfa_e234ax[] = {0.,10.,10.,15.,15.,90.}; |
37 |
float TrkParams::init__pfa_e234ay[] = {0.,20.,90.,90.,90.,90.}; |
float TrkParams::init__pfa_e234ay[] = {0.,20.,90.,90.,90.,90.}; |
38 |
|
double TrkParams::init__deltab_0 = 0.; |
39 |
|
double TrkParams::init__deltab_1 = 0.; |
40 |
|
|
41 |
TrkParams::TrkParams(){ |
TrkParams::TrkParams(){ |
42 |
|
|
56 |
ret1=(float)ret; |
ret1=(float)ret; |
57 |
return ret1; |
return ret1; |
58 |
} |
} |
59 |
|
|
60 |
|
/** |
61 |
|
* Static method to open a DB connection. |
62 |
|
* HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST, |
63 |
|
* $PAM_DBUSER and $PAM_DBPSW |
64 |
|
* NB! The method create a new connection, which has to be closed by the user. |
65 |
|
*/ |
66 |
|
TSQLServer* TrkParams::SetDBConnection(){ |
67 |
|
|
68 |
|
TString host = "mysql://localhost/pamelaprod"; |
69 |
|
TString user = "anonymous"; |
70 |
|
TString psw = ""; |
71 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
72 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
73 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
74 |
|
if ( !pamdbhost ) pamdbhost = ""; |
75 |
|
if ( !pamdbuser ) pamdbuser = ""; |
76 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
77 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
78 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
79 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
80 |
|
if(TrkParams::VerboseMode()){ |
81 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
82 |
|
cout<<"Connecting to DB"<<endl; |
83 |
|
cout<<"HOST "<<host<<endl; |
84 |
|
cout<<"USER "<<user<<endl; |
85 |
|
cout<<"PSW "<<psw<<endl; |
86 |
|
} |
87 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
88 |
|
if( !dbc )return NULL; |
89 |
|
if( !dbc->IsConnected() )return NULL; |
90 |
|
stringstream myquery; // EMILIANO |
91 |
|
myquery.str(""); // EMILIANO |
92 |
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
93 |
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
94 |
|
if(TrkParams::VerboseMode()){ |
95 |
|
cout << " ...done"<<endl; |
96 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
97 |
|
} |
98 |
|
|
99 |
|
return dbc; |
100 |
|
} |
101 |
/** |
/** |
102 |
* \brief Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
103 |
|
|
117 |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
118 |
false ){ |
false ){ |
119 |
|
|
|
// 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; |
|
|
// } |
|
|
// } |
|
120 |
|
|
121 |
GL_TRK_CALIB q2; |
GL_TRK_CALIB q2; |
122 |
GL_ROOT q3; |
GL_ROOT q3; |
123 |
GL_PARAM q4; |
GL_PARAM q4; |
124 |
|
|
125 |
|
|
126 |
|
bool LOCAL_CONNECTION = false; |
127 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
128 |
|
|
129 |
|
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
130 |
|
dbc = TrkParams::SetDBConnection(); |
131 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
132 |
|
|
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
if(TrkParams::VerboseMode()){ |
if(TrkParams::VerboseMode()){ |
137 |
cout << "--------------------------------------"<<endl; |
cout << "--------------------------------------"<<endl; |
158 |
calibpatht = q4.PATH + q4.NAME; |
calibpatht = q4.PATH + q4.NAME; |
159 |
} |
} |
160 |
|
|
161 |
|
if(LOCAL_CONNECTION){ |
162 |
|
dbc->Close(); |
163 |
|
delete dbc; |
164 |
|
} |
165 |
|
|
166 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
167 |
return true; |
return true; |
640 |
* @param dbc Database |
* @param dbc Database |
641 |
* @param type Parameter type |
* @param type Parameter type |
642 |
* @return FALSE if parameter set fails. |
* @return FALSE if parameter set fails. |
643 |
* 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. |
644 |
* If dbc==NULL, try to open a connection taking DB-connection |
* If dbc==NULL, try to open a connection taking DB-connection |
645 |
* parameters from PAMELA environment variables. |
* parameters from PAMELA environment variables. |
646 |
*/ |
*/ |
667 |
runheadtime > gl[index].TO_TIME || |
runheadtime > gl[index].TO_TIME || |
668 |
false ){ |
false ){ |
669 |
|
|
670 |
|
bool LOCAL_CONNECTION = false; |
671 |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
672 |
|
|
673 |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
674 |
TString host = "mysql://localhost/pamelaprod"; |
dbc = TrkParams::SetDBConnection(); |
675 |
TString user = "anonymous"; |
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
676 |
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; |
|
|
} |
|
677 |
} |
} |
678 |
|
|
679 |
GL_PARAM q4; |
GL_PARAM q4; |
680 |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
681 |
|
if(LOCAL_CONNECTION){ |
682 |
|
dbc->Close(); |
683 |
|
delete dbc; |
684 |
|
} |
685 |
gl[index] = q4; |
gl[index] = q4; |
686 |
glpath[index] = q4.PATH+q4.NAME; |
glpath[index] = q4.PATH+q4.NAME; |
687 |
glload[index] = false; |
glload[index] = false; |
725 |
|
|
726 |
return Set(0,0,type); |
return Set(0,0,type); |
727 |
|
|
|
// 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; |
|
728 |
|
|
729 |
}; |
}; |
730 |
/** |
/** |
735 |
*/ |
*/ |
736 |
Bool_t TrkParams::Set( ){ |
Bool_t TrkParams::Set( ){ |
737 |
|
|
|
// 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; |
|
738 |
|
|
739 |
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; |
740 |
|
|
879 |
} |
} |
880 |
|
|
881 |
|
|
|
|
|
882 |
/** |
/** |
883 |
* \brief Set tracking mode (0=standard. 1=???) |
* \brief Set tracking mode (0=standard. 1=???) |
884 |
*/ |
*/ |
885 |
void TrkParams::SetTrackingMode(int trackmode) { |
void TrkParams::SetTrackingMode(int trackmode) { |
886 |
init__mini_trackmode = trackmode; |
init__mini_trackmode = trackmode; |
887 |
SetTrackingMode(); |
SetTrackingMode(); //fill F77 common |
888 |
}; |
}; |
889 |
/** |
/** |
890 |
* \brief Set fit-precision factor (typical value fact=100.) |
* \brief Set fit-precision factor (typical value fact=100.) |
891 |
*/ |
*/ |
892 |
void TrkParams::SetPrecisionFactor(double fact){ |
void TrkParams::SetPrecisionFactor(double fact){ |
893 |
init__mini_fact = fact; |
init__mini_fact = fact; |
894 |
SetPrecisionFactor(); |
SetPrecisionFactor(); //fill F77 common |
895 |
}; |
}; |
896 |
/** |
/** |
897 |
* \brief Set minimum number of step in track fitting |
* \brief Set minimum number of step in track fitting |
898 |
*/ |
*/ |
899 |
void TrkParams::SetStepMin(int istepmin){ |
void TrkParams::SetStepMin(int istepmin){ |
900 |
init__mini_istepmin = istepmin; |
init__mini_istepmin = istepmin; |
901 |
SetStepMin(); |
SetStepMin(); //fill F77 common |
902 |
|
}; |
903 |
|
/** |
904 |
|
* \brief Set deltaB parameters (id=0,1) |
905 |
|
*/ |
906 |
|
void TrkParams::SetDeltaB(int id,double db){ |
907 |
|
if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; |
908 |
|
if(id==0)init__deltab_0 = db; |
909 |
|
if(id==1)init__deltab_1 = db; |
910 |
|
SetDeltaB(); //fill F77 common |
911 |
}; |
}; |
912 |
|
|
913 |
/** |
/** |
914 |
* Fill F77 commons with PFA settings |
* \brief Fill F77 commons with PFA settings |
915 |
*/ |
*/ |
916 |
void TrkParams::SetPFA(){ |
void TrkParams::SetPFA(){ |
917 |
sw_.pfaid = init__pfa; |
sw_.pfaid = init__pfa; |
938 |
*/ |
*/ |
939 |
void TrkParams::SetPFA(int pfaid){ |
void TrkParams::SetPFA(int pfaid){ |
940 |
init__pfa = pfaid; |
init__pfa = pfaid; |
941 |
SetPFA(); |
SetPFA(); //fill F77 common |
942 |
}; |
}; |
943 |
/** |
/** |
944 |
* \brief Set p.f.a. angular intervals |
* \brief Set p.f.a. angular intervals |
945 |
* |
* |
946 |
* This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4 |
* This methods allows to set amgular intervals to apply ETA2,ETA3 or ETA4 |
947 |
* algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)). |
* algorythm, in case ETA or ETAL is set (see TrkParams::SetPFA(int pfaid)). |
948 |
* @param v Pointer to a vector of 12 components, which represent the |
* @param v Pointer to a vector of 12 components, which represent the |
949 |
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
950 |
* |
* |
954 |
init__pfa_e234ax[i] = v[i]; |
init__pfa_e234ax[i] = v[i]; |
955 |
init__pfa_e234ay[i] = v[i+6]; |
init__pfa_e234ay[i] = v[i+6]; |
956 |
} |
} |
957 |
SetPFA(); |
SetPFA(); //fill F77 common |
958 |
}; |
}; |
959 |
|
|
960 |
|
|