]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDEvent.cxx
new functions, mc analysis can be performed also for pi0 and k0. eta of seed can...
[u/mrichter/AliRoot.git] / STEER / AliESDEvent.cxx
index 4b923f7cc998f667caf755e402f6829434379df8..a3082187bbb061d73e5e1af7f1e362ea7167754f 100644 (file)
@@ -66,6 +66,7 @@
 #include "AliLog.h"
 #include "AliESDACORDE.h"
 #include "AliESDHLTDecision.h"
+#include "AliCentrality.h"
 
 ClassImp(AliESDEvent)
 
@@ -74,31 +75,32 @@ ClassImp(AliESDEvent)
 // here we define the names, some classes are no TNamed, therefore the classnames 
 // are the Names
   const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun",
-                                                      "AliESDHeader",
-                                                      "AliESDZDC",
-                                                      "AliESDFMD",
-                                                      "AliESDVZERO",
-                                                      "AliESDTZERO",
-                                                      "TPCVertex",
-                                                      "SPDVertex",
-                                                      "PrimaryVertex",
-                                                      "AliMultiplicity",
-                                                      "PHOSTrigger",
-                                                      "EMCALTrigger",
-                                                      "SPDPileupVertices",
-                                                      "TrkPileupVertices",
-                                                      "Tracks",
-                                                      "MuonTracks",
-                                                      "PmdTracks",
-                                                      "TrdTracks",
-                                                      "V0s",
-                                                      "Cascades",
-                                                      "Kinks",
-                                                      "CaloClusters",
-                                                     "EMCALCells",
-                                                     "PHOSCells",
-                                                      "AliRawDataErrorLogs",
-                                                      "AliESDACORDE"};
+                                                       "AliESDHeader",
+                                                       "AliESDZDC",
+                                                       "AliESDFMD",
+                                                       "AliESDVZERO",
+                                                       "AliESDTZERO",
+                                                       "TPCVertex",
+                                                       "SPDVertex",
+                                                       "PrimaryVertex",
+                                                       "AliMultiplicity",
+                                                       "PHOSTrigger",
+                                                       "EMCALTrigger",
+                                                       "SPDPileupVertices",
+                                                       "TrkPileupVertices",
+                                                       "Tracks",
+                                                       "MuonTracks",
+                                                       "PmdTracks",
+                                                       "TrdTracks",
+                                                       "V0s",
+                                                       "Cascades",
+                                                       "Kinks",
+                                                       "CaloClusters",
+                                                       "EMCALCells",
+                                                       "PHOSCells",
+                                                       "AliRawDataErrorLogs",
+                                                       "AliESDACORDE",
+                                                       "AliTOFHeader"};
 
 //______________________________________________________________________________
 AliESDEvent::AliESDEvent():
@@ -133,10 +135,8 @@ AliESDEvent::AliESDEvent():
   fESDFriendOld(0),
   fConnected(kFALSE),
   fUseOwnList(kFALSE),
-  fEMCALClusters(0), 
-  fFirstEMCALCluster(-1),
-  fPHOSClusters(0), 
-  fFirstPHOSCluster(-1)
+  fTOFHeader(0),
+  fCentrality(0)
 {
 }
 //______________________________________________________________________________
@@ -173,11 +173,8 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   fESDFriendOld(esd.fESDFriendOld ? new AliESDfriend(*esd.fESDFriendOld) : 0),
   fConnected(esd.fConnected),
   fUseOwnList(esd.fUseOwnList),
-  fEMCALClusters(esd.fEMCALClusters), 
-  fFirstEMCALCluster(esd.fFirstEMCALCluster),
-  fPHOSClusters(esd.fPHOSClusters), 
-  fFirstPHOSCluster(esd.fFirstPHOSCluster)
-
+  fTOFHeader(new AliTOFHeader(*esd.fTOFHeader)),
+  fCentrality(new AliCentrality(*esd.fCentrality))
 {
   // CKB init in the constructor list and only add here ...
   AddObject(fESDRun);
@@ -206,6 +203,7 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   AddObject(fPHOSCells);
   AddObject(fErrorLogs);
   AddObject(fESDACORDE);
+  AddObject(fTOFHeader);
 
   GetStdContent();
 
@@ -257,8 +255,11 @@ AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
        ((TNamed*)mine)->SetName(name);
       }
       else if(mine->InheritsFrom("TCollection")){
-       if(mine->InheritsFrom("TClonesArray"))
-         dynamic_cast<TClonesArray*>(mine)->SetClass(dynamic_cast<TClonesArray*>(its)->GetClass());
+       if(mine->InheritsFrom("TClonesArray")) {
+         TClonesArray* tcits = dynamic_cast<TClonesArray*>(its);
+         if (tcits)
+           dynamic_cast<TClonesArray*>(mine)->SetClass(tcits->GetClass());
+       }
        dynamic_cast<TCollection*>(mine)->SetName(name);
       }
       AliDebug(1, Form("adding object %s of type %s", mine->GetName(), mine->ClassName()));
@@ -295,16 +296,12 @@ AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
     }
   }
 
-  fConnected = source.fConnected;
-  fUseOwnList = source.fUseOwnList;
-  fEMCALClusters = source.fEMCALClusters;
-  fFirstEMCALCluster = source.fFirstEMCALCluster;
-  fPHOSClusters = source.fPHOSClusters;
-  fFirstPHOSCluster = source.fFirstPHOSCluster;
+  fCentrality = source.fCentrality;
 
+  fConnected  = source.fConnected;
+  fUseOwnList = source.fUseOwnList;
 
   return *this;
-
 }
 
 
@@ -323,7 +320,7 @@ AliESDEvent::~AliESDEvent()
       delete fESDObjects;
       fESDObjects = 0;
     }
-
+  if (fCentrality) delete fCentrality;
   
 }
 
@@ -368,10 +365,18 @@ void AliESDEvent::Reset()
        ((TClonesArray*)pObject)->Delete();
       }
       else if(!pObject->InheritsFrom(TCollection::Class())){
-       ResetWithPlacementNew(pObject);
+       TClass *pClass = TClass::GetClass(pObject->ClassName());
+       if (pClass && pClass->GetListOfMethods()->FindObject("Clear")) {
+         AliDebug(1, Form("Clear for object %s class %s", pObject->GetName(), pObject->ClassName()));
+         pObject->Clear();
+       }
+       else {
+         AliDebug(1, Form("ResetWithPlacementNew for object %s class %s", pObject->GetName(), pObject->ClassName()));
+         ResetWithPlacementNew(pObject);
+       }
       }
       else{
-       AliWarning(Form("No reset for %s (%s)\n",
+       AliWarning(Form("No reset for %s \n",
                        pObject->ClassName()));
       }
     }
@@ -430,8 +435,13 @@ void AliESDEvent::ResetStdContent()
     fSPDMult->~AliMultiplicity();
     new (fSPDMult) AliMultiplicity();
   }
-  if(fPHOSTrigger)fPHOSTrigger->Reset(); 
-  if(fEMCALTrigger)fEMCALTrigger->Reset(); 
+  if(fTOFHeader){
+    fTOFHeader->~AliTOFHeader();
+    new (fTOFHeader) AliTOFHeader();
+    //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
+  }
+  if(fPHOSTrigger)fPHOSTrigger->DeAllocate(); 
+  if(fEMCALTrigger)fEMCALTrigger->DeAllocate(); 
   if(fSPDPileupVertices)fSPDPileupVertices->Delete();
   if(fTrkPileupVertices)fTrkPileupVertices->Delete();
   if(fTracks)fTracks->Delete();
@@ -448,10 +458,6 @@ void AliESDEvent::ResetStdContent()
 
   // don't reset fconnected fConnected and the list
 
-  fEMCALClusters=0; 
-  fFirstEMCALCluster=-1; 
-  fPHOSClusters=0; 
-  fFirstPHOSCluster=-1; 
 }
 
 
@@ -485,8 +491,8 @@ void AliESDEvent::Print(Option_t *) const
           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 Z=%.4f cm\n",
+        GetDiamondX(),GetDiamondY(),GetDiamondZ());
   if(fSPDMult)
     printf("SPD Multiplicity. Number of tracklets %d \n",
            fSPDMult->GetNumberOfTracklets());
@@ -507,8 +513,6 @@ void AliESDEvent::Print(Option_t *) const
   if(fEMCALCells)printf("                 EMCALCells %d\n", fEMCALCells->GetNumberOfCells());
   else printf("                 EMCALCells not in the Event\n");
   printf("                 CaloClusters %d\n", GetNumberOfCaloClusters());
-  printf("                 phos      %d\n", GetNumberOfPHOSClusters());
-  printf("                 emcal     %d\n", GetNumberOfEMCALClusters());
   printf("                 FMD       %s\n", (fESDFMD ? "yes" : "no"));
   printf("                 VZERO     %s\n", (fESDVZERO ? "yes" : "no"));
   TObject* pHLTDecision=GetHLTTriggerDecision();
@@ -956,6 +960,13 @@ void  AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) const {
   new(errlogs[errlogs.GetEntriesFast()])  AliRawDataErrorLog(*log);
 }
 
+void AliESDEvent::SetZDCData(AliESDZDC * obj)
+{ 
+  // use already allocated space
+  if(fESDZDC)
+    *fESDZDC = *obj;
+}
+
 void  AliESDEvent::SetPrimaryVertexTPC(const AliESDVertex *vertex) 
 {
   // Set the TPC vertex
@@ -1122,7 +1133,7 @@ void AliESDEvent::GetStdContent()
   fPHOSCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kPHOSCells]);
   fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]);
   fESDACORDE = (AliESDACORDE*)fESDObjects->FindObject(fgkESDListName[kESDACORDE]);
-
+  fTOFHeader = (AliTOFHeader*)fESDObjects->FindObject(fgkESDListName[kTOFHeader]);
 }
 
 void AliESDEvent::SetStdNames(){
@@ -1181,6 +1192,7 @@ void AliESDEvent::CreateStdContent()
   AddObject(new AliESDCaloCells());
   AddObject(new TClonesArray("AliRawDataErrorLog",0));
   AddObject(new AliESDACORDE()); 
+  AddObject(new AliTOFHeader());
 
   // check the order of the indices against enum...
 
@@ -1368,7 +1380,7 @@ 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 (!(strcmp(opt, "reconnect"))) fESDObjects->Delete();
     
     if(!fUseOwnList){
       // create a new TList from the UserInfo TList... 
@@ -1397,7 +1409,8 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
       if(bname.CompareTo("AliESDfriend")==0)
        {
          // AliESDfriend does not have a name ...
-         tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el));
+           TBranch *br = tree->GetBranch("ESDfriend.");
+           if (br) tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el));
        }
       else{
        // check if branch exists under this Name
@@ -1622,64 +1635,118 @@ 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 {
+//______________________________________________________________________________
+Bool_t  AliESDEvent::IsPileupFromSPD(Int_t minContributors, 
+                                    Double_t minZdist, 
+                                    Double_t nSigmaZdist, 
+                                    Double_t nSigmaDiamXY, 
+                                    Double_t nSigmaDiamZ) 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); 
+    if(nc2>=minContributors){
+      Double_t z1=fSPDVertex->GetZ();
+      Double_t z2=pv->GetZ();
+      Double_t distZ=TMath::Abs(z2-z1);
+      Double_t distZdiam=TMath::Abs(z2-GetDiamondZ());
+      Double_t cutZdiam=nSigmaDiamZ*TMath::Sqrt(GetSigma2DiamondZ());
+      if(GetSigma2DiamondZ()<0.0001)cutZdiam=99999.; //protection for missing z diamond information
+      if(distZ>minZdist && distZdiam<cutZdiam){
+       Double_t x2=pv->GetX();
+       Double_t y2=pv->GetY();
+       Double_t distXdiam=TMath::Abs(x2-GetDiamondX());
+       Double_t distYdiam=TMath::Abs(y2-GetDiamondY());
+       Double_t cov1[6],cov2[6];       
+       fSPDVertex->GetCovarianceMatrix(cov1);
+       pv->GetCovarianceMatrix(cov2);
+       Double_t errxDist=TMath::Sqrt(cov2[0]+GetSigma2DiamondX());
+       Double_t erryDist=TMath::Sqrt(cov2[2]+GetSigma2DiamondY());
+       Double_t errzDist=TMath::Sqrt(cov1[5]+cov2[5]);
+       Double_t cutXdiam=nSigmaDiamXY*errxDist;
+       if(GetSigma2DiamondX()<0.0001)cutXdiam=99999.; //protection for missing diamond information
+       Double_t cutYdiam=nSigmaDiamXY*erryDist;
+       if(GetSigma2DiamondY()<0.0001)cutYdiam=99999.; //protection for missing diamond information
+       if( (distXdiam<cutXdiam) && (distYdiam<cutYdiam) && (distZ>nSigmaZdist*errzDist) ){
+         return kTRUE;
+       }
+      }
     }
+  }
+  return kFALSE;
+}
 
-    
-      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;
+//______________________________________________________________________________
+void AliESDEvent::EstimateMultiplicity(Int_t &tracklets, Int_t &trITSTPC, Int_t &trITSSApure, Double_t eta, Bool_t useDCAFlag,Bool_t useV0Flag) const
+{
+  //
+  // calculates 3 estimators for the multiplicity in the -eta:eta range
+  // tracklets   : using SPD tracklets only
+  // trITSTPC    : using TPC/ITS + complementary ITS SA tracks + tracklets from clusters not used by tracks
+  // trITSSApure : using ITS standalone tracks + tracklets from clusters not used by tracks
+  // if useDCAFlag is true: account for the ESDtrack flag marking the tracks with large DCA
+  // if useV0Flag  is true: account for the ESDtrack flag marking conversion and K0's V0s
+  tracklets = trITSSApure = trITSTPC = 0;
+  int ntr = fSPDMult ? fSPDMult->GetNumberOfTracklets() : 0;
+  //
+  // count tracklets
+  for (int itr=ntr;itr--;) { 
+    if (TMath::Abs(fSPDMult->GetEta(itr))>eta) continue;
+    tracklets++;
+    if (fSPDMult->FreeClustersTracklet(itr,0)) trITSTPC++;    // not used in ITS/TPC or ITS_SA track
+    if (fSPDMult->FreeClustersTracklet(itr,1)) trITSSApure++; // not used in ITS_SA_Pure track
   }
-           
-           
-      
-      return kFALSE;
+  //
+  // count real tracks
+  ntr = GetNumberOfTracks();
+  for (int itr=ntr;itr--;) {
+    AliESDtrack *t = GetTrack(itr);
+    if (TMath::Abs(t->Eta())>eta) continue;
+    if (!t->IsOn(AliESDtrack::kITSin)) continue;
+    if (useDCAFlag && t->IsOn(AliESDtrack::kMultSec))  continue;
+    if (useV0Flag  && t->IsOn(AliESDtrack::kMultInV0)) continue;    
+    if (t->IsOn(AliESDtrack::kITSpureSA)) trITSSApure++;
+    else                                  trITSTPC++;
   }
+  //
+}
 
+Bool_t AliESDEvent::IsPileupFromSPDInMultBins() const {
+    Int_t nTracklets=GetMultiplicity()->GetNumberOfTracklets();
+    if(nTracklets<20) return IsPileupFromSPD(3,0.8);
+    else if(nTracklets<50) return IsPileupFromSPD(4,0.8);
+    else return IsPileupFromSPD(5,0.8);
+}
 
+void  AliESDEvent::SetTOFHeader(const AliTOFHeader *header)
+{
+  //
+  // Set the TOF event_time
+  //
+
+  if (fTOFHeader) {
+    *fTOFHeader=*header;
+    //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
+  }
+  else {
+    // for analysis of reconstructed events
+    // when this information is not avaliable
+    fTOFHeader = new AliTOFHeader(*header);
+    //AddObject(fTOFHeader);
+  }
 
+}
 
+AliCentrality* AliESDEvent::GetCentrality()
+{
+    if (!fCentrality) fCentrality = new AliCentrality();
+    return  fCentrality;
+}