| 64 | 
   memset(mip, 0, 2*22*96*sizeof(Float_t)); | 
   memset(mip, 0, 2*22*96*sizeof(Float_t)); | 
| 65 | 
   memset(base, 0, 2*22*6*sizeof(Float_t)); | 
   memset(base, 0, 2*22*6*sizeof(Float_t)); | 
| 66 | 
   memset(sbase, 0, 2*22*6*sizeof(Float_t)); | 
   memset(sbase, 0, 2*22*6*sizeof(Float_t)); | 
| 67 | 
  | 
   memset(obadmask, 0, 2*22*96*sizeof(Int_t)); | 
| 68 | 
  | 
   memset(obadpulsemask, 0, 2*22*6*sizeof(Int_t)); | 
| 69 | 
  | 
   memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); | 
| 70 | 
  | 
   memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); | 
| 71 | 
   calopar1 = true; | 
   calopar1 = true; | 
| 72 | 
   calopar2 = true; | 
   calopar2 = true; | 
| 73 | 
   calopar3 = true; | 
   calopar3 = true; | 
| 82 | 
  | 
  | 
| 83 | 
 void CaloLevel0::SetCrossTalk(Bool_t ct){ | 
 void CaloLevel0::SetCrossTalk(Bool_t ct){ | 
| 84 | 
   crosst = ct; | 
   crosst = ct; | 
| 85 | 
 }; | 
 } | 
| 86 | 
  | 
  | 
| 87 | 
  | 
 void CaloLevel0::SetCrossTalkType(Bool_t ct){ | 
| 88 | 
  | 
   ctground = ct; | 
| 89 | 
  | 
 } | 
| 90 | 
  | 
  | 
| 91 | 
 void CaloLevel0::SetVerbose(Bool_t ct){ | 
 void CaloLevel0::SetVerbose(Bool_t ct){ | 
| 92 | 
   verbose = ct; | 
   verbose = ct; | 
| 93 | 
 }; | 
 } | 
| 94 | 
  | 
  | 
| 95 | 
 /** | 
 /** | 
| 96 | 
  * Initialize CaloLevel0 object | 
  * Initialize CaloLevel0 object | 
| 97 | 
 **/ | 
 **/ | 
| 98 | 
 void CaloLevel0::ProcessingInit(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ | 
 void CaloLevel0::ProcessingInit(GL_TABLES *glt, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ | 
| 99 | 
  | 
   // | 
| 100 | 
  | 
   const TString host = glt->CGetHost(); | 
| 101 | 
  | 
   const TString user = glt->CGetUser(); | 
| 102 | 
  | 
   const TString psw = glt->CGetPsw(); | 
| 103 | 
  | 
   TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); | 
| 104 | 
  | 
   if ( !dbc->IsConnected() ) throw -116;   | 
| 105 | 
  | 
   stringstream myquery; | 
| 106 | 
  | 
   myquery.str(""); | 
| 107 | 
  | 
   myquery << "SET time_zone='+0:00'"; | 
| 108 | 
  | 
   dbc->Query(myquery.str().c_str()); | 
| 109 | 
   // | 
   // | 
| 110 | 
   debug = isdeb; | 
   debug = isdeb; | 
| 111 | 
   verbose = isverb; | 
   verbose = isverb; | 
| 182 | 
   // | 
   // | 
| 183 | 
   delete glcalo; | 
   delete glcalo; | 
| 184 | 
   delete glroot; | 
   delete glroot; | 
| 185 | 
  | 
   dbc->Close(); | 
| 186 | 
  | 
   delete dbc; | 
| 187 | 
   // | 
   // | 
| 188 | 
   return; | 
   return; | 
| 189 | 
   // | 
   // | 
| 190 | 
 } | 
 } | 
| 191 | 
  | 
  | 
| 192 | 
 Int_t CaloLevel0::ChkCalib(TSQLServer *dbc, UInt_t atime){ | 
 Int_t CaloLevel0::ChkCalib(GL_TABLES *glt, UInt_t atime){ | 
| 193 | 
   Int_t sgnl = 0; | 
   Int_t sgnl = 0; | 
| 194 | 
   for ( Int_t s = 0; s < 4; s++){ | 
   for ( Int_t s = 0; s < 4; s++){ | 
| 195 | 
     if ( atime > totime[s] ){ | 
     if ( atime > totime[s] ){ | 
| 196 | 
       if ( !dbc->IsConnected() ) throw -116; | 
       sgnl = Update(glt,atime,s); | 
 | 
       sgnl = Update(dbc,atime,s); | 
  | 
| 197 | 
       if ( sgnl < 0 ) return(sgnl);  | 
       if ( sgnl < 0 ) return(sgnl);  | 
| 198 | 
     }; | 
     }; | 
| 199 | 
   }; | 
   }; | 
| 200 | 
   return(sgnl); | 
   return(sgnl); | 
| 201 | 
 } | 
 } | 
| 202 | 
  | 
  | 
| 203 | 
 Int_t CaloLevel0::ChkParam(TSQLServer *dbc, UInt_t runheader){ | 
 Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ | 
| 204 | 
  | 
   const TString host = glt->CGetHost(); | 
| 205 | 
  | 
   const TString user = glt->CGetUser(); | 
| 206 | 
  | 
   const TString psw = glt->CGetPsw(); | 
| 207 | 
  | 
   TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); | 
| 208 | 
  | 
   if ( !dbc->IsConnected() ) throw -116; | 
| 209 | 
  | 
   stringstream myquery; | 
| 210 | 
  | 
   myquery.str(""); | 
| 211 | 
  | 
   myquery << "SET time_zone='+0:00'"; | 
| 212 | 
  | 
   dbc->Query(myquery.str().c_str()); | 
| 213 | 
  | 
   // | 
| 214 | 
   stringstream calfile; | 
   stringstream calfile; | 
| 215 | 
   stringstream bmfile; | 
   stringstream bmfile; | 
| 216 | 
   stringstream aligfile; | 
   stringstream aligfile; | 
| 220 | 
   GL_PARAM *glparam = new GL_PARAM(); | 
   GL_PARAM *glparam = new GL_PARAM(); | 
| 221 | 
   // | 
   // | 
| 222 | 
   if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ | 
   if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ | 
| 223 | 
  | 
     // | 
| 224 | 
  | 
     // | 
| 225 | 
  | 
     // | 
| 226 | 
  | 
     if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); | 
| 227 | 
  | 
     // | 
| 228 | 
     calopar1 = false; | 
     calopar1 = false; | 
| 229 | 
     // | 
     // | 
| 230 | 
     // determine where I can find calorimeter ADC to MIP conversion file   | 
     // determine where I can find calorimeter ADC to MIP conversion file   | 
| 252 | 
       for (Int_t k = 0; k < 22; k++ ){ | 
       for (Int_t k = 0; k < 22; k++ ){ | 
| 253 | 
         for (Int_t l = 0; l < 96; l++ ){ | 
         for (Int_t l = 0; l < 96; l++ ){ | 
| 254 | 
           fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); | 
           fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); | 
| 255 | 
  | 
           if ( debug ) printf(" %f \n",mip[m][k][l]); | 
| 256 | 
         }; | 
         }; | 
| 257 | 
       }; | 
       }; | 
| 258 | 
     }; | 
     }; | 
| 260 | 
   }; | 
   }; | 
| 261 | 
   // | 
   // | 
| 262 | 
   if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ | 
   if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ | 
| 263 | 
  | 
     if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); | 
| 264 | 
     calopar2 = false; | 
     calopar2 = false; | 
| 265 | 
     // | 
     // | 
| 266 | 
     // determine where I can find calorimeter alignment file   | 
     // determine where I can find calorimeter alignment file   | 
| 276 | 
     ftcalopar2 = glparam->FROM_TIME; | 
     ftcalopar2 = glparam->FROM_TIME; | 
| 277 | 
     ttcalopar2 = glparam->TO_TIME; | 
     ttcalopar2 = glparam->TO_TIME; | 
| 278 | 
     // | 
     // | 
| 279 | 
     if ( verbose ) printf("\n Using alignment file: \n %s \n",aligfile.str().c_str()); | 
     if ( verbose ) printf("\n Using parameter file: \n %s \n",aligfile.str().c_str()); | 
| 280 | 
     f = fopen(aligfile.str().c_str(),"rb"); | 
     f = fopen(aligfile.str().c_str(),"rb"); | 
| 281 | 
     if ( !f ){ | 
     if ( !f ){ | 
| 282 | 
       if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); | 
       if ( verbose ) printf(" CALORIMETER - ERROR: no parameter file!\n"); | 
| 283 | 
       return(-106); | 
       return(-106); | 
| 284 | 
     }; | 
     }; | 
| 285 | 
     // | 
     // | 
| 286 | 
     fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); | 
     if ( !mechal ){ | 
| 287 | 
     if ( debug ) printf(" xalig = %f \n",clevel1->xalig); | 
       // | 
| 288 | 
     fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); | 
       fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); | 
| 289 | 
     if ( debug ) printf(" yalig = %f \n",clevel1->yalig); | 
       if ( debug ) printf(" xalig = %f \n",clevel1->xalig); | 
| 290 | 
     fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); | 
       fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); | 
| 291 | 
     if ( debug ) printf(" zalig = %f \n",clevel1->zalig); | 
       if ( debug ) printf(" yalig = %f \n",clevel1->yalig); | 
| 292 | 
  | 
       fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); | 
| 293 | 
  | 
       if ( debug ) printf(" zalig = %f \n",clevel1->zalig); | 
| 294 | 
  | 
     } else { | 
| 295 | 
  | 
       if ( verbose ) printf("\n Using MECHANICAL alignement parameters \n"); | 
| 296 | 
  | 
       // | 
| 297 | 
  | 
       CaloStrip cs = CaloStrip(); | 
| 298 | 
  | 
       cs.UseMechanicalAlig(); | 
| 299 | 
  | 
       clevel1->xalig = cs.GetXalig(); | 
| 300 | 
  | 
       if ( debug ) printf(" xalig = %f \n",clevel1->xalig); | 
| 301 | 
  | 
       clevel1->yalig = cs.GetYalig(); | 
| 302 | 
  | 
       if ( debug ) printf(" yalig = %f \n",clevel1->yalig); | 
| 303 | 
  | 
       clevel1->zalig = cs.GetZalig(); | 
| 304 | 
  | 
       if ( debug ) printf(" zalig = %f \n",clevel1->zalig); | 
| 305 | 
  | 
       // | 
| 306 | 
  | 
       Float_t tmp = 0; | 
| 307 | 
  | 
       fread(&tmp,sizeof(clevel1->xalig),1,f); | 
| 308 | 
  | 
       fread(&tmp,sizeof(clevel1->yalig),1,f); | 
| 309 | 
  | 
       fread(&tmp,sizeof(clevel1->zalig),1,f); | 
| 310 | 
  | 
       //      clevel1->zalig = -265.82; | 
| 311 | 
  | 
       //     | 
| 312 | 
  | 
     }; | 
| 313 | 
     fread(&clevel1->emin,sizeof(clevel1->emin),1,f);   | 
     fread(&clevel1->emin,sizeof(clevel1->emin),1,f);   | 
| 314 | 
     if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); | 
     if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); | 
| 315 | 
     // | 
     // | 
| 319 | 
   // Load offline bad strip mask  | 
   // Load offline bad strip mask  | 
| 320 | 
   // | 
   // | 
| 321 | 
   if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ | 
   if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ | 
| 322 | 
  | 
     if ( debug ) printf(" calopar3 %i ftcalopar3 %u ttcalopar3 %u runheader %u \n",calopar3,ftcalopar3,ttcalopar3,runheader); | 
| 323 | 
     calopar3 = false; | 
     calopar3 = false; | 
| 324 | 
     // | 
     // | 
| 325 | 
     // determine where I can find calorimeter alignment file   | 
     // determine where I can find calorimeter alignment file   | 
| 367 | 
   }; | 
   }; | 
| 368 | 
   // | 
   // | 
| 369 | 
   delete glparam; | 
   delete glparam; | 
| 370 | 
  | 
   dbc->Close(); | 
| 371 | 
  | 
   delete dbc; | 
| 372 | 
   // | 
   // | 
| 373 | 
   return(0); | 
   return(0); | 
| 374 | 
 } | 
 } | 
| 375 | 
  | 
  | 
| 376 | 
  | 
 Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader){ | 
| 377 | 
  | 
   // | 
| 378 | 
 void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ | 
   if ( ctground ) return(0); | 
| 379 | 
     Float_t minstrip = 100000.; | 
   // | 
| 380 | 
     Float_t rms = 0.; | 
   const TString host = glt->CGetHost(); | 
| 381 | 
     base[l][m][pre] = 0.; | 
   const TString user = glt->CGetUser(); | 
| 382 | 
     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ | 
   const TString psw = glt->CGetPsw(); | 
| 383 | 
         if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 &&  dexy[l][m][e]-calped[l][m][e] < minstrip &&  dexy[l][m][e] > 0.) { | 
   TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); | 
| 384 | 
             minstrip = dexy[l][m][e]-calped[l][m][e]; | 
   if ( !dbc->IsConnected() ) throw -116; | 
| 385 | 
             rms = calthr[l][m][pre]; | 
   stringstream myquery; | 
| 386 | 
  | 
   myquery.str(""); | 
| 387 | 
  | 
   myquery << "SET time_zone='+0:00'"; | 
| 388 | 
  | 
   dbc->Query(myquery.str().c_str()); | 
| 389 | 
  | 
   // | 
| 390 | 
  | 
   stringstream bmfile; | 
| 391 | 
  | 
   Int_t error = 0; | 
| 392 | 
  | 
   ifstream badfile; | 
| 393 | 
  | 
   GL_PARAM *glparam = new GL_PARAM(); | 
| 394 | 
  | 
   // | 
| 395 | 
  | 
   // determine where I can find file with offline bad pulser mask  | 
| 396 | 
  | 
   // | 
| 397 | 
  | 
   error = 0; | 
| 398 | 
  | 
   error = glparam->Query_GL_PARAM(runheader,105,dbc); | 
| 399 | 
  | 
   if ( error < 0 ) return(error); | 
| 400 | 
  | 
   // | 
| 401 | 
  | 
   bmfile.str(""); | 
| 402 | 
  | 
   bmfile << glparam->PATH.Data() << "/"; | 
| 403 | 
  | 
   bmfile << glparam->NAME.Data(); | 
| 404 | 
  | 
   // | 
| 405 | 
  | 
   if ( verbose ) printf("\n Using bad pulser offline mask file: \n %s \n\n",bmfile.str().c_str()); | 
| 406 | 
  | 
   badfile.open(bmfile.str().c_str()); | 
| 407 | 
  | 
   if ( !badfile ){ | 
| 408 | 
  | 
     if ( verbose ) printf(" CALORIMETER - ERROR: no bad pulser offline mask file!\n"); | 
| 409 | 
  | 
     return(-115); | 
| 410 | 
  | 
   }; | 
| 411 | 
  | 
   // | 
| 412 | 
  | 
   Bool_t isdone = false; | 
| 413 | 
  | 
   Int_t bad = 0; | 
| 414 | 
  | 
   Int_t view = 1; | 
| 415 | 
  | 
   Int_t pre = 0; | 
| 416 | 
  | 
   Int_t plane = 21; | 
| 417 | 
  | 
   while ( !isdone ) { | 
| 418 | 
  | 
     badfile >> bad; | 
| 419 | 
  | 
     obadpulsemask[view][plane][pre] = bad; | 
| 420 | 
  | 
     if ( debug && bad ) printf(" SETTING view %i plane %i pre %i  BAD = %i \n",view,plane,pre,bad); | 
| 421 | 
  | 
     pre++; | 
| 422 | 
  | 
     if ( pre > 5 ){ | 
| 423 | 
  | 
       pre = 0; | 
| 424 | 
  | 
       plane--; | 
| 425 | 
  | 
       if ( plane < 0 ){ | 
| 426 | 
  | 
         plane = 21; | 
| 427 | 
  | 
         view--; | 
| 428 | 
  | 
       }; | 
| 429 | 
  | 
       if ( view < 0 ) isdone = true; | 
| 430 | 
  | 
     }; | 
| 431 | 
  | 
   }; | 
| 432 | 
  | 
   // | 
| 433 | 
  | 
   delete glparam; | 
| 434 | 
  | 
   badfile.close(); | 
| 435 | 
  | 
   // | 
| 436 | 
  | 
   // Let's start with cross-talk correction calculation | 
| 437 | 
  | 
   // | 
| 438 | 
  | 
   GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); | 
| 439 | 
  | 
   Float_t adcp[2][22][96]; | 
| 440 | 
  | 
   Float_t adcpcal[2][22][96]; | 
| 441 | 
  | 
   memset(adcp , 0, 2*22*96*sizeof(Float_t)); | 
| 442 | 
  | 
   memset(adcpcal , 0, 2*22*96*sizeof(Float_t)); | 
| 443 | 
  | 
   // | 
| 444 | 
  | 
   UInt_t pampli = 0;   | 
| 445 | 
  | 
   for (Int_t s=0; s<4; s++){ | 
| 446 | 
  | 
     // | 
| 447 | 
  | 
     // Save into matrix adcp the values of the highest pulse calibration (pulse amplitude = 2) | 
| 448 | 
  | 
     // | 
| 449 | 
  | 
     pampli = 2; | 
| 450 | 
  | 
     error = 0; | 
| 451 | 
  | 
     error = glp->Query_GL_CALOPULSE_CALIB(runheader,s,pampli,dbc); | 
| 452 | 
  | 
     if ( error < 0 ){ | 
| 453 | 
  | 
       if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); | 
| 454 | 
  | 
       return(error); | 
| 455 | 
  | 
     }; | 
| 456 | 
  | 
     // | 
| 457 | 
  | 
     UInt_t idcalib = glp->ID_ROOT_L0; | 
| 458 | 
  | 
     UInt_t fromtime = glp->FROM_TIME; | 
| 459 | 
  | 
     UInt_t calibno = glp->EV_ROOT; | 
| 460 | 
  | 
     // | 
| 461 | 
  | 
     // determine path and name and entry of the calibration file | 
| 462 | 
  | 
     // | 
| 463 | 
  | 
     GL_ROOT *glroot = new GL_ROOT();   | 
| 464 | 
  | 
     if ( verbose ) printf("\n"); | 
| 465 | 
  | 
     if ( verbose ) printf(" ** SECTION %i **\n",s); | 
| 466 | 
  | 
     // | 
| 467 | 
  | 
     error = 0; | 
| 468 | 
  | 
     error = glroot->Query_GL_ROOT(idcalib,dbc); | 
| 469 | 
  | 
     if ( error < 0 ){ | 
| 470 | 
  | 
       if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); | 
| 471 | 
  | 
       return(error); | 
| 472 | 
  | 
     }; | 
| 473 | 
  | 
     //   | 
| 474 | 
  | 
     stringstream name; | 
| 475 | 
  | 
     name.str(""); | 
| 476 | 
  | 
     name << glroot->PATH.Data() << "/"; | 
| 477 | 
  | 
     name << glroot->NAME.Data(); | 
| 478 | 
  | 
     // | 
| 479 | 
  | 
     TString fcalname = (TString)name.str().c_str(); | 
| 480 | 
  | 
     ifstream myfile; | 
| 481 | 
  | 
     myfile.open(fcalname.Data()); | 
| 482 | 
  | 
     if ( !myfile ){     | 
| 483 | 
  | 
       return(-107); | 
| 484 | 
  | 
     }; | 
| 485 | 
  | 
     myfile.close(); | 
| 486 | 
  | 
     // | 
| 487 | 
  | 
     TFile *File = new TFile(fcalname.Data()); | 
| 488 | 
  | 
     if ( !File ) return(-108); | 
| 489 | 
  | 
     TTree *tr = (TTree*)File->Get("CalibCalPulse2"); | 
| 490 | 
  | 
     if ( !tr ) return(-119); | 
| 491 | 
  | 
     // | 
| 492 | 
  | 
     TBranch *calo = tr->GetBranch("CalibCalPulse2"); | 
| 493 | 
  | 
     // | 
| 494 | 
  | 
     pamela::CalibCalPulse2Event *ce = 0; | 
| 495 | 
  | 
     tr->SetBranchAddress("CalibCalPulse2", &ce); | 
| 496 | 
  | 
     // | 
| 497 | 
  | 
     Long64_t ncalibs = calo->GetEntries(); | 
| 498 | 
  | 
     // | 
| 499 | 
  | 
     if ( !ncalibs ) return(-110);  | 
| 500 | 
  | 
     // | 
| 501 | 
  | 
     calo->GetEntry(calibno); | 
| 502 | 
  | 
     if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); | 
| 503 | 
  | 
     // | 
| 504 | 
  | 
     // retrieve calibration table | 
| 505 | 
  | 
     // | 
| 506 | 
  | 
     if ( ce->pstwerr[s] && ce->pperror[s] == 0 && ce->unpackError == 0 ){ | 
| 507 | 
  | 
       for ( Int_t d=0 ; d<11 ;d++  ){ | 
| 508 | 
  | 
         for ( Int_t j=0; j<96 ;j++){ | 
| 509 | 
  | 
           if ( s == 2 ){ | 
| 510 | 
  | 
             adcp[0][2*d+1][j] = ce->calpuls[3][d][j]; | 
| 511 | 
  | 
           }; | 
| 512 | 
  | 
           if ( s == 3 ){ | 
| 513 | 
  | 
             adcp[0][2*d][j] = ce->calpuls[1][d][j]; | 
| 514 | 
  | 
           }; | 
| 515 | 
  | 
           if ( s == 0 ){ | 
| 516 | 
  | 
             adcp[1][2*d][j] = ce->calpuls[0][d][j]; | 
| 517 | 
  | 
           }; | 
| 518 | 
  | 
           if ( s == 1 ){ | 
| 519 | 
  | 
             adcp[1][2*d+1][j] = ce->calpuls[2][d][j]; | 
| 520 | 
  | 
           }; | 
| 521 | 
         }; | 
         }; | 
| 522 | 
  | 
       }; | 
| 523 | 
  | 
     } else { | 
| 524 | 
  | 
       if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); | 
| 525 | 
  | 
       return(-111); | 
| 526 | 
  | 
     }; | 
| 527 | 
  | 
     // | 
| 528 | 
  | 
     File->Close(); | 
| 529 | 
  | 
     delete glroot; | 
| 530 | 
  | 
     // | 
| 531 | 
  | 
     // Save into matrix adcpcal the calibrated values of the pulse calibration (subtraction of pulse amplitude = 0 relative to the pulse2 calibration used) | 
| 532 | 
  | 
     // | 
| 533 | 
  | 
     pampli = 0; | 
| 534 | 
  | 
     error = 0; | 
| 535 | 
  | 
     error = glp->Query_GL_CALOPULSE_CALIB(fromtime,s,pampli,dbc); | 
| 536 | 
  | 
     if ( error < 0 ){ | 
| 537 | 
  | 
       if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); | 
| 538 | 
  | 
       return(error); | 
| 539 | 
     }; | 
     }; | 
| 540 | 
     if ( minstrip != 100000. ) { | 
     // | 
| 541 | 
         Float_t strip6s = 0.; | 
     idcalib = glp->ID_ROOT_L0; | 
| 542 | 
         for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ | 
     calibno = glp->EV_ROOT; | 
| 543 | 
             if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { | 
     // | 
| 544 | 
                 strip6s += 1.; | 
     // determine path and name and entry of the calibration file | 
| 545 | 
                 base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); | 
     // | 
| 546 | 
  | 
     glroot = new GL_ROOT();   | 
| 547 | 
  | 
     if ( verbose ) printf("\n"); | 
| 548 | 
  | 
     if ( verbose ) printf(" ** SECTION %i **\n",s); | 
| 549 | 
  | 
     // | 
| 550 | 
  | 
     error = 0; | 
| 551 | 
  | 
     error = glroot->Query_GL_ROOT(idcalib,dbc); | 
| 552 | 
  | 
     if ( error < 0 ){ | 
| 553 | 
  | 
       if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); | 
| 554 | 
  | 
       return(error); | 
| 555 | 
  | 
     }; | 
| 556 | 
  | 
     //   | 
| 557 | 
  | 
     name.str(""); | 
| 558 | 
  | 
     name << glroot->PATH.Data() << "/"; | 
| 559 | 
  | 
     name << glroot->NAME.Data(); | 
| 560 | 
  | 
     // | 
| 561 | 
  | 
     fcalname = (TString)name.str().c_str(); | 
| 562 | 
  | 
     myfile.open(fcalname.Data()); | 
| 563 | 
  | 
     if ( !myfile ){     | 
| 564 | 
  | 
       return(-107); | 
| 565 | 
  | 
     }; | 
| 566 | 
  | 
     myfile.close(); | 
| 567 | 
  | 
     // | 
| 568 | 
  | 
     TFile *File1 = new TFile(fcalname.Data()); | 
| 569 | 
  | 
     if ( !File1 ) return(-108); | 
| 570 | 
  | 
     TTree *tr1 = (TTree*)File1->Get("CalibCalPulse1"); | 
| 571 | 
  | 
     if ( !tr1 ) return(-120); | 
| 572 | 
  | 
     // | 
| 573 | 
  | 
     TBranch *calo1 = tr1->GetBranch("CalibCalPulse1"); | 
| 574 | 
  | 
     // | 
| 575 | 
  | 
     pamela::CalibCalPulse1Event *ce1 = 0; | 
| 576 | 
  | 
     tr1->SetBranchAddress("CalibCalPulse1", &ce1); | 
| 577 | 
  | 
     // | 
| 578 | 
  | 
     ncalibs = calo1->GetEntries(); | 
| 579 | 
  | 
     // | 
| 580 | 
  | 
     if ( !ncalibs ) return(-110);  | 
| 581 | 
  | 
     // | 
| 582 | 
  | 
     calo1->GetEntry(calibno); | 
| 583 | 
  | 
     if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); | 
| 584 | 
  | 
     // | 
| 585 | 
  | 
     // retrieve calibration table | 
| 586 | 
  | 
     // | 
| 587 | 
  | 
     if ( ce1->pstwerr[s] && ce1->pperror[s] == 0 && ce1->unpackError == 0 ){ | 
| 588 | 
  | 
       for ( Int_t d=0 ; d<11 ;d++  ){ | 
| 589 | 
  | 
         for ( Int_t j=0; j<96 ;j++){ | 
| 590 | 
  | 
           if ( s == 2 ){ | 
| 591 | 
  | 
             adcpcal[0][2*d+1][j] = adcp[0][2*d+1][j] - ce1->calpuls[3][d][j]; | 
| 592 | 
  | 
           }; | 
| 593 | 
  | 
           if ( s == 3 ){ | 
| 594 | 
  | 
             adcpcal[0][2*d][j] = adcp[0][2*d][j] - ce1->calpuls[1][d][j]; | 
| 595 | 
  | 
           }; | 
| 596 | 
  | 
           if ( s == 0 ){ | 
| 597 | 
  | 
             adcpcal[1][2*d][j] = adcp[1][2*d][j] - ce1->calpuls[0][d][j]; | 
| 598 | 
  | 
           }; | 
| 599 | 
  | 
           if ( s == 1 ){ | 
| 600 | 
  | 
             adcpcal[1][2*d+1][j] = adcp[1][2*d+1][j] - ce1->calpuls[2][d][j]; | 
| 601 | 
  | 
           }; | 
| 602 | 
  | 
         }; | 
| 603 | 
  | 
       }; | 
| 604 | 
  | 
     } else { | 
| 605 | 
  | 
       if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); | 
| 606 | 
  | 
       return(-111); | 
| 607 | 
  | 
     }; | 
| 608 | 
  | 
     // | 
| 609 | 
  | 
     File1->Close(); | 
| 610 | 
  | 
     // | 
| 611 | 
  | 
     delete glroot; | 
| 612 | 
  | 
     // | 
| 613 | 
  | 
   };// loop on the four sections | 
| 614 | 
  | 
   // | 
| 615 | 
  | 
   // | 
| 616 | 
  | 
   delete glp; | 
| 617 | 
  | 
   dbc->Close(); | 
| 618 | 
  | 
   delete dbc; | 
| 619 | 
  | 
   // | 
| 620 | 
  | 
   // Ok, now we can try to calculate the cross-talk correction for each pre-amplifier | 
| 621 | 
  | 
   // | 
| 622 | 
  | 
   for ( Int_t v=0; v<2; v++){ | 
| 623 | 
  | 
     if ( debug ) printf(" \n\n NEW VIEW \n"); | 
| 624 | 
  | 
     for ( Int_t p=0; p<22; p++){ | 
| 625 | 
  | 
       for ( Int_t npre=0; npre<6; npre++){ | 
| 626 | 
  | 
         ctprecor[v][p][npre] = 1000.; | 
| 627 | 
  | 
         ctneigcor[v][p][npre] = 1000.; | 
| 628 | 
  | 
         Int_t str0=npre*16; | 
| 629 | 
  | 
         Int_t str16= -1 + (1+npre)*16; | 
| 630 | 
  | 
         // | 
| 631 | 
  | 
         UInt_t neigc = 0; | 
| 632 | 
  | 
         UInt_t farc = 0; | 
| 633 | 
  | 
         UInt_t pulsc = 0; | 
| 634 | 
  | 
         Float_t sigpulsed = 0.; | 
| 635 | 
  | 
         Float_t neigbase = 0.; | 
| 636 | 
  | 
         Float_t farbase = 0.; | 
| 637 | 
  | 
         // | 
| 638 | 
  | 
         // Loop over the strip of the pre and sum all signal far away from pulsed strip, signal in the neighbour(s) strip(s) and save the pulsed signal | 
| 639 | 
  | 
         // moreover count the number of strips in each case | 
| 640 | 
  | 
         // | 
| 641 | 
  | 
         for (Int_t s=str0; s<=str16; s++){ | 
| 642 | 
  | 
           if ( adcpcal[v][p][s] > 10000.){ | 
| 643 | 
  | 
             sigpulsed = adcpcal[v][p][s]; | 
| 644 | 
  | 
             pulsc++; | 
| 645 | 
  | 
             if ( s > str0 ){ | 
| 646 | 
  | 
               neigbase += adcpcal[v][p][s-1]; | 
| 647 | 
  | 
               neigc++; | 
| 648 | 
  | 
               farbase -= adcpcal[v][p][s-1]; | 
| 649 | 
  | 
               farc--; | 
| 650 | 
             }; | 
             }; | 
| 651 | 
             // | 
             if ( s < str16 ){ | 
| 652 | 
             //  compression | 
               neigbase += adcpcal[v][p][s+1]; | 
| 653 | 
             // | 
               neigc++; | 
| 654 | 
             if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { | 
               farbase -= adcpcal[v][p][s+1]; | 
| 655 | 
                 dexyc[l][m][e] = 0.; | 
               farc--; | 
 | 
             } else { | 
  | 
 | 
                 dexyc[l][m][e] = dexy[l][m][e]; | 
  | 
| 656 | 
             }; | 
             }; | 
| 657 | 
  | 
           } else { | 
| 658 | 
  | 
             farc++; | 
| 659 | 
  | 
             farbase += adcpcal[v][p][s]; | 
| 660 | 
  | 
           }; | 
| 661 | 
         }; | 
         }; | 
| 662 | 
         if ( strip6s >= 9. ){        | 
         // | 
| 663 | 
             Double_t arro = base[l][m][pre]/strip6s; | 
         // Now calculate the corrections | 
| 664 | 
             Float_t deci = 1000.*((float)arro - float(int(arro)));                     | 
         // | 
| 665 | 
             if ( deci < 500. ) { | 
         Float_t avefarbase = 0.; | 
| 666 | 
                 arro = double(int(arro)); | 
         if ( farc ) avefarbase = farbase/(Float_t)farc; | 
| 667 | 
             } else { | 
         Float_t aveneigbase = 0.; | 
| 668 | 
                 arro = 1. + double(int(arro)); | 
         if ( neigc ) aveneigbase = neigbase/(Float_t)neigc; | 
| 669 | 
             }; | 
         // | 
| 670 | 
             base[l][m][pre] = arro; | 
         if ( pulsc == 1 && farc && neigc ){ | 
| 671 | 
  | 
           ctprecor[v][p][npre] = -avefarbase/(sigpulsed+fabs(avefarbase)); | 
| 672 | 
  | 
           ctneigcor[v][p][npre] = fabs(aveneigbase-avefarbase)/(sigpulsed+fabs(avefarbase));       | 
| 673 | 
  | 
           if ( debug ) printf(" Cross-talk correction View %i Plane %i Pre %i : pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); | 
| 674 | 
         } else { | 
         } else { | 
| 675 | 
             base[l][m][pre] = 31000.; | 
           // | 
| 676 | 
             for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ | 
           // did not find the pulsed strip or more than one pulsed strip found! | 
| 677 | 
                 dexyc[l][m][e] = dexy[l][m][e]; | 
           // | 
| 678 | 
  | 
           if ( debug ) printf(" Problems finding the cross-talk corrections: \n View %i Plane %i Pre %i number of pulsed strip %i \n Average faraway baseline %f number of strips %i Average neighbour baseline %f number of neighbour strips %i \n",v,p,npre,pulsc,avefarbase,farc,aveneigbase,neigc); | 
| 679 | 
  | 
         // | 
| 680 | 
  | 
         }; | 
| 681 | 
  | 
       }; | 
| 682 | 
  | 
       if ( debug ) printf(" \n ==================== \n"); | 
| 683 | 
  | 
     }; | 
| 684 | 
  | 
   }; | 
| 685 | 
  | 
   // | 
| 686 | 
  | 
   // Check the calculated corrections | 
| 687 | 
  | 
   // | 
| 688 | 
  | 
   Int_t opre=0; | 
| 689 | 
  | 
   Int_t ppre=0; | 
| 690 | 
  | 
   Bool_t found = false; | 
| 691 | 
  | 
   for ( Int_t v=0; v<2; v++){ | 
| 692 | 
  | 
     for ( Int_t p=0; p<22; p++){ | 
| 693 | 
  | 
       for ( Int_t npre=0; npre<6; npre++){ | 
| 694 | 
  | 
         if ( ctprecor[v][p][npre] == 1000. || ctneigcor[v][p][npre] == 1000. || obadpulsemask[v][p][npre] != 0 ){ | 
| 695 | 
  | 
           if ( debug ) printf(" Cross-talk correction CHANGED for view %i Plane %i Pre %i\n    BEFORE: pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); | 
| 696 | 
  | 
           if ( npre%2 ){ | 
| 697 | 
  | 
             opre = npre-1; | 
| 698 | 
  | 
           } else { | 
| 699 | 
  | 
             opre = npre+1;           | 
| 700 | 
  | 
           }; | 
| 701 | 
  | 
           if ( ctprecor[v][p][opre] == 1000. || ctneigcor[v][p][opre] == 1000. || obadpulsemask[v][p][opre] != 0 ){ | 
| 702 | 
  | 
             ppre=0; | 
| 703 | 
  | 
             found = false; | 
| 704 | 
  | 
             while ( ppre < 6 ){ | 
| 705 | 
  | 
               if ( ctprecor[v][p][ppre] != 1000. && ctneigcor[v][p][ppre] != 1000. && !obadpulsemask[v][p][ppre] ){ | 
| 706 | 
  | 
                 found = true; | 
| 707 | 
  | 
                 ctprecor[v][p][npre] = ctprecor[v][p][ppre]; | 
| 708 | 
  | 
                 ctneigcor[v][p][npre] = ctneigcor[v][p][ppre]; | 
| 709 | 
  | 
                 break; | 
| 710 | 
  | 
               }; | 
| 711 | 
  | 
               ppre++; | 
| 712 | 
  | 
             }; | 
| 713 | 
  | 
             if ( !found ){ | 
| 714 | 
  | 
               if ( verbose ) printf(" WARNING: cannot find a good cross-talk correction for view %i plane %i pre %i \n Setting to default values 0.002 0.002\n",v,p,npre); | 
| 715 | 
  | 
               ctprecor[v][p][npre] = 0.002; | 
| 716 | 
  | 
               ctneigcor[v][p][npre] = 0.002; | 
| 717 | 
             }; | 
             }; | 
| 718 | 
  | 
           } else { | 
| 719 | 
  | 
             ctprecor[v][p][npre] = ctprecor[v][p][opre]; | 
| 720 | 
  | 
             ctneigcor[v][p][npre] = ctneigcor[v][p][opre]; | 
| 721 | 
  | 
           }; | 
| 722 | 
  | 
           if ( debug ) printf("    AFTER: pre-correction: %f neighbour strips correction %f \n",ctprecor[v][p][npre],ctneigcor[v][p][npre]); | 
| 723 | 
         }; | 
         }; | 
| 724 | 
  | 
       }; | 
| 725 | 
  | 
     }; | 
| 726 | 
  | 
   }; | 
| 727 | 
  | 
   // | 
| 728 | 
  | 
   return(0); | 
| 729 | 
  | 
 } | 
| 730 | 
  | 
  | 
| 731 | 
  | 
 void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre){ | 
| 732 | 
  | 
   Int_t n = 0; | 
| 733 | 
  | 
   Float_t q = 0; | 
| 734 | 
  | 
   this->FindBaseCompress(l,m,pre,n,q); | 
| 735 | 
  | 
 } | 
| 736 | 
  | 
  | 
| 737 | 
  | 
 void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ | 
| 738 | 
  | 
   for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ | 
| 739 | 
  | 
     dexy[l][m][e] = dexyc[l][m][e]; | 
| 740 | 
  | 
   };   | 
| 741 | 
  | 
   this->FindBaseRaw(l,m,pre,nst,qp); | 
| 742 | 
  | 
 } | 
| 743 | 
  | 
  | 
| 744 | 
  | 
 void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ | 
| 745 | 
  | 
   Int_t n = 0; | 
| 746 | 
  | 
   Float_t q = 0; | 
| 747 | 
  | 
   this->FindBaseRaw(l,m,pre,n,q); | 
| 748 | 
  | 
 } | 
| 749 | 
  | 
  | 
| 750 | 
  | 
 void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ | 
| 751 | 
  | 
   // | 
| 752 | 
  | 
   Float_t minstrip = 100000.; | 
| 753 | 
  | 
   Float_t rms = 0.; | 
| 754 | 
  | 
   base[l][m][pre] = 0.; | 
| 755 | 
  | 
   qp = 0.; | 
| 756 | 
  | 
   // | 
| 757 | 
  | 
   for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ | 
| 758 | 
  | 
     if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 &&  dexy[l][m][e]-calped[l][m][e] < minstrip &&  dexy[l][m][e] > 0.) { | 
| 759 | 
  | 
       minstrip = dexy[l][m][e]-calped[l][m][e]; | 
| 760 | 
  | 
       rms = calthr[l][m][pre]; | 
| 761 | 
  | 
     }; | 
| 762 | 
  | 
     qp += (dexy[l][m][e]-calped[l][m][e]-sbase[l][m][e]); | 
| 763 | 
  | 
   }; | 
| 764 | 
  | 
   // | 
| 765 | 
  | 
   if ( debug && l==1 ){ | 
| 766 | 
  | 
     printf("\n BASELINE CALCULATION for view %i pl %i pre %i: \n => minstrip %f rms %f \n => qp = %f \n",l,m,pre,minstrip,rms,qp); | 
| 767 | 
  | 
   }; | 
| 768 | 
  | 
   if ( minstrip != 100000. ) { | 
| 769 | 
  | 
     Float_t strip6s = 0.; | 
| 770 | 
  | 
     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ | 
| 771 | 
  | 
       if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { | 
| 772 | 
  | 
         strip6s += 1.; | 
| 773 | 
  | 
         base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); | 
| 774 | 
  | 
       }; | 
| 775 | 
  | 
       // | 
| 776 | 
  | 
       //  compression | 
| 777 | 
  | 
       // | 
| 778 | 
  | 
       if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { | 
| 779 | 
  | 
         dexyc[l][m][e] = 0.; | 
| 780 | 
  | 
       } else { | 
| 781 | 
  | 
         dexyc[l][m][e] = dexy[l][m][e]; | 
| 782 | 
  | 
       }; | 
| 783 | 
  | 
     }; | 
| 784 | 
  | 
     // | 
| 785 | 
  | 
     nst = (Int_t)strip6s; | 
| 786 | 
  | 
     // | 
| 787 | 
  | 
     if ( debug && l==1 ){ | 
| 788 | 
  | 
       printf(" strip6s %f \n",strip6s); | 
| 789 | 
  | 
     }; | 
| 790 | 
  | 
     //  if ( strip6s >= 9. ){        | 
| 791 | 
  | 
     if ( strip6s >= 2. ){            | 
| 792 | 
  | 
       Double_t arro = base[l][m][pre]/strip6s; | 
| 793 | 
  | 
       Float_t deci = 1000.*((float)arro - float(int(arro)));                   | 
| 794 | 
  | 
       if ( deci < 500. ) { | 
| 795 | 
  | 
         arro = double(int(arro)); | 
| 796 | 
  | 
       } else { | 
| 797 | 
  | 
         arro = 1. + double(int(arro)); | 
| 798 | 
  | 
       }; | 
| 799 | 
  | 
       base[l][m][pre] = arro; | 
| 800 | 
  | 
       // | 
| 801 | 
  | 
       // if too few strips were used to determine the baseline check if it is comparable with the previous event, if not mark it as bad | 
| 802 | 
  | 
       // | 
| 803 | 
  | 
       if ( debug && l==1 ) printf(" Calculated baseline: base %f sbase*1.02 %f \n",base[l][m][pre],1.02*sbase[l][m][pre]); | 
| 804 | 
  | 
       // | 
| 805 | 
  | 
       if ( strip6s < 4 && base[l][m][pre] > 1.02*sbase[l][m][pre] && sbase[l][m][pre] > 0. ){ | 
| 806 | 
  | 
         if ( debug ) printf(" Suspicious calculated baseline: base %f sbase*1.02 %f strip6s %i \n",base[l][m][pre],1.02*sbase[l][m][pre],(Int_t)strip6s); | 
| 807 | 
  | 
         base[l][m][pre] = 31000.;        | 
| 808 | 
  | 
       }; | 
| 809 | 
     } else { | 
     } else { | 
| 810 | 
         base[l][m][pre] = 31000.; | 
       base[l][m][pre] = 31000.; | 
| 811 | 
  | 
       for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ | 
| 812 | 
  | 
         dexyc[l][m][e] = dexy[l][m][e]; | 
| 813 | 
  | 
       }; | 
| 814 | 
     }; | 
     }; | 
| 815 | 
  | 
   } else { | 
| 816 | 
  | 
     base[l][m][pre] = 31000.; | 
| 817 | 
  | 
   }; | 
| 818 | 
 } | 
 } | 
| 819 | 
  | 
  | 
| 820 | 
 Int_t CaloLevel0::Calibrate(Int_t ei){ | 
 Int_t CaloLevel0::Calibrate(Int_t ei){ | 
| 825 | 
   // | 
   // | 
| 826 | 
   // if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. | 
   // if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. | 
| 827 | 
   // | 
   // | 
| 828 | 
  | 
   clevel2->nsatstrip = 0.; | 
| 829 | 
   Int_t val = 0; | 
   Int_t val = 0; | 
| 830 | 
   Int_t del = 1100; | 
   Int_t del = 1100; | 
| 831 | 
  | 
   for (Int_t sec = 0; sec < 4; sec++){ | 
| 832 | 
  | 
     for (Int_t dsec = 0; dsec < 7; dsec++){ | 
| 833 | 
  | 
       val = (Int_t)de->calselftrig[sec][dsec]; | 
| 834 | 
  | 
       del = delay(val); | 
| 835 | 
  | 
       clevel2->selfdelay[sec][dsec] = del; | 
| 836 | 
  | 
     }; | 
| 837 | 
  | 
   }; | 
| 838 | 
  | 
   val = 0; | 
| 839 | 
  | 
   del = 1100; | 
| 840 | 
   if ( clevel2->trigty != 2. ){ | 
   if ( clevel2->trigty != 2. ){ | 
| 841 | 
     Bool_t ck = false; | 
     Bool_t ck = false; | 
| 842 | 
     for (Int_t sec = 0; sec < 4; sec++){ | 
     for (Int_t sec = 0; sec < 4; sec++){ | 
| 872 | 
   Float_t ener; | 
   Float_t ener; | 
| 873 | 
   Int_t doneb = 0; | 
   Int_t doneb = 0; | 
| 874 | 
   Int_t donec = 0; | 
   Int_t donec = 0; | 
| 875 | 
   Int_t ck = 0; | 
   Int_t ck[6] = {0,0,0,0,0,0}; | 
| 876 | 
   Int_t ipre = 0; | 
   Int_t ipre = 0; | 
| 877 | 
   Int_t ip[3] = {0}; | 
   //  Int_t ip[3] = {0}; | 
| 878 | 
  | 
   Int_t ip[3] = {0,0,0}; | 
| 879 | 
   Float_t base0, base1, base2; | 
   Float_t base0, base1, base2; | 
| 880 | 
   base0 = 0.; | 
   base0 = 0.; | 
| 881 | 
   base1 = 0.; | 
   base1 = 0.; | 
| 899 | 
   for (Int_t l = 0; l < 2; l++){ | 
   for (Int_t l = 0; l < 2; l++){ | 
| 900 | 
     for (Int_t m = 0; m < 22; m++){ | 
     for (Int_t m = 0; m < 22; m++){ | 
| 901 | 
       // | 
       // | 
| 902 | 
       // determine the section number | 
       // determine the section number    | 
| 903 | 
       // | 
       // | 
| 904 | 
       se = 5; | 
       se = 5; | 
| 905 | 
       if (l == 0 && m%2 == 0) se = 3; | 
       if (l == 0 && m%2 == 0) se = 3;  | 
| 906 | 
       if (l == 0 && m%2 != 0) se = 2; | 
       if (l == 0 && m%2 != 0) se = 2; | 
| 907 | 
       if (l == 1 && m%2 == 0) se = 1; | 
       if (l == 1 && m%2 != 0) se = 1; | 
| 908 | 
       if (l == 1 && m%2 != 0) se = 0;            | 
       if (l == 1 && m%2 == 0) se = 0;            | 
| 909 | 
       // | 
       // | 
| 910 | 
       // determine what kind of event we are going to analyze | 
       // determine what kind of event we are going to analyze | 
| 911 | 
       // | 
       // | 
| 951 | 
         // | 
         // | 
| 952 | 
         pre = -1; | 
         pre = -1; | 
| 953 | 
         cbase0 = 0.; | 
         cbase0 = 0.; | 
| 954 | 
  | 
         Int_t nstt[2]; | 
| 955 | 
  | 
         Float_t rqp[2]; | 
| 956 | 
         for (Int_t i = 0; i < 3; i++){ | 
         for (Int_t i = 0; i < 3; i++){ | 
| 957 | 
  | 
           nstt[0] = 0; | 
| 958 | 
  | 
           nstt[1] = 0; | 
| 959 | 
  | 
           rqp[0] = 0.; | 
| 960 | 
  | 
           rqp[1] = 0.; | 
| 961 | 
           for (Int_t j = 0; j < 2; j++){ | 
           for (Int_t j = 0; j < 2; j++){ | 
| 962 | 
             pre = j + i*2; | 
             pre = j + i*2; | 
| 963 | 
             //  | 
             //  | 
| 964 | 
             // baseline check and calculation | 
             // baseline check and calculation | 
| 965 | 
             // | 
             // | 
| 966 | 
             if ( !isRAW ) { | 
             if ( !isRAW ){ | 
| 967 | 
               base[l][m][pre] = de->base[l][m][pre] ;    | 
               // | 
| 968 | 
  | 
               // if it is a compress event with fully transmitted pre try to calculate the baseline | 
| 969 | 
  | 
               // | 
| 970 | 
  | 
               if ( de->base[l][m][pre] != 0. && de->base[l][m][pre]<31000. ) { | 
| 971 | 
  | 
                 base[l][m][pre] = de->base[l][m][pre] ;    | 
| 972 | 
  | 
               } else { | 
| 973 | 
  | 
                 FindBaseCompress(l,m,pre,nstt[j],rqp[j]); | 
| 974 | 
  | 
               }; | 
| 975 | 
               cbase0 += base[l][m][pre]; | 
               cbase0 += base[l][m][pre]; | 
| 976 | 
             } else { | 
             } else { | 
| 977 | 
               // | 
               // | 
| 978 | 
               // if it is a raw event and we haven't checked  | 
               // if it is a raw event calculate the baseline.  | 
 | 
               // yet, calculate the baseline.  | 
  | 
| 979 | 
               // | 
               // | 
| 980 | 
               FindBaseRaw(l,m,pre); | 
               FindBaseRaw(l,m,pre,nstt[j],rqp[j]); | 
| 981 | 
               cbase0 += base[l][m][pre]; | 
               cbase0 += base[l][m][pre]; | 
| 982 | 
             }; | 
             }; | 
| 983 | 
           }; | 
           }; | 
| 984 | 
  | 
           // | 
| 985 | 
  | 
           // if we are able to calculate the baseline with more than 3 strips on one pre and not in the other one choose the pre with more calculated strips | 
| 986 | 
  | 
           // | 
| 987 | 
  | 
           if ( nstt[0] < 4 && nstt[1] >= 4 ) base[l][m][pre-1] = 31000.; | 
| 988 | 
  | 
           if ( nstt[0] >= 4 && nstt[1] < 4 ) base[l][m][pre] = 31000.; | 
| 989 | 
  | 
 //        // | 
| 990 | 
  | 
 //        // if we are NOT able to calculate the baseline with more than 3 strips on both pres take the baseline (if any) of the one which has less energy | 
| 991 | 
  | 
 //        // | 
| 992 | 
  | 
 //        if ( nstt[0] < 4 && nstt[1] < 4 ){ | 
| 993 | 
  | 
 //          if ( rqp[0] >= rqp[1] ) base[l][m][pre-1] = 31000.; | 
| 994 | 
  | 
 //          if ( rqp[0] < rqp[1] ) base[l][m][pre] = 31000.; | 
| 995 | 
  | 
 //        }; | 
| 996 | 
         }; | 
         }; | 
| 997 | 
         // | 
         // | 
| 998 | 
         // run over strips | 
         // run over strips | 
| 1003 | 
           ip[i] = 0; | 
           ip[i] = 0; | 
| 1004 | 
           for (Int_t n = i*32 ; n < (i+1)*32 ; n++){                 | 
           for (Int_t n = i*32 ; n < (i+1)*32 ; n++){                 | 
| 1005 | 
             if (n%16 == 0) { | 
             if (n%16 == 0) { | 
 | 
               ck = 0; | 
  | 
| 1006 | 
               done = 0; | 
               done = 0; | 
| 1007 | 
               doneb = 0; | 
               doneb = 0; | 
| 1008 | 
               donec = 0; | 
               donec = 0; | 
| 1009 | 
               pre++; | 
               pre++; | 
| 1010 | 
  | 
               ck[pre] = 0; | 
| 1011 | 
               qpre[pre] = 0.; | 
               qpre[pre] = 0.; | 
| 1012 | 
             }; | 
             }; | 
| 1013 | 
             //  | 
             //  | 
| 1017 | 
             // | 
             // | 
| 1018 | 
             if ( !done ){ | 
             if ( !done ){ | 
| 1019 | 
               if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ | 
               if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ | 
| 1020 | 
                 ck = 1; | 
                 ck[pre] = 1; | 
| 1021 | 
                 if (pre%2 == 0) { | 
                 if (pre%2 == 0) { | 
| 1022 | 
                   ip[i] = pre + 1; | 
                   ip[i] = pre + 1; | 
| 1023 | 
                 } else {  | 
                 } else {  | 
| 1024 | 
                   ip[i] = pre - 1; | 
                   ip[i] = pre - 1; | 
| 1025 | 
                 }; | 
                 }; | 
| 1026 | 
                 if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0.) ){ | 
                 if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ | 
| 1027 | 
                   // | 
                   // | 
| 1028 | 
                   ck = 2; | 
                   ck[pre] = 2; | 
| 1029 | 
                   if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { | 
                   if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { | 
| 1030 | 
                     ck = 3; | 
                     ck[pre] = 3; | 
| 1031 | 
                   }; | 
                   }; | 
| 1032 | 
                 }; | 
                 }; | 
| 1033 | 
                 done = 1; | 
                 done = 1; | 
| 1037 | 
             // CALIBRATION ALGORITHM | 
             // CALIBRATION ALGORITHM | 
| 1038 | 
             //  | 
             //  | 
| 1039 | 
             if ( !doneb ){ | 
             if ( !doneb ){ | 
| 1040 | 
               switch (ck) { | 
               if ( debug ) printf(" ck[pre] is %i \n",ck[pre]); | 
| 1041 | 
  | 
               switch (ck[pre]) { | 
| 1042 | 
               case 0:  | 
               case 0:  | 
| 1043 | 
                 base0 = base[l][m][pre]; | 
                 base0 = base[l][m][pre]; | 
| 1044 | 
                 base2 = calbase[l][m][pre]; | 
                 base2 = calbase[l][m][pre]; | 
| 1045 | 
  | 
                 if ( debug ) printf(" base0 = base l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,base[l][m][pre],calbase[l][m][pre]); | 
| 1046 | 
                 break; | 
                 break; | 
| 1047 | 
               case 1:  | 
               case 1:  | 
| 1048 | 
                 base0 = base[l][m][ip[i]]; | 
                 base0 = base[l][m][ip[i]]; | 
| 1049 | 
                 base2 = calbase[l][m][ip[i]]; | 
                 base2 = calbase[l][m][ip[i]]; | 
| 1050 | 
  | 
                 if ( debug ) printf(" base0 = base l%i m%i ip(i)%i = %f base2 = calbase l m ip(i) = %f \n",l,m,ip[i],base[l][m][ip[i]],calbase[l][m][ip[i]]); | 
| 1051 | 
                 break; | 
                 break; | 
| 1052 | 
               case 2:  | 
               case 2:  | 
| 1053 | 
                 base0 = sbase[l][m][pre]; | 
                 base0 = sbase[l][m][pre]; | 
| 1054 | 
                 base2 = calbase[l][m][pre]; | 
                 base2 = calbase[l][m][pre];      | 
| 1055 | 
  | 
                 if ( debug ) printf(" base0 = sbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,sbase[l][m][pre],calbase[l][m][pre]); | 
| 1056 | 
                 break; | 
                 break; | 
| 1057 | 
               case 3:  | 
               case 3:  | 
| 1058 | 
                 base0 = calbase[l][m][pre]; | 
                 base0 = calbase[l][m][pre]; | 
| 1059 | 
                 base2 = calbase[l][m][pre]; | 
                 base2 = calbase[l][m][pre]; | 
| 1060 | 
  | 
                 if ( debug ) printf(" base0 = calbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,calbase[l][m][pre],calbase[l][m][pre]); | 
| 1061 | 
                 break; | 
                 break; | 
| 1062 | 
               }; | 
               }; | 
| 1063 | 
               base1 = calbase[l][m][pre]; | 
               base1 = calbase[l][m][pre]; | 
| 1067 | 
             ener0 += ener; | 
             ener0 += ener; | 
| 1068 | 
             clevel1->estrip[n][m][l] = 0.; | 
             clevel1->estrip[n][m][l] = 0.; | 
| 1069 | 
             if ( base0>0 && base0 < 30000. ){ | 
             if ( base0>0 && base0 < 30000. ){ | 
| 1070 | 
               if ( !donec && (base0 - base1 + base2) != 0. ){ | 
               //              if ( !donec && (base0 - base1 + base2) != 0. ){ | 
| 1071 | 
                 sbase[l][m][pre] = base0 - base1 + base2; | 
               //                sbase[l][m][pre] = base0 - base1 + base2; | 
| 1072 | 
  | 
               if ( !donec && (base0 + base1 - base2) != 0. ){ | 
| 1073 | 
  | 
                 sbase[l][m][pre] = base0 + base1 - base2; | 
| 1074 | 
                 donec = 1; | 
                 donec = 1; | 
| 1075 | 
               }; | 
               }; | 
| 1076 | 
               if ( ener > 0. ){ | 
               if ( ener > 0. ){ | 
| 1079 | 
                 // OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course) | 
                 // OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course) | 
| 1080 | 
                 // | 
                 // | 
| 1081 | 
                 qpre[pre] += clevel1->estrip[n][m][l]; | 
                 qpre[pre] += clevel1->estrip[n][m][l]; | 
| 1082 | 
  | 
                 // | 
| 1083 | 
  | 
                 // | 
| 1084 | 
               }; | 
               }; | 
| 1085 | 
             }; | 
             }; | 
| 1086 | 
           }; | 
           }; | 
| 1087 | 
           if ( crosst ){ | 
           if ( crosst ){ | 
| 1088 | 
             if (ck == 1){ | 
             if (ck[pre] == 1 || ck[pre-1] == 1){ | 
| 1089 | 
               if (ip[i]%2 == 0) { | 
               if (ck[pre] == 1){ | 
| 1090 | 
                 ipre = ip[i] + 1; | 
                 ipre = pre; | 
| 1091 | 
  | 
                 ip[i] = pre - 1; | 
| 1092 | 
               } else { | 
               } else { | 
| 1093 | 
                 ipre = ip[i] - 1; | 
                 ipre = pre - 1; | 
| 1094 | 
  | 
                 ip[i] = pre; | 
| 1095 | 
               }; | 
               }; | 
| 1096 | 
  | 
               //              if (ip[i]%2 == 0) { | 
| 1097 | 
  | 
               //                ipre = ip[i] + 1; | 
| 1098 | 
  | 
               //              } else { | 
| 1099 | 
  | 
               //                ipre = ip[i] - 1; | 
| 1100 | 
  | 
               //              }; | 
| 1101 | 
               for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ | 
               for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ | 
| 1102 | 
                 clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * 0.00478; | 
                 if ( !ctground ){ | 
| 1103 | 
  | 
                   clevel1->estrip[j][m][l] += qpre[ipre] * ctprecor[l][m][ipre] - qpre[ip[i]] * ctprecor[l][m][ip[i]]; | 
| 1104 | 
  | 
                 } else { | 
| 1105 | 
  | 
                   clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * 0.00478; | 
| 1106 | 
  | 
                 }; | 
| 1107 | 
               }; | 
               }; | 
| 1108 | 
             }; | 
             }; | 
| 1109 | 
             if (ck == 2){ | 
             if (ck[pre] == 2 && ck[pre-1] == 2){ | 
| 1110 | 
               for (Int_t j = i*32 ; j < (i+1)*32 ; j++){ | 
               for (Int_t j = i*32 ; j < (i+1)*32 ; j++){ | 
| 1111 | 
                 ipre = j/16 + 1; | 
                 //              ipre = j/16 + 1; | 
| 1112 | 
                 clevel1->estrip[j][m][l] +=  qpre[ipre] * 0.00478; | 
                 ipre = j/16 ; | 
| 1113 | 
  | 
                 if ( !ctground ){ | 
| 1114 | 
  | 
                   clevel1->estrip[j][m][l] +=  qpre[ipre] * ctprecor[l][m][ipre]; | 
| 1115 | 
  | 
                 } else { | 
| 1116 | 
  | 
                   clevel1->estrip[j][m][l] +=  qpre[ipre] * 0.00478; | 
| 1117 | 
  | 
                 }; | 
| 1118 | 
               }; | 
               }; | 
| 1119 | 
             }; | 
             }; | 
| 1120 | 
           }; | 
           }; | 
| 1129 | 
         Int_t j4 = -4; | 
         Int_t j4 = -4; | 
| 1130 | 
         Int_t jjj = -3; | 
         Int_t jjj = -3; | 
| 1131 | 
         Int_t jj = -2; | 
         Int_t jj = -2; | 
| 1132 | 
         for (Int_t j = 0 ; j < 100 ; j++){ | 
         Int_t jjpre = -1; | 
| 1133 | 
  | 
         Int_t jjjpre = -1; | 
| 1134 | 
  | 
         for (Int_t j = 0 ; j < 100 ; j++){         | 
| 1135 | 
           jj++; | 
           jj++; | 
| 1136 | 
           jjj++; | 
           jjj++; | 
| 1137 | 
           j4++; | 
           j4++; | 
| 1138 | 
           if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; | 
           if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; | 
| 1139 | 
           if ( crosst ){ | 
           if ( crosst ){ | 
| 1140 | 
             if ( jj >= 0 && jj < 96 ){ | 
             if ( jj >= 0 && jj < 96 ){ | 
| 1141 | 
               if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; | 
               if ( !ctground ){ | 
| 1142 | 
               if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581;                         | 
                 if ( jj%16 == 0 ) jjpre++;             | 
| 1143 | 
  | 
                 if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; | 
| 1144 | 
  | 
                 if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre];                        | 
| 1145 | 
  | 
               } else { | 
| 1146 | 
  | 
                 if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; | 
| 1147 | 
  | 
                 if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581;                       | 
| 1148 | 
  | 
               }; | 
| 1149 | 
             }; | 
             }; | 
| 1150 | 
             if ( jjj >= 0 && jjj < 96 ){ | 
             if ( jjj >= 0 && jjj < 96 ){ | 
| 1151 | 
               if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] +=  -ene[jjj] * 0.01581; | 
               if ( !ctground ){ | 
| 1152 | 
               if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] +=  -ene[jjj] * 0.01581; | 
                 if ( jjj%16 == 0 ) jjjpre++;           | 
| 1153 | 
  | 
                 if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] +=  -ene[jjj] * ctneigcor[l][m][jjjpre]; | 
| 1154 | 
  | 
                 if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] +=  -ene[jjj] * ctneigcor[l][m][jjjpre]; | 
| 1155 | 
  | 
               } else { | 
| 1156 | 
  | 
                 if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] +=  -ene[jjj] * 0.01581; | 
| 1157 | 
  | 
                 if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] +=  -ene[jjj] * 0.01581; | 
| 1158 | 
  | 
               }; | 
| 1159 | 
             }; | 
             }; | 
| 1160 | 
           }; | 
           }; | 
| 1161 | 
           if ( j4 >= 0 && j4 < 96 ){ | 
           if ( j4 >= 0 && j4 < 96 ){ | 
| 1165 | 
             if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ | 
             if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ | 
| 1166 | 
               clevel1->estrip[j4][m][l] = 0.; | 
               clevel1->estrip[j4][m][l] = 0.; | 
| 1167 | 
             }; | 
             }; | 
| 1168 | 
             // | 
             // | 
| 1169 | 
             // code and save the energy for each strip in svstrip | 
             // code and save the energy for each strip in svstrip | 
| 1170 | 
             // | 
             // | 
| 1171 | 
             if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ | 
             if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ | 
| 1172 | 
               // | 
               // | 
| 1173 | 
  | 
               Float_t savel1 = clevel1->estrip[j4][m][l]; | 
| 1174 | 
  | 
               if ( dexyc[l][m][j4] == 32767. ){ | 
| 1175 | 
  | 
                 savel1 += 5000.;  | 
| 1176 | 
  | 
                 clevel2->nsatstrip += 1.; | 
| 1177 | 
  | 
               }; | 
| 1178 | 
  | 
               // | 
| 1179 | 
               tim = 100000.; | 
               tim = 100000.; | 
| 1180 | 
               plo = m; | 
               plo = m; | 
| 1181 | 
               fbi = 0; | 
               fbi = 0; | 
| 1182 | 
               if ( clevel1->estrip[j4][m][l] > 0.99995 ){ | 
               if ( savel1 > 0.99995 ){ | 
| 1183 | 
                 tim = 10000.; | 
                 tim = 10000.; | 
| 1184 | 
                 plo = m; | 
                 plo = m; | 
| 1185 | 
                 fbi = 1; | 
                 fbi = 1; | 
| 1186 | 
               }; | 
               }; | 
| 1187 | 
               if ( clevel1->estrip[j4][m][l] > 9.9995 ){ | 
               if ( savel1 > 9.9995 ){ | 
| 1188 | 
                 tim = 1000.; | 
                 tim = 1000.; | 
| 1189 | 
                 plo = 22 + m; | 
                 plo = 22 + m; | 
| 1190 | 
                 fbi = 1; | 
                 fbi = 1; | 
| 1191 | 
               }; | 
               }; | 
| 1192 | 
               if ( clevel1->estrip[j4][m][l] > 99.995 ){ | 
               if ( savel1 > 99.995 ){ | 
| 1193 | 
                 tim = 100.; | 
                 tim = 100.; | 
| 1194 | 
                 plo = 22 + m; | 
                 plo = 22 + m; | 
| 1195 | 
                 fbi = 0; | 
                 fbi = 0; | 
| 1196 | 
               }; | 
               }; | 
| 1197 | 
               if ( clevel1->estrip[j4][m][l] > 999.95 ){ | 
               if ( savel1 > 999.95 ){ | 
| 1198 | 
                 tim = 10.; | 
                 tim = 10.; | 
| 1199 | 
                 plo = 44 + m; | 
                 plo = 44 + m; | 
| 1200 | 
                 fbi = 0; | 
                 fbi = 0; | 
| 1201 | 
               }; | 
               }; | 
| 1202 | 
               if ( clevel1->estrip[j4][m][l] > 9999.5 ){ | 
               if ( savel1 > 9999.5 ){ | 
| 1203 | 
                 tim = 1.; | 
                 tim = 1.; | 
| 1204 | 
                 plo = 66 + m; | 
                 plo = 66 + m; | 
| 1205 | 
                 fbi = 0; | 
                 fbi = 0; | 
| 1206 | 
               }; | 
               }; | 
| 1207 | 
               // | 
               // | 
| 1208 | 
               cle = (Int_t)lroundf(tim*clevel1->estrip[j4][m][l]);  | 
               cle = (Int_t)lroundf(tim*savel1);  | 
| 1209 | 
               // | 
               // | 
| 1210 | 
               if ( l == 0 ){ | 
               if ( l == 0 ){ | 
| 1211 | 
                 // | 
                 // | 
| 1285 | 
     memcpy(t_ca->tibar,clevel2->cibar,sizeof(clevel2->cibar)); | 
     memcpy(t_ca->tibar,clevel2->cibar,sizeof(clevel2->cibar)); | 
| 1286 | 
     memcpy(t_ca->tbar,clevel2->cbar,sizeof(clevel2->cbar)); | 
     memcpy(t_ca->tbar,clevel2->cbar,sizeof(clevel2->cbar)); | 
| 1287 | 
     memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); | 
     memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); | 
| 1288 | 
  | 
     memcpy(ca->selfdelay,clevel2->selfdelay,sizeof(clevel2->selfdelay)); | 
| 1289 | 
     ca->varcfit[2] = clevel2->varcfit[0]; | 
     ca->varcfit[2] = clevel2->varcfit[0]; | 
| 1290 | 
     ca->varcfit[3] = clevel2->varcfit[1]; | 
     ca->varcfit[3] = clevel2->varcfit[1]; | 
| 1291 | 
     ca->npcfit[2] = clevel2->npcfit[0]; | 
     ca->npcfit[2] = clevel2->npcfit[0]; | 
| 1326 | 
   memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); | 
   memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); | 
| 1327 | 
   memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); | 
   memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); | 
| 1328 | 
   ca->nstrip = (Int_t)clevel2->nstrip; | 
   ca->nstrip = (Int_t)clevel2->nstrip; | 
| 1329 | 
  | 
   ca->nsatstrip = (Int_t)clevel2->nsatstrip; | 
| 1330 | 
   ca->qtot = clevel2->qtot; | 
   ca->qtot = clevel2->qtot; | 
| 1331 | 
   //  ca->impx = clevel2->impx; | 
   //  ca->impx = clevel2->impx; | 
| 1332 | 
   //  ca->impy = clevel2->impy; | 
   //  ca->impy = clevel2->impy; | 
| 1339 | 
   ca->selen = clevel2->selen; | 
   ca->selen = clevel2->selen; | 
| 1340 | 
   memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); | 
   memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); | 
| 1341 | 
   memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); | 
   memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); | 
| 1342 | 
  | 
   memcpy(ca->selfdelay,clevel2->selfdelay,sizeof(clevel2->selfdelay)); | 
| 1343 | 
   ca->varcfit[0] = clevel2->varcfit[0]; | 
   ca->varcfit[0] = clevel2->varcfit[0]; | 
| 1344 | 
   ca->varcfit[1] = clevel2->varcfit[1]; | 
   ca->varcfit[1] = clevel2->varcfit[1]; | 
| 1345 | 
   ca->npcfit[0] = clevel2->npcfit[0]; | 
   ca->npcfit[0] = clevel2->npcfit[0]; | 
| 1371 | 
   memset(dexyc, 0, 2*22*96*sizeof(Float_t)); | 
   memset(dexyc, 0, 2*22*96*sizeof(Float_t)); | 
| 1372 | 
   memset(base, 0, 2*22*6*sizeof(Float_t)); | 
   memset(base, 0, 2*22*6*sizeof(Float_t)); | 
| 1373 | 
   memset(sbase, 0, 2*22*6*sizeof(Float_t)); | 
   memset(sbase, 0, 2*22*6*sizeof(Float_t)); | 
| 1374 | 
  | 
   memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); | 
| 1375 | 
  | 
   memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); | 
| 1376 | 
   // | 
   // | 
| 1377 | 
 } | 
 } | 
| 1378 | 
  | 
  | 
| 1417 | 
   clevel2->wartrig = 0.; | 
   clevel2->wartrig = 0.; | 
| 1418 | 
   clevel2->good = 0; | 
   clevel2->good = 0; | 
| 1419 | 
   clevel2->nstrip = 0.; | 
   clevel2->nstrip = 0.; | 
| 1420 | 
  | 
   clevel2->nsatstrip = 0.; | 
| 1421 | 
   clevel2->qtot = 0.; | 
   clevel2->qtot = 0.; | 
| 1422 | 
   //  clevel2->impx = 0.; | 
   //  clevel2->impx = 0.; | 
| 1423 | 
   //  clevel2->impy = 0.; | 
   //  clevel2->impy = 0.; | 
| 1433 | 
   memset(clevel2->varcfit, 0, 4*sizeof(Float_t)); | 
   memset(clevel2->varcfit, 0, 4*sizeof(Float_t)); | 
| 1434 | 
   memset(clevel2->npcfit, 0, 4*sizeof(Int_t)); | 
   memset(clevel2->npcfit, 0, 4*sizeof(Int_t)); | 
| 1435 | 
   memset(clevel2->planemax, 0, 2*sizeof(Int_t)); | 
   memset(clevel2->planemax, 0, 2*sizeof(Int_t)); | 
| 1436 | 
  | 
   memset(clevel2->selfdelay, 0, 4*7*sizeof(Int_t)); | 
| 1437 | 
   memset(clevel2->fmode, 0, 2*sizeof(Int_t)); | 
   memset(clevel2->fmode, 0, 2*sizeof(Int_t)); | 
| 1438 | 
   memset(clevel2->cibar, 0, 2*22*sizeof(Int_t)); | 
   memset(clevel2->cibar, 0, 2*22*sizeof(Int_t)); | 
| 1439 | 
   memset(clevel2->cbar, 0, 2*22*sizeof(Float_t)); | 
   memset(clevel2->cbar, 0, 2*22*sizeof(Float_t)); | 
| 1490 | 
   return; | 
   return; | 
| 1491 | 
 } | 
 } | 
| 1492 | 
  | 
  | 
| 1493 | 
 Int_t CaloLevel0::Update(TSQLServer *dbc, UInt_t atime, Int_t s){ | 
 Int_t CaloLevel0::Update(GL_TABLES *glt, UInt_t atime, Int_t s){ | 
| 1494 | 
   // | 
   // | 
| 1495 | 
  | 
   const TString host = glt->CGetHost(); | 
| 1496 | 
  | 
   const TString user = glt->CGetUser(); | 
| 1497 | 
  | 
   const TString psw = glt->CGetPsw(); | 
| 1498 | 
  | 
   TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); | 
| 1499 | 
  | 
   if ( !dbc->IsConnected() ) throw -116; | 
| 1500 | 
  | 
   stringstream myquery; | 
| 1501 | 
  | 
   myquery.str(""); | 
| 1502 | 
  | 
   myquery << "SET time_zone='+0:00'"; | 
| 1503 | 
  | 
   dbc->Query(myquery.str().c_str()); | 
| 1504 | 
   Int_t sgnl = 0; | 
   Int_t sgnl = 0; | 
| 1505 | 
   // | 
   // | 
| 1506 | 
   GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); | 
   GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |