| 1 | pam-fi | 1.22 |  | 
| 2 | pam-fi | 1.1 | /** | 
| 3 |  |  | * \file TrkParams.cpp | 
| 4 |  |  | * \author Elena Vannuccini | 
| 5 |  |  | */ | 
| 6 |  |  |  | 
| 7 |  |  | #include <TrkParams.h> | 
| 8 |  |  | #include <iostream> | 
| 9 | pam-fi | 1.10 | #include <iomanip> | 
| 10 | pam-fi | 1.1 | using namespace std; | 
| 11 |  |  |  | 
| 12 |  |  |  | 
| 13 | mocchiut | 1.28 | Bool_t TrkParams::simuflag = kFALSE; | 
| 14 | pam-fi | 1.1 | // ------------------------- | 
| 15 |  |  | // CALIBRATION (PED,SIG,BAD) | 
| 16 |  |  | // ------------------------- | 
| 17 |  |  | GL_TRK_CALIB TrkParams::calib      = GL_TRK_CALIB(); | 
| 18 |  |  | TString      TrkParams::calibpatht = ""; | 
| 19 |  |  | TString      TrkParams::calibpathf = ""; | 
| 20 |  |  | Bool_t       TrkParams::calib104   = 0; | 
| 21 |  |  | Bool_t       TrkParams::calibload  = false; | 
| 22 | pam-fi | 1.24 | TrkCalib*    TrkParams::calib1 = 0; | 
| 23 |  |  | TrkCalib*    TrkParams::calib2 = 0; | 
| 24 | pam-fi | 1.8 | // ------------------------- | 
| 25 |  |  | // PARAMETERS loaded from DB | 
| 26 |  |  | // ------------------------- | 
| 27 | pam-fi | 1.1 | UInt_t       TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; | 
| 28 |  |  | GL_PARAM     TrkParams::gl[]           = {GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM()}; | 
| 29 |  |  | TString      TrkParams::glpath[]       = {"","","","","","",""}; | 
| 30 |  |  | Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false}; | 
| 31 | pam-fi | 1.8 | // ---------------- | 
| 32 |  |  | // other parameters | 
| 33 |  |  | // ---------------- | 
| 34 | pam-fi | 1.12 | cDbg   TrkParams::init__dbg_mode       = {0,0,0}; | 
| 35 | pam-fi | 1.15 | //int    TrkParams::init__pfa            = 14;//COG4 | 
| 36 |  |  | int    TrkParams::init__pfa            = 5;//ETAL | 
| 37 | pam-fi | 1.8 | int    TrkParams::init__mini_trackmode = 0; | 
| 38 | pam-fi | 1.13 | int    TrkParams::init__mini_istepmin  = 5; //3; | 
| 39 |  |  | double TrkParams::init__mini_fact      = 1.e4; //100.; | 
| 40 |  |  | float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.}; | 
| 41 |  |  | float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.}; | 
| 42 | pam-fi | 1.19 | double TrkParams::init__deltab_0       = 0.; | 
| 43 |  |  | double TrkParams::init__deltab_1       = 0.; | 
| 44 | pam-fi | 1.20 | double TrkParams::init__dlt            = 1.e-5; | 
| 45 | pam-fi | 1.21 | // ------------------------------------------ | 
| 46 |  |  | // nominal z-coordinates to define acceptance | 
| 47 |  |  | // ------------------------------------------ | 
| 48 |  |  | int   TrkParams::nGF   = NGF; | 
| 49 |  |  | float TrkParams::zGF[] = {+53.74,+53.04,+23.94,+23.44,+22.29,+21.83,+13.39,+4.49,-4.41,-13.31,-21.83,-22.22,-23.49,-24.34}; | 
| 50 |  |  | float TrkParams::xGF_min[] = {-20.40,-20.40,-9.00,-9.00,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-9.00,-9.00}; | 
| 51 |  |  | float TrkParams::xGF_max[] = {+20.40,+20.40,+9.00,+9.00,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+9.00,+9.00}; | 
| 52 |  |  | // float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-7.25,-7.25,-7.25,-7.25,-6.57,-6.75,-7.50,-7.50}; | 
| 53 |  |  | // float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.75,+6.75,+6.75,+6.75,+6.57,+7.25,+7.50,+7.50}; | 
| 54 |  |  | // per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa | 
| 55 |  |  | float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-6.57,-6.57,-6.57,-6.57,-6.57,-6.75,-7.50,-7.50}; | 
| 56 |  |  | float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.57,+6.57,+6.57,+6.57,+6.57,+7.25,+7.50,+7.50}; | 
| 57 |  |  | TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"}; | 
| 58 | pam-fi | 1.1 |  | 
| 59 |  |  | TrkParams::TrkParams(){ | 
| 60 |  |  |  | 
| 61 | pam-fi | 1.8 | cout<<"TrkParams::TrkParams()"<<endl; | 
| 62 | pam-fi | 1.1 |  | 
| 63 |  |  | } | 
| 64 |  |  | float aint(float f){ | 
| 65 |  |  | int   ret  = (int)f; | 
| 66 |  |  | float ret1 = 0; | 
| 67 |  |  | ret1=(float)ret; | 
| 68 |  |  | return ret1; | 
| 69 |  |  | } | 
| 70 |  |  |  | 
| 71 |  |  | float anint(float f){ | 
| 72 |  |  | int   ret  = (int)(f+0.5); | 
| 73 |  |  | float ret1 = 0; | 
| 74 |  |  | ret1=(float)ret; | 
| 75 |  |  | return ret1; | 
| 76 |  |  | } | 
| 77 | pam-fi | 1.18 |  | 
| 78 | mocchiut | 1.28 | void TrkParams::SetSimuFlag(Bool_t flag){ | 
| 79 |  |  | simuflag = flag; | 
| 80 |  |  | } | 
| 81 |  |  |  | 
| 82 |  |  | Bool_t TrkParams::GetSimuFlag(){ | 
| 83 |  |  | return simuflag; | 
| 84 |  |  | } | 
| 85 |  |  |  | 
| 86 |  |  |  | 
| 87 | pam-fi | 1.18 | /** | 
| 88 |  |  | * Static method to open a DB connection. | 
| 89 |  |  | * HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST, | 
| 90 |  |  | * $PAM_DBUSER and $PAM_DBPSW | 
| 91 |  |  | * NB! The method create a new connection, which has to be closed by the user. | 
| 92 |  |  | */ | 
| 93 |  |  | TSQLServer* TrkParams::SetDBConnection(){ | 
| 94 |  |  |  | 
| 95 |  |  | TString host = "mysql://localhost/pamelaprod"; | 
| 96 |  |  | TString user = "anonymous"; | 
| 97 |  |  | TString psw = ""; | 
| 98 |  |  | const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); | 
| 99 |  |  | const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); | 
| 100 |  |  | const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); | 
| 101 |  |  | if ( !pamdbhost ) pamdbhost = ""; | 
| 102 |  |  | if ( !pamdbuser ) pamdbuser = ""; | 
| 103 |  |  | if ( !pamdbpsw ) pamdbpsw = ""; | 
| 104 |  |  | if ( strcmp(pamdbhost,"") ) host = pamdbhost; | 
| 105 |  |  | if ( strcmp(pamdbuser,"") ) user = pamdbuser; | 
| 106 |  |  | if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; | 
| 107 | pam-fi | 1.22 | if(TrkParams::DebugMode()){ | 
| 108 | pam-fi | 1.18 | cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; | 
| 109 | pam-fi | 1.22 | cout<<"TrkParams::SetDBConnection() >> Connecting to DB"<<endl; | 
| 110 | pam-fi | 1.18 | cout<<"HOST "<<host<<endl; | 
| 111 |  |  | cout<<"USER "<<user<<endl; | 
| 112 |  |  | cout<<"PSW  "<<psw<<endl; | 
| 113 |  |  | } | 
| 114 |  |  | TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); | 
| 115 |  |  | if( !dbc )return NULL; | 
| 116 |  |  | if( !dbc->IsConnected() )return NULL; | 
| 117 |  |  | stringstream myquery;  // EMILIANO | 
| 118 |  |  | myquery.str("");  // EMILIANO | 
| 119 | mocchiut | 1.31 | myquery << "SET time_zone='+0:00'; SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';";  // EMILIANO | 
| 120 | pam-fi | 1.18 | dbc->Query(myquery.str().c_str());  // EMILIANO | 
| 121 | pam-fi | 1.22 | if(TrkParams::DebugMode()){ | 
| 122 | pam-fi | 1.18 | cout << " ...done"<<endl; | 
| 123 |  |  | cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; | 
| 124 |  |  | } | 
| 125 |  |  |  | 
| 126 |  |  | return dbc; | 
| 127 |  |  | } | 
| 128 | pam-fi | 1.1 | /** | 
| 129 | pam-fi | 1.10 | * \brief Static method to set the calibration to be loaded. | 
| 130 | pam-fi | 1.1 |  | 
| 131 |  |  | * It retrieves the calibration associated to a given run, from | 
| 132 |  |  | * a given DB. It fills the F77 common. | 
| 133 |  |  | * @param glrun Pointer to a GL_RUN row | 
| 134 |  |  | * @param dbc   Pointer to a DB connection | 
| 135 |  |  | */ | 
| 136 |  |  | Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ | 
| 137 |  |  |  | 
| 138 | pam-fi | 1.6 | //    cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; | 
| 139 |  |  |  | 
| 140 | pam-fi | 1.3 | if( !CalibIsLoaded()                          || | 
| 141 |  |  | (glrun->TRK_CALIB_USED==104 && !calib104) || | 
| 142 |  |  | (glrun->TRK_CALIB_USED!=104 && calib104)  || | 
| 143 |  |  | glrun->RUNHEADER_TIME < calib.FROM_TIME   || | 
| 144 |  |  | glrun->RUNHEADER_TIME > calib.TO_TIME     || | 
| 145 |  |  | false ){ | 
| 146 |  |  |  | 
| 147 | pam-fi | 1.10 |  | 
| 148 | pam-fi | 1.3 | GL_TRK_CALIB q2; | 
| 149 |  |  | GL_ROOT q3; | 
| 150 |  |  | GL_PARAM q4; | 
| 151 | pam-fi | 1.18 |  | 
| 152 |  |  |  | 
| 153 |  |  | bool LOCAL_CONNECTION = false; | 
| 154 |  |  | if( !dbc || (dbc && !dbc->IsConnected()) ){ | 
| 155 |  |  |  | 
| 156 | pam-fi | 1.24 | //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; | 
| 157 | pam-fi | 1.18 | dbc = TrkParams::SetDBConnection(); | 
| 158 |  |  | if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; | 
| 159 |  |  |  | 
| 160 |  |  | } | 
| 161 |  |  |  | 
| 162 | pam-fi | 1.3 |  | 
| 163 | pam-fi | 1.6 | if(TrkParams::VerboseMode()){ | 
| 164 |  |  | cout << "--------------------------------------"<<endl; | 
| 165 |  |  | cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; | 
| 166 |  |  | } | 
| 167 | pam-fi | 1.3 | if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ | 
| 168 | pam-fi | 1.6 | cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; | 
| 169 | pam-fi | 1.3 | return false; | 
| 170 |  |  | } | 
| 171 |  |  | if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) | 
| 172 | pam-fi | 1.6 | printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); | 
| 173 | pam-fi | 1.3 | if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ | 
| 174 | pam-fi | 1.6 | cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; | 
| 175 | pam-fi | 1.3 | return false; | 
| 176 |  |  | } | 
| 177 |  |  |  | 
| 178 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; | 
| 179 | pam-fi | 1.3 | calib      = q2; | 
| 180 |  |  | calibpathf = q3.PATH + q3.NAME; | 
| 181 |  |  | calib104   = (glrun->TRK_CALIB_USED==104); | 
| 182 |  |  | calibload  = kFALSE; | 
| 183 |  |  | if(calib104){ | 
| 184 |  |  | if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; | 
| 185 |  |  | calibpatht = q4.PATH + q4.NAME; | 
| 186 |  |  | } | 
| 187 |  |  |  | 
| 188 | pam-fi | 1.25 | if(LOCAL_CONNECTION&&dbc){ | 
| 189 | pam-fi | 1.18 | dbc->Close(); | 
| 190 | pam-fi | 1.27 | delete dbc; | 
| 191 | pam-fi | 1.22 | if(TrkParams::DebugMode()){ | 
| 192 |  |  | cout << " DB connection closed."<<endl; | 
| 193 |  |  | } | 
| 194 | pam-fi | 1.18 | } | 
| 195 | pam-fi | 1.1 |  | 
| 196 | pam-fi | 1.3 | //    return TrkParams::LoadCalib(); | 
| 197 |  |  | return true; | 
| 198 | pam-fi | 1.1 | } | 
| 199 |  |  |  | 
| 200 | pam-fi | 1.3 | return false; | 
| 201 | pam-fi | 1.1 | }; | 
| 202 |  |  |  | 
| 203 |  |  | /** | 
| 204 | pam-fi | 1.4 | * Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation | 
| 205 |  |  | * in YodaProfiler. | 
| 206 |  |  | */ | 
| 207 |  |  | UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ | 
| 208 |  |  |  | 
| 209 | pam-fi | 1.10 | UInt_t validate = 1; | 
| 210 | pam-fi | 1.4 | Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; | 
| 211 |  |  | //    UInt_t timeaftercalib=120000; //2000; | 
| 212 |  |  | TString classname = caltrk->GetName(); | 
| 213 |  |  | //  ---------- | 
| 214 |  |  | //  Check CRCs | 
| 215 |  |  | //  ---------- | 
| 216 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout << " DSP: "; | 
| 217 | pam-fi | 1.4 | for(Int_t ipkt=0; ipkt<6; ipkt++){ | 
| 218 | pam-fi | 1.7 | if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; | 
| 219 | pam-fi | 1.5 | if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ | 
| 220 |  |  | if( caltrk->crc_hcal[ipkt] ){ | 
| 221 | pam-fi | 1.6 | if(TrkParams::WarningMode())cout<<"(CRC Header)"; | 
| 222 |  |  | //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; | 
| 223 | pam-fi | 1.5 | //              return 0; // :-( | 
| 224 | pam-fi | 1.10 | validate = 0; | 
| 225 | pam-fi | 1.5 | } | 
| 226 |  |  | for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ | 
| 227 | pam-fi | 1.6 | if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; | 
| 228 |  |  | //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; | 
| 229 | pam-fi | 1.5 | //              return 0; // :-( | 
| 230 | pam-fi | 1.10 | validate = 0; | 
| 231 | pam-fi | 1.5 | } | 
| 232 | pam-fi | 1.4 | } | 
| 233 |  |  | } | 
| 234 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout << endl;; | 
| 235 | pam-fi | 1.4 | //  ----------------------- | 
| 236 |  |  | //  Check missing packets: | 
| 237 |  |  | //  ----------------------- | 
| 238 |  |  | //    Readout order: | 
| 239 |  |  | //    ------------------ | 
| 240 |  |  | //    DSP   packet board | 
| 241 |  |  | //    ------------------ | 
| 242 |  |  | //    12    0      1 | 
| 243 |  |  | //    10    1      1 | 
| 244 |  |  | //     8    2      1 | 
| 245 |  |  | //     4    3      1 | 
| 246 |  |  | //     6    4      1 | 
| 247 |  |  | //     2    5      1 | 
| 248 |  |  | //    ------------------ | 
| 249 |  |  | //    11    0      2 | 
| 250 |  |  | //     9    1      2 | 
| 251 |  |  | //     7    2      2 | 
| 252 |  |  | //     3    3      2 | 
| 253 |  |  | //     5    4      2 | 
| 254 |  |  | //     1    5      2 | 
| 255 |  |  | //    ------------------ | 
| 256 |  |  | //  ------------------------------------------------- | 
| 257 |  |  | //  Check if it is first or second calibration packet | 
| 258 |  |  | //  ------------------------------------------------- | 
| 259 |  |  | UInt_t build=0; | 
| 260 |  |  | UInt_t base=0; | 
| 261 | mocchiut | 1.29 | //    UInt_t mask=0;// EM GCC 4.7 | 
| 262 | pam-fi | 1.4 | if(classname.Contains("CalibTrk1Event")){ | 
| 263 |  |  | base=12; | 
| 264 | mocchiut | 1.29 | //      mask=0x03F000; // EM GCC 4.7 | 
| 265 | pam-fi | 1.4 | } | 
| 266 |  |  | if(classname.Contains("CalibTrk2Event")){ | 
| 267 |  |  | base=18; | 
| 268 | mocchiut | 1.29 | //      mask=0xFC0000;  // EM GCC 4.7 | 
| 269 | pam-fi | 1.4 | } | 
| 270 |  |  | //  ------------------------------------------------- | 
| 271 |  |  | //  Count number of packets and set build variable | 
| 272 |  |  | //  ------------------------------------------------- | 
| 273 |  |  | Int_t  npkts=0; | 
| 274 |  |  | for(Int_t ipkt=0; ipkt<6; ipkt++){ | 
| 275 |  |  | if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ | 
| 276 |  |  | npkts++; | 
| 277 |  |  | build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); | 
| 278 |  |  | }; | 
| 279 |  |  | } | 
| 280 | pam-fi | 1.10 | if( npkts==6 ){}//return 1; // :-) | 
| 281 | pam-fi | 1.6 | else { | 
| 282 |  |  | if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-(  ( "<<npkts<<" instead of 6 ) --> "<<endl; | 
| 283 | pam-fi | 1.10 | validate = 0; | 
| 284 | pam-fi | 1.6 | } | 
| 285 | pam-fi | 1.4 | //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; | 
| 286 |  |  |  | 
| 287 |  |  | //  ----------------------------------------------- | 
| 288 |  |  | //  If missing packets: check the acq configuration | 
| 289 |  |  | //  (some DSPs might be excluded from acquisition) | 
| 290 |  |  | //  ----------------------------------------------- | 
| 291 |  |  |  | 
| 292 |  |  | //  ----------------------------------------------- | 
| 293 |  |  | //  retrieve the first run header after calib | 
| 294 |  |  | //  ----------------------------------------------- | 
| 295 |  |  | //      PacketType *pctp; | 
| 296 |  |  | //      EventCounter *cod; | 
| 297 |  |  | //      cod = eh->GetCounter(); | 
| 298 |  |  | //      Int_t irun = cod->Get(pctp->RunHeader); | 
| 299 |  |  | //      TTree *rh=(TTree*)file->Get("RunHeader"); | 
| 300 |  |  | //      if ( !rh || rh->IsZombie() ) throw -17; | 
| 301 |  |  | //      if( rh->GetEntries() == irun ){ | 
| 302 |  |  | //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1)  -- cannot validate :-( "<<endl; | 
| 303 |  |  | //       return 0; // :-( | 
| 304 |  |  | //      } | 
| 305 |  |  |  | 
| 306 |  |  | //      RunHeaderEvent *run  = 0; | 
| 307 |  |  | //      EventHeader    *hrun = 0; | 
| 308 |  |  | //      rh->SetBranchAddress("RunHeader", &run); | 
| 309 |  |  | //      rh->SetBranchAddress("Header", &hrun); | 
| 310 |  |  | //      rh->GetEntry(irun); | 
| 311 |  |  | // //     cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; | 
| 312 |  |  |  | 
| 313 |  |  | //      if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ | 
| 314 |  |  | //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; | 
| 315 |  |  | //       return 0; // :-( | 
| 316 |  |  | //      } | 
| 317 |  |  |  | 
| 318 |  |  | //      if( !run->RM_ACQ_AFTER_CALIB ){ | 
| 319 |  |  | //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0    -- cannot validate :-( "<<endl; | 
| 320 |  |  | //       return 0; // :-( | 
| 321 |  |  | //      } | 
| 322 |  |  |  | 
| 323 |  |  | //      UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); | 
| 324 |  |  | //      if( dtime > timeaftercalib ){ | 
| 325 |  |  | //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; | 
| 326 |  |  | //       return 0; // :-( | 
| 327 |  |  | //      } | 
| 328 |  |  |  | 
| 329 |  |  | //      if( (run->ACQ_BUILD_INFO & mask) != build ){ | 
| 330 |  |  | //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; | 
| 331 |  |  | //       return 0; // :-( | 
| 332 |  |  | //      } | 
| 333 | pam-fi | 1.10 |  | 
| 334 |  |  | //      return 1; // :-) | 
| 335 |  |  |  | 
| 336 |  |  | //    cout << validate << endl; | 
| 337 |  |  | return validate; | 
| 338 | pam-fi | 1.4 |  | 
| 339 |  |  | } | 
| 340 |  |  | /** | 
| 341 | pam-fi | 1.1 | * Method to fill the tracker calibration-parameter struct from on-line calibrations | 
| 342 |  |  | */ | 
| 343 |  |  | void TrkParams::FillACalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ | 
| 344 |  |  |  | 
| 345 |  |  | cTrkCalib *ca = &pedsigbad_; | 
| 346 | pam-fi | 1.10 | ca->Reset(); | 
| 347 | pam-fi | 1.1 |  | 
| 348 |  |  | TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); | 
| 349 |  |  | TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); | 
| 350 |  |  |  | 
| 351 | pam-fi | 1.24 | if(!calib1)calib1 = new TrkCalib(); | 
| 352 |  |  | if(!calib2)calib2 = new TrkCalib(); | 
| 353 |  |  | //     calibx->Set(calibdata1); | 
| 354 |  |  | //     caliby->Set(calibdata2); | 
| 355 |  |  |  | 
| 356 |  |  | //     CalibTrk1Event *calibdata1 = 0; | 
| 357 |  |  | //     CalibTrk2Event *calibdata2 = 0; | 
| 358 |  |  | //     tr1->SetBranchAddress("CalibTrk1",&calibdata1); | 
| 359 |  |  | //     tr2->SetBranchAddress("CalibTrk2",&calibdata2); | 
| 360 |  |  | tr1->SetBranchAddress("CalibTrk1",calib1->GetPointerTo()); | 
| 361 |  |  | tr2->SetBranchAddress("CalibTrk2",calib2->GetPointerTo()); | 
| 362 | mocchiut | 1.26 | if ( tr1->GetEntry(ev_reg1) <= 0 ) throw -36;//EM | 
| 363 |  |  | if ( tr2->GetEntry(ev_reg2) <= 0 ) throw -36;//EM | 
| 364 | pam-fi | 1.1 | Int_t dspn1(0),dspn2(0); | 
| 365 | pam-fi | 1.24 |  | 
| 366 | pam-fi | 1.4 |  | 
| 367 |  |  | // --- TEST TEST TEST TEST --- // | 
| 368 | pam-fi | 1.24 | //    TrkParams::ValidateTrkCalib(calib1->Get()); | 
| 369 |  |  | //    TrkParams::ValidateTrkCalib((CalibTrk1Event*)calib2->Get()); | 
| 370 | pam-fi | 1.10 |  | 
| 371 | pam-fi | 1.24 | UInt_t test1 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib1->Get())); | 
| 372 |  |  | UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib2->Get())); | 
| 373 | pam-fi | 1.10 | if( !test1 || !test2 ){ | 
| 374 | pam-fi | 1.24 | //      if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; | 
| 375 | pam-fi | 1.10 | TrkParams::calib.VALIDATION = 0; | 
| 376 |  |  | } | 
| 377 | pam-fi | 1.24 | //    if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; | 
| 378 | pam-fi | 1.10 |  | 
| 379 | pam-fi | 1.1 | for(Int_t i=0;i<6;i++){ | 
| 380 | pam-fi | 1.24 |  | 
| 381 |  |  |  | 
| 382 |  |  | dspn1=calib1->Get()->DSPnumber[i]-1; | 
| 383 |  |  | dspn2=calib2->Get()->DSPnumber[i]-1; | 
| 384 | pam-fi | 1.10 | //      cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; | 
| 385 | pam-fi | 1.1 | for(Int_t ii=0;ii<3072;ii++){ | 
| 386 |  |  | Int_t j=(ii/128); | 
| 387 |  |  | Int_t jj=ii-j*128; | 
| 388 | pam-fi | 1.10 | if(dspn1>=0 && dspn1<12){ | 
| 389 | pam-fi | 1.24 | ca->pedestal[jj][j][dspn1]=calib1->Get()->DSPped_par[i][ii]; | 
| 390 |  |  | ca->pedestal_t[jj][j][dspn1]=aint(calib1->Get()->DSPped_par[i][ii]); | 
| 391 |  |  | ca->sigma[jj][j][dspn1]=calib1->Get()->DSPsig_par[i][ii]; | 
| 392 |  |  | ca->sigma_t[jj][j][dspn1]=anint(calib1->Get()->DSPsig_par[i][ii]); | 
| 393 |  |  | if(calib1->Get()->DSPbad_par[i][ii]==0) | 
| 394 | pam-fi | 1.10 | ca->bad[jj][j][dspn1]=1; | 
| 395 | pam-fi | 1.24 | else if(calib1->Get()->DSPbad_par[i][ii]==1) | 
| 396 | pam-fi | 1.10 | ca->bad[jj][j][dspn1]=0; | 
| 397 |  |  | //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; | 
| 398 |  |  | //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; | 
| 399 |  |  | } | 
| 400 |  |  |  | 
| 401 |  |  | if(dspn2>=0 && dspn2<12){ | 
| 402 | pam-fi | 1.24 | ca->pedestal[jj][j][dspn2]=calib2->Get()->DSPped_par[i][ii]; | 
| 403 |  |  | ca->pedestal_t[jj][j][dspn2]=aint(calib2->Get()->DSPped_par[i][ii]); | 
| 404 |  |  | ca->sigma[jj][j][dspn2]=calib2->Get()->DSPsig_par[i][ii]; | 
| 405 |  |  | ca->sigma_t[jj][j][dspn2]=anint(calib2->Get()->DSPsig_par[i][ii]); | 
| 406 |  |  | if(calib2->Get()->DSPbad_par[i][ii]==0) | 
| 407 | pam-fi | 1.10 | ca->bad[jj][j][dspn2]=1; | 
| 408 | pam-fi | 1.24 | else if(calib2->Get()->DSPbad_par[i][ii]==1) | 
| 409 | pam-fi | 1.10 | ca->bad[jj][j][dspn2]=0; | 
| 410 |  |  | //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; | 
| 411 |  |  | //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; | 
| 412 |  |  | } | 
| 413 | pam-fi | 1.1 | }; | 
| 414 |  |  | }; | 
| 415 |  |  |  | 
| 416 |  |  | tr1->Delete(); | 
| 417 |  |  | tr2->Delete(); | 
| 418 |  |  | }; | 
| 419 |  |  | /** | 
| 420 |  |  | * Method to fill the tracker calibration-parameter struct from on-line calibrations | 
| 421 |  |  | */ | 
| 422 | pam-fi | 1.24 | // void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ | 
| 423 | pam-fi | 1.1 |  | 
| 424 | pam-fi | 1.24 | //     cTrkCalib *ca = &pedsigbad_; | 
| 425 |  |  | // //    ca->Reset(); | 
| 426 | pam-fi | 1.1 |  | 
| 427 | pam-fi | 1.24 | //     TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); | 
| 428 |  |  | //     TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); | 
| 429 | pam-fi | 1.1 |  | 
| 430 | pam-fi | 1.24 | //     CalibTrk1Event *calibdata1 = 0; | 
| 431 |  |  | //     CalibTrk2Event *calibdata2 = 0; | 
| 432 |  |  | //     tr1->SetBranchAddress("CalibTrk1",&calibdata1); | 
| 433 |  |  | //     tr2->SetBranchAddress("CalibTrk2",&calibdata2); | 
| 434 |  |  | //     tr1->GetEntry(ev_reg1); | 
| 435 |  |  | //     tr2->GetEntry(ev_reg2); | 
| 436 |  |  | //     Int_t dspn1(0),dspn2(0); | 
| 437 |  |  |  | 
| 438 |  |  | //     // --- TEST TEST TEST TEST --- // | 
| 439 |  |  | // //     TrkParams::ValidateTrkCalib(calibdata1); | 
| 440 |  |  | // //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); | 
| 441 |  |  | //     UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); | 
| 442 |  |  | //     UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); | 
| 443 |  |  | //     if( !test1 || !test2 ){ | 
| 444 |  |  | //      if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; | 
| 445 |  |  | //      TrkParams::calib.VALIDATION = 0; | 
| 446 |  |  | //     } | 
| 447 |  |  | //     if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; | 
| 448 | pam-fi | 1.1 |  | 
| 449 | pam-fi | 1.24 | //     for(Int_t i=0;i<6;i++){ | 
| 450 |  |  | //      dspn1=calibdata1->DSPnumber[i]-1; | 
| 451 |  |  | //      dspn2=calibdata2->DSPnumber[i]-1; | 
| 452 |  |  | //      /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */ | 
| 453 |  |  | //      for(Int_t ii=0;ii<3072;ii++){ | 
| 454 |  |  | //          Int_t j=(ii/128); | 
| 455 |  |  | //          Int_t jj=ii-j*128; | 
| 456 |  |  | //          if(dspn1>=0 && dspn1<12){ | 
| 457 |  |  | //              ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; | 
| 458 |  |  | //              ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; | 
| 459 |  |  | //              if(calibdata1->DSPbad_par[i][ii]==0) | 
| 460 |  |  | //                  ca->bad[jj][j][dspn1]=1; | 
| 461 |  |  | //              else if(calibdata1->DSPbad_par[i][ii]==1) | 
| 462 |  |  | //                  ca->bad[jj][j][dspn1]=0; | 
| 463 |  |  | //              //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; | 
| 464 |  |  | //              //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; | 
| 465 |  |  | //          } | 
| 466 |  |  | //          if(dspn2>=0 && dspn2<12){ | 
| 467 |  |  | //              ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; | 
| 468 |  |  | //              ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; | 
| 469 |  |  | //              if(calibdata2->DSPbad_par[i][ii]==0) | 
| 470 |  |  | //                  ca->bad[jj][j][dspn2]=1; | 
| 471 |  |  | //              else if(calibdata2->DSPbad_par[i][ii]==1) | 
| 472 |  |  | //                  ca->bad[jj][j][dspn2]=0; | 
| 473 |  |  | //              //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; | 
| 474 |  |  | //              //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; | 
| 475 |  |  | //          } | 
| 476 |  |  | //      }; | 
| 477 |  |  | //     }; | 
| 478 | pam-fi | 1.1 |  | 
| 479 | pam-fi | 1.24 | //     tr1->Delete(); | 
| 480 |  |  | //     tr2->Delete(); | 
| 481 |  |  | // }; | 
| 482 | pam-fi | 1.1 | /** | 
| 483 |  |  | * Method to fill the tracker calibration-parameter struct from on-line calibrations | 
| 484 |  |  | */ | 
| 485 | pam-fi | 1.24 | // void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ | 
| 486 | pam-fi | 1.1 |  | 
| 487 | pam-fi | 1.24 | //     cTrkCalib *ca = &pedsigbad_; | 
| 488 |  |  | // //    ca->Reset(); | 
| 489 | pam-fi | 1.1 |  | 
| 490 | pam-fi | 1.24 | //     TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); | 
| 491 |  |  | //     TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); | 
| 492 | pam-fi | 1.1 |  | 
| 493 | pam-fi | 1.24 | //     CalibTrk1Event *calibdata1 = 0; | 
| 494 |  |  | //     CalibTrk2Event *calibdata2 = 0; | 
| 495 |  |  | //     tr1->SetBranchAddress("CalibTrk1",&calibdata1); | 
| 496 |  |  | //     tr2->SetBranchAddress("CalibTrk2",&calibdata2); | 
| 497 |  |  | //     tr1->GetEntry(ev_reg1); | 
| 498 |  |  | //     tr2->GetEntry(ev_reg2); | 
| 499 |  |  | //     Int_t dspn1(0),dspn2(0); | 
| 500 | pam-fi | 1.1 |  | 
| 501 | pam-fi | 1.24 | //     // --- TEST TEST TEST TEST --- // | 
| 502 |  |  | // //     TrkParams::ValidateTrkCalib(calibdata1); | 
| 503 |  |  | // //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); | 
| 504 |  |  | //     UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); | 
| 505 |  |  | //     UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); | 
| 506 |  |  | //     if( !test1 || !test2 ){ | 
| 507 |  |  | //      if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; | 
| 508 |  |  | //      TrkParams::calib.VALIDATION = 0; | 
| 509 |  |  | //     } | 
| 510 |  |  | //     if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; | 
| 511 | pam-fi | 1.4 |  | 
| 512 | pam-fi | 1.24 | //     for(Int_t i=0;i<6;i++){ | 
| 513 |  |  | //      dspn1=calibdata1->DSPnumber[i]-1; | 
| 514 |  |  | //      dspn2=calibdata2->DSPnumber[i]-1; | 
| 515 |  |  | //      /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */ | 
| 516 |  |  | //      for(Int_t ii=0;ii<3072;ii++){ | 
| 517 |  |  | //          Int_t j=(ii/128); | 
| 518 |  |  | //          Int_t jj=ii-j*128; | 
| 519 |  |  | //          if(dspn1>=0 && dspn1<12){ | 
| 520 |  |  | //              ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); | 
| 521 |  |  | //              ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); | 
| 522 |  |  | //          } | 
| 523 |  |  | //          if(dspn2>=0 && dspn2<12){ | 
| 524 |  |  | //              ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); | 
| 525 |  |  | //              ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); | 
| 526 |  |  | //          } | 
| 527 |  |  | //      }; | 
| 528 |  |  | //     }; | 
| 529 | pam-fi | 1.1 |  | 
| 530 | pam-fi | 1.24 | //     tr1->Delete(); | 
| 531 |  |  | //     tr2->Delete(); | 
| 532 |  |  | // }; | 
| 533 | pam-fi | 1.1 | /** | 
| 534 |  |  | * Method to fill the tracker calibration-parameter struct from default calibration | 
| 535 |  |  | */ | 
| 536 |  |  | void TrkParams::FillTCalibFrom(TString path){ | 
| 537 |  |  |  | 
| 538 |  |  | path_.FillWith(path); | 
| 539 |  |  | fillpedsigfromdefault_(); | 
| 540 |  |  | if(path_.error) throw -216; | 
| 541 |  |  |  | 
| 542 |  |  | }; | 
| 543 |  |  | /** | 
| 544 |  |  | * Method to fill the tracker VA1-mask struct from calibration | 
| 545 |  |  | */ | 
| 546 |  |  | void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ | 
| 547 |  |  |  | 
| 548 |  |  | cTrkMask *ma = &mask_; | 
| 549 | pam-fi | 1.10 | ma->Reset(); | 
| 550 | pam-fi | 1.1 |  | 
| 551 |  |  | TrkCalib *calib = new TrkCalib(); | 
| 552 |  |  |  | 
| 553 |  |  | for(Int_t i=0; i<2; i++){ | 
| 554 |  |  | TTree *tr=0; | 
| 555 |  |  | if(i==0){ | 
| 556 |  |  | //------------------------- | 
| 557 |  |  | //read calibration packet 1 | 
| 558 |  |  | //------------------------- | 
| 559 |  |  | tr = (TTree*)f0->Get("CalibTrk1"); | 
| 560 |  |  | tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo()); | 
| 561 | mocchiut | 1.26 | if ( tr->GetEntry(ev_reg1) <= 0 ) throw -36;//EM | 
| 562 | pam-fi | 1.1 | } | 
| 563 |  |  | if(i==1){ | 
| 564 |  |  | //------------------------- | 
| 565 |  |  | //read calibration packet 2 | 
| 566 |  |  | //------------------------- | 
| 567 |  |  | tr = (TTree*)f0->Get("CalibTrk2"); | 
| 568 |  |  | tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo()); | 
| 569 | mocchiut | 1.26 | if ( tr->GetEntry(ev_reg2) <= 0 ) throw -36; | 
| 570 | pam-fi | 1.1 | } | 
| 571 |  |  | for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ | 
| 572 | pam-fi | 1.10 | Int_t view   = calib->GetView(ipkt); | 
| 573 |  |  | if( (view-1)>= 0 && (view-1)<12 ){ | 
| 574 |  |  | for(Int_t ivk=0; ivk<NVK; ivk++){ | 
| 575 |  |  | Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); | 
| 576 |  |  | Float_t sigmin = 0.; | 
| 577 |  |  | if(view%2)sigmin = 6.5; | 
| 578 |  |  | else      sigmin = 2.5; | 
| 579 |  |  | Int_t mask = 1; | 
| 580 |  |  | if( sigm<sigmin )mask = 0; | 
| 581 |  |  | ma->mask_vk_run[ivk][view-1] = mask; | 
| 582 |  |  | } | 
| 583 |  |  | } | 
| 584 | pam-fi | 1.1 | } | 
| 585 |  |  | if(tr)tr->Delete(); | 
| 586 |  |  | } | 
| 587 |  |  |  | 
| 588 | pam-fi | 1.10 | if(TrkParams::VerboseMode()){ | 
| 589 |  |  | for(Int_t iv=0; iv<NVIEW; iv++){ | 
| 590 |  |  | cout<<"view "<<setw(3)<<iv<<": "; | 
| 591 |  |  | for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv]; | 
| 592 |  |  | cout << endl; | 
| 593 |  |  | } | 
| 594 |  |  | } | 
| 595 |  |  |  | 
| 596 | pam-fi | 1.1 | if(calib)calib->Delete(); | 
| 597 |  |  |  | 
| 598 |  |  | }; | 
| 599 |  |  |  | 
| 600 | pam-fi | 1.3 | // Bool_t TrkParams::CalibIsLoaded(UInt_t time){ | 
| 601 |  |  |  | 
| 602 |  |  | //     if( !calibload ) return false; | 
| 603 |  |  |  | 
| 604 |  |  | // }; | 
| 605 |  |  |  | 
| 606 |  |  |  | 
| 607 | pam-fi | 1.1 | /** | 
| 608 | pam-fi | 1.10 | * \brief Static method to load calibration. | 
| 609 |  |  | * Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens after the method TrkParams::SetCalib(***) is called. | 
| 610 | pam-fi | 1.1 | */ | 
| 611 |  |  | Bool_t TrkParams::LoadCalib( ){ | 
| 612 |  |  |  | 
| 613 |  |  | if( TrkParams::CalibIsLoaded() )return false; | 
| 614 |  |  |  | 
| 615 |  |  | // ============================================================= | 
| 616 |  |  | // retrieve calibration file needed to reduce data | 
| 617 |  |  | // ============================================================= | 
| 618 |  |  | // if run OBT is > last calibration "expiration date" | 
| 619 |  |  | //  - search for new calibration packet | 
| 620 |  |  | //  - load calibration parameters (full + truncated) | 
| 621 | pam-fi | 1.6 | if(TrkParams::VerboseMode()){ | 
| 622 |  |  | cout << "--------------------------------------"<<endl; | 
| 623 |  |  | cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; | 
| 624 |  |  | cout << " Full pedestals for cluster finding:"; | 
| 625 |  |  | cout << " >> loading from LEVEL0 file: "<< calibpathf << endl; | 
| 626 |  |  | } | 
| 627 | pam-fi | 1.1 | FileStat_t t; | 
| 628 |  |  | if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; | 
| 629 |  |  |  | 
| 630 | pam-fi | 1.6 | bool alreadyopened = false; | 
| 631 |  |  | TFile *f0_c=0; | 
| 632 |  |  | f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf); | 
| 633 |  |  | if(f0_c)alreadyopened=true; | 
| 634 |  |  | else f0_c = new TFile(calibpathf); | 
| 635 | pam-fi | 1.1 | if ( !f0_c ) return false; | 
| 636 | pam-fi | 1.6 |  | 
| 637 |  |  | if(TrkParams::VerboseMode()){ | 
| 638 |  |  | cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; | 
| 639 |  |  | cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; | 
| 640 |  |  | cout << " - full+truncated parameters "<<endl; | 
| 641 |  |  | } | 
| 642 | pam-fi | 1.1 | TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); | 
| 643 | pam-fi | 1.21 | if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl; | 
| 644 | pam-fi | 1.1 | TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); | 
| 645 |  |  |  | 
| 646 |  |  | // ============================================================= | 
| 647 |  |  | // retrieve calibration file needed to uncompress data | 
| 648 |  |  | // ============================================================= | 
| 649 |  |  | // if the run was compressed using default calib | 
| 650 |  |  | // load truncated pedestals from default | 
| 651 |  |  | // otherwise reload them from on-line calibration | 
| 652 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; | 
| 653 | pam-fi | 1.1 | if( calib104 ){ | 
| 654 |  |  |  | 
| 655 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; | 
| 656 | pam-fi | 1.1 | TrkParams::FillTCalibFrom(calibpatht); | 
| 657 |  |  |  | 
| 658 |  |  | }else{ | 
| 659 |  |  |  | 
| 660 | pam-fi | 1.6 | //      if ( !f0_c ) return false; | 
| 661 |  |  | if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; | 
| 662 |  |  | //      TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); | 
| 663 | pam-fi | 1.1 | }; | 
| 664 | pam-fi | 1.6 | if(!alreadyopened)f0_c->Close(); | 
| 665 |  |  | if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; | 
| 666 | pam-fi | 1.1 |  | 
| 667 |  |  | calibload = kTRUE; | 
| 668 |  |  | return true; | 
| 669 |  |  | }; | 
| 670 |  |  |  | 
| 671 |  |  | Int_t TrkParams::GetIndex( UInt_t type ){ | 
| 672 |  |  | Int_t index = -1; | 
| 673 |  |  | for (Int_t i=0; i< NTYPES; i++)if( type == trkparamtype[i] )index=i; | 
| 674 |  |  | return index; | 
| 675 |  |  | }; | 
| 676 |  |  |  | 
| 677 |  |  | /** | 
| 678 |  |  | * Set tracker parameters proper for a run querying the DB. | 
| 679 |  |  | * @param glrun Input run info | 
| 680 |  |  | * @param dbc   Database | 
| 681 |  |  | * @param type  Parameter type | 
| 682 |  |  | * @return FALSE if parameter set fails. | 
| 683 | pam-fi | 1.18 | * If glrun==NULL the first parameter entry from GL_PARAM table is set. | 
| 684 | pam-fi | 1.1 | * If dbc==NULL, try to open a connection taking DB-connection | 
| 685 |  |  | * parameters from PAMELA environment variables. | 
| 686 |  |  | */ | 
| 687 | mocchiut | 1.28 | Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type, UInt_t abstime){ | 
| 688 | pam-fi | 1.1 |  | 
| 689 |  |  |  | 
| 690 | pam-fi | 1.6 | UInt_t index = TrkParams::GetIndex( type ); | 
| 691 |  |  | if(index < 0)return false; | 
| 692 |  |  |  | 
| 693 | mocchiut | 1.28 | if(TrkParams::VerboseMode()) | 
| 694 |  |  | cout <<"Calling Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ,UInt_t " <<abstime << " ) >> (**WARNING** check that this is all ok!! )"<<endl; | 
| 695 | pam-fi | 1.24 |  | 
| 696 |  |  | UInt_t runheadtime=1; | 
| 697 | pam-fi | 1.16 | UInt_t runid=0; | 
| 698 |  |  | //    UInt_t runheadtime = numeric_limits<UInt_t>::max(); | 
| 699 |  |  | if(glrun){ | 
| 700 |  |  | runheadtime = glrun->RUNHEADER_TIME; | 
| 701 |  |  | runid       = glrun->ID; | 
| 702 | pam-fi | 1.24 | }else | 
| 703 | mocchiut | 1.28 | cout <<"Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ,UInt_t " <<abstime << " ) >> GL_RUN==NULL -- taking first entry (**WARNING** check that this is ok!! )"<<endl; | 
| 704 | pam-fi | 1.16 |  | 
| 705 |  |  |  | 
| 706 | mocchiut | 1.28 | if( !abstime || !simuflag ) abstime = runheadtime;// EM: if simu? | 
| 707 | pam-fi | 1.1 |  | 
| 708 | mocchiut | 1.28 | if(TrkParams::VerboseMode()) | 
| 709 |  |  | cout << "TrkParams::IsLoaded(type)=" << TrkParams::IsLoaded(type) << " abstime=" << abstime << " runheadtime=" << runheadtime << " gl[index].FROM_TIME=" << gl[index].FROM_TIME << " gl[index].TO_TIME=" << gl[index].TO_TIME << endl; | 
| 710 | pam-fi | 1.1 |  | 
| 711 | mocchiut | 1.28 | if( !TrkParams::IsLoaded(type) || | 
| 712 |  |  | abstime < gl[index].FROM_TIME   || | 
| 713 |  |  | abstime > gl[index].TO_TIME     || | 
| 714 |  |  | false ){ | 
| 715 |  |  |  | 
| 716 |  |  | if(TrkParams::VerboseMode()) | 
| 717 |  |  | cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl; | 
| 718 |  |  |  | 
| 719 |  |  | bool LOCAL_CONNECTION = false; | 
| 720 |  |  | if( !dbc || (dbc && !dbc->IsConnected()) ){ | 
| 721 |  |  |  | 
| 722 |  |  | //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; | 
| 723 |  |  | dbc = TrkParams::SetDBConnection(); | 
| 724 |  |  | if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; | 
| 725 |  |  |  | 
| 726 |  |  | } | 
| 727 |  |  |  | 
| 728 |  |  | GL_PARAM q4; | 
| 729 |  |  | //        if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; | 
| 730 |  |  | if( q4.Query_GL_PARAM(abstime,type,dbc) )return false;     //VALERIO | 
| 731 |  |  | if(LOCAL_CONNECTION){ | 
| 732 |  |  | dbc->Close(); | 
| 733 |  |  | delete dbc; | 
| 734 |  |  | if(TrkParams::DebugMode()){ | 
| 735 |  |  | cout << " DB connection closed."<<endl; | 
| 736 |  |  | } | 
| 737 |  |  | } | 
| 738 |  |  | gl[index]     = q4; | 
| 739 |  |  | glpath[index] = q4.PATH+q4.NAME; | 
| 740 |  |  | glload[index] = false; | 
| 741 |  |  |  | 
| 742 |  |  | //return true; | 
| 743 |  |  |  | 
| 744 | pam-fi | 1.6 | } | 
| 745 | mocchiut | 1.28 | return true; | 
| 746 |  |  |  | 
| 747 | pam-fi | 1.1 | }; | 
| 748 |  |  | /** | 
| 749 | pam-fi | 1.2 | * Set tracker parameters proper for the run, from input. | 
| 750 | pam-fi | 1.1 | * @param path  Path to parameters directory | 
| 751 |  |  | * @param type  Parameter type | 
| 752 |  |  | * @return FALSE if parameter set fails. | 
| 753 |  |  | */ | 
| 754 |  |  | Bool_t TrkParams::Set( TString path , UInt_t type){ | 
| 755 |  |  |  | 
| 756 |  |  | UInt_t index = TrkParams::GetIndex( type ); | 
| 757 |  |  | if(index < 0)return false; | 
| 758 |  |  |  | 
| 759 |  |  | gl[index].TYPE= type; | 
| 760 |  |  | glpath[index] = path; | 
| 761 | pam-fi | 1.12 | if(TrkParams::VerboseMode()) | 
| 762 |  |  | cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; | 
| 763 | pam-fi | 1.1 | glload[index] = false; | 
| 764 |  |  |  | 
| 765 |  |  | //    return TrkParams::Load(type); | 
| 766 |  |  | return true; | 
| 767 |  |  |  | 
| 768 |  |  | }; | 
| 769 |  |  |  | 
| 770 |  |  | /** | 
| 771 |  |  | * Set and load tracker parameters. | 
| 772 |  |  | * @param type  Parameter type | 
| 773 |  |  | * If no path as been yet specified, it set a default path. | 
| 774 |  |  | * @return FALSE if parameter set fails. | 
| 775 |  |  | */ | 
| 776 |  |  | Bool_t TrkParams::Set(UInt_t type){ | 
| 777 |  |  |  | 
| 778 |  |  |  | 
| 779 | pam-fi | 1.16 | return Set(0,0,type); | 
| 780 |  |  |  | 
| 781 | pam-fi | 1.1 |  | 
| 782 |  |  | }; | 
| 783 |  |  | /** | 
| 784 |  |  | * Set tracker parameters. | 
| 785 |  |  | * If no path as been yet specified, try to read from DB | 
| 786 |  |  | * otherwise it set a default path. | 
| 787 |  |  | * @return FALSE if parameter set fails. | 
| 788 |  |  | */ | 
| 789 | mocchiut | 1.28 |  | 
| 790 | pam-fi | 1.1 | Bool_t  TrkParams::Set( ){ | 
| 791 |  |  |  | 
| 792 | pam-fi | 1.16 |  | 
| 793 |  |  | for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; | 
| 794 | pam-fi | 1.3 |  | 
| 795 |  |  | return true; | 
| 796 | pam-fi | 1.1 | } | 
| 797 |  |  |  | 
| 798 |  |  | /** | 
| 799 |  |  | * Load tracker parameter, if not already loaded. | 
| 800 |  |  | * @param type Parameter type | 
| 801 |  |  | * ( Any call to TrkParams::Set(...) forces reloading ) | 
| 802 |  |  | */ | 
| 803 |  |  | Bool_t TrkParams::Load(UInt_t type){ | 
| 804 |  |  |  | 
| 805 |  |  | Int_t index = TrkParams::GetIndex( type ); | 
| 806 |  |  | if( index<0 )return false; | 
| 807 | pam-fi | 1.24 | if( glload[index] )return false; | 
| 808 | pam-fi | 1.1 | if( glpath[index].IsNull() )TrkParams::Set(type); | 
| 809 |  |  |  | 
| 810 |  |  | switch( type ){ | 
| 811 |  |  | //------------------------------------------ | 
| 812 |  |  | case 1: | 
| 813 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; | 
| 814 | pam-fi | 1.1 | strcpy(path_.path,glpath[index].Data()); | 
| 815 |  |  | path_.pathlen = glpath[index].Length(); | 
| 816 |  |  | path_.error   = 0; | 
| 817 |  |  | readb_(); | 
| 818 |  |  | if(path_.error) return false; | 
| 819 |  |  | glload[index]=true; | 
| 820 |  |  | break; | 
| 821 |  |  | //------------------------------------------ | 
| 822 |  |  | case 2: | 
| 823 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl; | 
| 824 | pam-fi | 1.1 | strcpy(path_.path,glpath[index].Data()); | 
| 825 |  |  | path_.pathlen = glpath[index].Length(); | 
| 826 |  |  | path_.error   = 0; | 
| 827 |  |  | readmipparam_(); | 
| 828 |  |  | if(path_.error) return false; | 
| 829 |  |  | glload[index]=true; | 
| 830 |  |  | break; | 
| 831 |  |  | //------------------------------------------ | 
| 832 |  |  | case 3: | 
| 833 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; | 
| 834 | pam-fi | 1.1 | strcpy(path_.path,glpath[index].Data()); | 
| 835 |  |  | path_.pathlen = glpath[index].Length(); | 
| 836 |  |  | path_.error   = 0; | 
| 837 |  |  | readchargeparam_(); | 
| 838 |  |  | if(path_.error) return false; | 
| 839 |  |  | glload[index]=true; | 
| 840 |  |  | break; | 
| 841 |  |  | //------------------------------------------ | 
| 842 |  |  | case 4: | 
| 843 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; | 
| 844 | pam-fi | 1.1 | strcpy(path_.path,glpath[index].Data()); | 
| 845 |  |  | path_.pathlen = glpath[index].Length(); | 
| 846 |  |  | path_.error   = 0; | 
| 847 |  |  | readetaparam_(); | 
| 848 |  |  | if(path_.error) return false; | 
| 849 |  |  | glload[index]=true; | 
| 850 |  |  | break; | 
| 851 |  |  | //------------------------------------------ | 
| 852 |  |  | case 5: | 
| 853 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; | 
| 854 | pam-fi | 1.1 | strcpy(path_.path,glpath[index].Data()); | 
| 855 |  |  | path_.pathlen = glpath[index].Length(); | 
| 856 |  |  | path_.error   = 0; | 
| 857 |  |  | readalignparam_(); | 
| 858 |  |  | if(path_.error) return false; | 
| 859 |  |  | glload[index]=true; | 
| 860 |  |  | break; | 
| 861 |  |  | //------------------------------------------ | 
| 862 |  |  | case 6: | 
| 863 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; | 
| 864 | pam-fi | 1.1 | strcpy(path_.path,glpath[index].Data()); | 
| 865 |  |  | path_.pathlen = glpath[index].Length(); | 
| 866 |  |  | path_.error   = 0; | 
| 867 |  |  | readvkmask_(); | 
| 868 |  |  | if(path_.error) return false; | 
| 869 |  |  | glload[index]=true; | 
| 870 |  |  | break; | 
| 871 |  |  | //------------------------------------------ | 
| 872 |  |  | case 7: | 
| 873 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; | 
| 874 | pam-fi | 1.1 | strcpy(path_.path,glpath[index].Data()); | 
| 875 |  |  | path_.pathlen = glpath[index].Length(); | 
| 876 |  |  | path_.error   = 0; | 
| 877 |  |  | //      fillpedsigfromdefault_(); | 
| 878 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; | 
| 879 | pam-fi | 1.1 | if(path_.error) return false; | 
| 880 |  |  | glload[index]=true; | 
| 881 |  |  | break; | 
| 882 |  |  | default: | 
| 883 | pam-fi | 1.6 | if(TrkParams::VerboseMode())cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl; | 
| 884 | pam-fi | 1.1 | return false; | 
| 885 |  |  | }; | 
| 886 |  |  |  | 
| 887 |  |  | return true; | 
| 888 |  |  | } | 
| 889 |  |  |  | 
| 890 |  |  | Bool_t TrkParams::Load( ){ | 
| 891 | pam-fi | 1.27 | Bool_t result = true; | 
| 892 |  |  | for(Int_t i=0 ; i<NTYPES; i++) | 
| 893 |  |  | if(!glload[i] && trkparamtype[i]>0 ) | 
| 894 |  |  | if( !TrkParams::Load(trkparamtype[i]) ) | 
| 895 |  |  | result = false; | 
| 896 |  |  | return result; | 
| 897 | pam-fi | 1.1 | }; | 
| 898 |  |  | Bool_t TrkParams::IsLoaded( ){ | 
| 899 |  |  | for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false; | 
| 900 |  |  | return true; | 
| 901 |  |  | }; | 
| 902 |  |  |  | 
| 903 | pam-fi | 1.30 | /** | 
| 904 |  |  | * Get ADC-to-MIP conversion parameters | 
| 905 |  |  | * @param nl ladder number (0-2) | 
| 906 |  |  | * @param nv view number (0-11) | 
| 907 |  |  | */ | 
| 908 |  |  | float TrkParams::GetMIP(int nl, int nv){ | 
| 909 |  |  | TrkParams::Load(2); | 
| 910 |  |  | if( !TrkParams::IsLoaded(2) )return 0.; | 
| 911 |  |  | return adc2mip_.mip[nl][nv]; | 
| 912 |  |  | } | 
| 913 | pam-fi | 1.8 |  | 
| 914 |  |  | /** | 
| 915 |  |  | * Get BY (kGauss) | 
| 916 |  |  | * @param v (x,y,z) coordinates in cm | 
| 917 |  |  | */ | 
| 918 |  |  | float TrkParams::GetBX(float* v){ | 
| 919 |  |  | TrkParams::Load(1); | 
| 920 |  |  | if( !TrkParams::IsLoaded(1) )return 0.; | 
| 921 |  |  | float b[3]; | 
| 922 |  |  | gufld_(v,b); | 
| 923 |  |  | return b[0]/10.; | 
| 924 |  |  | } | 
| 925 |  |  | /** | 
| 926 |  |  | * Get BY (kGauss) | 
| 927 |  |  | * @param v (x,y,z) coordinates in cm | 
| 928 |  |  | */ | 
| 929 |  |  | float TrkParams::GetBY(float* v){ | 
| 930 |  |  | TrkParams::Load(1); | 
| 931 |  |  | if( !TrkParams::IsLoaded(1) )return 0.; | 
| 932 |  |  | float b[3]; | 
| 933 |  |  | gufld_(v,b); | 
| 934 |  |  | return b[1]/10.; | 
| 935 |  |  | } | 
| 936 |  |  | /** | 
| 937 |  |  | * Get BY (kGauss) | 
| 938 |  |  | * @param v (x,y,z) coordinates in cm | 
| 939 |  |  | */ | 
| 940 |  |  | float TrkParams::GetBZ(float* v){ | 
| 941 |  |  | TrkParams::Load(1); | 
| 942 |  |  | if( !TrkParams::IsLoaded(1) )return 0.; | 
| 943 |  |  | float b[3]; | 
| 944 |  |  | gufld_(v,b); | 
| 945 |  |  | return b[2]/10.; | 
| 946 |  |  | } | 
| 947 |  |  |  | 
| 948 | pam-fi | 1.9 |  | 
| 949 | pam-fi | 1.8 | /** | 
| 950 |  |  | * \brief Set tracking mode (0=standard. 1=???) | 
| 951 |  |  | */ | 
| 952 |  |  | void TrkParams::SetTrackingMode(int trackmode) { | 
| 953 |  |  | init__mini_trackmode = trackmode; | 
| 954 | pam-fi | 1.19 | SetTrackingMode(); //fill F77 common | 
| 955 | pam-fi | 1.8 | }; | 
| 956 |  |  | /** | 
| 957 |  |  | * \brief Set fit-precision factor (typical value fact=100.) | 
| 958 |  |  | */ | 
| 959 |  |  | void TrkParams::SetPrecisionFactor(double fact){ | 
| 960 |  |  | init__mini_fact      = fact; | 
| 961 | pam-fi | 1.19 | SetPrecisionFactor(); //fill F77 common | 
| 962 | pam-fi | 1.8 | }; | 
| 963 |  |  | /** | 
| 964 |  |  | * \brief Set minimum number of step in track fitting | 
| 965 |  |  | */ | 
| 966 |  |  | void TrkParams::SetStepMin(int istepmin){ | 
| 967 |  |  | init__mini_istepmin  = istepmin; | 
| 968 | pam-fi | 1.19 | SetStepMin(); //fill F77 common | 
| 969 |  |  | }; | 
| 970 |  |  | /** | 
| 971 |  |  | * \brief Set deltaB parameters (id=0,1) | 
| 972 |  |  | */ | 
| 973 |  |  | void TrkParams::SetDeltaB(int id,double db){ | 
| 974 |  |  | if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; | 
| 975 |  |  | if(id==0)init__deltab_0 = db; | 
| 976 |  |  | if(id==1)init__deltab_1 = db; | 
| 977 |  |  | SetDeltaB(); //fill F77 common | 
| 978 | pam-fi | 1.8 | }; | 
| 979 | pam-fi | 1.20 | /** | 
| 980 |  |  | * \brief Set DLT-grkuta precision factor (default 1.e-4) | 
| 981 |  |  | */ | 
| 982 |  |  | void TrkParams::SetDLT(double fact){ | 
| 983 |  |  | init__dlt               = fact; | 
| 984 |  |  | SetDLT(); //fill F77 common | 
| 985 |  |  | }; | 
| 986 | pam-fi | 1.8 |  | 
| 987 |  |  | /** | 
| 988 | pam-fi | 1.19 | * \brief Fill F77 commons with PFA settings | 
| 989 | pam-fi | 1.13 | */ | 
| 990 |  |  | void TrkParams::SetPFA(){ | 
| 991 |  |  | sw_.pfaid = init__pfa; | 
| 992 |  |  | for(int i=0; i<6; i++){ | 
| 993 |  |  | pfa_.e234ax[i] = init__pfa_e234ax[i]; | 
| 994 |  |  | pfa_.e234ay[i] = init__pfa_e234ay[i]; | 
| 995 |  |  | } | 
| 996 |  |  | }; | 
| 997 |  |  | /** | 
| 998 | pam-fi | 1.8 | * \brief Set p.f.a. | 
| 999 |  |  | * | 
| 1000 |  |  | * Implemented algorythms: | 
| 1001 | pam-fi | 1.11 | * 0  ETA | 
| 1002 | pam-fi | 1.8 | * 1  --- | 
| 1003 |  |  | * 2  ETA2 | 
| 1004 |  |  | * 3  ETA3 | 
| 1005 |  |  | * 4  ETA4 | 
| 1006 | pam-fi | 1.11 | * 5  ETAL ==> ETA+LANDI | 
| 1007 | pam-fi | 1.8 | * 10 COG | 
| 1008 |  |  | * 11 COG1 | 
| 1009 |  |  | * 12 COG2 | 
| 1010 |  |  | * 13 COG3 | 
| 1011 |  |  | * 14 COG4 | 
| 1012 |  |  | */ | 
| 1013 |  |  | void TrkParams::SetPFA(int pfaid){ | 
| 1014 |  |  | init__pfa  = pfaid; | 
| 1015 | pam-fi | 1.19 | SetPFA(); //fill F77 common | 
| 1016 | pam-fi | 1.8 | }; | 
| 1017 | pam-fi | 1.9 | /** | 
| 1018 | pam-fi | 1.13 | * \brief Set p.f.a. angular intervals | 
| 1019 |  |  | * | 
| 1020 | pam-fi | 1.19 | * This methods allows to set amgular intervals to apply ETA2,ETA3 or ETA4 | 
| 1021 |  |  | * algorythm, in case ETA or ETAL is set (see TrkParams::SetPFA(int pfaid)). | 
| 1022 | pam-fi | 1.13 | * @param v Pointer to a vector of 12 components, which represent the | 
| 1023 |  |  | * angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. | 
| 1024 |  |  | * | 
| 1025 |  |  | */ | 
| 1026 |  |  | void TrkParams::SetPFA(float *v){ | 
| 1027 |  |  | for(int i=0; i<6; i++){ | 
| 1028 |  |  | init__pfa_e234ax[i]  = v[i]; | 
| 1029 |  |  | init__pfa_e234ay[i]  = v[i+6]; | 
| 1030 |  |  | } | 
| 1031 | pam-fi | 1.19 | SetPFA(); //fill F77 common | 
| 1032 | pam-fi | 1.13 | }; | 
| 1033 | pam-fi | 1.14 |  | 
| 1034 |  |  |  | 
| 1035 | pam-fi | 1.13 | /** | 
| 1036 | pam-fi | 1.9 | * \brief Get spatial resolution. | 
| 1037 |  |  | * | 
| 1038 |  |  | * Method to retrieve the spatial resolution associated with the | 
| 1039 |  |  | * adopted p.f.a. | 
| 1040 |  |  | * @param view Tracker view (1-12) | 
| 1041 |  |  | * @param angle Track projected angle | 
| 1042 |  |  | * | 
| 1043 |  |  | * In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: | 
| 1044 |  |  | * | 
| 1045 |  |  | *  TrkParams::SetPFA(0)  // ETA | 
| 1046 |  |  | * | 
| 1047 |  |  | */ | 
| 1048 |  |  | float TrkParams::GetResolution(int view, float angle){ | 
| 1049 |  |  | float res = 1000; | 
| 1050 | pam-fi | 1.22 | if     ( init__pfa == 0 )res = riseta_(&view,&angle); | 
| 1051 |  |  | else if( init__pfa == 5 )res = riseta_(&view,&angle); | 
| 1052 | pam-fi | 1.9 | else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; | 
| 1053 |  |  | return res; | 
| 1054 |  |  | } | 
| 1055 | pam-fi | 1.8 |  | 
| 1056 | pam-fi | 1.22 | /** | 
| 1057 |  |  | * Returns the number of angular bins for p.f.a. parameters | 
| 1058 |  |  | */ | 
| 1059 |  |  | int TrkParams::GetPFA_NbinsAngle(){ | 
| 1060 |  |  | TrkParams::Load(4); | 
| 1061 |  |  | if( !TrkParams::IsLoaded(4) ){ | 
| 1062 |  |  | cout << "int TrkParams::GetPFA_NbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl; | 
| 1063 |  |  | return 0; | 
| 1064 |  |  | } | 
| 1065 |  |  | return pfa_.nangbin; | 
| 1066 |  |  | }; | 
| 1067 |  |  | /** | 
| 1068 |  |  | * Returns the number of eta bins for p.f.a. parameters | 
| 1069 |  |  | */ | 
| 1070 |  |  | int TrkParams::GetPFA_NbinsETA(){ | 
| 1071 |  |  | TrkParams::Load(4); | 
| 1072 |  |  | if( !TrkParams::IsLoaded(4) ){ | 
| 1073 |  |  | cout << "int TrkParams::GetPFA_NbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl; | 
| 1074 |  |  | return 0; | 
| 1075 |  |  | } | 
| 1076 |  |  | return pfa_.netaval; | 
| 1077 |  |  | }; | 
| 1078 |  |  |  | 
| 1079 |  |  | /** | 
| 1080 |  |  | * Returns the pointer to a vector ( of size TrkParams::GetPFA_NbinsETA() ), | 
| 1081 |  |  | * with eta-correction values for each eta bin. | 
| 1082 |  |  | * Bin extremes are given by float* TrkParams::GetPFA_ETAabs(pfa,int). | 
| 1083 |  |  | * | 
| 1084 |  |  | * @param pfa "ETA2","ETA3" or "ETA4" | 
| 1085 |  |  | * @param nview View number (0-11) | 
| 1086 |  |  | * @param nladder Ladder number (0-2) | 
| 1087 |  |  | * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). | 
| 1088 |  |  | * | 
| 1089 |  |  | * NB! the vector must be deallocated! | 
| 1090 |  |  | * delete [] vname; | 
| 1091 |  |  | */ | 
| 1092 |  |  | float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang){ | 
| 1093 |  |  |  | 
| 1094 |  |  | TrkParams::Load(4); | 
| 1095 |  |  | if( !TrkParams::IsLoaded(4) ){ | 
| 1096 |  |  | cout << "float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl; | 
| 1097 |  |  | return 0; | 
| 1098 |  |  | } | 
| 1099 |  |  |  | 
| 1100 |  |  | int nbins = GetPFA_NbinsETA(); | 
| 1101 |  |  | if(!nbins)return 0; | 
| 1102 |  |  |  | 
| 1103 |  |  | if( nview   <   0 || | 
| 1104 |  |  | nview   >= 12 || | 
| 1105 |  |  | nladder <   0 || | 
| 1106 |  |  | nladder >=  3 || | 
| 1107 |  |  | nang    <   0 || | 
| 1108 |  |  | nang    >=  GetPFA_NbinsAngle() || | 
| 1109 |  |  | false)return 0; | 
| 1110 |  |  |  | 
| 1111 |  |  | float *fcorr = new float [nbins]; | 
| 1112 |  |  | //    float fcorr[nbins]; | 
| 1113 |  |  |  | 
| 1114 |  |  | if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ | 
| 1115 |  |  | for(int ib=0; ib<nbins; ib++){ | 
| 1116 |  |  | fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib]; | 
| 1117 |  |  | //          cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;; | 
| 1118 |  |  | } | 
| 1119 |  |  | }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ | 
| 1120 |  |  | for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib]; | 
| 1121 |  |  | }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ | 
| 1122 |  |  | for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib]; | 
| 1123 |  |  | }else{ | 
| 1124 |  |  | cout << "float* TrkParams::GetPFA_ETAcorr("<<pfa<<",...) ---  pfa parameters not implemented "<<endl; | 
| 1125 |  |  | return 0; | 
| 1126 |  |  | } | 
| 1127 |  |  |  | 
| 1128 |  |  | return fcorr; | 
| 1129 |  |  |  | 
| 1130 |  |  | }; | 
| 1131 |  |  |  | 
| 1132 |  |  | /** | 
| 1133 |  |  | * Returns the pointer to a vector with eta-bin extremes (@see float* TrkParams::GetPFA_ETAcorr(TString,int,int,int)). | 
| 1134 |  |  | * | 
| 1135 |  |  | * @param pfa "ETA2","ETA3" or "ETA4" | 
| 1136 |  |  | * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). | 
| 1137 |  |  | * | 
| 1138 |  |  | * NB the vector must be deallocated | 
| 1139 |  |  | * delete [] vname; | 
| 1140 |  |  | */ | 
| 1141 |  |  | float* TrkParams::GetPFA_ETAabs(TString pfa, int nang){ | 
| 1142 |  |  |  | 
| 1143 |  |  | TrkParams::Load(4); | 
| 1144 |  |  | if( !TrkParams::IsLoaded(4) ){ | 
| 1145 |  |  | cout << "float* TrkParams::GetPFA_ETAabs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl; | 
| 1146 |  |  | return 0; | 
| 1147 |  |  | } | 
| 1148 |  |  |  | 
| 1149 |  |  | int nbins = GetPFA_NbinsETA(); | 
| 1150 |  |  | if(!nbins)return 0; | 
| 1151 |  |  |  | 
| 1152 |  |  | float *fcorr = new float [nbins]; | 
| 1153 |  |  | //    float fcorr[nbins]; | 
| 1154 |  |  | if( nang    <   0 || | 
| 1155 |  |  | nang    >=  GetPFA_NbinsAngle() || | 
| 1156 |  |  | false)return 0; | 
| 1157 |  |  |  | 
| 1158 |  |  | if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ | 
| 1159 |  |  | for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib]; | 
| 1160 |  |  | }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ | 
| 1161 |  |  | for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib]; | 
| 1162 |  |  | }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ | 
| 1163 |  |  | for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib]; | 
| 1164 |  |  | }else{ | 
| 1165 |  |  | cout << "float* TrkParams::GetPFA_ETAabs("<<pfa<<",...) ---  pfa parameters not implemented "<<endl; | 
| 1166 |  |  | return 0; | 
| 1167 |  |  | } | 
| 1168 |  |  |  | 
| 1169 |  |  | return fcorr; | 
| 1170 |  |  |  | 
| 1171 |  |  | }; | 
| 1172 |  |  | /** | 
| 1173 |  |  | * Returns the "Landi-correction". | 
| 1174 |  |  | * | 
| 1175 |  |  | * @param nview View number (0-11) | 
| 1176 |  |  | * @param nladder Ladder number (0-2) | 
| 1177 |  |  | * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). | 
| 1178 |  |  | */ | 
| 1179 |  |  | float TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang){ | 
| 1180 |  |  |  | 
| 1181 |  |  | //     TrkParams::Load(4); | 
| 1182 |  |  | //     if( !TrkParams::IsLoaded(4) ){ | 
| 1183 |  |  | //      cout << "float* TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl; | 
| 1184 |  |  | //      return 0; | 
| 1185 |  |  | //     } | 
| 1186 |  |  | int nbins = GetPFA_NbinsAngle(); | 
| 1187 |  |  | if(!nbins)return 0; | 
| 1188 |  |  |  | 
| 1189 |  |  | if( nview   <   0 || | 
| 1190 |  |  | nview   >= 12 || | 
| 1191 |  |  | nladder <   0 || | 
| 1192 |  |  | nladder >=  3 || | 
| 1193 |  |  | nang    <   0 || | 
| 1194 |  |  | nang    >=  nbins || | 
| 1195 |  |  | false)return 0; | 
| 1196 |  |  |  | 
| 1197 |  |  |  | 
| 1198 |  |  | return pfa_.fcorr[nang][nladder][nview]; | 
| 1199 |  |  |  | 
| 1200 |  |  | }; | 
| 1201 |  |  |  | 
| 1202 |  |  | /** | 
| 1203 |  |  | * Returns the index (0, n.bin-1) of the angular bin for pfa parameters | 
| 1204 |  |  | * @param angle Effective angle (deg) | 
| 1205 |  |  | */ | 
| 1206 |  |  | int TrkParams::GetPFA_AngleBin(float angle){ | 
| 1207 |  |  |  | 
| 1208 |  |  | int nangbin = TrkParams::GetPFA_NbinsAngle(); | 
| 1209 |  |  | int istart = (int)(nangbin/2); | 
| 1210 |  |  | int idbin = -1; | 
| 1211 | pam-fi | 1.23 | //    cout << angle <<" ??" << endl; | 
| 1212 | pam-fi | 1.22 | if( angle > pfa_.angR[istart] ){ | 
| 1213 |  |  | idbin = nangbin-1; | 
| 1214 |  |  | for(int id=istart+1; id<nangbin; id++ ){ | 
| 1215 | pam-fi | 1.23 | //          cout << id << endl; | 
| 1216 | pam-fi | 1.22 | if( pfa_.angR[id] >= angle ){ | 
| 1217 |  |  | idbin = id; | 
| 1218 |  |  | break; | 
| 1219 |  |  | } | 
| 1220 |  |  | } | 
| 1221 |  |  | }else{ | 
| 1222 |  |  | idbin = 0; | 
| 1223 |  |  | for(int id=istart; id>=0; id-- ){ | 
| 1224 | pam-fi | 1.23 | //          cout << id << endl; | 
| 1225 | pam-fi | 1.22 | if( pfa_.angL[id] < angle ){ | 
| 1226 |  |  | idbin = id; | 
| 1227 |  |  | break; | 
| 1228 |  |  | } | 
| 1229 |  |  | } | 
| 1230 |  |  |  | 
| 1231 |  |  | } | 
| 1232 | pam-fi | 1.23 | //    cout << ">>> "<<idbin<<" "<<pfa_.angL[idbin]<<" "<<pfa_.angR[idbin]<<endl; | 
| 1233 | pam-fi | 1.22 | return idbin; | 
| 1234 |  |  | } | 
| 1235 | pam-fi | 1.8 |  | 
| 1236 |  |  |  | 
| 1237 | pam-fi | 1.14 |  | 
| 1238 | pam-fi | 1.1 | ClassImp(TrkParams); |