]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDEvent.cxx
reorganization of TRD PID reference maker classes. Data management has
[u/mrichter/AliRoot.git] / STEER / AliESDEvent.cxx
index 1ead29b9cc9619182c098fa2b46f372a2091025c..3f9af9cee4ae7ca67874859ab2b9e314b74c8806 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"
@@ -164,8 +167,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), 
@@ -864,18 +867,24 @@ Bool_t AliESDEvent::Clean(Float_t *cleanPars) {
   return rc;
 }
 
-void  AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx) 
+Char_t  AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx) 
 {
     // Add a pileup primary vertex reconstructed with SPD
     TClonesArray &ftr = *fSPDPileupVertices;
-    new(ftr[fSPDPileupVertices->GetEntriesFast()]) AliESDVertex(*vtx);
+    Char_t n=Char_t(ftr.GetEntriesFast());
+    AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx);
+    vertex->SetID(n);
+    return n;
 }
 
-void  AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx) 
+Char_t  AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx) 
 {
     // Add a pileup primary vertex reconstructed with SPD
     TClonesArray &ftr = *fTrkPileupVertices;
-    new(ftr[fTrkPileupVertices->GetEntriesFast()]) AliESDVertex(*vtx);
+    Char_t n=Char_t(ftr.GetEntriesFast());
+    AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx);
+    vertex->SetID(n);
+    return n;
 }
 
 Int_t  AliESDEvent::AddTrack(const AliESDtrack *t) 
@@ -987,6 +996,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
@@ -1223,7 +1257,7 @@ void AliESDEvent::WriteToTree(TTree* tree) const {
 }
 
 
-void AliESDEvent::ReadFromTree(TTree *tree, Option_t* /*opt*/){
+void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
 //
 // Connect the ESDEvent to a tree
 //
@@ -1295,7 +1329,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;
@@ -1310,8 +1344,11 @@ 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"));
-    if (connectedList) {
+
+    
+    if (connectedList && (strcmp(opt, "reconnect"))) {
       // If connected use the connected list if objects
       fESDObjects->Delete();
       fESDObjects = connectedList;
@@ -1322,14 +1359,13 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* /*opt*/){
 
     // Connect to tree
     // prevent a memory leak when reading back the TList
-
+    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
@@ -1375,13 +1411,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
@@ -1404,7 +1441,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);
   }
 }
 
@@ -1441,6 +1478,11 @@ void AliESDEvent::CopyFromOldESD()
            fESDOld->GetZDCN2Energy(),
            fESDOld->GetZDCP2Energy(),
            fESDOld->GetZDCParticipants(),
+          0,
+          0,
+          0,
+          0,
+          0,
           0);
 
     // FMD
@@ -1498,5 +1540,77 @@ 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
+
+  // cast away const'nes because the FindListObject method
+  // is not const
+  AliESDEvent* pNonConst=const_cast<AliESDEvent*>(this);
+  return pNonConst->FindListObject("HLTGlobalTrigger");
+}
+
+TString   AliESDEvent::GetHLTTriggerDescription() const
+{
+  // get the HLT trigger decission description
+  TString description;
+  TObject* pDecision=GetHLTTriggerDecision();
+  if (pDecision) {
+    description=pDecision->GetTitle();
+  }
+
+  return description;
+}
+
+Bool_t    AliESDEvent::IsHLTTriggerFired(const char* name) const
+{
+  // get the HLT trigger decission description
+  TObject* pDecision=GetHLTTriggerDecision();
+  if (!pDecision) return kFALSE;
+
+  Option_t* option=pDecision->GetOption();
+  if (option==NULL || *option!='1') return kFALSE;
+
+  if (name) {
+    TString description=GetHLTTriggerDescription();
+    Int_t index=description.Index(name);
+    if (index<0) return kFALSE;
+    index+=strlen(name);
+    if (index>=description.Length()) return kFALSE;
+    if (description[index]!=0 && description[index]!=' ') return kFALSE;
+  }
+  return kTRUE;
+}