Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TTools.C

Go to the documentation of this file.
00001 
00002 // Class TTools
00003 //
00004 // Author     : F. Cassol Brunner
00005 // Created    : 12/9/2002
00006 // Last update: $Date: 2005/06/28 21:19:21 $
00007 //          by: $Author: sauvan $
00008 // Comment: class for general tool routines
00010 
00011 #include "Marana/TTools.h"
00012 
00013 #include "H1Mods/H1PartSelTrackArrayPtr.h"
00014 #include "H1Mods/H1PartSelTrack.h"
00015 
00016 
00017 // Import class
00018 ClassImp(TTools);
00019 
00020 TTools::TTools()
00021 {
00022   GenPl = 27.598;
00023   GenPp = 919.971;  
00024   RunNumber=0;
00025   EventNumber=0;
00026   NewRun=kTRUE;
00027   MCFlag=0; 
00028   num=0;
00029   numMax=10000000;
00030 }
00031 
00032 TTools::TTools(Int_t Run, Int_t Event,Int_t MCFlag)
00033 {
00034   GenPl = 27.598;
00035   GenPp = 919.971;  
00036   RunNumber=Run;
00037   EventNumber=Event;
00038   NewRun=kTRUE;
00039   MCFlag=MCFlag; 
00040   num=0;
00041   numMax=10000000;
00042 }
00043 
00044 Bool_t TTools::Next()
00045 {
00046   if(num==numMax)return false;
00047   if(!gH1Tree->Next())return false;
00048 
00049   num++;
00050 //...re-set run and event number
00051  if(RunNumber!=gH1Tree->GetRunNumber()) NewRun=kTRUE;
00052  else NewRun=kFALSE;
00053 
00054  RunNumber=gH1Tree->GetRunNumber();
00055  EventNumber=gH1Tree->GetEventNumber();
00056 
00057  static H1ShortPtr RunType("RunType");
00058  MCFlag=*RunType;
00059 
00060 
00061  return true;
00062 }
00063 
00064 
00065 
00066 
00067 void TTools::SetEventList(Char_t *ListFileName)
00068 {
00070 //     set an eventlist to the tree
00072   cout << "Set  eventlist from " << ListFileName <<endl;
00073   TFile *file=NULL;
00074   file = TFile::Open(ListFileName);
00075   TList *keys = file->GetListOfKeys();
00076   TIter next (keys);
00077   Bool_t haslist=kFALSE;
00078   
00079   while ( TKey *thekey = (TKey*)next() ) {
00080       if ( strcmp(thekey->GetClassName(),"H1EventList") == 0 ) {
00081           H1EventList *thelist = (H1EventList*)file->Get( thekey->GetName() );
00082           gH1Tree->SetEventList(thelist);
00083           haslist=kTRUE;
00084           break;
00085       }
00086   }
00087 
00088   if (! haslist ) {
00089       cerr << "Found no H1EventList on file! "<<endl;
00090   }
00091 
00092 }
00093 
00094 
00095 
00096 Double_t TTools::GetMod(Double_t x, Double_t y)
00097 {
00098 // Return modulo 
00099   return((x - ((Int_t) (x/y)) * y));
00100 }
00101 
00102 Double_t TTools::GetRealPhi(Double_t PhiIn)
00103 {
00104 // Get phi range of input angle PhiIn
00105 
00106   Double_t phi = PhiIn;
00107   if(phi <= TMath::Pi()){
00108     if(phi > -TMath::Pi()){ }//      return phi;  } 
00109     else if(phi > -3*TMath::Pi()){ phi += 2*TMath::Pi(); } 
00110     else { phi = -GetMod(TMath::Pi()-phi, 2*TMath::Pi()) + TMath::Pi(); }
00111   }
00112   else if(phi <= 3*TMath::Pi()) { phi -= 2*TMath::Pi(); }
00113   else { phi = GetMod(TMath::Pi()+phi, 2*TMath::Pi()) - TMath::Pi(); }
00114 
00115   if(fabs(phi) <= 1e-15) phi = 0.;
00116   return phi;
00117 }
00118 
00119 Double_t TTools::GetMergedPhi(Double_t PhiPart1,Double_t PtPart1,Double_t PhiPart2,Double_t PtPart2)
00120 {
00121 // Get phi angle between two particles
00122 
00123   Double_t WeightOfFirst = 0;
00124   Double_t PhiAngle = 0;  
00125   
00126   if (PtPart1>0 && PtPart2) {
00127     WeightOfFirst = GetRealPhi(PhiPart1-PhiPart2) * PtPart1/(PtPart1+PtPart2);
00128     PhiAngle = GetRealPhi(WeightOfFirst+PhiPart2);
00129   }
00130   return(PhiAngle);
00131 }
00132 
00133 
00134 
00135 Double_t TTools::GetProjPhi(Double_t Phi)
00136 {
00138 //     ProjPhi :
00139 //      phi projection into -22.5-22.5 degrees to see cracks
00140 //      Phi in rad.
00142 Double_t PhiProjection=-99999.;
00143 Double_t pi=3.14159265359;
00144  
00145 PhiProjection=Phi;
00146  
00147         if(fabs(Phi*MYR2D)>22.5&&fabs(Phi*MYR2D)<=67.5) {
00148                 if(Phi*MYR2D>0.) {
00149                         PhiProjection=Phi-pi/4.;
00150                 } else {
00151                         PhiProjection=Phi+pi/4.;
00152                 }
00153         }
00154         if(fabs(Phi*MYR2D)>67.5&&fabs(Phi*MYR2D)<=112.5) {
00155                 if(Phi*MYR2D>0.) {
00156                         PhiProjection=Phi-pi/2.;
00157                 } else {
00158                         PhiProjection=Phi+pi/2.;
00159                 }
00160         }
00161         if(fabs(Phi*MYR2D)>112.5&&fabs(Phi*MYR2D)<=157.5) {
00162                         if(Phi*MYR2D>0.) {
00163                         PhiProjection=Phi-3.*pi/4.;
00164                 } else {
00165                         PhiProjection=Phi+3.*pi/4.;
00166                 }
00167         }
00168         if(fabs(Phi*MYR2D)>157.5&&fabs(Phi*MYR2D)<180.) {
00169 //                 if(Phi*MYR2D>0.) {
00170 //                         PhiProjection=Phi-9.*pi/8.;
00171 //                 } else {
00172 //                         PhiProjection=Phi+9.*pi/8.;
00173 //                 }
00174                  if(Phi*MYR2D>0.) {
00175                         PhiProjection=Phi-pi;
00176                 } else {
00177                         PhiProjection=Phi+pi;
00178                 }
00179        }
00180         if(fabs(Phi*MYR2D)==180.) {
00181                 if(Phi*MYR2D>0.) {
00182                         PhiProjection=Phi-pi;
00183                 } else {
00184                         PhiProjection=Phi+pi;
00185                 }
00186         }
00187  
00188 return PhiProjection;
00189 }    
00190 
00191 
00192 Int_t TTools::GetMuonGrade(H1PartMuon *Muon)
00193 {
00195 //    decode and returns muon grade (best (==min.0 muon grade)
00197  Int_t iMinGr = 1000;
00198  for(Int_t iGr=1;iGr<=6;iGr++){
00199    if (Muon->TestGrade(iGr) == kTRUE)
00200      if (iGr < iMinGr) iMinGr = iGr;
00201  }
00202  return iMinGr;
00203 }
00204 
00205 Bool_t TTools::IsData2005(void)
00206 {
00207 // Check Data set using runnumber
00208  
00209   Bool_t Selection = kFALSE;
00210  
00211   if (MCFlag == 0 && RunNumber > 399101)
00212     Selection = kTRUE;
00213 
00214   // Return selection flag
00215   return(Selection);
00216 }
00217 
00218 Bool_t TTools::IsData2004e(void)
00219 {
00220 // Check Data set using runnumber
00221  
00222   Bool_t Selection = kFALSE;
00223  
00224 //  if (MCFlag == 0 && RunNumber >= 335423)
00225   if (MCFlag == 0 && RunNumber <= 398818 && RunNumber >= 396674)
00226     Selection = kTRUE;
00227 
00228   // Return selection flag
00229   return(Selection);
00230 }
00231 
00232 Bool_t TTools::IsData0304R1(void)
00233 {
00234 // Check Data set using runnumber
00235  
00236   Bool_t Selection = kFALSE;
00237 //   if (MCFlag == 0 && RunNumber <= 376562 && RunNumber >= 356241)
00238   if (MCFlag == 0 && RunNumber <= 376562 && RunNumber >= 357072) //--- duk ranges
00239     Selection = kTRUE;
00240 
00241   return(Selection);
00242 }
00243 Bool_t TTools::IsData0304L1(void)
00244 {
00245 // Check Data set using runnumber
00246  
00247   Bool_t Selection = kFALSE;
00248   if (MCFlag == 0 && RunNumber < 377533 && RunNumber > 376562)
00249     Selection = kTRUE;
00250 
00251   return(Selection);
00252 }
00253 Bool_t TTools::IsData0304L2(void)
00254 {
00255 // Check Data set using runnumber
00256  
00257   Bool_t Selection = kFALSE;
00258 //  if (MCFlag == 0 && RunNumber < 387537 && RunNumber >= 377533)
00259   if (MCFlag == 0 && RunNumber <= 386696 && RunNumber >= 377533)//--- duk ranges
00260     Selection = kTRUE;
00261 
00262   return(Selection);
00263 }
00264 Bool_t TTools::IsData0304R2(void)
00265 {
00266 // Check Data set using runnumber
00267  
00268   Bool_t Selection = kFALSE;
00269 //   if (MCFlag == 0 && RunNumber <= 392213 && RunNumber >= 387537)
00270   if (MCFlag == 0 && RunNumber <= 392213 && RunNumber >= 387942)//--- duk ranges
00271     Selection = kTRUE;
00272 
00273   return(Selection);
00274 }
00275 
00276 Bool_t TTools::IsData2004p(void)
00277 {
00278 // Check Data set using runnumber
00279  
00280   Bool_t Selection = kFALSE;
00281  
00282 //  if (MCFlag == 0 && RunNumber >= 335423)
00283   if (MCFlag == 0 && RunNumber <= 392213 && RunNumber >= 367257)
00284     Selection = kTRUE;
00285 
00286   // Return selection flag
00287   return(Selection);
00288 }
00289 Bool_t TTools::IsData2003(void)
00290 {
00291 // Check Data set using runnumber
00292  
00293   Bool_t Selection = kFALSE;
00294  
00295 //  if (MCFlag == 0 && RunNumber >= 335423)
00296   if (MCFlag == 0 && RunNumber > 335000)
00297     Selection = kTRUE;
00298 
00299   // Return selection flag
00300   return(Selection);
00301 }
00302 Bool_t TTools::IsDataHeraII(void)
00303 {
00304 // Check Data set using runnumber
00305  
00306   Bool_t Selection = kFALSE;
00307  
00308 //  if (MCFlag == 0 && RunNumber >= 335423)
00309   if (MCFlag == 0 && RunNumber > 335000)
00310     Selection = kTRUE;
00311 
00312   // Return selection flag
00313   return(Selection);
00314 }
00315 Bool_t TTools::IsData2002(void)
00316 {
00317 // Check Data set using runnumber
00318  
00319   Bool_t Selection = kFALSE;
00320  
00321 //  if (MCFlag == 0 && RunNumber > 303906 && RunNumber <= 334964)
00322   if (MCFlag == 0 && RunNumber > 300000 && RunNumber < 335000)
00323     Selection = kTRUE;
00324 
00325   // Return selection flag
00326   return(Selection);
00327 }
00328 
00329 Bool_t TTools::IsData2000(void)
00330 {
00331 // Check Data set using runnumber
00332  
00333   Bool_t Selection = kFALSE;
00334  
00335   if (MCFlag == 0 && RunNumber > 262144 && RunNumber < 279215)
00336     Selection = kTRUE;
00337 
00338   // Return selection flag
00339   return(Selection);
00340 }
00341 Bool_t TTools::IsData1999p(void)
00342 {
00343 // Check Data set using runnumber
00344  
00345   Bool_t Selection = kFALSE;
00346  
00347   if (MCFlag == 0 && RunNumber >= 244968 && RunNumber <= 261338)
00348     Selection = kTRUE;
00349 
00350   // Return selection flag
00351   return(Selection);
00352 }
00353 Bool_t TTools::IsData1999e(void)
00354 {
00355 // Check Data set using runnumber
00356  
00357   Bool_t Selection = kFALSE;
00358  
00359   if (MCFlag == 0 && RunNumber >= 231721 && RunNumber <= 241649)
00360     Selection = kTRUE;
00361 
00362   // Return selection flag
00363   return(Selection);
00364 }
00365 Bool_t TTools::IsData1998(void)
00366 {
00367 // Check Data set using runnumber
00368  
00369   Bool_t Selection = kFALSE;
00370  
00371   if (MCFlag == 0 && RunNumber >= 218217 && RunNumber <= 230164)
00372     Selection = kTRUE;
00373 
00374   // Return selection flag
00375   return(Selection);
00376 }
00377 Bool_t TTools::IsData1997(void)
00378 {
00379 // Check Data set using runnumber
00380  
00381   Bool_t Selection = kFALSE;
00382  
00383   if (MCFlag == 0 && RunNumber > 176421 && RunNumber <= 201519)
00384     Selection = kTRUE;
00385 
00386   // Return selection flag
00387   return(Selection);
00388 }
00389 Bool_t TTools::IsData1996(void)
00390 {
00391 // Check Data set using runnumber
00392  
00393   Bool_t Selection = kFALSE;
00394  
00395   if (MCFlag == 0 && RunNumber >= 146416 && RunNumber <= 171156)
00396     Selection = kTRUE;
00397 
00398   // Return selection flag
00399   return(Selection);
00400 }
00401 Bool_t TTools::IsData1995(void)
00402 {
00403 // Check Data set using runnumber
00404  
00405   Bool_t Selection = kFALSE;
00406  
00407   if (MCFlag == 0 && RunNumber >= 110946 && RunNumber <= 131045)
00408     Selection = kTRUE;
00409 
00410   // Return selection flag
00411   return(Selection);
00412 }
00413 Bool_t TTools::IsData1994(void)
00414 {
00415 // Check Data set using runnumber
00416  
00417   Bool_t Selection = kFALSE;
00418  
00419   if (MCFlag == 0 && RunNumber > 0 && RunNumber < 110946)
00420     Selection = kTRUE;
00421 
00422   // Return selection flag
00423   return(Selection);
00424 }
00425 
00426 
00427 Bool_t TTools::IsData94(const UInt_t& irun)
00428 {
00429    if(irun>=76137 && irun<=90419)return kTRUE;
00430    return kFALSE;
00431 }
00432 Bool_t TTools::IsData95S(const UInt_t& irun)
00433 {
00434   if(irun>=110946 && irun<=131045)
00435     {
00436       if(irun>=130066 && irun<=130385)return kTRUE;
00437       else if (irun>=129473&& irun<=129933)return kTRUE;
00438       else return kFALSE;
00439     }
00440   return kFALSE;
00441 }
00442 Bool_t TTools::IsData95P(const UInt_t& irun)
00443 {
00444   if(irun>=110946 && irun<=131045)
00445     {
00446       if(irun>=130066 && irun<=130385)return kFALSE;
00447       else if (irun>=129473&& irun<=129933)return kFALSE;
00448       else return kTRUE;
00449     }
00450   return kFALSE;
00451 }
00452 Bool_t TTools::IsData96P(const UInt_t& irun)
00453 {
00454   if(irun>=146416 && irun<=171156) return kTRUE;
00455   return kFALSE;
00456 }
00457 Bool_t TTools::IsData97P(const UInt_t& irun)
00458 {
00459   if(irun>=177920 && irun<=200407)return kTRUE;
00460   return kFALSE;
00461 }
00462 Bool_t TTools::IsData97S(const UInt_t& irun)
00463 {
00464   if(irun>=200445 && irun<=201519)return kTRUE;
00465   return kFALSE;
00466 }
00467 Bool_t TTools::IsData98E(const UInt_t& irun)
00468 {
00469   if(irun>=218217 && irun<=230164) return kTRUE;
00470   return kFALSE;
00471 }
00472 
00473 Bool_t TTools::IsData99S(const UInt_t& irun)
00474 {
00475   if(irun>=259487 && irun<=261338)return kTRUE;
00476   return kFALSE;
00477 }
00478 Bool_t TTools::IsData99E(const UInt_t& irun)
00479 {
00480   if(irun>=231721 && irun<=241649) return kTRUE;
00481   return kFALSE;
00482 }
00483 
00484 Bool_t TTools::IsData99P(const UInt_t& irun)
00485 {
00486   if(irun>=244968 && irun<=261338)
00487     {
00488       if(irun>=244968 && irun<=259461) return kTRUE;
00489       else  if(irun>=259487 && irun<=261338)return kFALSE;
00490       else {cerr<<"Warning in <RTools::IsData99P>: Irun "<<irun<<" unassignable (year 1999)."<<endl;return kFALSE;}
00491     }
00492   return kFALSE;
00493 }
00494 Bool_t TTools::IsData00S(const UInt_t& irun)
00495 {
00496   if(irun>=278691 && irun<=278978)return kTRUE;
00497   return kFALSE;
00498 }
00499 Bool_t TTools::IsData00P(const UInt_t& irun)
00500 {
00501   if(irun>=262204 && irun<=279215)
00502     {
00503       if(irun>=278691 && irun<=278978)return kFALSE;
00504       else return kTRUE;
00505     }
00506   return kFALSE;
00507 }
00508 
00509 
00510 
00511 
00512 
00513 
00514 
00515 
00516 Bool_t TTools::IsHV(void)
00517 {
00518 // Are HV bits on??
00519   if(MCFlag) return kTRUE;      //--- valid only if DATA
00520 
00521 //  if(IsData2005()||IsData2004e()) return IsHVCJCLoose();
00522 
00523    // High voltage bits
00524    static H1ShortPtr hv1("Mhv1");
00525    static H1ShortPtr hv2("Mhv2");
00526    static H1ShortPtr bbl3("Mbbl3");
00527 
00528    if(IsData2003()) {
00529      if ( (
00530          (hv1[0]||hv1[1]||hv2[0]||hv2[1]||hv2[2]||bbl3[0]>0) // CJC
00531          || (hv1[11]||bbl3[6]>0) // LAr
00532 //       || (hv1[18]||hv1[19]||hv1[20]||hv2[17]||hv2[18]||hv2[19]||bbl3[12]>0) // lumi
00533 //       || (hv1[20]||hv2[18]||bbl3[12]>0) // lumi
00534          || (hv1[20]||hv2[18]) // lumi
00535          || (hv1[14]||bbl3[9]>0) // ToF
00536          || bbl3[8]>0 // Spacal
00537          ))
00538          return(kFALSE);
00539       else 
00540          return(kTRUE); 
00541    }else{
00542      if ( (
00543          (hv1[0]||hv1[1]||hv2[0]||hv2[1]||hv2[2]||bbl3[0]>0) // CJC
00544          || (hv1[11]||bbl3[6]>0) // LAr
00545          || (hv1[18]||hv1[19]||hv1[20]||hv2[17]||hv2[18]||hv2[19]||bbl3[12]>0) // lumi
00546          || (hv1[14]||bbl3[9]>0) // ToF
00547          || bbl3[8]>0 // Spacal
00548          ))
00549          return(kFALSE);
00550       else 
00551          return(kTRUE); 
00552    }  
00553 
00554 } 
00555 
00556 Bool_t TTools::IsHVCJCLoose(void)
00557 {
00558 // Are HV bits on?? (with CJC1 or CJC2
00559 
00560   if(MCFlag) return kTRUE;      //--- valid only if DATA
00561 
00562 
00563    // High voltage bits
00564    static H1ShortPtr hv1("Mhv1");
00565    static H1ShortPtr hv2("Mhv2");
00566    static H1ShortPtr bbl3("Mbbl3");
00567 
00568    if(IsDataHeraII()) {
00569      if ( (
00570 //          ((hv1[0]||hv2[0]>0)||
00571 //          ((hv1[1]||hv2[1]||hv2[2]>0)&&bbl3[0]>0) // CJC1 or CJC2
00572          (hv1[1]||hv2[1]||hv2[2]>0) // CJC
00573          || (hv1[11]||bbl3[6]>0) // LAr
00574          || (hv1[20]||hv2[18]) // lumi
00575          || (hv1[14]||bbl3[9]>0) // ToF
00576          || bbl3[8]>0 // Spacal
00577          ))
00578          return(kFALSE);
00579       else 
00580          return(kTRUE); 
00581    }else{
00582      if ( (
00583          (hv1[0]||hv1[1]||hv2[0]||hv2[1]||hv2[2]||bbl3[0]>0) // CJC
00584          || (hv1[11]||bbl3[6]>0) // LAr
00585          || (hv1[18]||hv1[19]||hv1[20]||hv2[17]||hv2[18]||hv2[19]||bbl3[12]>0) // lumi
00586          || (hv1[14]||bbl3[9]>0) // ToF
00587          || bbl3[8]>0 // Spacal
00588          ))
00589          return(kFALSE);
00590       else 
00591          return(kTRUE); 
00592    }  
00593 
00594 } 
00595 
00596 
00597 Bool_t TTools::IsBdcOn()
00598 {
00599   // 0/1 : CIP and COP off/on
00600 // Are HV bits on??
00601   if(MCFlag) return kTRUE;      //--- valid only if DATA
00602 
00603 
00604    // High voltage bits
00605    static H1ShortPtr hv1("Mhv1");
00606    static H1ShortPtr hv2("Mhv2");
00607    static H1ShortPtr bbl3("Mbbl3");
00608 
00609   return hv1[21]||hv1[22]>0 ? 0 : 1;
00610 }
00611 
00612 Bool_t TTools::IsFmdOn()
00613 {
00614   // 0/1 : CIP and COP off/on
00615 // Are HV bits on??
00616   if(MCFlag) return kTRUE;      //--- valid only if DATA
00617 
00618 
00619    // High voltage bits
00620    static H1ShortPtr hv1("Mhv1");
00621    static H1ShortPtr hv2("Mhv2");
00622    static H1ShortPtr bbl3("Mbbl3");
00623 
00624   return hv1[31] || hv2[23]>0 ? 0 : 1;
00625 }
00626 
00627 Bool_t TTools::IsPlugOn()
00628 {
00629   // 0/1 : CIP and COP off/on
00630 // Are HV bits on??
00631   if(MCFlag) return kTRUE;      //--- valid only if DATA
00632 
00633 
00634    // High voltage bits
00635    static H1ShortPtr hv1("Mhv1");
00636    static H1ShortPtr hv2("Mhv2");
00637    static H1ShortPtr bbl3("Mbbl3");
00638 
00639   return hv1[12] || hv2[15] || bbl3[7]>0 ? 0 : 1;
00640 }
00641 
00642 
00643 
00644 
00645 Bool_t TTools::IsCipCopOn()
00646 {
00647   // 0/1 : CIP and COP off/on
00648 // Are HV bits on??
00649   if(MCFlag) return kTRUE;      //--- valid only if DATA
00650 
00651 
00652    // High voltage bits
00653    static H1ShortPtr hv1("Mhv1");
00654    static H1ShortPtr hv2("Mhv2");
00655    static H1ShortPtr bbl3("Mbbl3");
00656 
00657   return hv1[7]||hv1[8]||hv2[11]||hv2[12]||bbl3[14]>0 ? 0 : 1;
00658 }
00659 
00660 Bool_t TTools::IsCipOn()
00661 {
00662   // 0/1 : CIP  off/on
00663 // Are HV bits on??
00664   if(MCFlag) return kTRUE;      //--- valid only if DATA
00665 
00666 
00667    // High voltage bits
00668    static H1ShortPtr hv1("Mhv1");
00669    static H1ShortPtr hv2("Mhv2");
00670    static H1ShortPtr bbl3("Mbbl3");
00671 
00672   return  hv1[7]|| hv2[11]|| bbl3[14]>0 ? 0 : 1;
00673 }
00674 
00675 
00676 
00677 
00678 
00679 //------------------------------------------------------
00680 Bool_t TTools::IsCjcLooseOn()  
00681 { 
00682   // 0/1 : CJC1 and CJC2 off / either CJC1 or CJC2 on
00683    // High voltage bits
00684    static H1ShortPtr hv1("Mhv1");
00685    static H1ShortPtr hv2("Mhv2");
00686    static H1ShortPtr bbl3("Mbbl3");
00687 
00688   if ((hv1[0]||hv2[0]>0)||
00689       (hv1[1]||hv2[1]||hv2[2]>0)&&bbl3[0]>0) return 0;
00690   else return 1;
00691 }
00692 //------------------------------------------------------
00693 
00694 
00695 
00696   
00697 Bool_t TTools::IsZCrack(Float_t z)
00698 {
00699 // Is z Crack
00700 
00701   // selection is false at beg.
00702   Bool_t selection = kFALSE;
00703 
00704   // Define crack position in z
00705   const Int_t nCracks = 7;
00706 //  Float_t zCrack[nCracks] = {-211.14,-151.43,-64.63,23.17,110.12,198.43,289.145};
00707   Float_t zCrack[nCracks] = {-211.14,-151.43,-64.63,23.17,110.12};
00708   // Define Min approach in z
00709   const Float_t ZAppr = 2.0;
00710 
00711   // Check all phi-cracks
00712   for(Int_t iCrack=0;iCrack<nCracks;iCrack++){
00713     if (fabs(z-zCrack[iCrack]) < ZAppr){
00714       selection = kTRUE;
00715       break;
00716     }
00717   }
00718 
00719   // Return selection 
00720   return(selection);
00721 
00722 }
00723 
00724 Bool_t TTools::IsPhiCrack(Float_t Phi)
00725 {
00726 // Check if Phi is phi-crack +- 2deg
00727 
00728   // selection is false at beg.
00729   Bool_t selection = kFALSE;
00730 
00731   // Define crack position in phi
00732   const Int_t nCracks = 9;
00733   Float_t PhiCrack[nCracks]={-180.0,-135.0,-90.0,-45.0,0.0,45.0,90.0,135.0,180.0};
00734   
00735   // Define Min approach in phi
00736   const Float_t PhiAppr = 2.0;
00737 
00738   // Phi in degree
00739   Float_t PhiDeg = Phi*180/3.1415;
00740 
00741   // Check all phi-cracks
00742   for(Int_t iCrack=0;iCrack<nCracks;iCrack++){
00743     if (fabs(PhiDeg-PhiCrack[iCrack]) < PhiAppr){
00744       selection = kTRUE;
00745       break;
00746     }
00747   }
00748   // Return selection 
00749   return(selection);
00750 }
00751 
00752 
00753 Bool_t TTools::IsLArCrack(Float_t z,Float_t phi)
00754 {
00755   // init at false
00756   Bool_t selection=kFALSE;
00757 
00758   // exclude CB2-CB3 crack
00759   if(z<-180 || (z<=25 && z>=15) ) selection=kTRUE;
00760 
00761   // put Phi in 0-360 deg range 
00762   if(phi<0) phi+=2*TMath::Pi();
00763   phi*=MYR2D;
00764   Float_t phimod=GetMod(phi,45);
00765 
00766   // exlude cracks in barrrel part + 2 cracks in IF part
00767   if(   z <=290 && (phimod < 2 || phimod > 43)
00768         || z > 290 && ( phi<2 || (phi>178 && phi <180) || phi>358  )) selection=kTRUE;
00769 
00770 
00771   // Return selection 
00772   return(selection);
00773 }
00774 
00775 
00776 
00777 Bool_t TTools::IsLArCrack(Float_t z,Float_t zBBE,Float_t phi)
00778 {
00779 // Definition of LAr cracks taken into account BBE structure
00780 // (Benjamin)
00781 
00782   // init at false
00783   Bool_t selection=kFALSE;
00784 
00785   // exclude CB2-CB3 crack (190)
00786   if(z<-190 || (z<=25 && z>=15) ){
00787     //    cout << " z= " << z;
00788         selection=kTRUE;
00789   } 
00790   if (z<=-150){
00791     if (zBBE <= -190) selection=kTRUE;
00792   }
00793 
00794  // if(z<=25 && z>=15) selection=kTRUE;
00795 
00796   // put Phi in 0-360 deg range 
00797   if(phi<0) phi+=2*TMath::Pi();
00798   phi*=MYR2D;
00799   Float_t phimod=GetMod(phi,45);
00800 
00801   // exlude cracks in barrrel part + 2 cracks in IF part
00802   if(   z <=292 && (phimod < 2 || phimod > 43)
00803         || z > 292 && ( phi<2 || (phi>178 && phi <180) || phi>358  )) selection=kTRUE;
00804 
00805 
00806   // Return selection 
00807   return(selection);
00808 }
00809 
00810 
00811 Bool_t TTools::IsHVCaloCJC(void)
00812 {
00813 // Are HV bits on??
00814   if(MCFlag) return kTRUE;      //--- valid only if DATA
00815 
00816    // High voltage bits
00817    static H1ShortPtr hv1("Mhv1");
00818    static H1ShortPtr hv2("Mhv2");
00819    static H1ShortPtr bbl3("Mbbl3");
00820 
00821 
00822    if ( (
00823          (hv1[0]||hv1[1]||hv2[0]||hv2[1]||hv2[2]||bbl3[0]>0) // CJC
00824          || (hv1[11]||bbl3[6]>0) // LAr
00825          || bbl3[8]>0 // Spacal
00826          ))
00827      return(kFALSE);
00828    else 
00829      return(kTRUE);   
00830 } 
00831 
00832 
00833 
00834 
00835 Bool_t TTools::IsCosmic(void)
00836 {
00837 // Check if QBGFMAR fired or not
00838  
00839   Bool_t selection = kFALSE;
00840 
00841   static H1IntPtr Ibg ("Ibg");     //standard array of background finders
00842 //  static H1IntPtr Ibgam ("Ibgam"); // Add array of background finders
00843 
00844   // Check bits 0-8 of Ibgf
00845   for(Int_t iBit=0;iBit<9;iBit++)
00846     if (((*Ibg >> iBit) & 1) == 1){
00847           selection = kTRUE;
00848       break;
00849     }
00850 
00851   /*
00852   // Check bits 0-8 of Ibgfam
00853   for(Int_t iBit=0;iBit<7;iBit++)
00854     if ((*Ibgam & (1 << iBit)) == 1){
00855       selection = kTRUE;
00856       break;
00857     }
00858   */
00859 
00860   return(selection);
00861 
00862 }
00863 
00864 Bool_t TTools::IsIbgBit(Int_t iBit)
00865 {
00866 // Check if QBGFMAR fired or not
00867 // bits ranging from 0 to 9 !
00868  
00869   Bool_t selection = kFALSE;
00870   static H1IntPtr Ibg ("Ibg");     //standard array of background finders
00871 
00872     if (((*Ibg >> iBit) & 1) == 1) selection = kTRUE;
00873   return(selection);
00874 
00875 }
00876 
00877 
00878 Bool_t TTools::IsL4Trigg(Int_t iTrigg)
00879 {
00880 // Has trigger iTrigg fired (L4 verified)
00881   H1BytePtr STrigg("Il4vst");
00882 
00883   // Has trigger iTrigg really fired
00884   if (STrigg[iTrigg] == kTRUE)
00885     return(kTRUE);
00886   else
00887     return(kFALSE);
00888 }
00889 
00890 Bool_t TTools::IsL1Trigg(Int_t iTrigg)
00891 {
00892 // Has trigger iTrigg fired (L1 actual subtrigger)
00893   H1BytePtr L1Trigg("Il1ac");
00894 
00895   // Has trigger iTrigg really fired
00896   if (L1Trigg[iTrigg] == kTRUE)
00897     return(kTRUE);
00898   else
00899     return(kFALSE);
00900 }
00901 
00902 Bool_t TTools::IsL2TTTrigg(Int_t iTrigg)
00903 {
00904 // Has trigger iTrigg fired (L1 actual subtrigger)
00905   H1BytePtr L2TTTrigg("Il2tte");
00906 
00907   // Has trigger iTrigg really fired
00908   if (L2TTTrigg[iTrigg] == kTRUE)
00909     return(kTRUE);
00910   else
00911     return(kFALSE);
00912 }
00913 
00914 
00915 
00916 Bool_t TTools::Is2004CalibratedTimingOK(void)
00917 {
00918 // Check timing of event, adapted to calibrated LAr timing in 2.7.7
00919   
00920   if(MCFlag) return kTRUE;      //--- valid only if DATA
00921   Bool_t selection = kFALSE;
00922 
00923   // Get timing from HAT
00924   static H1FloatPtr t0_CJC("T0_CJC");
00925   static H1FloatPtr t0_LAr("T0_LAr");
00926 
00927   // define offsets for timing determination of LAr
00928   const Float_t OffsetLAr0304 = -0.0097;
00929 
00930   // define offsets for timing determination of CJC
00931    Float_t OffsetCJC0304 = 458.0;
00932   
00933   // define cuts
00934   Float_t CJCCutWidth=50.0; // 50 ticks == 0.1 BC
00935 //   Float_t LArCutWidth=0.54; // in BC
00936   Float_t LArCutWidth=0.7; // in BC
00937 
00938   if(RunNumber >=300000 && RunNumber <= 368000  ) {
00939         OffsetCJC0304 = 435.0;
00940         CJCCutWidth=75.0;
00941   }
00942   
00943   // Final timings values
00944   Float_t FinalLArTim=0.0; 
00945   Float_t FinalCJCTim=0.0;
00946 
00947   // Get present LAr /CJC timing
00948   FinalLArTim=*t0_LAr; 
00949   FinalCJCTim=*t0_CJC;
00950   FinalLArTim = FinalLArTim - OffsetLAr0304;
00951   FinalCJCTim = FinalCJCTim - OffsetCJC0304;
00952 
00953 
00954   Int_t NbBCLAr=-99;
00955   Int_t NbBCCJC=+99;
00956 
00957   if(fabs(FinalCJCTim)<CJCCutWidth) NbBCCJC=0;
00958   if(fabs(FinalCJCTim-500.)<CJCCutWidth) NbBCCJC=1;
00959   if(fabs(FinalCJCTim-1000.)<CJCCutWidth) NbBCCJC=2;
00960   if(fabs(FinalCJCTim+500.)<CJCCutWidth) NbBCCJC=-1;
00961   if(fabs(FinalCJCTim+1000.)<CJCCutWidth) NbBCCJC=-2;
00962   
00963   if(fabs(FinalLArTim)<LArCutWidth) NbBCLAr=0;
00964   if(fabs(FinalLArTim-1.)<LArCutWidth&&NbBCLAr!=0) NbBCLAr=1;
00965   if(fabs(FinalLArTim-2.)<LArCutWidth&&NbBCLAr!=1) NbBCLAr=2;
00966   if(fabs(FinalLArTim+1.)<LArCutWidth&&NbBCLAr!=0) NbBCLAr=-1;
00967   if(fabs(FinalLArTim+2.)<LArCutWidth&&NbBCLAr!=1) NbBCLAr=-2;
00968 //   if(fabs(FinalLArTim-1.)<LArCutWidth&&NbBCCJC==1) NbBCLAr=1;
00969 //   if(fabs(FinalLArTim-2.)<LArCutWidth&&NbBCCJC==2) NbBCLAr=2;
00970 //   if(fabs(FinalLArTim+1.)<LArCutWidth&&NbBCCJC==-1) NbBCLAr=-1;
00971 //   if(fabs(FinalLArTim+2.)<LArCutWidth&&NbBCCJC==-2) NbBCLAr=-2;
00972 
00973 
00974   Bool_t NbTrkOk=kFALSE;
00975   static H1ShortPtr ncent("NumCentralTracks");
00976   if((*ncent)>0.){
00977        NbTrkOk=kTRUE;
00978 //        NbBCCJC=0; //---- if no tracks, CJC timing not used for cut !
00979   }// end of theta max cut
00980 
00981   if((NbBCLAr==NbBCCJC)||(NbTrkOk==kFALSE&&NbBCLAr==0)) selection=kTRUE;
00982 
00983   
00984   return(selection);   
00985 }
00986 
00987  
00988  
00989 Bool_t TTools::IsTimingOk(void)
00990 {
00991 // Check timing of event
00992   if(MCFlag) return kTRUE;      //--- valid only if DATA
00993   
00994   if(IsDataHeraII()) return Is2004CalibratedTimingOK();
00995   
00996   Bool_t selection = kTRUE;
00997 
00998   // define offsets for timing determination of CJC (1.guess)
00999   const Float_t Offset100000 = 500;
01000   const Float_t Offset209999 = 400;
01001   const Float_t Offset221499 = 437;
01002   const Float_t Offset244999 = 462;
01003   const Float_t Offset245000 = 444;
01004   const Float_t OffsetCJC03 = 450;
01005 
01006   // define offsets for timing determination of LAr
01007   const Float_t OffsetLAr94 = -0.0;
01008   const Float_t OffsetLAr95 = -0.055;
01009   const Float_t OffsetLAr96 = -0.022;
01010   const Float_t OffsetLAr97 = -0.012;
01011   const Float_t OffsetLAr9899e = 0.045;
01012   const Float_t OffsetLAr9900 = 0.077;
01013   const Float_t OffsetLAr03 = 0.125;
01014 
01015   // define offsets for timing determination of CJC
01016   const Float_t OffsetCJC94 = 0.0;
01017   const Float_t OffsetCJC95 = -1.48;
01018   const Float_t OffsetCJC96 = 10.61;
01019   const Float_t OffsetCJC97 = 1.61;
01020   const Float_t OffsetCJC9899e = 15.23;
01021   const Float_t OffsetCJC9900 = 13.41;
01022 
01023   // Final timings values
01024   Float_t FinalLArTim=0.0; 
01025   Float_t FinalCJCTim=0.0;
01026 
01027 
01028   // Get timing from HAT
01029   static H1FloatPtr t0_CJC("T0_CJC");
01030   static H1FloatPtr t0_LAr("T0_LAr");
01031 
01032   // Timing de CJC
01033   Float_t TCJC = 1000000;
01034   if (RunNumber < 100000){
01035     //    TCJC = *t0_CJC - Offset100000;
01036     TCJC = Offset100000;
01037   }
01038   else if (RunNumber >= 100000 && RunNumber <= 209999)
01039     TCJC = *t0_CJC - Offset209999;
01040   else if (RunNumber > 209999 && RunNumber <= 221499)
01041     TCJC = *t0_CJC - Offset221499;
01042   else if (RunNumber > 221499 && RunNumber <= 244999)
01043     TCJC = *t0_CJC - Offset244999;
01044   else if (RunNumber >= 245000 && RunNumber < 300000)
01045     TCJC = *t0_CJC - Offset245000;
01046   else if (IsData2003()){
01047     TCJC = *t0_CJC - OffsetCJC03;
01048   } else{
01049     printf("No timing available\n");
01050     return(kTRUE);
01051   }  
01052 
01053   // Get present LAr /CJC timing
01054   FinalLArTim=*t0_LAr; 
01055   FinalCJCTim=TCJC;
01056 
01057   // Correction finale 
01058   if (RunNumber >= 76345 && RunNumber <= 90417){
01059     //    FinalLArTim = FinalLArTim - OffsetLAr94;
01060     //    FinalCJCTim = FinalCJCTim - OffsetCJC94;
01061     FinalLArTim = OffsetLAr94;
01062     FinalCJCTim = OffsetCJC94;
01063   }
01064   else if (RunNumber >= 101902 && RunNumber <= 131045){
01065     FinalLArTim = FinalLArTim - OffsetLAr95;
01066     FinalCJCTim = FinalCJCTim - OffsetCJC95;
01067   }
01068   else if (RunNumber >= 144000 && RunNumber <= 171573){
01069     FinalLArTim = FinalLArTim - OffsetLAr96;
01070     FinalCJCTim = FinalCJCTim - OffsetCJC96;
01071   }
01072   else if (RunNumber >= 177920 && RunNumber <= 200407){
01073     FinalLArTim = FinalLArTim - OffsetLAr97;
01074     FinalCJCTim = FinalCJCTim - OffsetCJC97;
01075   }
01076   else if (RunNumber >= 218217 && RunNumber <= 241649){
01077     FinalLArTim = FinalLArTim - OffsetLAr9899e;
01078     FinalCJCTim = FinalCJCTim - OffsetCJC9899e;
01079   }
01080   else if (RunNumber >= 244968 && RunNumber <= 279215){
01081     FinalLArTim = FinalLArTim - OffsetLAr9900;
01082     FinalCJCTim = FinalCJCTim - OffsetCJC9900;
01083   }
01084   else if (IsData2003()){
01085     FinalLArTim = FinalLArTim - OffsetLAr03;
01086     FinalCJCTim = TCJC;
01087   }
01088   else {
01089     FinalLArTim = 0.0;
01090     FinalCJCTim = 0.0;
01091   }
01092 
01093 //   // Fill timing histos
01094 //   hEventtLAr->Fill(FinalLArTim);
01095 //   hEventtCJC->Fill(FinalCJCTim);
01096 //   hEventTTRTCAL->Fill(FinalLArTim,FinalCJCTim);
01097 
01098 
01099   // Check LAr timing
01100 
01101 //  printf("LAr Timing = %f\n",TMath::Abs(FinalLArTim));
01102   if (TMath::Abs(FinalLArTim) > 0.7){
01103      return(kFALSE);
01104   }else if(IsData2003()&&(TMath::Abs(FinalLArTim) > 0.8)){
01105     return(kFALSE);
01106   }
01107 
01108   // Check absolute T_CJC 500 ticks = 1 BC
01109   
01110 //  printf("CJC Timing = %f\n",TMath::Abs(FinalCJCTim));
01111   if (TMath::Abs(FinalCJCTim) > 60){
01112     return(kFALSE);
01113   }else if(IsData2003()&&(FinalCJCTim > 60 || FinalCJCTim < -100 )){
01114     return(kFALSE);
01115   }
01116 
01117   return(selection);   
01118 }
01119  
01120  
01121 
01122 // Bool_t TTools::IsTimingOk()
01123 // {
01124 // // Check timing of event
01125 //   if(MCFlag) return kTRUE;   //--- valid only if DATA
01126 //   
01127 //   Bool_t selection = kTRUE;
01128 // 
01129 //   // define offsets for timing determination
01130 //   const Float_t Offset100000 = 500;
01131 //   const Float_t Offset209999 = 400;
01132 //   const Float_t Offset221499 = 437;
01133 //   const Float_t Offset244999 = 462;
01134 //   const Float_t Offset245000 = 444;
01135 // 
01136 //   // Get timing from HAT
01137 //   H1FloatPtr t0_CJC("T0_CJC");
01138 //   H1FloatPtr t0_LAr("T0_LAr");
01139 // 
01140 //   // Timing de CJC
01141 //   Float_t TCJC = 1000000;
01142 //   if (RunNumber < 100000)
01143 //     TCJC = *t0_CJC - Offset100000;
01144 //   else if (RunNumber >= 100000 && RunNumber <= 209999)
01145 //     TCJC = *t0_CJC - Offset209999;
01146 //   else if (RunNumber > 209999 && RunNumber <= 221499)
01147 //     TCJC = *t0_CJC - Offset221499;
01148 //   else if (RunNumber > 221499 && RunNumber <= 244999)
01149 //     TCJC = *t0_CJC - Offset244999;
01150 //   else if (RunNumber >= 245000)
01151 //     TCJC = *t0_CJC - Offset245000;
01152 //   else{
01153 // //    printf("No timing available\n");
01154 //     return(kTRUE);
01155 //   }  
01156 // 
01157 //   // Fill timing histos
01158 //   const Float_t FinalDATAOffsetLAr = 0.077;
01159 //   const Float_t FinalDATAOffsetCJC = 13.41;
01160 //   Float_t FinalLArTim=*t0_LAr-FinalDATAOffsetLAr; 
01161 //   Float_t FinalCJCTim=TCJC-FinalDATAOffsetCJC; 
01162 // 
01163 // 
01164 // 
01165 //   // Check LAr timing
01166 //   if (TMath::Abs(FinalLArTim) > 0.7){
01167 // //    printf("LAr Timing = %f\n",FinalLArTim);
01168 //     return(kFALSE);
01169 //   }
01170 // 
01171 //   // Check absolute T_CJC 500 ticks = 1 BC
01172 //   if (TMath::Abs(FinalCJCTim) > 50){
01173 // //    printf("CJC Timing = %f\n",FinalCJCTim);
01174 //     return(kFALSE);
01175 //   }
01176 // 
01177 //   return(selection);   
01178 // }
01179 
01180  Bool_t TTools::IsCCCosmic(void)
01181 {
01182 // Is Special CC cosmic
01183 // Test 24 bits of QBGFMAR
01184 
01185   Bool_t selection = kFALSE;
01186 
01187   static H1IntPtr Ibg ("Ibg");     //standard array of background finders
01188   static H1IntPtr Ibgam ("Ibgam"); // Add array of background finders
01189   static H1IntPtr Ibgfm ("Ibgfm"); // Add array of background finders
01190 
01191   // Check bits 0-9 of Ibg
01192   for(Int_t iBit=0;iBit<10;iBit++)
01193     if (((*Ibg >> iBit) & 1) == 1){
01194           selection = kTRUE;
01195       break;
01196     }
01197 
01198   // Check bits 0-5 and 8,9 of Ibgfm
01199   for(Int_t iBit=0;iBit<25;iBit++){
01200     if (((*Ibgfm >> iBit) & 1) == 1){
01201          if(iBit !=6 ) {//--- too inefficient bits disabled
01202                 selection = kTRUE;
01203 //              printf("CC Bg finder: Ibgfm bit %d fired !\n",iBit);
01204                 break;
01205          }
01206     }
01207   }
01208 
01209   // Check bits 0-8 of Ibgfam
01210   for(Int_t iBit=0;iBit<9;iBit++)
01211     if (((*Ibgam >> iBit) & 1) == 1){
01212          if(iBit!=3 && iBit !=4 && iBit !=8 ) {
01213                 selection = kTRUE; //--- too inefficient bits disabled
01214 //              printf("UK CC Bg finder: Ibgfam bit %d fired !\n",iBit);
01215                 break;
01216         }
01217     }
01218 
01219   // return selection
01220   return(selection);
01221 }
01222 
01223 
01224 
01225 
01226 Bool_t TTools::IsNonEP03(void)
01227 {
01228 // Is NOISE (electronic LAr noisy runs for 2003 oct-dec)
01229 
01230   Bool_t selection = kFALSE;
01231     
01232   if (RunNumber == 360178) return(kTRUE);
01233   else if(RunNumber == 360180) return(kTRUE);
01234   else if(RunNumber == 360181) return(kTRUE);
01235   else if(RunNumber == 360191) return(kTRUE);
01236   else if(RunNumber == 360213) return(kTRUE);
01237   else if(RunNumber == 360223) return(kTRUE);
01238   else if(RunNumber == 360224) return(kTRUE);
01239   else if(RunNumber == 360227) return(kTRUE);
01240   else if(RunNumber == 360229) return(kTRUE);
01241   else if(RunNumber == 360236) return(kTRUE);
01242 //--- Runs with calo "OFF" ?? reported by Benji  
01243   else if(RunNumber >= 358730 && RunNumber <= 358735) return(kTRUE);
01244   else if(RunNumber == 367227) return(kTRUE);
01245   else if(RunNumber == 367523) return(kTRUE);
01246 //--- jnp scanning generic analysis... (13/12/03)
01247   else if(RunNumber == 359925 && EventNumber ==  15639) return(kTRUE);
01248   else if(RunNumber == 360296 && EventNumber ==  14958) return(kTRUE);
01249   else if(RunNumber == 360296&& EventNumber == 137296 ) return(kTRUE);
01250   else if(RunNumber == 360298 && EventNumber == 58016 ) return(kTRUE);
01251   else if(RunNumber == 360409 && EventNumber == 648 ) return(kTRUE);
01252   else if(RunNumber == 361096 && EventNumber == 12481 ) return(kTRUE);
01253   else if(RunNumber ==  361096&& EventNumber == 37679 ) return(kTRUE);
01254   else if(RunNumber == 361175 && EventNumber == 21831 ) return(kTRUE);
01255   else if(RunNumber == 362266 && EventNumber == 4434 ) return(kTRUE);
01256   else if(RunNumber == 362268 && EventNumber == 12951 ) return(kTRUE);
01257   else if(RunNumber == 362412 && EventNumber ==  8810) return(kTRUE);
01258   else if(RunNumber == 362526 && EventNumber == 13957 ) return(kTRUE);
01259   else if(RunNumber == 363060 && EventNumber == 29468 ) return(kTRUE);
01260   else if(RunNumber == 363076 && EventNumber == 4538 ) return(kTRUE);
01261   else if(RunNumber == 363290 && EventNumber == 82572 ) return(kTRUE);
01262   else if(RunNumber == 363313 && EventNumber ==  29343) return(kTRUE);
01263   else if(RunNumber == 363411 && EventNumber == 22679 ) return(kTRUE);
01264   else if(RunNumber == 363411 && EventNumber ==  38055) return(kTRUE);
01265   else if(RunNumber ==  363455&& EventNumber ==  30769) return(kTRUE);
01266   else if(RunNumber == 363475 && EventNumber == 26888 ) return(kTRUE);
01267   else if(RunNumber == 363475 && EventNumber == 53887 ) return(kTRUE);
01268   else if(RunNumber == 364484 && EventNumber == 31657 ) return(kTRUE);
01269   else if(RunNumber == 365153 && EventNumber == 2943 ) return(kTRUE);
01270   else if(RunNumber == 365153 && EventNumber ==  32023) return(kTRUE);
01271   else if(RunNumber == 365414 && EventNumber == 31028) return(kTRUE);
01272   else if(RunNumber == 365512 && EventNumber == 29897 ) return(kTRUE);
01273   else if(RunNumber == 365520 && EventNumber == 49896 ) return(kTRUE);
01274 //---- jjjnp scanning generic analysis ...(13/12/03)
01275   else if(RunNumber == 365164 && EventNumber == 84268 ) return(kTRUE);
01276 //--- munp scanning generic analysis...(13/12/03)
01277   else if(RunNumber ==  358760&& EventNumber ==  37303) return(kTRUE);
01278   else if(RunNumber ==  360135&& EventNumber ==  6818) return(kTRUE);
01279   else if(RunNumber ==  360296&& EventNumber ==  8968) return(kTRUE);
01280   else if(RunNumber ==  360296&& EventNumber ==  119968) return(kTRUE);
01281   else if(RunNumber ==  361309&& EventNumber ==  1202) return(kTRUE);
01282   else if(RunNumber ==  362453&& EventNumber ==  98583) return(kTRUE);
01283   else if(RunNumber ==  363597&& EventNumber ==  19723) return(kTRUE);
01284   else if(RunNumber ==  363666&& EventNumber ==  6819) return(kTRUE);
01285   else if(RunNumber ==  363865&& EventNumber == 44606 ) return(kTRUE);
01286   else if(RunNumber ==  363874&& EventNumber ==  3430) return(kTRUE);
01287   else if(RunNumber ==  365083&& EventNumber ==  44578) return(kTRUE);
01288 //--- CC Dq scanning ...(16/12/03)
01289   else if(RunNumber ==  360121&& EventNumber == 5463) return(kTRUE);
01290   else if(RunNumber ==  363284&& EventNumber == 102592) return(kTRUE);
01291   else if(RunNumber ==  363459&& EventNumber == 14932) return(kTRUE);
01292   else if(RunNumber ==  364484&& EventNumber == 10143) return(kTRUE);
01293 
01294 
01295   return(selection);
01296 }
01297 
01298  
01299 
01300 Bool_t TTools::IsNonEP()
01301 {
01302 // Is NOISE or cosmic
01303   if(MCFlag) return kFALSE;     //--- valid only if DATA
01304 
01305   Bool_t selection = kFALSE;
01306 
01307   // NOISE + EYE ID OF COSMICS RUNS/EVENTS
01308   // Check if actual event is noisy or cosmic
01309 
01310   // Eliminate cosmic events
01311   if (RunNumber == 265513 && EventNumber == 80488)
01312     return(kTRUE);
01313   else if (RunNumber == 274259 && EventNumber == 103462)
01314     return(kTRUE);
01315   else if (RunNumber == 262491 && EventNumber == 103171)
01316     return(kTRUE);
01317   else if (RunNumber == 252787 && EventNumber == 84899)
01318     return(kTRUE);
01319   else if (RunNumber == 256965 && EventNumber == 160670)
01320     return(kTRUE);
01321   else if (RunNumber == 258147 && EventNumber == 42406)
01322     return(kTRUE);
01323   else if (RunNumber == 258678 && EventNumber == 179589)
01324     return(kTRUE);
01325   else if (RunNumber == 257627 && EventNumber == 48985)
01326     return(kTRUE);
01327   else if (RunNumber == 258808 && EventNumber == 28416)
01328     return(kTRUE);
01329   else if (RunNumber == 259734 && EventNumber == 60542)
01330     return(kTRUE);
01331   else if (RunNumber == 261338 && EventNumber == 22402)
01332     return(kTRUE);
01333   // j-pho scanning
01334   else if (RunNumber == 253523 && EventNumber == 1603)
01335     return(kTRUE);
01336   else if (RunNumber == 256697 && EventNumber == 9599)
01337     return(kTRUE);
01338   else if (RunNumber == 256965 && EventNumber == 169670)
01339     return(kTRUE);
01340   else if (RunNumber == 258113 && EventNumber == 42406)
01341     return(kTRUE);
01342   else if (RunNumber == 258147 && EventNumber == 179589)
01343     return(kTRUE);
01344   else if (RunNumber == 258147 && EventNumber == 333546)
01345     return(kTRUE);
01346   else if (RunNumber == 258674 && EventNumber == 64200)
01347     return(kTRUE);
01348   else if (RunNumber == 258678 && EventNumber == 48985)
01349     return(kTRUE);
01350   else if (RunNumber == 257691 && EventNumber == 2219)
01351     return(kTRUE);
01352   else if (RunNumber == 258025 && EventNumber == 167887)
01353     return(kTRUE);
01354   else if (RunNumber == 258808 && EventNumber == 28601)
01355     return(kTRUE);
01356   else if (RunNumber == 259107 && EventNumber == 95002)
01357     return(kTRUE);
01358   else if (RunNumber == 260845 && EventNumber == 40143)
01359     return(kTRUE);
01360   else if (RunNumber == 260036 && EventNumber == 84418)
01361     return(kTRUE);
01362   else if (RunNumber == 260210 && EventNumber == 8222)
01363     return(kTRUE);
01364   else if (RunNumber == 260354 && EventNumber == 126164)
01365     return(kTRUE);
01366   // Eye scanning e-mu
01367   else if (RunNumber == 264246 && EventNumber == 12180)
01368     return(kTRUE);
01369   else if (RunNumber == 268319 && EventNumber == 28736)
01370     return(kTRUE);
01371   else if (RunNumber == 275086 && EventNumber == 35719)
01372     return(kTRUE);
01373   // Eye scanning mu-mu
01374   else if (RunNumber == 252377 && EventNumber == 93828)
01375     return(kTRUE);
01376   else if (RunNumber == 250996 && EventNumber == 48582)
01377     return(kTRUE);
01378   else if (RunNumber == 254433 && EventNumber == 21344)
01379     return(kTRUE);
01380   else if (RunNumber == 255109 && EventNumber == 75418)
01381     return(kTRUE);
01382   else if (RunNumber == 259107 && EventNumber == 66564)
01383     return(kTRUE);
01384   else if (RunNumber == 249271 && EventNumber == 114116)
01385     return(kTRUE);
01386   else if (RunNumber == 278496 && EventNumber == 21284)
01387     return(kTRUE);
01388   else if (RunNumber == 278541 && EventNumber == 17094)
01389     return(kTRUE);
01390   else if (RunNumber == 264171 && EventNumber == 155107)
01391     return(kTRUE);
01392   else if (RunNumber == 264257 && EventNumber == 9015)
01393     return(kTRUE);
01394   else if (RunNumber == 264442 && EventNumber == 57876)
01395     return(kTRUE);
01396   else if (RunNumber == 265270 && EventNumber == 13543)
01397     return(kTRUE);
01398   else if (RunNumber == 267206 && EventNumber == 205856)
01399     return(kTRUE);
01400   else if (RunNumber == 267207 && EventNumber == 112373)
01401     return(kTRUE);
01402   else if (RunNumber == 268338 && EventNumber == 57765)
01403     return(kTRUE);
01404   else if (RunNumber == 262534 && EventNumber == 5367)
01405     return(kTRUE);
01406   else if (RunNumber == 262752 && EventNumber == 8585)
01407     return(kTRUE);
01408   else if (RunNumber == 269754 && EventNumber == 1409)
01409     return(kTRUE);
01410   else if (RunNumber == 269633 && EventNumber == 17192)
01411     return(kTRUE);
01412   else if (RunNumber == 272932 && EventNumber == 58808)
01413     return(kTRUE);
01414   else if (RunNumber == 272037 && EventNumber == 77213)
01415     return(kTRUE);
01416   else if (RunNumber == 275081 && EventNumber == 1076)
01417     return(kTRUE);
01418   else if (RunNumber == 275591 && EventNumber == 143305)
01419     return(kTRUE);
01420   else if (RunNumber == 275615 && EventNumber == 12772)
01421     return(kTRUE);
01422   else if (RunNumber == 275722 && EventNumber == 69943)
01423     return(kTRUE);
01424   else if (RunNumber == 275843 && EventNumber == 31714)
01425     return(kTRUE);
01426   else if (RunNumber == 275993 && EventNumber == 80659)
01427     return(kTRUE);
01428   else if (RunNumber == 276036 && EventNumber == 120319)
01429     return(kTRUE);
01430   else if (RunNumber == 276662 && EventNumber == 82873)
01431     return(kTRUE);
01432   else if (RunNumber == 276839 && EventNumber == 3475)
01433     return(kTRUE);
01434   else if (RunNumber == 276965 && EventNumber == 64052)
01435     return(kTRUE);
01436   else if (RunNumber == 277996 && EventNumber == 37571)
01437     return(kTRUE);
01438   else if (RunNumber == 270343 && EventNumber == 15397)
01439     return(kTRUE);
01440   else if (RunNumber == 270321 && EventNumber == 40892)
01441     return(kTRUE);
01442   else if (RunNumber == 263675 && EventNumber == 170286)
01443     return(kTRUE);
01444   else if (RunNumber == 278496 && EventNumber == 21234)
01445     return(kTRUE);
01446   else if (RunNumber == 265372 && EventNumber == 89946)
01447     return(kTRUE);
01448   else if (RunNumber == 275709 && EventNumber == 63682)
01449     return(kTRUE);
01450   else if (RunNumber == 278078 && EventNumber == 4137)
01451     return(kTRUE);
01452   // Eye scanning mu-j
01453   else if (RunNumber == 273527 && EventNumber == 4799)
01454     return(kTRUE);
01455   else if (RunNumber == 276219 && EventNumber == 148101)
01456     return(kTRUE);
01457   else if (RunNumber == 271223 && EventNumber == 987)
01458     return(kTRUE);
01459   // Eye scanning mu-np
01460   else if (RunNumber == 249504 && EventNumber == 73715)
01461     return(kTRUE);
01462   else if (RunNumber == 252377 && EventNumber == 105453)
01463     return(kTRUE);
01464   else if (RunNumber == 254855 && EventNumber == 23864)
01465     return(kTRUE);
01466   else if (RunNumber == 258073 && EventNumber == 201294)
01467     return(kTRUE);
01468   else if (RunNumber == 257779 && EventNumber == 88729)
01469     return(kTRUE);
01470   else if (RunNumber == 259399 && EventNumber == 16567)
01471     return(kTRUE);
01472   else if (RunNumber == 258880 && EventNumber == 184942)
01473     return(kTRUE);
01474   else if (RunNumber == 259088 && EventNumber == 62683)
01475     return(kTRUE);
01476   else if (RunNumber == 259312 && EventNumber == 179641)
01477     return(kTRUE);
01478   else if (RunNumber == 278653 && EventNumber == 92192)
01479     return(kTRUE);
01480   else if (RunNumber == 268024 && EventNumber == 25327)
01481     return(kTRUE);
01482   else if (RunNumber == 267315 && EventNumber == 11062)
01483     return(kTRUE);
01484   else if (RunNumber == 267405 && EventNumber == 13005)
01485     return(kTRUE);
01486   else if (RunNumber == 272035 && EventNumber == 194608)
01487     return(kTRUE);
01488   else if (RunNumber == 273497 && EventNumber == 53854)
01489     return(kTRUE);
01490   else if (RunNumber == 274258 && EventNumber == 63331)
01491     return(kTRUE);
01492   else if (RunNumber == 276133 && EventNumber == 18337)
01493     return(kTRUE);
01494   else if (RunNumber == 276789 && EventNumber == 33060)
01495     return(kTRUE);
01496   else if (RunNumber == 277369 && EventNumber == 131891)
01497     return(kTRUE);
01498   else if (RunNumber == 276941 && EventNumber == 85829)
01499     return(kTRUE);
01500   else if (RunNumber == 270750 && EventNumber == 149391)
01501     return(kTRUE);
01502   else if (RunNumber == 270273 && EventNumber == 54901)
01503     return(kTRUE);
01504   // Eye scanning np-pho
01505   else if (RunNumber == 251667 && EventNumber == 9890)
01506     return(kTRUE);
01507   else if (RunNumber == 250414 && EventNumber == 15294)
01508     return(kTRUE);
01509   else if (RunNumber == 278460 && EventNumber == 119514)
01510     return(kTRUE);
01511   else if (RunNumber == 278849 && EventNumber == 26720)
01512     return(kTRUE);
01513   else if (RunNumber == 252642 && EventNumber == 51145)
01514     return(kTRUE);
01515   else if (RunNumber == 252725 && EventNumber == 119991)
01516     return(kTRUE);
01517   else if (RunNumber == 252792 && EventNumber == 82955)
01518     return(kTRUE);
01519   else if (RunNumber == 251866 && EventNumber == 86526)
01520     return(kTRUE);
01521   else if (RunNumber == 252380 && EventNumber == 112743)
01522     return(kTRUE);
01523   else if (RunNumber == 254229 && EventNumber == 20194)
01524     return(kTRUE);
01525   else if (RunNumber == 254385 && EventNumber == 37410)
01526     return(kTRUE);
01527   else if (RunNumber == 254818 && EventNumber == 178930)
01528     return(kTRUE);
01529   else if (RunNumber == 264403 && EventNumber == 7264)
01530     return(kTRUE);
01531   else if (RunNumber == 256562 && EventNumber == 10616)
01532     return(kTRUE);
01533   else if (RunNumber == 256425 && EventNumber == 38159)
01534     return(kTRUE);
01535   else if (RunNumber == 256496 && EventNumber == 10830)
01536     return(kTRUE);
01537   else if (RunNumber == 256551 && EventNumber == 31171)
01538     return(kTRUE);
01539   else if (RunNumber == 265528 && EventNumber == 15519)
01540     return(kTRUE);
01541   else if (RunNumber == 265528 && EventNumber == 92368)
01542     return(kTRUE);
01543   else if (RunNumber == 265019 && EventNumber == 18073)
01544     return(kTRUE);
01545   else if (RunNumber == 265180 && EventNumber == 71515)
01546     return(kTRUE);
01547   else if (RunNumber == 266281 && EventNumber == 159387)
01548     return(kTRUE);
01549   else if (RunNumber == 266171 && EventNumber == 61707)
01550     return(kTRUE);
01551   else if (RunNumber == 259561 && EventNumber == 1312)
01552     return(kTRUE);
01553   else if (RunNumber == 259347 && EventNumber == 16880)
01554     return(kTRUE);
01555   else if (RunNumber == 267771 && EventNumber == 50401)
01556     return(kTRUE);
01557   else if (RunNumber == 267827 && EventNumber == 149334)
01558     return(kTRUE);
01559   else if (RunNumber == 266936 && EventNumber == 3510)
01560     return(kTRUE);
01561   else if (RunNumber == 267477 && EventNumber == 5168)
01562     return(kTRUE);
01563   else if (RunNumber == 259733 && EventNumber == 15503)
01564     return(kTRUE);
01565   else if (RunNumber == 260155 && EventNumber == 9196)
01566     return(kTRUE);
01567   else if (RunNumber == 268338 && EventNumber == 69658)
01568     return(kTRUE);
01569   else if (RunNumber == 268652 && EventNumber == 82354)
01570     return(kTRUE);
01571   else if (RunNumber == 268661 && EventNumber == 3143)
01572     return(kTRUE);
01573   else if (RunNumber == 268072 && EventNumber == 88380)
01574     return(kTRUE);
01575   else if (RunNumber == 246631 && EventNumber == 20449)
01576     return(kTRUE);
01577   else if (RunNumber == 262817 && EventNumber == 24252)
01578     return(kTRUE);
01579   else if (RunNumber == 270024 && EventNumber == 26844)
01580     return(kTRUE);
01581   else if (RunNumber == 270819 && EventNumber == 51303)
01582     return(kTRUE);
01583   else if (RunNumber == 272793 && EventNumber == 132804)
01584     return(kTRUE);
01585   else if (RunNumber == 271156 && EventNumber == 6015)
01586     return(kTRUE);
01587   else if (RunNumber == 272319 && EventNumber == 133943)
01588     return(kTRUE);
01589   else if (RunNumber == 273242 && EventNumber == 56531)
01590     return(kTRUE);
01591   else if (RunNumber == 274918 && EventNumber == 76937)
01592     return(kTRUE);
01593   else if (RunNumber == 274480 && EventNumber == 38737)
01594     return(kTRUE);
01595   else if (RunNumber == 274627 && EventNumber == 105476)
01596     return(kTRUE);
01597   else if (RunNumber == 275242 && EventNumber == 16100)
01598     return(kTRUE);
01599   else if (RunNumber == 275353 && EventNumber == 111236)
01600     return(kTRUE);
01601   else if (RunNumber == 275381 && EventNumber == 50776)
01602     return(kTRUE);
01603   else if (RunNumber == 276133 && EventNumber == 37695)
01604     return(kTRUE);
01605   else if (RunNumber == 276839 && EventNumber == 97017)
01606     return(kTRUE);
01607   else if (RunNumber == 276459 && EventNumber == 130863)
01608     return(kTRUE);
01609   else if (RunNumber == 277452 && EventNumber == 30340)
01610     return(kTRUE);
01611   else if (RunNumber == 270464 && EventNumber == 169398)
01612     return(kTRUE);
01613   else if (RunNumber == 270509 && EventNumber == 14807)
01614     return(kTRUE);
01615   else if (RunNumber == 270099 && EventNumber == 44898)
01616     return(kTRUE);
01617   else if (RunNumber == 270137 && EventNumber == 56412)
01618     return(kTRUE);
01619   else if (RunNumber == 270147 && EventNumber == 195335)
01620     return(kTRUE);
01621   else if (RunNumber == 263754 && EventNumber == 14959)
01622     return(kTRUE);
01623   else if (RunNumber == 263846 && EventNumber == 129382)
01624     return(kTRUE);
01625   else if (RunNumber == 275616 && EventNumber == 47523)
01626     return(kTRUE);
01627   else if (RunNumber == 249108 && EventNumber == 24810)
01628     return(kTRUE);
01629   else if (RunNumber == 275715 && EventNumber == 3919)
01630     return(kTRUE);
01631   else if(RunNumber == 278414 && EventNumber == 21088)
01632     return(kTRUE);
01633   else if(RunNumber == 278999 && EventNumber == 6385)
01634     return(kTRUE);
01635   else if(RunNumber == 265490 && EventNumber == 146599)
01636     return(kTRUE);
01637   else if(RunNumber == 266171 && EventNumber == 61701)
01638     return(kTRUE);
01639   else if(RunNumber == 267949 && EventNumber == 54921)
01640     return(kTRUE);
01641   else if(RunNumber == 268211 && EventNumber == 8027)
01642     return(kTRUE);
01643   else if(RunNumber == 275071 && EventNumber == 7335)
01644     return(kTRUE);
01645   else if(RunNumber == 277996 && EventNumber == 43191)
01646     return(kTRUE);
01647   // Eliminate hot cells noise events 
01648   if (RunNumber == 274737 && EventNumber == 99795)
01649     return(kTRUE);
01650   else if (RunNumber == 274737 && EventNumber == 57052)
01651     return(kTRUE);
01652   else if (RunNumber == 274737 && EventNumber == 57162)
01653     return(kTRUE);
01654   else if (RunNumber == 274737 && EventNumber == 57236)
01655     return(kTRUE);
01656   else if (RunNumber == 274737 && EventNumber == 57447)
01657     return(kTRUE);
01658   else if (RunNumber == 274737 && EventNumber == 57488)
01659     return(kTRUE);
01660   else if (RunNumber == 274737 && EventNumber == 57497)
01661     return(kTRUE);
01662   else if (RunNumber == 274737 && EventNumber == 57543)
01663     return(kTRUE);
01664   else if (RunNumber == 274737 && EventNumber == 57748)
01665     return(kTRUE);
01666   else if (RunNumber == 274737 && EventNumber == 57794)
01667     return(kTRUE);
01668   else if (RunNumber == 274737 && EventNumber == 58242)
01669     return(kTRUE);
01670   else if (RunNumber == 274737 && EventNumber == 58257)
01671     return(kTRUE);
01672   else if (RunNumber == 274737 && EventNumber == 58457)
01673     return(kTRUE);
01674   else if (RunNumber == 274737 && EventNumber == 58697)
01675     return(kTRUE);
01676   else if (RunNumber == 274737 && EventNumber == 58700)
01677     return(kTRUE);
01678   else if (RunNumber == 274737 && EventNumber == 58783)
01679     return(kTRUE);
01680   else if (RunNumber == 274737 && EventNumber == 58827)
01681     return(kTRUE);
01682   else if (RunNumber == 274737 && EventNumber == 58945)
01683     return(kTRUE);
01684   else if (RunNumber == 274737 && EventNumber == 58974)
01685     return(kTRUE);
01686   else if (RunNumber == 274737 && EventNumber == 59113)
01687     return(kTRUE);
01688   else if (RunNumber == 274737 && EventNumber == 59761)
01689     return(kTRUE);
01690   else if (RunNumber == 274737 && EventNumber == 59852)
01691     return(kTRUE);
01692   else if (RunNumber == 274737 && EventNumber == 59984)
01693     return(kTRUE);
01694   else if (RunNumber == 274737 && EventNumber == 60304)
01695     return(kTRUE);
01696   else if (RunNumber == 274737 && EventNumber == 60116)
01697     return(kTRUE);
01698   else if (RunNumber == 274737 && EventNumber == 60450)
01699     return(kTRUE);
01700   else if (RunNumber == 274737 && EventNumber == 60598)
01701     return(kTRUE);
01702   else if (RunNumber == 274737 && EventNumber == 60618)
01703     return(kTRUE);
01704   else if (RunNumber == 274737 && EventNumber == 60943)
01705     return(kTRUE);
01706   else if (RunNumber == 274737 && EventNumber == 60988)
01707     return(kTRUE);
01708   else if (RunNumber == 274737 && EventNumber == 61043)
01709     return(kTRUE);
01710   else if (RunNumber == 274737 && EventNumber == 61100)
01711     return(kTRUE);
01712   else if (RunNumber == 274737 && EventNumber == 61186)
01713     return(kTRUE);
01714   else if (RunNumber == 274737 && EventNumber == 61206)
01715     return(kTRUE);
01716   else if (RunNumber == 274737 && EventNumber == 61321)
01717     return(kTRUE);
01718   else if (RunNumber == 274737 && EventNumber == 61600)
01719     return(kTRUE);
01720   else if (RunNumber == 274737 && EventNumber == 61645)
01721     return(kTRUE);
01722   else if (RunNumber == 274737 && EventNumber == 61702)
01723     return(kTRUE);
01724   else if (RunNumber == 274737 && EventNumber == 61780)
01725     return(kTRUE);
01726   else if (RunNumber == 274737 && EventNumber == 61854)
01727     return(kTRUE);
01728   else if (RunNumber == 274737 && EventNumber == 62039)
01729     return(kTRUE);
01730   else if (RunNumber == 274737 && EventNumber == 62589)
01731     return(kTRUE);
01732   else if (RunNumber == 274737 && EventNumber == 62690)
01733     return(kTRUE);
01734   else if (RunNumber == 274737 && EventNumber == 62772)
01735     return(kTRUE);
01736   else if (RunNumber == 274737 && EventNumber == 62859)
01737     return(kTRUE);
01738   else if (RunNumber == 274737 && EventNumber == 62874)
01739     return(kTRUE);
01740   else if (RunNumber == 274737 && EventNumber == 63060)
01741     return(kTRUE);
01742   else if (RunNumber == 274737 && EventNumber == 63433)
01743     return(kTRUE);
01744   else if (RunNumber == 274737 && EventNumber == 63610)
01745     return(kTRUE);
01746   else if (RunNumber == 274737 && EventNumber == 63731)
01747     return(kTRUE);
01748   else if (RunNumber == 274737 && EventNumber == 63797)
01749     return(kTRUE);
01750   else if (RunNumber == 274737 && EventNumber == 63814)
01751     return(kTRUE);
01752   else if (RunNumber == 274737 && EventNumber == 64018)
01753     return(kTRUE);
01754   else if (RunNumber == 274737 && EventNumber == 64028)
01755     return(kTRUE);
01756   else if (RunNumber == 274737 && EventNumber == 64311)
01757     return(kTRUE);
01758   else if (RunNumber == 274737 && EventNumber == 64505)
01759     return(kTRUE);
01760   else if (RunNumber == 274737 && EventNumber == 64628)
01761     return(kTRUE);
01762   else if (RunNumber == 274737 && EventNumber == 64741)
01763     return(kTRUE);
01764   else if (RunNumber == 274737 && EventNumber == 65027)
01765     return(kTRUE);
01766   else if (RunNumber == 274737 && EventNumber == 65235)
01767     return(kTRUE);
01768   else if (RunNumber == 274737 && EventNumber == 65366)
01769     return(kTRUE);
01770   else if (RunNumber == 274737 && EventNumber == 65909)
01771     return(kTRUE);
01772   else if (RunNumber == 274737 && EventNumber == 66073)
01773     return(kTRUE);
01774   else if (RunNumber == 274737 && EventNumber == 66589)
01775     return(kTRUE);
01776   else if (RunNumber == 274737 && EventNumber == 66606)
01777     return(kTRUE);
01778   else if (RunNumber == 274737 && EventNumber == 66674)
01779     return(kTRUE);
01780   else if (RunNumber == 274737 && EventNumber == 94597)
01781     return(kTRUE);
01782   else if (RunNumber == 274737 && EventNumber == 94806)
01783     return(kTRUE);
01784   else if (RunNumber == 274737 && EventNumber == 94925)
01785     return(kTRUE);
01786   else if (RunNumber == 274737 && EventNumber == 94962)
01787     return(kTRUE);
01788   else if (RunNumber == 274737 && EventNumber == 95072)
01789     return(kTRUE);
01790   else if (RunNumber == 274737 && EventNumber == 95088)
01791     return(kTRUE);
01792   else if (RunNumber == 274737 && EventNumber == 95225)
01793     return(kTRUE);
01794   else if (RunNumber == 274737 && EventNumber == 95738)
01795     return(kTRUE);
01796   else if (RunNumber == 274737 && EventNumber == 95924)
01797     return(kTRUE);
01798   else if (RunNumber == 274737 && EventNumber == 96060)
01799     return(kTRUE);
01800   else if (RunNumber == 274737 && EventNumber == 96130)
01801     return(kTRUE);
01802   else if (RunNumber == 274737 && EventNumber == 96389)
01803     return(kTRUE);
01804   else if (RunNumber == 274737 && EventNumber == 96760)
01805     return(kTRUE);
01806   else if (RunNumber == 274737 && EventNumber == 96958)
01807     return(kTRUE);
01808   else if (RunNumber == 274737 && EventNumber == 96991)
01809     return(kTRUE);
01810   else if (RunNumber == 274737 && EventNumber == 97031)
01811     return(kTRUE);
01812   else if (RunNumber == 274737 && EventNumber == 97103)
01813     return(kTRUE);
01814   else if (RunNumber == 274737 && EventNumber == 97396)
01815     return(kTRUE);
01816   else if (RunNumber == 274737 && EventNumber == 97443)
01817     return(kTRUE);
01818   else if (RunNumber == 274737 && EventNumber == 97556)
01819     return(kTRUE);
01820   else if (RunNumber == 274737 && EventNumber == 97827)
01821     return(kTRUE);
01822   else if (RunNumber == 274737 && EventNumber == 98001)
01823     return(kTRUE);
01824   else if (RunNumber == 274737 && EventNumber == 98233)
01825     return(kTRUE);
01826   else if (RunNumber == 274737 && EventNumber == 98948)
01827     return(kTRUE);
01828   else if (RunNumber == 274737 && EventNumber == 98964)
01829     return(kTRUE);
01830   else if (RunNumber == 274737 && EventNumber == 99038)
01831     return(kTRUE);
01832   else if (RunNumber == 274737 && EventNumber == 99153)
01833     return(kTRUE);
01834   else if (RunNumber == 274737 && EventNumber == 99256)
01835     return(kTRUE);
01836   else if (RunNumber == 274737 && EventNumber == 99369)
01837     return(kTRUE);
01838   else if (RunNumber == 274737 && EventNumber == 99465)
01839     return(kTRUE);
01840   else if (RunNumber == 274737 && EventNumber == 99597)
01841     return(kTRUE);
01842   else if (RunNumber == 269604 && EventNumber == 175)
01843     return(kTRUE);
01844   else if (RunNumber == 270856 && EventNumber == 75790)
01845     return(kTRUE);
01846   else if (RunNumber == 272435 && EventNumber == 25542)
01847     return(kTRUE);
01848   else if (RunNumber == 273711 && EventNumber == 45868)
01849     return(kTRUE);
01850   else if (RunNumber == 273711 && EventNumber == 45952)
01851     return(kTRUE);
01852   else if (RunNumber == 273711 && EventNumber == 45854)
01853     return(kTRUE);
01854   else if (RunNumber == 273744 && EventNumber == 4529)
01855     return(kTRUE);
01856   else if (RunNumber == 274737 && EventNumber == 99765)
01857     return(kTRUE);
01858   else if (RunNumber == 275083 && EventNumber == 53806)
01859     return(kTRUE);
01860   else if (RunNumber == 274737 && EventNumber == 57167)
01861     return(kTRUE);
01862   else if (RunNumber == 274737 && EventNumber == 57263)
01863     return(kTRUE);
01864   else if (RunNumber == 274737 && EventNumber == 59994)
01865     return(kTRUE);
01866   else if (RunNumber == 274737 && EventNumber == 60306)
01867     return(kTRUE);
01868   else if (RunNumber == 274737 && EventNumber == 60416)
01869     return(kTRUE);
01870   else if (RunNumber == 274673 && EventNumber == 2066)
01871     return(kTRUE);
01872   else if (RunNumber == 274673 && EventNumber == 2123)
01873     return(kTRUE);
01874   else if (RunNumber == 274737 && EventNumber == 55104)
01875     return(kTRUE);
01876   else if (RunNumber == 274737 && EventNumber == 56001)
01877     return(kTRUE);
01878   else if (RunNumber == 274737 && EventNumber == 56002)
01879     return(kTRUE);
01880   else if (RunNumber == 274737 && EventNumber == 56088)
01881     return(kTRUE);
01882   else if (RunNumber == 274737 && EventNumber == 56095)
01883     return(kTRUE);
01884   else if (RunNumber == 274737 && EventNumber == 56263)
01885     return(kTRUE);
01886   else if (RunNumber == 274737 && EventNumber == 56272)
01887     return(kTRUE);
01888   else if (RunNumber == 274737 && EventNumber == 56311)
01889     return(kTRUE);
01890   else if (RunNumber == 274737 && EventNumber == 56746)
01891     return(kTRUE);
01892   else if (RunNumber == 274737 && EventNumber == 56760)
01893     return(kTRUE);
01894   else if (RunNumber == 274737 && EventNumber == 56770)
01895     return(kTRUE);
01896   else if (RunNumber == 274737 && EventNumber == 56945)
01897     return(kTRUE);
01898   else if (RunNumber == 274737 && EventNumber == 56991)
01899     return(kTRUE);
01900   else if (RunNumber == 270132 && EventNumber == 118742)
01901     return(kTRUE);
01902   else if (RunNumber == 270132 && EventNumber == 118857)
01903     return(kTRUE);
01904   else if (RunNumber == 270132 && EventNumber == 118883)
01905     return(kTRUE);
01906   else if (RunNumber == 270132 && EventNumber == 119033)
01907     return(kTRUE);
01908   else if (RunNumber == 270270 && EventNumber == 103708)
01909     return(kTRUE);
01910   else if (RunNumber == 270270 && EventNumber == 111491)
01911     return(kTRUE);
01912   else if (RunNumber == 270270 && EventNumber == 111659)
01913     return(kTRUE);
01914   else if (RunNumber == 270270 && EventNumber == 111786)
01915     return(kTRUE);
01916   // mu-np scanning
01917   else if (RunNumber == 279003 && EventNumber == 20339)
01918     return(kTRUE);
01919   else if (RunNumber == 278612 && EventNumber == 71506)
01920     return(kTRUE);
01921   else if (RunNumber == 264735 && EventNumber == 83011)
01922     return(kTRUE);
01923   else if (RunNumber == 264403 && EventNumber == 117528)
01924     return(kTRUE);
01925   else if (RunNumber == 266830 && EventNumber == 61617)
01926     return(kTRUE);
01927   else if (RunNumber == 266000 && EventNumber == 216997)
01928     return(kTRUE);
01929   else if (RunNumber == 266926 && EventNumber == 150936)
01930     return(kTRUE);
01931   else if (RunNumber == 267665 && EventNumber == 82141)
01932     return(kTRUE);
01933   else if (RunNumber == 269049 && EventNumber == 14371)
01934     return(kTRUE);
01935   else if (RunNumber == 271908 && EventNumber == 62529)
01936     return(kTRUE);
01937   else if (RunNumber == 270899 && EventNumber == 2338)
01938     return(kTRUE);
01939   else if (RunNumber == 271115 && EventNumber == 139166)
01940     return(kTRUE);
01941   else if (RunNumber == 272398 && EventNumber == 16831)
01942     return(kTRUE);
01943   else if (RunNumber == 272218 && EventNumber == 12581)
01944     return(kTRUE);
01945   else if (RunNumber == 273348 && EventNumber == 25257)
01946     return(kTRUE);
01947   else if (RunNumber == 273497 && EventNumber == 116838)
01948     return(kTRUE);
01949   else if (RunNumber == 273105 && EventNumber == 231053)
01950     return(kTRUE);
01951   else if (RunNumber == 273230 && EventNumber == 26104)
01952     return(kTRUE);
01953   else if (RunNumber == 274361 && EventNumber == 95877)
01954     return(kTRUE);
01955   else if (RunNumber == 273694 && EventNumber == 27612)
01956     return(kTRUE);
01957   else if (RunNumber == 273738 && EventNumber == 37091)
01958     return(kTRUE);
01959   else if (RunNumber == 273744 && EventNumber == 2549)
01960     return(kTRUE);
01961   else if (RunNumber == 274736 && EventNumber == 17683)
01962     return(kTRUE);
01963   else if (RunNumber == 275256 && EventNumber == 54317)
01964     return(kTRUE);
01965   else if (RunNumber == 275401 && EventNumber == 31574)
01966     return(kTRUE);
01967   else if (RunNumber == 276305 && EventNumber == 142797)
01968     return(kTRUE);
01969   else if (RunNumber == 276132 && EventNumber == 98651)
01970     return(kTRUE);
01971   else if (RunNumber == 276756 && EventNumber == 67880)
01972     return(kTRUE);
01973   else if (RunNumber == 276462 && EventNumber == 18266)
01974     return(kTRUE);
01975   else if (RunNumber == 276974 && EventNumber == 6466)
01976     return(kTRUE);
01977   else if (RunNumber == 278206 && EventNumber == 27372)
01978     return(kTRUE);
01979   else if (RunNumber == 278307 && EventNumber == 13763)
01980     return(kTRUE);
01981   else if (RunNumber == 268008 && EventNumber == 214400)
01982     return(kTRUE);
01983   else if (RunNumber == 249371 && EventNumber == 71211)
01984     return(kTRUE);
01985   else if (RunNumber == 252276 && EventNumber == 118618)
01986     return(kTRUE);
01987   else if (RunNumber == 252428 && EventNumber == 31173)
01988     return(kTRUE);
01989   else if (RunNumber == 254195 && EventNumber == 1244)
01990     return(kTRUE);
01991   else if (RunNumber == 254466 && EventNumber == 117267)
01992     return(kTRUE);
01993   else if (RunNumber == 253567 && EventNumber == 1006)
01994     return(kTRUE);
01995   else if (RunNumber == 253973 && EventNumber == 10515)
01996     return(kTRUE);
01997   else if (RunNumber == 256916 && EventNumber == 193529)
01998     return(kTRUE);
01999   else if (RunNumber == 254853 && EventNumber == 26151)
02000     return(kTRUE);
02001   else if (RunNumber == 255077 && EventNumber == 27797)
02002     return(kTRUE);
02003   else if (RunNumber == 256343 && EventNumber == 7200)
02004     return(kTRUE);
02005   else if (RunNumber == 256553 && EventNumber == 29340)
02006     return(kTRUE);
02007   else if (RunNumber == 258708 && EventNumber == 125833)
02008     return(kTRUE);
02009   else if (RunNumber == 257772 && EventNumber == 50965)
02010     return(kTRUE);
02011   else if (RunNumber == 259688 && EventNumber == 19688)
02012     return(kTRUE);
02013   else if (RunNumber == 258812 && EventNumber == 67459)
02014     return(kTRUE);
02015   else if (RunNumber == 258867 && EventNumber == 175276)
02016     return(kTRUE);
02017   else if (RunNumber == 258917 && EventNumber == 119958)
02018     return(kTRUE);
02019   else if (RunNumber == 259090 && EventNumber == 69640)
02020     return(kTRUE);
02021   else if (RunNumber == 260035 && EventNumber == 94532)
02022     return(kTRUE);
02023   else if (RunNumber == 248744 && EventNumber == 20110)
02024     return(kTRUE);
02025   else if (RunNumber == 249089 && EventNumber == 7075)
02026     return(kTRUE);
02027 
02028   return(selection);
02029 }
02030 
02031 Bool_t TTools::IsCJCDead(Float_t PhiTr )
02032 {
02033 
02034    if(MCFlag>=1)
02035      return(kFALSE); 
02036 
02037    if ((MCFlag==0 &&RunNumber >= 257590 && RunNumber <= 262144)
02038         || (MCFlag>0 &&RunNumber >= 257590 && RunNumber <= 262144)) { //---- hole in 99 data
02039         if(PhiTr*57.3 < -80 && PhiTr*57.3 > -170) return(kTRUE);
02040         else return(kFALSE);
02041    }else if((MCFlag==0 && RunNumber<=201519)){  //--- 94-97 data 
02042         if(PhiTr*57.3 < -110 && PhiTr*57.3 > -130) {
02043           return(kTRUE);
02044         }
02045         else return(kFALSE);
02046    }
02047    return(kFALSE); // to make the compiler happy...
02048 }
02049 
02050 // Bool_t TMyEvent::IsCJCDead(Float_t PhiTr)
02051 // {
02052 // // Is CJC dead (Dead period in 1999 data)
02053 // // Return kFALSE if CJC alive and kTRUE if CJC dead
02054 // // Check MC or not
02055 //   Float_t lumitot=65.85;
02056 //   if(MCFlag>=3&&MCFlag <12) lumitot= 79.5405;
02057 // 
02058 //    if ((MCFlag==0 &&RunNumber >= 257590 && RunNumber <= 262144)
02059 //         || (MCFlag>=12 && MCFlag<40 &&RunNumber >= 257637 && RunNumber <= 262144)) { //---- hole in 99 data
02060 //    
02061 //      if(PhiTr*57.3 < -80 && PhiTr*57.3 > -170) return(kTRUE);
02062 //      else return(kFALSE);
02063 //    }else if(MCFlag>0 && MCFlag<12) {//---- for old MC's
02064 //      if((gRandom->Rndm()<8.0267/lumitot)&&(PhiTr*57.3 < -80 && PhiTr*57.3 > -170)) return(kTRUE);
02065 //      else return(kFALSE);
02066 //    }else if((MCFlag==0 && RunNumber<=201519)
02067 //            ||(RunYear=TMarEvent::Y9497)){    //--- 94-97 data 
02068 //      if(PhiTr*57.3 < -110 && PhiTr*57.3 > -130) {
02069 //        //      cout <<"ICI\n";
02070 //        return(kTRUE);
02071 //      }
02072 //      else return(kFALSE);
02073 //         
02074 //    }
02075 //    // Sinon retourner kFALSE
02076 //    return(kFALSE);
02077 // }
02078 
02079 
02080 Bool_t TTools::IsCJCMCDead(Float_t PhiTr)
02081 {
02082 // Is CJC MC dead (Equivalent to Dead period in 1999 data)
02083 // Return kFALSE if CJC alive and kTRUE if CJC dead
02084 
02085   // Check dead CJC segment 
02086   // => By eye analysis choice of Phi range
02087    if (PhiTr*57.3 > -180 && PhiTr*57.3<-150)
02088      return(kTRUE);
02089    else 
02090      return(kFALSE);
02091 }
02092 
02093 
02094 Bool_t TTools::IsEPzOK(Float_t Epz)
02095 {
02096 // Is E-Pz physical (E-Pz < 75 GeV)
02097 
02098   const Double_t EPZMAX = 75.0;
02099 
02100   // Check event variable Epz
02101   if (Epz < EPZMAX)
02102     return(kTRUE);
02103   else
02104     return(kFALSE);
02105 }
02106 
02107 Float_t TTools::qhadcor_98_00(Int_t ITRA,Int_t ITYPE,Float_t jetpos,Float_t ptin,Float_t qvar){
02108 // ===========================================================================
02109 //
02110 // INPUT :
02111 // -----
02112 //              ITRA = 0  for calibration without track information
02113 //                     1   "     "        with     "         "
02114 //
02115 //              ITYPE = 1  for DATA 98-99 (nrun<233404)
02116 //                      2  for DATA 99    (nrun>233404)
02117 //                      3  for NC MC 98 e-p
02118 //                      4  for DATA 99-00
02119 //                      5  for NC MC 99 e+p
02120 //
02121 //              jetpos = theta of the jet
02122 //
02123 //              ptin = transverse inmpulsion of the jet
02124 //
02125 //              qvar = energie or pt or px or py or pz
02126 //
02127 //
02128 // OUTPUT :
02129 // ------       qhadcor_98_00 = corrected varin
02130 //
02131 //                                                                             
02134   // No track info
02135   Float_t a_da9900[8]={0.868093,0.877024,0.921192,0.949944,0.977572,1.09807,1.17005,0.95448};
02136   Float_t b_da9900[8]={0.0,-1.08682,-1.70889,0.0,0.0,0.0,-0.175373,0.0};
02137   Float_t c_da9900[8]={5.65951,10.0505,17.0786,5.55913,5.84501,6.47199,8.74776,5.50889};
02138 
02139   // track info
02140   Float_t a_da9900_tr[8]={0.868376,0.879944,1.151,0.960589,0.987846,1.15057,1.76864,0.915961};
02141   Float_t b_da9900_tr[8]={0.0,-1.20845,-1.33753,-1.91097,-1.71629,-1.40015,-0.691473,0.0};
02142   Float_t c_da9900_tr[8]={5.60348,10.699,196.481,9.64211,9.27777,13.1271,66.3346,2.53625};
02143 
02145   // No track info
02146 
02147 
02148   // Define helper vars
02149   Int_t ith=0; 
02150   Float_t acorr=0,bcorr=0,ccorr=0,ptinter=0,scale=0;
02151 
02152   // Check validity of input parameters
02153   if (ITRA != 0 && ITRA != 1)
02154     return(qvar);
02155   if (ITYPE != 1 && ITYPE != 2 && ITYPE != 3 && ITYPE != 4 && ITYPE != 5) 
02156     return(qvar);
02157   if (ptin<0)
02158     return(qvar);
02159 
02160   if (jetpos>0 && jetpos<10 ) ith=1;
02161   if (jetpos>=10 && jetpos<15 ) ith=2;
02162   if (jetpos>=30 && jetpos<55 ) ith=4;
02163   if (jetpos>=5 && jetpos<80 ) ith=5;
02164   if (jetpos>=80 && jetpos<110) ith=6;
02165   if (jetpos>=110 && jetpos<135) ith=7;
02166   if (jetpos>=135 && jetpos<180) ith=8;                           
02167 
02168   // DATA 99/00
02169   if (ITYPE == 4){
02170     if (!ITRA){
02171       if (ith){
02172         acorr = a_da9900[ith];
02173         bcorr = b_da9900[ith];
02174         ccorr = c_da9900[ith];
02175       }
02176       else return(qvar);
02177     }
02178     else if (ITRA == 1){
02179       if (ith){
02180         acorr = a_da9900_tr[ith];
02181         bcorr = b_da9900_tr[ith];
02182         ccorr = c_da9900_tr[ith];
02183       }
02184       else return(qvar);
02185     }
02186   }
02187   // DATA 98/00, MC...
02188 
02189   // Without track
02190   if (!ITRA){
02191     // --- Constante for data 98 e-p : bin 8
02192     //               for data 99 e-p : bin 8
02193     //               for NC MC  e+p  : bin 8
02194     if ((ITYPE == 1 && ith==8)||(ITYPE==2 && ith ==8)||(ITYPE==5 && ith==8)){
02195      scale = acorr;
02196     }
02197     // Exponential function for all others
02198     else{
02199       scale = acorr*(1-TMath::Exp(bcorr-ptin/ccorr));
02200       ptinter = ptin/scale;
02201       scale = acorr*(1-TMath::Exp(bcorr-ptinter/ccorr));
02202     }
02203   }
02204 
02205   // With track
02206   if (ITRA == 1){
02207     // --- Constante for data 98 e-p  : if,of,cb3,cb2,cb1,bbe
02208     //               for data 99 e-p  : bbe
02209     //               for nc mc e+p    : cb3,bbe                                
02210     if ((ITYPE == 1 && (ith==5 || ith==7 || ith==8 || ith==2 || ith==3 || ith==6)) || (ITYPE==2 && ith==8) || (ITYPE==5 && (ith==5 || ith==8))){
02211       scale = acorr;
02212     }
02213     // Special function for nc mc e-p bbe
02214     else if ((ITYPE==3 && ith==8)){
02215       scale = acorr/ptin + ccorr;
02216       ptinter = ptin /scale;
02217       scale = acorr/ptinter + ccorr;
02218     }
02219     // Exponential function for all others
02220     else{
02221       scale = acorr*(1-TMath::Exp(bcorr-ptin/ccorr));
02222       ptinter = ptin/scale;
02223       scale = acorr*(1-TMath::Exp(bcorr-ptinter/ccorr));
02224     }
02225   }
02226 
02227   // Return correction of qvar
02228   return(qvar/scale);
02229 
02230 }
02231 
02232 
02233 
02234  
02235   
02236 Bool_t TTools::IsMCQ2OK(void)
02237 {
02238 // Is Q2 OK (Combination of diff. MCs)
02239 
02240  static H1FloatPtr Q2gki("Q2Gki");
02241 
02242  // Check for RAPGAP NC Q2<100 GeV2
02243  if (MCFlag != MCRAPGAPNCID)
02244    return(kTRUE);
02245  else{
02246    printf("Found rapgap q2 = %#8.3f\n",*Q2gki);
02247    if (*Q2gki < 100)
02248      return(kTRUE);
02249    else{
02250      return(kFALSE);
02251    }
02252  }
02253 }
02254 
02255 
02256 
02257 
02258 Float_t TTools::abscor(Int_t icalfac,Float_t theta_rad,Float_t ptj,Float_t qvar){
02259 // Final calib using qhadcor
02260 // ONLY FORSEEN FOR DATA 99/00
02261  
02262   // Vars for calib
02263   Float_t ej,theta_deg;
02264   Int_t itype_new,ITRA;
02265  
02266   // Get energy
02267   ej = qvar;
02268   theta_deg = theta_rad*180/3.1415;
02269 
02270   // 99/00
02271   ITRA = 1; // (0/1) = (NO TRACK INFO/TRACK INFO)
02272   if (RunNumber>205000 && RunNumber < 233404 && icalfac == 1)
02273     itype_new = 1; // data 99 e- before oc
02274   else if (RunNumber>233404 && RunNumber <241650 && icalfac == 1)
02275     itype_new = 2; // data 99 e-, after oc 
02276   else if (RunNumber>241650 && icalfac == 1)
02277     itype_new = 4;
02278   else if (icalfac==2)
02279     itype_new = 5;
02280 
02281   if (RunNumber>205000 && icalfac == 1){
02282     return(qhadcor_98_00_trans(&ITRA,&itype_new,&theta_deg,&ptj,&ej));
02283   }
02284   else if (icalfac == 2){
02285     return(qhadcor_98_00_trans(&ITRA,&itype_new,&theta_deg,&ptj,&ej));
02286   }  
02287   else {
02288     printf("no calib\n");
02289     return(qvar);
02290   }
02291 }
02292 
02293 Float_t TTools::qhadcor_98_00_trans(Int_t *itra,Int_t *itype,Float_t *jetpos, Float_t *ptin, Float_t *qvar)
02294 {
02295 // Translated qhadcor
02296 
02297     /* Initialized data */
02298 
02299     Float_t a_da98__[8] = { 0.879904,0.896318,0.906617,0.952872,0.955324,1.11211,1.14113,0.877522 };
02300     Float_t a_da99_tr__[8] = { 0.909524,0.964727,
02301             1.53204,0.980311,1.00269,1.14101,
02302             1.14013,0.984392 };
02303     Float_t b_da99_tr__[8] = { 0.,-1.56025,-.830946,-2.10923,0.,0.,0.,0. };
02304     Float_t c_da99_tr__[8] = { 5.48443,28.4622,
02305             406.365,10.539,3.07687,2.63095,
02306             3.14387,0. };
02307     Float_t a_ncem__[8] = { 0.924608,0.936066,1.01124,0.992175,0.958481,1.06982,1.09196,0.951766 };
02308     Float_t b_ncem__[8] = { 0.,-1.0471,-1.74525,-1.83088,0.,0.,0.,0. };
02309     Float_t c_ncem__[8] = { 5.60523,11.141,34.3981,19.3739,4.75546,5.05682,5.48667,4.65611 };
02310     Float_t a_ncem_tr__[8] = { 0.923356,0.935513,1.0688,1.12909,0.971356,1.09247,1.10269,1.4647 };
02311     Float_t b_ncem_tr__[8] = { 0.,-1.21237,-1.79435,-1.81835,0.,0.,0.,0. };
02312     Float_t c_ncem_tr__[8] = { 5.4633,11.7644,
02313             80.2606,186.33,2.62928,3.13916,
02314             3.11973,0.803558 };
02315     Float_t a_da9900__[8] = { 0.868093,0.877024,
02316             .921192,0.949944,0.977572,1.09807,
02317             1.17005,0.95448 };
02318     Float_t b_da98__[8] = { 0.,0.,0.,0.,0.,0.,0.,0. };
02319     Float_t b_da9900__[8] = { 0.,-1.08682,-1.70889,0.,0.,0.,-.175373,0. };
02320     Float_t c_da9900__[8] = { 5.65951,10.0507,
02321             17.0786,5.55913,5.84501,6.47199,
02322             8.74776,5.50889 };
02323     Float_t a_da9900_tr__[8] = { 0.868376,0.879944,
02324             1.151,0.960589,0.987846,1.15057,1.76864,
02325             0.915961 };
02326     Float_t b_da9900_tr__[8] = { 0.,-1.20845,
02327             -1.33753,-1.91097,-1.71629,-1.40015,
02328             -.691473,0. };
02329     Float_t c_da9900_tr__[8] = { 5.60348,10.699,
02330             196.481,9.64211,9.27777,13.1271,
02331             66.3346,2.53625 };
02332     Float_t a_ncep__[8] = { 0.89243,0.937066,0.949565,0.96273,0.934171,1.05762,1.06794,0.807267 };
02333     Float_t b_ncep__[8] = { 0.,-1.72168,-2.03856,-1.49543,0.,0.,0.,0. };
02334     Float_t c_ncep__[8] = { 4.95748,23.913,18.111,11.2861,4.50758,5.62712,5.91176,0.0 };
02335     Float_t a_ncep_tr__[8] = { 0.892234,0.909234,
02336             1.13882,0.981473,0.943926,1.07693,
02337             1.10456,0.877618 };
02338     Float_t b_ncep_tr__[8] = { 0.,-1.40548,-1.56322,-2.71634,0.,0.,-1.52819,0. };
02339     Float_t c_da98__[8] = { 4.47972,6.72565,5.85448,5.28593,3.44614,6.03909,6.58739,0. };
02340     Float_t c_ncep_tr__[8] = { 4.8741,11.5655,
02341             246.091,25.2448,0.,3.20811,9.36505,0. };
02342     Float_t a_da98_tr__[8] = { 0.878587,0.857764,
02343             0.885084,0.957587,0.979401,1.0804,
02344             1.05171,0.906565 };
02345     Float_t b_da98_tr__[8] = { 0.,0.,0.,0.,0.,0.,0.,0. };
02346     Float_t c_da98_tr__[8] = { 4.39525,0.,0.,
02347             2.63626,0.,0.,0.,0. };
02348     Float_t a_da99__[8] = { 0.911278,0.954436,0.993601,0.964861,1.00978,1.13403,1.15267,0.939532 };
02349     Float_t b_da99__[8] = { 0.,-1.4355,-1.65515,0.,0.,0.,0.,0. };
02350     Float_t c_da99__[8] = { 5.66306,22.6958,39.045,5.45322,6.05385,5.75632,6.33544,0. };
02351 
02352     /* System generated locals */
02353     Float_t ret_val;
02354 
02355     /* Local variables */
02356     Float_t scale=0, acorr=0, bcorr=0, ccorr=0;
02357     Int_t ith;
02358     Float_t ptinter;
02359 
02360 /*=======================================================================
02361 ====*/
02362 
02363 /* INPUT : */
02364 /* ----- */
02365 /*              ITRA = 0  for calibration without track information */
02366 /*                     1   "     "        with     "         " */
02367 
02368 /*              ITYPE = 1  for DATA 98-99 (nrun<233404) */
02369 /*                      2  for DATA 99    (nrun>233404) */
02370 /*                      3  for NC MC 98 e-p */
02371 /*                      4  for DATA 99-00 */
02372 /*                      5  for NC MC 99 e+p */
02373 
02374 /*              jetpos = theta of the jet */
02375 
02376 /*              ptin = transverse inmpulsion of the jet */
02377 
02378 /*              qvar = energie or pt or px or py or pz */
02379 
02380 
02381 /* OUTPUT : */
02382 /* ------       qhadcor_98_00 = corrected varin */
02383 
02384 
02385 /*===========================================================================*/
02386 /* correction factors for  DATA 98/99 e-p (before online calibration change)*/
02387 /*===========================================================================*/
02388     if (*itra != 0 && *itra != 1) {
02389         goto L101;
02390     }
02391     if (*itype != 1 && *itype != 2 && *itype != 3 && *itype != 4 && *itype != 
02392             5) {
02393         goto L101;
02394     }
02395     if (*ptin <= 0.) {
02396         goto L101;
02397     }
02398     ith = 0;
02399     if (*jetpos >= 0. && *jetpos < 10.) {
02400         ith = 1;
02401     }
02402     if (*jetpos >= 10. && *jetpos < 15.) {
02403         ith = 2;
02404     }
02405     if (*jetpos >= 15. && *jetpos < 30.) {
02406         ith = 3;
02407     }
02408     if (*jetpos >= 30. && *jetpos < 55.) {
02409         ith = 4;
02410     }
02411     if (*jetpos >= 55. && *jetpos < 80.) {
02412         ith = 5;
02413     }
02414     if (*jetpos >= 80. && *jetpos < 110.) {
02415         ith = 6;
02416     }
02417     if (*jetpos >= 110. && *jetpos < 135.) {
02418         ith = 7;
02419     }
02420     if (*jetpos >= 135. && *jetpos < 180.) {
02421         ith = 8;
02422     }
02423 /* -------------------------------------------------------------- */
02424     if (*itype == 1) {
02425 /* data 98/99 */
02426         if (*itra == 0) {
02427             if (ith != 0) {
02428                 acorr = a_da98__[ith - 1];
02429                 bcorr = b_da98__[ith - 1];
02430                 ccorr = c_da98__[ith - 1];
02431             } else {
02432                 goto L101;
02433             }
02434         }
02435         if (*itra == 1) {
02436             if (ith != 0) {
02437                 acorr = a_da98_tr__[ith - 1];
02438                 bcorr = b_da98_tr__[ith - 1];
02439                 ccorr = c_da98_tr__[ith - 1];
02440             } else {
02441                 goto L101;
02442             }
02443         }
02444     }
02445 /* -------------------------------------------------------------- */
02446     if (*itype == 2) {
02447 /* data 99 */
02448         if (*itra == 0) {
02449             if (ith != 0) {
02450                 acorr = a_da99__[ith - 1];
02451                 bcorr = b_da99__[ith - 1];
02452                 ccorr = c_da99__[ith - 1];
02453             } else {
02454                 goto L101;
02455             }
02456         }
02457         if (*itra == 1) {
02458             if (ith != 0) {
02459                 acorr = a_da99_tr__[ith - 1];
02460                 bcorr = b_da99_tr__[ith - 1];
02461                 ccorr = c_da99_tr__[ith - 1];
02462             } else {
02463                 goto L101;
02464             }
02465         }
02466     }
02467 /* -------------------------------------------------------------- */
02468     if (*itype == 4) {
02469 /* data 99/00 */
02470         if (*itra == 0) {
02471             if (ith != 0) {
02472                 acorr = a_da9900__[ith - 1];
02473                 bcorr = b_da9900__[ith - 1];
02474                 ccorr = c_da9900__[ith - 1];
02475             } else {
02476                 goto L101;
02477             }
02478         }
02479         if (*itra == 1) {
02480             if (ith != 0) {
02481                 acorr = a_da9900_tr__[ith - 1];
02482                 bcorr = b_da9900_tr__[ith - 1];
02483                 ccorr = c_da9900_tr__[ith - 1];
02484             } else {
02485                 goto L101;
02486             }
02487         }
02488     }
02489 /* -------------------------------------------------------------- */
02490     if (*itype == 3) {
02491 /* NC MC e-p */
02492         if (*itra == 0) {
02493             if (ith != 0) {
02494                 acorr = a_ncem__[ith - 1];
02495                 bcorr = b_ncem__[ith - 1];
02496                 ccorr = c_ncem__[ith - 1];
02497             } else {
02498                 goto L101;
02499             }
02500         }
02501         if (*itra == 1) {
02502             if (ith != 0) {
02503                 acorr = a_ncem_tr__[ith - 1];
02504                 bcorr = b_ncem_tr__[ith - 1];
02505                 ccorr = c_ncem_tr__[ith - 1];
02506             } else {
02507                 goto L101;
02508             }
02509         }
02510     }
02511 /* -------------------------------------------------------------- */
02512     if (*itype == 5) {
02513 /* NC MC e+p */
02514         if (*itra == 0) {
02515             if (ith != 0) {
02516                 acorr = a_ncep__[ith - 1];
02517                 bcorr = b_ncep__[ith - 1];
02518                 ccorr = c_ncep__[ith - 1];
02519             } else {
02520                 goto L101;
02521             }
02522         }
02523         if (*itra == 1) {
02524             if (ith != 0) {
02525                 acorr = a_ncep_tr__[ith - 1];
02526                 bcorr = b_ncep_tr__[ith - 1];
02527                 ccorr = c_ncep_tr__[ith - 1];
02528             } else {
02529                 goto L101;
02530             }
02531         }
02532     }
02533 /* ================================================================ */
02534 /*                    without track */
02535 /* ================================================================ */
02536     if (*itra == 0) {
02537 
02538 /* --- Constante for data 98 e-p : bin 8 */
02539 /*               for data 99 e-p : bin 8 */
02540 /*               for NC MC  e+p  : bin 8 */
02541 
02542         if (*itype == 1 && ith == 8 || *itype == 2 && ith == 8 || *itype == 5 
02543                 && ith == 8) {
02544             scale = acorr;
02545             goto L99;
02546         }
02547 
02548 /* --- Exponential function for all others -------------------------- 
02549 */
02550 
02551         scale = acorr * (1. - exp(bcorr - *ptin / ccorr));
02552         ptinter = *ptin / scale;
02553         scale = acorr * (1. - exp(bcorr - ptinter / ccorr));
02554     }
02555 /* ================================================================ */
02556 /*                 with track */
02557 /* ================================================================ */
02558     if (*itra == 1) {
02559 
02560 /* --- Constante for data 98 e-p  : if,of,cb3,cb2,cb1,bbe */
02561 /*               for data 99 e-p  : bbe */
02562 /*               for nc mc e+p    : cb3,bbe */
02563         if (*itype == 1 && (ith == 5 || ith == 7 || ith <= 8 || ith == 2 || 
02564                 ith == 3 || ith == 6) || *itype == 2 && ith == 8 || *itype == 
02565                 5 && (ith == 5 || ith == 8)) {
02566             scale = acorr;
02567             goto L99;
02568         }
02569 
02570 /* --- Special function for nc mc e-p bbe */
02571 
02572         if (*itype == 3 && ith == 8) {
02573             scale = acorr / *ptin + ccorr;
02574             ptinter = *ptin / scale;
02575             scale = acorr / ptinter + ccorr;
02576             goto L99;
02577         }
02578 
02579 /* --- Exponential function for all others -------------------------- 
02580 */
02581 
02582         scale = acorr * (1. - exp(bcorr - *ptin / ccorr));
02583         ptinter = *ptin / scale;
02584         scale = acorr * (1. - exp(bcorr - ptinter / ccorr));
02585     }
02586 /* ================================================================ */
02587 L99:
02588     ret_val = *qvar / scale;
02589     goto L100;
02590 L101:
02591     ret_val = *qvar;
02592 L100:
02593     return ret_val;
02594 } /* qhadcor_98_00__ */
02595 
02596 
02597 
02598  
02599 Bool_t TTools::ReadNoiseRuns(Char_t *InputFile)
02600 {
02601 // Read in noise runs
02602 
02603   // Def file pointer
02604   FILE *fpIn;
02605 
02606   // Def char. to read
02607   Char_t Ch; 
02608   Int_t cCounter = 0;
02609   Int_t EvNumber,RnNumber;
02610   Int_t MAXNOISEEVTS=1497;
02611   Int_t NoiseRuns[MAXNOISEEVTS];   // Noise Runs
02612   Int_t NoiseEvents[MAXNOISEEVTS]; // Noise events 
02613 
02614   // Check if input file is existing
02615   if ((fpIn = fopen(InputFile,"r")) == NULL) {
02616     printf("File %s not found\n",InputFile);
02617     return(kFALSE);
02618   }
02619 
02620   // Loop over all input numbers
02621   while ((Ch = fscanf(fpIn,"%d %d",&RnNumber,&EvNumber)) != EOF) {
02622 
02623     // For each line fill in event.NoiseRuns[]/event.NoiseEvents
02624     NoiseRuns[cCounter] = RnNumber;
02625     NoiseEvents[cCounter] = EvNumber; 
02626 
02627     // Increase counter
02628     if (cCounter < MAXNOISEEVTS)
02629       cCounter++;
02630     else {
02631       printf("ARRAY of NoiseRuns out of bounds => Please check validity\n");
02632       fclose(fpIn);
02633       return(kFALSE);
02634     }
02635   }
02636   // Close file
02637   fclose(fpIn);
02638 
02639   return(kTRUE);
02640 
02641 }
02642 
02643 
02644 Int_t TTools::OctogonIntersection(TVector3 ClusStart,Float_t Theta, Float_t Phi,
02645         Float_t RCurv,Float_t Zmin,Float_t Zmax,Float_t RBarr,TVector3 &XOut,Float_t &PhiOut)
02646 {
02647 // Calculer intersection entre la trace et le calorimetre 
02648 Int_t IFlag=0;
02649 
02650 Float_t Ph=0,DPh=0;
02651 Float_t L8=0;
02652 Float_t XOUT[2],X[2];
02653 
02654 Float_t Dz=0;
02655 Int_t ifl;
02656 
02657 Float_t CosU;
02658 Float_t CosV;
02659 Float_t SinU;
02660 Float_t Psi;
02661 Float_t ZDelta;
02662 Float_t RR;
02663 Int_t N2Pi;
02664 
02665 
02666 //--- Outer radius of octogon
02667  Float_t ROctog=RBarr/cos(TMath::Pi()/8.);
02668 
02669 //--- Start poInt_tshould be inside octogone
02670 if(ClusStart.Z()<=Zmin|| ClusStart.Z()>=Zmax) return IFlag;
02671 Float_t R=sqrt(pow(ClusStart.X(),2)+pow(ClusStart.Y(),2));
02672 if(R>=RBarr) {
02673         Ph=TMath::ATan2(ClusStart.Y(),ClusStart.X());
02674         if(Ph<0) Ph+=2.*TMath::Pi();
02675         L8=Ph/(TMath::Pi()/4.);
02676         DPh=Ph-L8*TMath::Pi()/4.;
02677         DPh=fabs(DPh-TMath::Pi()/8.);
02678         if(R*cos(DPh)>=RBarr) return IFlag;
02679 }
02680 
02681 //--- curvature radius
02682  Float_t RC=fabs(RCurv);
02683 
02684 //--- sign of curvature defined to be 1 if phi increases with particle movement (otherwise -1.)
02685  Int_t IC=(Int_t) TMath::Sign(1,(Int_t)RCurv);
02686 
02687  Float_t CosT=cos(Theta);
02688  Float_t SinT=sin(Theta);
02689 
02690 //--- unit vector from center of helix circle to start point
02691  Float_t UC[2],XC[2],VC[2],XX[2];
02692  UC[0]=cos(Phi-IC*TMath::Pi()/2.);
02693  UC[1]=sin(Phi-IC*TMath::Pi()/2.);
02694 //--- center of helix circle
02695  XC[0]=ClusStart.X()-RC*UC[0];
02696  XC[1]=ClusStart.Y()-RC*UC[1];
02697 //--- unit vector in direction of particle at start point
02698  VC[0]=cos(Phi);
02699  VC[1]=sin(Phi);
02700 
02701  if(R+2*RC<RBarr) goto jump100;
02702  if(fabs(SinT)<0.001) goto jump100;
02703 
02704 //--- intersection with octogon in XY plane
02705  X[0]=ClusStart.X();
02706  X[1]=ClusStart.Y();
02707  OctgXY(X,Phi,IC,RC,ROctog,XOUT,ifl);
02708  XOut.SetX(XOUT[0]);
02709  XOut.SetY(XOUT[1]);
02710 //  printf("Bad flag ... %d\n",ifl);
02711  if(ifl!=1) goto jump100;
02712 //--- get turn angle of a particle (psi)
02713  XX[0]=XOut.X()-XC[0];
02714  XX[1]=XOut.Y()-XC[1];
02715  RR=sqrt(XX[0]*XX[0]+X[1]*XX[1]);
02716  XX[0]/=RR;
02717  XX[1]/=RR;
02718  CosU=UC[0]*XX[0]+UC[1]*XX[1];
02719  CosV=VC[0]*XX[0]+VC[1]*XX[1];
02720  SinU=CosV;
02721  Psi=TMath::ATan2(SinU,CosU);
02722 //--- Range 0 -2*pi
02723  if(Psi<0) Psi+=2*TMath::Pi();
02724 
02725 //--- distance to outer z plane
02726  if(CosT>=0) Dz=Zmax-ClusStart.Z();
02727  else Dz=ClusStart.Z()-Zmin;
02728 
02729 //--- check where intersection occurs
02730  ZDelta=RC*Psi*CosT/SinT;
02731  if(fabs(ZDelta)>=Dz) goto jump100;
02732  XOut.SetZ(ClusStart.Z()+ZDelta);
02733  IFlag=1;
02734  goto jump200;
02735 
02736 
02737 //--- intersection with z planes
02738 jump100:
02739  if(CosT>0.0001) XOut.SetZ(Zmax);
02740  else if(CosT<-0.0001) XOut.SetZ(Zmin);
02741  else return IFlag;
02742 
02743 //--- get turn angle of a particle
02744  if(RC>0.0001) {
02745         Dz=XOut.Z()-ClusStart.Z();
02746         Psi=Dz*SinT/(RC*CosT);
02747         Psi=fabs(Psi);
02748         N2Pi=(Int_t) (Psi/(2*TMath::Pi()));
02749         Psi=Psi-N2Pi*2*TMath::Pi();
02750  }else{
02751        Psi=0.;
02752  }
02753 
02754 //--- leaving poInt_tXY plane
02755  XOut.SetX(XC[0]+RC*(cos(Psi)*UC[0]+sin(Psi)*VC[0]));
02756  XOut.SetY(XC[1]+RC*(cos(Psi)*UC[1]+sin(Psi)*VC[1]));
02757 
02758  IFlag=2;
02759 
02760 jump200:
02761 //--- range 0-4*Pi
02762  PhiOut=Phi+IC*Psi+(1-IC)*TMath::Pi();
02763 //--- range 0-2*Pi
02764  if(PhiOut>2*TMath::Pi()) PhiOut-=2*TMath::Pi();
02765 
02766 
02767 return IFlag;
02768 }
02769 
02770 
02771 
02772 void TTools::OctgXY(Float_t *xl,Float_t phi,Int_t ic,Float_t rc,
02773                                 Float_t roctog,Float_t *xout,Int_t &iflag)
02774 {
02775 // Calc. X,Y
02776 
02777     Int_t i1, i2;
02778 
02779 
02780     /* Local variables */
02781     Float_t phil;
02782     Int_t l;
02783     Float_t r;
02784     Int_t l1, l2;
02785     Float_t xylin[2];
02786     Float_t philin, xycirc[2];
02787     Int_t ll1, ll2;
02788     Float_t xy1[2], xy2[2];
02789     Int_t ifl = 0;
02790     Float_t phi1, phi2;
02791 
02792 /* *********************************************************************** */
02793 /* PURPOSE: Intersection of a particle with an octogon in xy plane      * */
02794 /*                                                                      * */
02795 /* INPUT:   XL(2)  - start poInt_tinside octogon                         * */
02796 /*          PHI    - gives direction of a particle at start poInt_t(rad.)* */
02797 /*          IC     - sign of curvature defined to be 1 if phi increases * */
02798 /*                   with particle movement (otherwise -1.)             * */
02799 /*          RC     - curvature radius                             (cm)  * */
02800 /*          ROCTOG - outer radius of octogon                            * */
02801 /*                                                                      * */
02802 /* OUTPUT:  XOUT(2)  - intersection (leaving) poInt_t                    * */
02803 /*          IFLAG  = 1 if particle intersects octogon, otherwise =0     * */
02804 /*                                                                      * */
02805 /* AUTHOR:  V. Shekelyan                                at 14.11.91     * */
02806 /* *********************************************************************** */
02807 
02808     iflag = 0;
02809 /* find intersection of a line defined by XL(2) and PHI with an outer */
02810 /* circle of octogon */
02811     xycirc[0] = 0.;
02812     xycirc[1] = 0.;
02813     //    printf("xl[0]=%f xl[1]=%f phi = %f circ[0] = %f circ[1] = %f r = %f xy1[0] = %f xy1[1] = %f xy2[0] = %f xy2[1] = %f ifl = %d\n",xl[0],xl[1],phi,xycirc[0],xycirc[1],roctog,xy1[0],xy1[1],xy2[0],xy2[1],ifl);
02814     LinCir(xl, phi, xycirc, roctog, xy1, xy2, ifl);
02815     if (ifl != 1) {
02816 //     printf("First return \n");
02817     return;
02818     }
02819 //     printf("test octxy ....... \n");
02820 
02821 /* octant numbers of intersection of straight line from X with octogon */
02822 /* ----- in particle direction */
02823     phi1 = TMath::ATan2(xy2[1], xy2[0]);
02824     if (phi1 < 0.) phi1 += 2*TMath::Pi();
02825     ll1 = (Int_t) (phi1 / (TMath::Pi()/4));
02826     if (ll1 > 7) ll1 = 7;
02827 
02828 /* ----- in opposite direction */
02829     phi2 = TMath::ATan2(xy1[1], xy1[0]);
02830     if (phi2 < 0.) phi2 += 2*TMath::Pi();
02831     ll2 = (Int_t) (phi2 / (TMath::Pi()/4));
02832     if (ll2 > 7) ll2 = 7;
02833 
02834 /* loop boundaries over sides of octogon from LL1 to LL2 */
02835 /* in direction defined by a sign of curvature */
02836     l1 = ll1;
02837     l2 = ll2;
02838     if (ic > 0) {
02839         if (l2 < l1) {
02840             l2 = ll2 + 8;
02841         }
02842     } else {
02843         if (l2 > l1) {
02844             l1 = ll1 + 8;
02845         }
02846     }
02847 /* center of particle circle */
02848     xycirc[0] = xl[0] + rc * cos(phi + ic * TMath::Pi()/2);
02849     xycirc[1] = xl[1] + rc * sin(phi + ic * TMath::Pi()/2);
02850 /* try sides of octogon (first acceptable intersection is a solution) */
02851     i1 = l2;
02852     i2 = ic;
02853 //     printf("l1=%d l2=%d %d %d\n",l1,l2,ll1,ll2);
02854     for (l = l1; i2 < 0 ? l >= i1 : l <= i1; l += i2) {
02855 //   for (l = l1; l<=l2; l += ic) {
02856         phil = l * TMath::Pi()/4;
02857 /* ------ define some poInt_tat octogon side */
02858         xylin[0] = roctog * cos(phil);
02859         xylin[1] = roctog * sin(phil);
02860 /* ------ define direction of a side line */
02861         philin = phil + ic * TMath::Pi()/2 + TMath::Pi()/8;
02862         LinCir(xylin, philin, xycirc, rc, xout, xy2, ifl);
02863 //      printf("LinCir : xout(%f,%f) ifl=%d\n",xout[0],xout[1],ifl);
02864         if (ifl != 1) {
02865 //      printf("Badflag LinCir \n");
02866         continue;
02867         }
02868 /* ------ check first intersection along side line direction */
02869 /*        (with care about accuracy of calculations) */
02870         r = sqrt(xout[0] * xout[0] + xout[1] * xout[1]);
02871 //      printf("%f roctog= %f \n",r,roctog);
02872         if (r < roctog + 0.001) goto L200;
02873     }
02874     return;
02875 
02876 L200:
02877     iflag = 1;
02878     return;
02879 }
02880 
02881 
02882 void TTools::LinCir(Float_t *xl,Float_t phi,Float_t *xc,Float_t rc,
02883                         Float_t *xy1, Float_t *xy2, Int_t &iflag)
02884 {
02885  Float_t cosp, sinp, a, b;
02886  Int_t isign;
02887  Float_t aa, bb, cc, det;
02888  Int_t iax1, iax2;
02889 
02890 /* *********************************************************************** */
02891 /* PURPOSE: Intersection of of a line with a circle in xy plane         * */
02892 /*          equations:      (y-yc)**2+(x-xc)**2=rc**2                   * */
02893 /*                          ax+by+c=0.                                  * */
02894 /* INPUT:   XL(2),PHI - poInt_tat line and direction given by phi        * */
02895 /*          XC(2),RC  - center of circle and radius                     * */
02896 /*                                                                      * */
02897 /* OUTPUT:  XY1(2),XY2(2) - intersection points (first and second one)  * */
02898 /*                          ordered along line direction                * */
02899 /*          IFLAG = 1 if there is intersection, otherwise =0            * */
02900 /*                                                                      * */
02901 /* AUTHOR:  V. Shekelyan                                at 14.11.91     * */
02902 /* *********************************************************************** */
02903 
02904     iflag = 0;
02905     sinp = sin(phi);
02906     cosp = cos(phi);
02907 /* define equation for a line */
02908     isign = 1;
02909     if (fabs(cosp) > fabs(sinp)) {
02910 /* ------ y=ax+b */
02911         iax1 = 1;
02912         iax2 = 2;
02913         a = sinp / cosp;
02914         if (cosp < 0.) isign = -1;
02915     } else {
02916 /* ------ x=ay+b */
02917         iax1 = 2;
02918         iax2 = 1;
02919         a = cosp / sinp;
02920         if (sinp < 0.) isign = -1;
02921     }
02922     b = xl[iax2-1] - a * xl[iax1-1];
02923 /* solve equation aa*x(IAX1)**2+2.*bb*x(IAX1)+cc=0. */
02924 /* which gives intersection points */
02925     aa = a * a + 1.;
02926     bb = a * (b - xc[iax2-1]) - xc[iax1-1];
02927     cc = (b -xc[iax2-1])*(b-xc[iax2-1])+xc[iax1-1]*xc[iax1-1]-rc*rc;
02928     det = bb*bb-aa*cc;
02929     if (det < 0.) return ;
02930 
02931     det = sqrt(det);
02932 /* get intersection points ordered along line direction */
02933     xy1[iax1-1] = (-bb - isign * det) / aa;
02934     xy2[iax1-1] = (-bb + isign * det) / aa;
02935     xy1[iax2-1] = a * xy1[iax1-1] + b;
02936     xy2[iax2-1] = a * xy2[iax1-1] + b;
02937 
02938     iflag = 1;
02939     return ;
02940 }
02941 
02942 
02943 
02944 
02945 void TTools::CalcExtraPolTrack(TVector3 XStart,H1PartSelTrack *Track,Float_t &XOut,Float_t &YOut,Float_t &ZOut,Float_t &ThTrOut,Float_t &PhTrOut)
02946 {
02947 // Calculate track extrapolation into calo using octogon function
02948 // Variables: - Track     => Track object to consider
02949 //            - XOut      => X position extrapolated
02950 //            - PhTrOut   => Extrapolated phi of track
02951 
02952 //--- octogon extrapolation test
02953    TVector3 VecOut(0,0,0);
02954 // 
02955 //    // Get vertex of event
02956 //    TVector3 XStart(0.,0.,0.);
02957 //    if(Vertex[2] != -999999) {
02958 //      XStart.SetX(Vertex[0]);
02959 //      XStart.SetY(Vertex[1]);
02960 //      XStart.SetZ(Vertex[2]);
02961 //    }
02962 
02963    // Get phi of track
02964    TVector3 TrackEndPosition(0,0,0);
02965    Float_t PhiOut = 0.0;
02966    Float_t PhiTrk=Track->GetPhi();
02967    if(PhiTrk<0) PhiTrk+=2*TMath::Pi();
02968 
02969    // Calc curvature of track with nominal field (CONST !!!!!)
02970    Float_t RCurv= -1.0*Track->GetCharge()
02971         /((1/Track->GetPt())*BFIELDCONST * BFIELDNOM);
02972 
02973    // Calc intersection with octogon (if any)
02974    //   printf("x(z)=%f th=%f ph=%f r=%f z=%f z2=%f r=%f\n",XStart.Z(),Track->GetTheta(),PhiTrk,RCurv,zEDBBE,zIF1,rCalo);
02975       Int_t iflag=OctogonIntersection(XStart,Track->GetTheta(),PhiTrk,RCurv,zEDBBE,zIF1,rCalo,VecOut,PhiOut);
02976 
02977 //  printf("OctoExt : (%f %f %f) flag=%d \n",XOut.X(),XOut.Y(),XOut.Z(),iflag);
02978 
02979   if(VecOut.Z()<=zEDBBE) {
02980         iflag=OctogonIntersection(XStart,Track->GetTheta(),PhiTrk,RCurv,zBACKDET,zIF1,rCalo,VecOut,PhiOut);
02981 //   printf("OctoExt2 : (%f %f %f) flag=%d \n",VecOut.X(),VecOut.Y(),VecOut.Z(),iflag);
02982   }
02983 //  printf("CylinderExt : (%f %f %f) \n",TrackEndPosition.X(),TrackEndPosition.Y(),TrackEndPosition.Z());
02984 
02985 
02986   // Final values
02987   TrackEndPosition=VecOut;
02988 //  Double_t trackPhi   = TrackEndPosition.Phi(); 
02989   XOut = VecOut.X();  
02990   YOut = VecOut.Y();  
02991   ZOut = VecOut.Z();  
02992   PhTrOut = PhiOut;
02993 }
02994 
02995 
02996 

Generated on Thu Jul 28 11:48:53 2005 for SFHMarana by doxygen 1.3.2