#include "TList.h"
#include "TRefArray.h"
#include <TNamed.h>
+#include <TROOT.h>
+#include <TInterpreter.h>
#include "AliESDEvent.h"
#include "AliESDfriend.h"
#include "AliESDPmdTrack.h"
#include "AliESDTrdTrack.h"
#include "AliESDVertex.h"
+#include "AliVertexerTracks.h"
#include "AliESDcascade.h"
#include "AliESDkink.h"
#include "AliESDtrack.h"
#include "AliRawDataErrorLog.h"
#include "AliLog.h"
#include "AliESDACORDE.h"
+#include "AliESDHLTDecision.h"
+#include "AliCentrality.h"
+#include "AliEventplane.h"
+
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",
- "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():
fPHOSTrigger(0),
fEMCALTrigger(0),
fESDACORDE(0),
+ fSPDPileupVertices(0),
+ fTrkPileupVertices(0),
fTracks(0),
fMuonTracks(0),
fPmdTracks(0),
fESDOld(0),
fESDFriendOld(0),
fConnected(kFALSE),
- fEMCALClusters(0),
- fFirstEMCALCluster(-1),
- fPHOSClusters(0),
- fFirstPHOSCluster(-1)
+ fUseOwnList(kFALSE),
+ fTOFHeader(0),
+ fCentrality(0),
+ fEventplane(0)
{
}
//______________________________________________________________________________
fPHOSTrigger(new AliESDCaloTrigger(*esd.fPHOSTrigger)),
fEMCALTrigger(new AliESDCaloTrigger(*esd.fEMCALTrigger)),
fESDACORDE(new AliESDACORDE(*esd.fESDACORDE)),
+ fSPDPileupVertices(new TClonesArray(*esd.fSPDPileupVertices)),
+ fTrkPileupVertices(new TClonesArray(*esd.fTrkPileupVertices)),
fTracks(new TClonesArray(*esd.fTracks)),
fMuonTracks(new TClonesArray(*esd.fMuonTracks)),
fPmdTracks(new TClonesArray(*esd.fPmdTracks)),
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),
- fEMCALClusters(esd.fEMCALClusters),
- fFirstEMCALCluster(esd.fFirstEMCALCluster),
- fPHOSClusters(esd.fPHOSClusters),
- fFirstPHOSCluster(esd.fFirstPHOSCluster)
-
+ fUseOwnList(esd.fUseOwnList),
+ fTOFHeader(new AliTOFHeader(*esd.fTOFHeader)),
+ fCentrality(new AliCentrality(*esd.fCentrality)),
+ fEventplane(new AliEventplane(*esd.fEventplane))
{
// CKB init in the constructor list and only add here ...
AddObject(fESDRun);
AddObject(fSPDMult);
AddObject(fPHOSTrigger);
AddObject(fEMCALTrigger);
+ AddObject(fSPDPileupVertices);
+ AddObject(fTrkPileupVertices);
AddObject(fTracks);
AddObject(fMuonTracks);
AddObject(fPmdTracks);
AddObject(fPHOSCells);
AddObject(fErrorLogs);
AddObject(fESDACORDE);
+ AddObject(fTOFHeader);
GetStdContent();
// otherwise only TObject::Copy() will be used
+
if((fESDObjects->GetSize()==0)&&(source.fESDObjects->GetSize()>=kESDListN)){
// We cover the case that we do not yet have the
// standard content but the source has it
name.Form("%s", its->GetName());
TObject *mine = fESDObjects->FindObject(name.Data());
if(!mine){
- // not in this: can be added to list (to be implemented)
- AliWarning(Form("%s:%d Could not find %s for copying \n",
- (char*)__FILE__,__LINE__,name.Data()));
- continue;
- }
+ TClass* pClass=TClass::GetClass(its->ClassName());
+ if (!pClass) {
+ AliWarning(Form("Can not find class description for entry %s (%s)\n",
+ its->ClassName(), name.Data()));
+ continue;
+ }
+ mine=(TObject*)pClass->New();
+ if(!mine){
+ // not in this: can be added to list
+ AliWarning(Form("%s:%d Could not find %s for copying \n",
+ (char*)__FILE__,__LINE__,name.Data()));
+ continue;
+ }
+ if(mine->InheritsFrom("TNamed")){
+ ((TNamed*)mine)->SetName(name);
+ }
+ else if(mine->InheritsFrom("TCollection")){
+ 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()));
+ AddObject(mine);
+ }
+
if(!its->InheritsFrom("TCollection")){
// simple objects
its->Copy(*mine);
}
}
- fConnected = source.fConnected;
- fEMCALClusters = source.fEMCALClusters;
- fFirstEMCALCluster = source.fFirstEMCALCluster;
- fPHOSClusters = source.fPHOSClusters;
- fFirstPHOSCluster = source.fFirstPHOSCluster;
+ fCentrality = source.fCentrality;
+ fEventplane = source.fEventplane;
+ fConnected = source.fConnected;
+ fUseOwnList = source.fUseOwnList;
return *this;
-
}
delete fESDObjects;
fESDObjects = 0;
}
-
+ if (fCentrality) delete fCentrality;
+ if (fEventplane) delete fEventplane;
}
void AliESDEvent::Reset()
{
-
+ // Handle the cases
+ // Std content + Non std content
+
// Reset the standard contents
ResetStdContent();
+
+ // reset for the old data without AliESDEvent...
if(fESDOld)fESDOld->Reset();
- // reset for the friends...
if(fESDFriendOld){
fESDFriendOld->~AliESDfriend();
new (fESDFriendOld) AliESDfriend();
}
- // for new data we have to fetch the Pointer from the list
- AliESDfriend *fr = (AliESDfriend*)FindListObject("AliESDfriend");
- if(fr){
- // delete the content
- fr->~AliESDfriend();
- // make a new valid ESDfriend at the same place
- new (fr) AliESDfriend();
+ //
+
+ if(fESDObjects->GetSize()>kESDListN){
+ // we have non std content
+ // this also covers esdfriends
+ for(int i = kESDListN;i < fESDObjects->GetSize();++i){
+ TObject *pObject = fESDObjects->At(i);
+ // TClonesArrays
+ if(pObject->InheritsFrom(TClonesArray::Class())){
+ ((TClonesArray*)pObject)->Delete();
+ }
+ else if(!pObject->InheritsFrom(TCollection::Class())){
+ 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 \n",
+ pObject->ClassName()));
+ }
+ }
}
- // call reset for user supplied data?
+}
+
+Bool_t AliESDEvent::ResetWithPlacementNew(TObject *pObject){
+ Long_t dtoronly = TObject::GetDtorOnly();
+ TClass *pClass = TClass::GetClass(pObject->ClassName());
+ TObject::SetDtorOnly(pObject);
+ delete pObject;
+ // Recreate with placement new
+ pClass->New(pObject);
+ // Restore the state.
+ TObject::SetDtorOnly((void*)dtoronly);
+ return kTRUE;
}
void AliESDEvent::ResetStdContent()
// Reset the standard contents
if(fESDRun) fESDRun->Reset();
if(fHeader) fHeader->Reset();
+ if(fCentrality) fCentrality->Reset();
+ if(fEventplane) fEventplane->Reset();
if(fESDZDC) fESDZDC->Reset();
if(fESDFMD) {
- fESDFMD->~AliESDFMD();
- new (fESDFMD) AliESDFMD();
+ fESDFMD->Clear();
}
if(fESDVZERO){
// reset by callin d'to /c'tor keep the pointer
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();
if(fMuonTracks)fMuonTracks->Delete();
if(fPmdTracks)fPmdTracks->Delete();
// don't reset fconnected fConnected and the list
- fEMCALClusters=0;
- fFirstEMCALCluster=-1;
- fPHOSClusters=0;
- fFirstPHOSCluster=-1;
}
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 Z=%.4f cm\n",
+ GetDiamondX(),GetDiamondY(),GetDiamondZ());
+ if(fSPDMult)
printf("SPD Multiplicity. Number of tracklets %d \n",
fSPDMult->GetNumberOfTracklets());
+ printf("Number of pileup primary vertices reconstructed with SPD %d\n",
+ GetNumberOfPileupVerticesSPD());
+ printf("Number of pileup primary vertices reconstructed using the tracks %d\n",
+ GetNumberOfPileupVerticesTracks());
printf("Number of tracks: \n");
printf(" charged %d\n", GetNumberOfTracks());
printf(" muon %d\n", GetNumberOfMuonTracks());
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();
+ printf("HLT trigger decision: %s\n", pHLTDecision?pHLTDecision->GetOption():"not available");
+ if (pHLTDecision) pHLTDecision->Print("compact");
return;
}
Int_t idx=cs->GetIndex();
if (rm==idx) return kFALSE;
if (idx==last) used++;
+
+ AliESDv0 *v0=cs;
+ idx=v0->GetNindex();
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
+
+ idx=v0->GetPindex();
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
}
Int_t nkn=GetNumberOfKinks();
if (idx==last) used++;
}
+ // Check if this track is associated with a CaloCluster
+ Int_t ncl=GetNumberOfCaloClusters();
+ for (Int_t n=0; n<ncl; n++) {
+ AliESDCaloCluster *cluster=GetCaloCluster(n);
+ TArrayI *arr=cluster->GetTracksMatched();
+ Int_t s=arr->GetSize();
+ while (s--) {
+ Int_t idx=arr->At(s);
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
+ }
+ }
+
+
//Replace the removed track with the last track
TClonesArray &a=*fTracks;
used--;
if (!used) return kTRUE;
}
+ AliESDv0 *v0=cs;
+ if (v0->GetIndex(0)==last) {
+ v0->SetIndex(0,rm);
+ used--;
+ if (!used) return kTRUE;
+ }
+ if (v0->GetIndex(1)==last) {
+ v0->SetIndex(1,rm);
+ used--;
+ if (!used) return kTRUE;
+ }
}
for (Int_t n=0; n<nkn; n++) {
}
}
+ // Remap the indices of the tracks accosicated with CaloClusters
+ for (Int_t n=0; n<ncl; n++) {
+ AliESDCaloCluster *cluster=GetCaloCluster(n);
+ TArrayI *arr=cluster->GetTracksMatched();
+ Int_t s=arr->GetSize();
+ while (s--) {
+ Int_t idx=arr->At(s);
+ if (idx==last) {
+ arr->AddAt(rm,s);
+ used--;
+ if (!used) return kTRUE;
+ }
+ }
+ }
+
return kTRUE;
}
return rc;
}
+Char_t AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx)
+{
+ // Add a pileup primary vertex reconstructed with SPD
+ TClonesArray &ftr = *fSPDPileupVertices;
+ Char_t n=Char_t(ftr.GetEntriesFast());
+ AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx);
+ vertex->SetID(n);
+ return n;
+}
+
+Char_t AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx)
+{
+ // Add a pileup primary vertex reconstructed with SPD
+ TClonesArray &ftr = *fTrkPileupVertices;
+ 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)
{
// Add track
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
}
}
-void AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex)
+void AliESDEvent::SetPrimaryVertexTracks(const AliESDVertex *vertex)
{
- // Set the primary vertex
+ // Set the primary vertex reconstructed using he ESD tracks.
// use already allocated space
if(fPrimaryVertex){
*fPrimaryVertex = *vertex;
}
}
+const AliESDVertex * AliESDEvent::GetPrimaryVertex() const
+{
+ //
+ // Get the "best" available reconstructed primary vertex.
+ //
+ if(fPrimaryVertex){
+ if (fPrimaryVertex->GetStatus()) return fPrimaryVertex;
+ }
+ if(fSPDVertex){
+ if (fSPDVertex->GetStatus()) return fSPDVertex;
+ }
+ if(fTPCVertex) return fTPCVertex;
+
+ AliWarning("No primary vertex available. Returning the \"default\"...");
+ 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
t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
}
-}
+ AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindListObject("AliESDfriend"));
+ if (fr) ev->SetVZEROfriend(fr->GetVZEROfriend());
+}
void AliESDEvent::AddObject(TObject* obj)
{
fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fgkESDListName[kSPDMult]);
fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kPHOSTrigger]);
fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kEMCALTrigger]);
+ fSPDPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kSPDPileupVertices]);
+ fTrkPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrkPileupVertices]);
fTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTracks]);
fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]);
fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]);
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(){
// Set the names of the standard contents
//
- if(fESDObjects->GetEntries()==kESDListN){
- for(int i = 0;i < fESDObjects->GetEntries();i++){
+ if(fESDObjects->GetEntries()>=kESDListN){
+ for(int i = 0;i < fESDObjects->GetEntries() && i<kESDListN;i++){
TObject *fObj = fESDObjects->At(i);
if(fObj->InheritsFrom("TNamed")){
((TNamed*)fObj)->SetName(fgkESDListName[i]);
}
}
else{
- printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
+ AliWarning("Std Entries missing");
}
}
+
+void AliESDEvent::CreateStdContent(Bool_t bUseThisList){
+ fUseOwnList = bUseThisList;
+ CreateStdContent();
+}
+
void AliESDEvent::CreateStdContent()
{
// create the standard AOD content and set pointers
AddObject(new AliMultiplicity());
AddObject(new AliESDCaloTrigger());
AddObject(new AliESDCaloTrigger());
+ AddObject(new TClonesArray("AliESDVertex",0));
+ AddObject(new TClonesArray("AliESDVertex",0));
AddObject(new TClonesArray("AliESDtrack",0));
AddObject(new TClonesArray("AliESDMuonTrack",0));
AddObject(new TClonesArray("AliESDPmdTrack",0));
AddObject(new AliESDCaloCells());
AddObject(new TClonesArray("AliRawDataErrorLog",0));
AddObject(new AliESDACORDE());
+ AddObject(new AliTOFHeader());
// check the order of the indices against enum...
GetStdContent();
}
-TObject* AliESDEvent::FindListObject(const char *name){
+TObject* AliESDEvent::FindListObject(const char *name) const {
//
// Find object with name "name" in the list of branches
//
return clusters->GetEntriesFast();
}
-const void AliESDEvent::WriteToTree(TTree* tree) const {
+void AliESDEvent::WriteToTree(TTree* tree) const {
// Book the branches as in TTree::Branch(TCollection*)
// but add a "." at the end of top level branches which are
// not a TClonesArray
while ((obj = next())) {
branchname.Form("%s", obj->GetName());
+ if(branchname.CompareTo("AliESDfriend")==0)branchname = "ESDfriend.";
if ((kSplitlevel > 1) && !obj->InheritsFrom(TClonesArray::Class())) {
if(!branchname.EndsWith("."))branchname += ".";
}
- tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj),
- kBufsize, kSplitlevel - 1);
+ if (!tree->FindBranch(branchname)) {
+ // For the custom streamer to be called splitlevel
+ // has to be negative, only needed for HLT
+ Int_t splitLevel = (TString(obj->ClassName()) == "AliHLTGlobalTriggerDecision") ? -1 : kSplitlevel - 1;
+ tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj),kBufsize, splitLevel);
+ }
}
-
}
-void AliESDEvent::ReadFromTree(TTree *tree){
+void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
//
// Connect the ESDEvent to a tree
//
if(!tree){
- Printf("%s %d AliESDEvent::ReadFromTree() Zero Pointer to Tree \n",(char*)__FILE__,__LINE__);
+ AliWarning("AliESDEvent::ReadFromTree() Zero Pointer to Tree \n");
return;
}
// load the TTree
char ** addressF = 0;
if(esdFB)addressF = (char **)(esdFB->GetAddress());
if (!address) {
- printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__);
+ AliInfo("AliESDEvent::ReadFromTree() Reading old Tree");
tree->SetBranchAddress("ESD", &fESDOld);
if(esdFB){
tree->SetBranchAddress("ESDfriend.",&fESDFriendOld);
}
} else {
- printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__);
- printf("%s %d Branch already connected. Using existing branch address. \n",(char*)__FILE__,__LINE__);
+ AliInfo("AliESDEvent::ReadFromTree() Reading old Tree");
+ AliInfo("Branch already connected. Using existing branch address.");
fESDOld = (AliESD*) (*address);
// addressF can still be 0, since branch needs to switched on
if(addressF)fESDFriendOld = (AliESDfriend*) (*addressF);
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;
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;
// Connect to tree
// prevent a memory leak when reading back the TList
- 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);
+ // if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete();
+
+ if(!fUseOwnList){
+ // create a new TList from the UserInfo TList...
+ // copy constructor does not work...
+ fESDObjects = (TList*)(esdEvent->GetList()->Clone());
+ fESDObjects->SetOwner(kTRUE);
+ }
+ else if ( fESDObjects->GetEntries()==0){
+ // at least create the std content if we want to read to our list
+ CreateStdContent();
+ }
// in principle
// we only need new things in the list if we do no already have it..
// TODO just add new entries
if(fESDObjects->GetEntries()<kESDListN){
- printf("%s %d AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n",
- (char*)__FILE__,__LINE__,fESDObjects->GetEntries(),kESDListN);
+ AliWarning(Form("AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n",
+ fESDObjects->GetEntries(),kESDListN));
}
// set the branch addresses
TIter next(fESDObjects);
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
tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el));
}
else{
- printf("%s %d AliESDEvent::ReadFromTree() No Branch found with Name %s or %s. \n",
- (char*)__FILE__,__LINE__,bname.Data(),bname.Data());
+ AliWarning(Form("AliESDEvent::ReadFromTree() No Branch found with Name %s or %s.",bname.Data(),bname.Data()));
}
}
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
GetStdContent();
// when reading back we are not owner of the list
// must not delete it
- fESDObjects->SetOwner(kFALSE);
+ fESDObjects->SetOwner(kTRUE);
}
}
0,
fESDOld->GetZDCN2Energy(),
fESDOld->GetZDCP2Energy(),
- fESDOld->GetZDCParticipants());
+ fESDOld->GetZDCParticipants(),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0);
// FMD
if(fESDOld->GetVertex())SetPrimaryVertexSPD(fESDOld->GetVertex());
- if(fESDOld->GetPrimaryVertex())SetPrimaryVertex(fESDOld->GetPrimaryVertex());
+ if(fESDOld->GetPrimaryVertex())SetPrimaryVertexTracks(fESDOld->GetPrimaryVertex());
if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity());
}// 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;
+}
+
+//______________________________________________________________________________
+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
+ //
+ 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);
+ Int_t nc2=pv->GetNContributors();
+ 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;
+}
+
+//______________________________________________________________________________
+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
+ }
+ //
+ // 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;
+}
+
+AliEventplane* AliESDEvent::GetEventplane()
+{
+ if (!fEventplane) fEventplane = new AliEventplane();
+ return fEventplane;
+}