]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDEvent.cxx
Fixes to remove warnings
[u/mrichter/AliRoot.git] / STEER / AliESDEvent.cxx
index 7c9996e727f0ef1f4587e9754dfd78ae4623f573..f29fe1640a9caa6eaeaf71754b859efeac2e8bf9 100644 (file)
@@ -35,6 +35,8 @@
 #include "TList.h"
 #include "TRefArray.h"
 #include <TNamed.h>
+#include <TROOT.h>
+#include <TInterpreter.h>
 
 #include "AliESDEvent.h"
 #include "AliESDfriend.h"
@@ -49,6 +51,7 @@
 #include "AliESDPmdTrack.h"
 #include "AliESDTrdTrack.h"
 #include "AliESDVertex.h"
+#include "AliVertexerTracks.h"
 #include "AliESDcascade.h"
 #include "AliESDkink.h"
 #include "AliESDtrack.h"
@@ -62,6 +65,8 @@
 #include "AliRawDataErrorLog.h"
 #include "AliLog.h"
 #include "AliESDACORDE.h"
+#include "AliESDHLTDecision.h"
+
 ClassImp(AliESDEvent)
 
 
@@ -164,8 +169,8 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   fEMCALCells(new AliESDCaloCells(*esd.fEMCALCells)),
   fPHOSCells(new AliESDCaloCells(*esd.fPHOSCells)),
   fErrorLogs(new TClonesArray(*esd.fErrorLogs)),
-  fESDOld(new AliESD(*esd.fESDOld)),
-  fESDFriendOld(new AliESDfriend(*esd.fESDFriendOld)),
+  fESDOld(esd.fESDOld ? new AliESD(*esd.fESDOld) : 0),
+  fESDFriendOld(esd.fESDFriendOld ? new AliESDfriend(*esd.fESDFriendOld) : 0),
   fConnected(esd.fConnected),
   fUseOwnList(esd.fUseOwnList),
   fEMCALClusters(esd.fEMCALClusters), 
@@ -475,18 +480,20 @@ void AliESDEvent::Print(Option_t *) const
         GetRunNumber(),
         GetTriggerMask(),
         GetMagneticField() );
-  printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
+  if (fPrimaryVertex)
+    printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
           fPrimaryVertex->GetXv(), fPrimaryVertex->GetXRes(),
           fPrimaryVertex->GetYv(), fPrimaryVertex->GetYRes(),
           fPrimaryVertex->GetZv(), fPrimaryVertex->GetZRes());
-    printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
-          GetDiamondX(),GetDiamondY());
+  printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
+        GetDiamondX(),GetDiamondY());
+  if(fSPDMult)
     printf("SPD Multiplicity. Number of tracklets %d \n",
            fSPDMult->GetNumberOfTracklets());
   printf("Number of pileup primary vertices reconstructed with SPD %d\n", 
-        GetNumberOfPileupVerticesSPD());
+        GetNumberOfPileupVerticesSPD());
   printf("Number of pileup primary vertices reconstructed using the tracks %d\n",
-        GetNumberOfPileupVerticesTracks());
+        GetNumberOfPileupVerticesTracks());
   printf("Number of tracks: \n");
   printf("                 charged   %d\n", GetNumberOfTracks());
   printf("                 muon      %d\n", GetNumberOfMuonTracks());
@@ -504,6 +511,9 @@ void AliESDEvent::Print(Option_t *) const
   printf("                 emcal     %d\n", GetNumberOfEMCALClusters());
   printf("                 FMD       %s\n", (fESDFMD ? "yes" : "no"));
   printf("                 VZERO     %s\n", (fESDVZERO ? "yes" : "no"));
+  TObject* pHLTDecision=GetHLTTriggerDecision();
+  printf("HLT trigger decision: %s\n", pHLTDecision?pHLTDecision->GetOption():"not available");
+  if (pHLTDecision) pHLTDecision->Print("compact");
 
   return;
 }
@@ -993,6 +1003,31 @@ const AliESDVertex * AliESDEvent::GetPrimaryVertex() const
   return fSPDVertex;
 }
 
+AliESDVertex * AliESDEvent::PrimaryVertexTracksUnconstrained() const 
+{
+  //
+  // Removes diamond constraint from fPrimaryVertex (reconstructed with tracks)
+  // Returns a AliESDVertex which has to be deleted by the user
+  //
+  if(!fPrimaryVertex) {
+    AliWarning("No primary vertex from tracks available.");
+    return 0;
+  }
+  if(!fPrimaryVertex->GetStatus()) {
+    AliWarning("No primary vertex from tracks available.");
+    return 0;
+  }
+
+  AliVertexerTracks vertexer(GetMagneticField());
+  Float_t diamondxyz[3]={(Float_t)GetDiamondX(),(Float_t)GetDiamondY(),0.};
+  Float_t diamondcovxy[3]; GetDiamondCovXY(diamondcovxy);
+  Float_t diamondcov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,7.};
+  AliESDVertex *vertex = 
+    (AliESDVertex*)vertexer.RemoveConstraintFromVertex(fPrimaryVertex,diamondxyz,diamondcov);
+
+  return vertex;
+}
+
 void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) 
 {
   // Set the SPD Multiplicity
@@ -1301,7 +1336,7 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
     if(fESDFriendOld)AddObject(fESDFriendOld);
     // we are not owner of the list objects 
     // must not delete it
-    fESDObjects->SetOwner(kFALSE);
+    fESDObjects->SetOwner(kTRUE);
     fESDObjects->SetName("ESDObjectsConnectedToTree");
     tree->GetUserInfo()->Add(fESDObjects);
     fConnected = true;
@@ -1316,6 +1351,7 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
   esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent");
   if(esdEvent){   
       // Check if already connected to tree
+    esdEvent->Reset();
     TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
 
     
@@ -1333,12 +1369,10 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
     if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete();
     
     if(!fUseOwnList){
-      delete fESDObjects;
-      fESDObjects = 0;
       // create a new TList from the UserInfo TList... 
       // copy constructor does not work...
       fESDObjects = (TList*)(esdEvent->GetList()->Clone());
-      fESDObjects->SetOwner(kFALSE);
+      fESDObjects->SetOwner(kTRUE);
     }
     else if ( fESDObjects->GetEntries()==0){
       // at least create the std content if we want to read to our list
@@ -1384,13 +1418,14 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
     GetStdContent();
     // when reading back we are not owner of the list 
     // must not delete it
-    fESDObjects->SetOwner(kFALSE);
+    fESDObjects->SetOwner(kTRUE);
     fESDObjects->SetName("ESDObjectsConnectedToTree");
     // we are not owner of the list objects 
     // must not delete it
     tree->GetUserInfo()->Add(fESDObjects);
+    tree->GetUserInfo()->SetOwner(kFALSE);
     fConnected = true;
-  }// no esdEvent
+  }// no esdEvent -->
   else {
     // we can't get the list from the user data, create standard content
     // and set it by hand (no ESDfriend at the moment
@@ -1413,7 +1448,7 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
     GetStdContent();
     // when reading back we are not owner of the list 
     // must not delete it
-    fESDObjects->SetOwner(kFALSE);
+    fESDObjects->SetOwner(kTRUE);
   }
 }
 
@@ -1512,6 +1547,37 @@ void AliESDEvent::CopyFromOldESD()
   }// if fesdold
 }
 
+Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const
+{
+  // Check if the event satisfies the trigger
+  // selection expression trigExpr.
+  // trigExpr can be any logical expression
+  // of the trigger classes defined in AliESDRun
+  // In case of wrong syntax return kTRUE.
+
+  TString expr(trigExpr);
+  if (expr.IsNull()) return kTRUE;
+
+  ULong64_t mask = GetTriggerMask();
+  for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses; itrig++) {
+    if (mask & (1ull << itrig)) {
+      expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"1");
+    }
+    else {
+      expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"0");
+    }
+  }
+
+  Int_t error;
+  if ((gROOT->ProcessLineFast(expr.Data(),&error) == 0) &&
+      (error == TInterpreter::kNoError)) {
+    return kFALSE;
+  }
+
+  return kTRUE;
+
+}
+
 TObject*  AliESDEvent::GetHLTTriggerDecision() const
 {
   // get the HLT trigger decission object
@@ -1554,4 +1620,64 @@ Bool_t    AliESDEvent::IsHLTTriggerFired(const char* name) const
   return kTRUE;
 }
 
+Bool_t  AliESDEvent::IsPileupFromSPD(Int_t ncont, Double_t distz, Double_t nSigmaDeltaZ, Double_t nSigmaXY, Int_t option) const {
+  //
+  // This function checks if there was a pile up
+  // reconstructed with SPD
+  //
+  Double_t diamx= GetDiamondX();
+  Double_t diamsigma2x= GetSigma2DiamondX();
+  Double_t diamy= GetDiamondY();
+  Double_t diamsigma2y= GetSigma2DiamondY();
+  
+  Double_t sigmax= TMath::Sqrt(diamsigma2x);
+  Double_t sigmay= TMath::Sqrt(diamsigma2y);
+  
+  Double_t z1=fSPDVertex->GetZ();
+  Int_t nc1=fSPDVertex->GetNContributors();
+  if(nc1<1) return kFALSE;
+  Int_t nPileVert=GetNumberOfPileupVerticesSPD();
+  if(nPileVert==0) return kFALSE;
+  for(Int_t i=0; i<nPileVert;i++){
+    const AliESDVertex* pv=GetPileupVertexSPD(i);
+    Double_t z2=pv->GetZ();
+    Double_t x2=pv->GetX();
+    Double_t y2=pv->GetY();
+    Int_t nc2=pv->GetNContributors();
+    Double_t distanceZ=TMath::Abs(z2-z1);
+    Double_t distanceX=TMath::Abs(x2-diamx);
+    Double_t distanceY=TMath::Abs(y2-diamy);
+    Double_t errzDist=0.;
+    Double_t errxDist=0.;
+    Double_t erryDist=0.;
+    if(option==0){
+      Double_t ez1=fSPDVertex->GetZRes();
+      Double_t ez2=pv->GetZRes();
+      errzDist=TMath::Sqrt(ez1*ez1+ez2*ez2);
+    }else{  
+      Double_t resol1=-75.6+834.6/TMath::Sqrt((Double_t)nc1);
+      resol1/=10000.;
+      Double_t resol2=-75.6+834.6/TMath::Sqrt((Double_t)nc2);
+      resol2/=10000.;
+      errzDist=TMath::Sqrt(resol1*resol1+resol2*resol2); 
+    }
+
+    
+      Double_t ex2 = pv->GetXRes();
+      Double_t ey2= pv->GetYRes();
+      errxDist=TMath::Sqrt(ex2*ex2+sigmax*sigmax); 
+      erryDist=TMath::Sqrt(ey2*ey2+sigmay*sigmay); 
+    
+      if(nc2>=ncont && distanceZ>nSigmaDeltaZ*errzDist && distanceX<nSigmaXY*errxDist && distanceY<nSigmaXY*erryDist && distanceZ>distz)
+       
+       return kTRUE;
+  }
+           
+           
+      
+      return kFALSE;
+  }
+
+
+