]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Changes for #95136: CPass0/CPass1 porting request for STEER and ANALISYS directory
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Jun 2012 13:47:07 +0000 (13:47 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Jun 2012 13:47:07 +0000 (13:47 +0000)
STEER/ESD/AliESDHeader.cxx
STEER/ESD/AliESDHeader.h
STEER/STEER/AliRelAlignerKalman.cxx
STEER/STEER/AliRelAlignerKalman.h
STEER/STEERBase/TTreeStream.cxx
STEER/STEERBase/TTreeStream.h

index 35f65c1e961643a69f856225150cb39390667366..23c48c33bbb772902b6689e56de78fc5c4ed4d11 100644 (file)
@@ -304,3 +304,166 @@ Bool_t AliESDHeader::IsTriggerInputFired(const char *name) const
   else if (fL2TriggerInputs & (1 << (inputIndex-48))) return kTRUE;
   else return kFALSE;
 }
+//________________________________________________________________________________
+Int_t  AliESDHeader::GetTriggerIREntries(Int_t int1, Int_t int2, Float_t deltaTime) const
+{
+  // returns number of IR-s within time window deltaTime
+  // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit
+  //
+  const AliTriggerIR *IR;
+  // triggered event 
+  Int_t nIR = GetTriggerIREntries();
+  UInt_t orbit1 = GetOrbitNumber();
+  const Double_t ot=0.0889218; //orbit time msec
+  Float_t timediff; // time difference between orbits (msec)
+  //
+  Int_t nofIR;
+  nofIR=0;
+  // loop over IR-s
+    for(Int_t i=0;i<nIR;i++){//1
+      IR=GetTriggerIR(i);
+      //
+      UInt_t orbit2 = IR->GetOrbit();
+      timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot : 
+       (Float_t)((16777215-orbit1+orbit2))*ot;
+      if (timediff>deltaTime) continue; //timediff outside time window
+      if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window
+       nofIR++;
+        continue;
+      }
+      // now check if int1, int2 bits are set
+      UInt_t nw = IR->GetNWord();
+      Bool_t *bint1 = IR->GetInt1s();
+      Bool_t *bint2 = IR->GetInt2s();
+      //
+      Int_t flag1,flag2;
+      flag1=0;
+      flag2=0;
+      for(UInt_t j=0;j<nw;j++){//2
+       if(bint1[j]) flag1=1; // at least one int1 set
+       if(bint2[j]) flag2=1; //  at least one int2 set
+        //printf("IR %d, bint1 %d, bint2 %d\n",i,bint1[j],bint2[j]);
+      }//2
+      // checking combinations
+      //
+      
+      if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1         
+          nofIR++;
+          continue;       
+      }
+      if(int1 == -1){// ignore int1
+        if(flag2&int2){// int2=1
+          nofIR++;
+          continue;
+       }
+        else if (!flag2&!int2){ //int2=0 
+          nofIR++;
+          continue;          
+       }
+      }
+      
+      if(int2 ==-1){//ignore int2
+        if(flag1&int1){//int1=1
+          nofIR++;
+          continue;  
+       }
+        else if(!flag1&!int1){ //int1=0
+          nofIR++;
+          continue;  
+       }
+      }
+      
+      if((flag1*int1)&!flag2&!int2){// int1=1, int2=0
+          nofIR++;
+          continue;  
+      }
+      
+      if((int2*flag2)&!int1&!flag1){// int1=0, int2=1
+          nofIR++;
+          continue;  
+      } 
+         
+      
+
+    }//1
+  
+    return nofIR;
+}
+//__________________________________________________________________________
+TObjArray AliESDHeader::GetIRArray(Int_t int1, Int_t int2, Float_t deltaTime) const
+{
+  //
+  // returns an array of IR-s within time window deltaTime
+  // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit
+  //
+  const AliTriggerIR *IR;
+  TObjArray arr;
+  // triggered event 
+  Int_t nIR = GetTriggerIREntries();
+  UInt_t orbit1 = GetOrbitNumber();
+  const Double_t ot=0.0889218; //orbit time msec
+  Float_t timediff; // time difference between orbits (msec)
+  //
+  // loop over IR-s
+    for(Int_t i=0;i<nIR;i++){//1
+      IR=GetTriggerIR(i);
+      //
+      UInt_t orbit2 = IR->GetOrbit();
+      timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot : 
+       (Float_t)((16777215-orbit1+orbit2))*ot;
+      if (timediff>deltaTime) continue; //timediff outside time window
+      if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window
+       arr.Add((AliTriggerIR*)IR); //add this IR
+        continue;
+      }
+      // now check if int1, int2 bits are set
+      UInt_t nw = IR->GetNWord();
+      Bool_t *bint1 = IR->GetInt1s();
+      Bool_t *bint2 = IR->GetInt2s();
+      //
+      Int_t flag1,flag2;
+      flag1=0;
+      flag2=0;
+      for(UInt_t j=0;j<nw;j++){//2
+       if(bint1[j]) flag1=1; // at least one int1 set
+       if(bint2[j]) flag2=1; //  at least one int2 set
+      }//2
+      // checking combinations
+      //
+      if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1
+         arr.Add((AliTriggerIR*)IR); //add this IR
+          continue;       
+      }
+      if(int1 == -1){// ignore int1
+        if(flag2&int2){// int2=1
+         arr.Add((AliTriggerIR*)IR); //add this IR
+          continue;
+       }
+        else if (!flag2&!int2){ //int2=0 
+          arr.Add((AliTriggerIR*)IR); //add this IR
+          continue;          
+       }
+      }
+      if(int2 ==-1){//ignore int2
+        if(flag1&int1){//int1=1
+         arr.Add((AliTriggerIR*)IR); //add this IR
+          continue;  
+       }
+        else if(!flag1&!int1){ //int1=0
+         arr.Add((AliTriggerIR*)IR); //add this IR
+          continue;  
+       }
+      }
+      if ((flag1*int1)&!flag2&!int2){// int1=1, int2=0
+         arr.Add((AliTriggerIR*)IR); //add this IR
+          continue;  
+      }
+      if ((int2*flag2)&!int1&!flag1){// int1=0, int2=1
+         arr.Add((AliTriggerIR*)IR); //add this IR
+          continue;  
+      }      
+
+    }//1
+  
+  return arr;
+}
index eb280cfc873700ed726eeb23222348cd66efdd14..3cd0410d099ecac85fbc4f02306bc996a372e695 100644 (file)
@@ -73,7 +73,9 @@ public:
   UShort_t  GetBunchCrossNumber() const {return fBunchCrossNumber;}
   UInt_t    GetPeriodNumber() const {return fPeriodNumber;}
   UChar_t   GetTriggerCluster() const {return fTriggerCluster;}
-
+  Int_t     GetTriggerIREntries() const { return fIRBufferArray.GetEntriesFast();};
+  Int_t     GetTriggerIREntries(Int_t int1, Int_t int2, Float_t deltaTime = 180.) const;
+  TObjArray GetIRArray(Int_t int1, Int_t int2, Float_t deltaTime = 180.) const;
   void      Reset();
   void      Print(const Option_t *opt=0) const;
 
index e4222fbdad6cfa5804d376ec1227affdfe6e9ff4..32c4d0b6d32ce19e9dc4f0182e55c4c38892417b 100644 (file)
@@ -1558,3 +1558,23 @@ void AliRelAlignerKalman::SetRejectOutliersSigma2Median(const Bool_t set )
     fRejectOutliersSigma2Median = kFALSE;
   }//if
 }
+
+
+Int_t AliRelAlignerKalman::CheckCovariance(){
+  //
+  // check covariance matrix
+  // Return values:
+  //         -1    - everything OK
+  //          >=0  - index of "corrupted" element in the covariance matrix
+  TMatrixDSym& mat =(*fPXcov);
+  for (Int_t irow=0; irow<9; irow++){
+    if (mat(irow,irow)<=0.) return  irow*9;
+    for (Int_t icol=0; icol<irow; icol++){
+      Double_t corel = mat(irow,irow)*mat(icol,icol);
+      if (corel<=0.) return irow*9+icol;
+      corel=mat(irow,icol)/TMath::Sqrt(corel);
+      if (TMath::Abs(corel)>=1.) return irow*9+icol;
+    }  
+  }
+  return -1;
+}
index 3871532f181de75fa490a1263425b588d1618996..4df9ac36ab685bce2527156b6c670bdccc914df4 100644 (file)
@@ -84,6 +84,7 @@ public:
     void PrintCorrelationMatrix();
     //void PrintCovarianceCorrection();
     void PrintSystemMatrix();
+  Int_t CheckCovariance(); // check covariance matrix
     void Reset();
     void ResetCovariance( const Double_t number=0. );
     void ResetTPCparamsCovariance( const Double_t number=0. );
index 6149ce5c0b30aa6a004bfa04fe7d80258cc158e6..acd1487ba1db95913a6c29a7e65ee57ec8ddedfd 100644 (file)
@@ -139,18 +139,20 @@ void TTreeSRedirector::Test()
 }
 
 
-TTreeSRedirector::TTreeSRedirector(const char *fname) :
-  fFile(new TFile(fname,"recreate")),
+TTreeSRedirector::TTreeSRedirector(const char *fname,const char * option) :
+  fFile(new TFile(fname,option)),
   fDataLayouts(0)
 {
   //
   // Constructor
   //
   if (!fFile){
-    fFile = new TFile(fname,"new");
+    fFile = new TFile(fname,option);
   }
 }
 
+
+
 TTreeSRedirector::~TTreeSRedirector()
 {
   //
@@ -171,6 +173,18 @@ void TTreeSRedirector::StoreObject(TObject* object){
 }
 
 
+void  TTreeSRedirector::SetFile(TFile *sfile){
+  //
+  // Set the external file 
+  // In case other file already attached old file is closed before
+  // Redirector will be the owner of file ?
+  if (fFile) {
+    fFile->Close();
+    delete fFile;
+  }
+  fFile=sfile;
+}
+
 
 TTreeStream  & TTreeSRedirector::operator<<(Int_t id)
 {
index 7d9a6a25d685dfcd21c8e06c3c8b2f444a8533e1..6e4538b5a23c7a636aee2ca92dbd9ae390862b37 100644 (file)
@@ -84,7 +84,7 @@ public:
 
 class TTreeSRedirector: public TObject { 
 public:
-  TTreeSRedirector(const char *fname);
+  TTreeSRedirector(const char *fname, const char * option="new");
   virtual ~TTreeSRedirector();
   void Close();
   static void Test();
@@ -92,6 +92,7 @@ public:
   TFile * GetFile() {return fFile;};
   virtual   TTreeStream  &operator<<(Int_t id);
   virtual   TTreeStream  &operator<<(const char *name);
+  void      SetFile(TFile *sfile); 
  private:
 
   TTreeSRedirector(const TTreeSRedirector & tsr);