X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliAODEvent.cxx;h=65dbf72e3e0c853725eb35c5c09e8d1f4f3c12cc;hb=dd474063b690f0356c150cdbe2887b807c7675d7;hp=4dbb5dd6c8ba7e2f08b42a99dfa32d1a30f58274;hpb=a98c78e57bdccb2bbe4b5cf77bfe3999e7b303c6;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliAODEvent.cxx b/STEER/AliAODEvent.cxx index 4dbb5dd6c8b..65dbf72e3e0 100644 --- a/STEER/AliAODEvent.cxx +++ b/STEER/AliAODEvent.cxx @@ -47,7 +47,9 @@ ClassImp(AliAODEvent) "caloClusters", "fmdClusters", "pmdClusters", - "dimuons" + "dimuons", + "AliAODVZERO", + "AliAODZDC" }; //______________________________________________________________________________ @@ -68,7 +70,9 @@ AliAODEvent::AliAODEvent() : fCaloClusters(0), fFmdClusters(0), fPmdClusters(0), - fDimuons(0) + fDimuons(0), + fAODVZERO(0), + fAODZDC(0) { // default constructor } @@ -91,7 +95,9 @@ AliAODEvent::AliAODEvent(const AliAODEvent& aod): fCaloClusters(new TClonesArray(*aod.fCaloClusters)), fFmdClusters(new TClonesArray(*aod.fFmdClusters)), fPmdClusters(new TClonesArray(*aod.fPmdClusters)), - fDimuons(new TClonesArray(*aod.fDimuons)) + fDimuons(new TClonesArray(*aod.fDimuons)), + fAODVZERO(new AliAODVZERO(*aod.fAODVZERO)), + fAODZDC(new AliAODZDC(*aod.fAODZDC)) { // Copy constructor AddObject(fHeader); @@ -107,6 +113,8 @@ AliAODEvent::AliAODEvent(const AliAODEvent& aod): AddObject(fFmdClusters); AddObject(fPmdClusters); AddObject(fDimuons); + AddObject(fAODVZERO); + AddObject(fAODZDC); fConnected = aod.fConnected; GetStdContent(); CreateStdFolders(); @@ -212,14 +220,8 @@ AliAODEvent & AliAODEvent::operator=(const AliAODEvent& aod) { AliAODEvent::~AliAODEvent() { // destructor - if(fAODObjects&&!fConnected) - { - delete fAODObjects; - fAODObjects = 0; - } - + if(!fConnected) delete fAODObjects; delete fAODFolder; - fAODFolder = 0; } //______________________________________________________________________________ @@ -229,7 +231,10 @@ void AliAODEvent::AddObject(TObject* obj) // Please be aware that in order to increase performance you should // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. - fAODObjects->AddLast(obj); + if ( !fAODObjects->FindObject(obj) ) + { + fAODObjects->AddLast(obj); + } } //______________________________________________________________________________ @@ -267,6 +272,8 @@ void AliAODEvent::CreateStdContent() AddObject(new TClonesArray("AliAODFmdCluster", 0)); AddObject(new TClonesArray("AliAODPmdCluster", 0)); AddObject(new TClonesArray("AliAODDimuon", 0)); + AddObject(new AliAODVZERO()); + AddObject(new AliAODZDC()); // set names SetStdNames(); @@ -350,6 +357,8 @@ void AliAODEvent::GetStdContent() fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters"); fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters"); fDimuons = (TClonesArray*)fAODObjects->FindObject("dimuons"); + fAODVZERO = (AliAODVZERO*)fAODObjects->FindObject("AliAODVZERO"); + fAODZDC = (AliAODZDC*)fAODObjects->FindObject("AliAODZDC"); } //______________________________________________________________________________ @@ -366,65 +375,88 @@ void AliAODEvent::ResetStd(Int_t trkArrSize, { // deletes content of standard arrays and resets size - fTracks->Delete(); - if (trkArrSize > fTracks->GetSize()) - fTracks->Expand(trkArrSize); - - fVertices->Delete(); - if (vtxArrSize > fVertices->GetSize()) - fVertices->Expand(vtxArrSize); - - fV0s->Delete(); - if (v0ArrSize > fV0s->GetSize()) - fV0s->Expand(v0ArrSize); - - fCascades->Delete(); - if (cascadeArrSize > fCascades->GetSize()) - fCascades->Expand(cascadeArrSize); - - fJets->Delete(); - if (jetSize > fJets->GetSize()) - fJets->Expand(jetSize); - - fCaloClusters->Delete(); - if (caloClusSize > fCaloClusters->GetSize()) - fCaloClusters->Expand(caloClusSize); - - fFmdClusters->Delete(); - if (fmdClusSize > fFmdClusters->GetSize()) - fFmdClusters->Expand(fmdClusSize); - - fPmdClusters->Delete(); - if (pmdClusSize > fPmdClusters->GetSize()) - fPmdClusters->Expand(pmdClusSize); - - fDimuons->Delete(); - if (dimuonArrSize > fDimuons->GetSize()) - fDimuons->Expand(dimuonArrSize); - - // Reset the tracklets - fTracklets->DeleteContainer(); - fPhosCells->DeleteContainer(); - fEmcalCells->DeleteContainer(); - + if (fTracks) { + fTracks->Delete(); + if (trkArrSize > fTracks->GetSize()) + fTracks->Expand(trkArrSize); + } + if (fVertices) { + fVertices->Delete(); + if (vtxArrSize > fVertices->GetSize()) + fVertices->Expand(vtxArrSize); + } + if (fV0s) { + fV0s->Delete(); + if (v0ArrSize > fV0s->GetSize()) + fV0s->Expand(v0ArrSize); + } + if (fCascades) { + fCascades->Delete(); + if (cascadeArrSize > fCascades->GetSize()) + fCascades->Expand(cascadeArrSize); + } + if (fJets) { + fJets->Delete(); + if (jetSize > fJets->GetSize()) + fJets->Expand(jetSize); + } + if (fCaloClusters) { + fCaloClusters->Delete(); + if (caloClusSize > fCaloClusters->GetSize()) + fCaloClusters->Expand(caloClusSize); + } + if (fFmdClusters) { + fFmdClusters->Delete(); + if (fmdClusSize > fFmdClusters->GetSize()) + fFmdClusters->Expand(fmdClusSize); + } + if (fPmdClusters) { + fPmdClusters->Delete(); + if (pmdClusSize > fPmdClusters->GetSize()) + fPmdClusters->Expand(pmdClusSize); + } + if (fDimuons) { + fDimuons->Delete(); + if (dimuonArrSize > fDimuons->GetSize()) + fDimuons->Expand(dimuonArrSize); + } + if (fTracklets) + fTracklets->DeleteContainer(); + if (fPhosCells) + fPhosCells->DeleteContainer(); + if (fEmcalCells) + fEmcalCells->DeleteContainer(); } void AliAODEvent::ClearStd() { // clears the standard arrays - fHeader ->RemoveQTheta(); - fTracks ->Delete(); - fVertices ->Delete(); - fV0s ->Delete(); - fCascades ->Delete(); - fTracklets ->DeleteContainer(); - fJets ->Delete(); - fEmcalCells ->DeleteContainer(); - fPhosCells ->DeleteContainer(); - fCaloClusters ->Delete(); - fFmdClusters ->Clear(); - fPmdClusters ->Clear(); - fDimuons ->Clear(); + if (fHeader) + fHeader ->Clear(); + if (fTracks) + fTracks ->Delete(); + if (fVertices) + fVertices ->Delete(); + if (fV0s) + fV0s ->Delete(); + if (fCascades) + fCascades ->Delete(); + if (fTracklets) + fTracklets ->DeleteContainer(); + if (fJets) + fJets ->Delete(); + if (fEmcalCells) + fEmcalCells ->DeleteContainer(); + if (fPhosCells) + fPhosCells ->DeleteContainer(); + if (fCaloClusters) + fCaloClusters ->Delete(); + if (fFmdClusters) + fFmdClusters ->Clear(); + if (fPmdClusters) + fPmdClusters ->Clear(); + if (fDimuons) + fDimuons ->Clear(); } //_________________________________________________________________ @@ -436,9 +468,9 @@ Int_t AliAODEvent::GetPHOSClusters(TRefArray *clusters) const AliAODCaloCluster *cl = 0; Bool_t first = kTRUE; - for (Int_t i = 0; i < GetNCaloClusters() ; i++) { + for (Int_t i = 0; i < GetNumberOfCaloClusters() ; i++) { if ( (cl = GetCaloCluster(i)) ) { - if (cl->IsPHOSCluster()){ + if (cl->IsPHOS()){ if(first) { new (clusters) TRefArray(TProcessID::GetProcessWithUID(cl)); first=kFALSE; @@ -459,9 +491,9 @@ Int_t AliAODEvent::GetEMCALClusters(TRefArray *clusters) const clusters->Clear(); AliAODCaloCluster *cl = 0; Bool_t first = kTRUE; - for (Int_t i = 0; i < GetNCaloClusters(); i++) { + for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) { if ( (cl = GetCaloCluster(i)) ) { - if (cl->IsEMCALCluster()){ + if (cl->IsEMCAL()){ if(first) { new (clusters) TRefArray(TProcessID::GetProcessWithUID(cl)); first=kFALSE; @@ -484,7 +516,8 @@ Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const AliAODTrack *track = 0; for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) { - if ((track = GetTrack(iTrack))->IsMuonTrack()) { + track = GetTrack(iTrack); + if (track->IsMuonTrack()) { muonTracks->Add(track); } } @@ -498,9 +531,8 @@ Int_t AliAODEvent::GetNumberOfMuonTracks() const { // get number of muon tracks Int_t nMuonTracks=0; - AliAODTrack *track = 0; for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) { - if ((track = GetTrack(iTrack))->IsMuonTrack()) { + if ((GetTrack(iTrack))->IsMuonTrack()) { nMuonTracks++; } } @@ -508,103 +540,107 @@ Int_t AliAODEvent::GetNumberOfMuonTracks() const return nMuonTracks; } +//______________________________________________________________________________ void AliAODEvent::ReadFromTree(TTree *tree, Option_t* opt /*= ""*/) { - // Connects aod event to tree + // Connects aod event to tree if(!tree){ - Printf("%s %d AliAODEvent::ReadFromTree() Zero Pointer to Tree \n",(char*)__FILE__,__LINE__); + AliWarning("Zero Pointer to Tree \n"); return; } - // load the TTree + // load the TTree if(!tree->GetTree())tree->LoadTree(0); - - // Try to find AliAODEvent + + // Try to find AliAODEvent AliAODEvent *aodEvent = 0; aodEvent = (AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"); if(aodEvent){ - // Check if already connected to tree + // This event is connected to the tree by definition, just say so + aodEvent->SetConnected(); + // Check if already connected to tree TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("AODObjectsConnectedToTree")); if (connectedList && (strcmp(opt, "reconnect"))) { - // If connected use the connected list of objects - fAODObjects->Delete(); + // If connected use the connected list of objects + delete fAODObjects; fAODObjects = connectedList; GetStdContent(); fConnected = kTRUE; return; } - // Connect to tree - // prevent a memory leak when reading back the TList - // if (!(strcmp(opt, "reconnect"))) fAODObjects->Delete(); - - // create a new TList from the UserInfo TList... - // copy constructor does not work... - fAODObjects = (TList*)(aodEvent->GetList()->Clone()); + // Connect to tree + // prevent a memory leak when reading back the TList +// if (!(strcmp(opt, "reconnect"))) fAODObjects->Delete(); + + // create a new TList from the UserInfo TList... + // copy constructor does not work... + // fAODObjects = (TList*)(aodEvent->GetList()->Clone()); + fAODObjects = (TList*)aodEvent->GetList(); fAODObjects->SetOwner(kTRUE); - if(fAODObjects->GetEntries()GetEntries(),kAODListN); + if(fAODObjects->GetEntries()GetEntries(),kAODListN)); } - // - // Let's find out whether we have friends + // + // Let's find out whether we have friends TList* friendL = tree->GetTree()->GetListOfFriends(); if (friendL) { - TIter next(friendL); - TFriendElement* fe; - while ((fe = (TFriendElement*)next())){ - aodEvent = (AliAODEvent*)(fe->GetTree()->GetUserInfo()->FindObject("AliAODEvent")); - if (!aodEvent) { - printf("No UserInfo on tree \n"); - } else { - - TList* objL = (TList*)(aodEvent->GetList()->Clone()); - printf("Get list of object from tree %d !!\n", objL->GetEntries()); - TIter nextobject(objL); - TObject* obj = 0; - while((obj = nextobject())) - { - printf("Adding object from friend %s !\n", obj->GetName()); - fAODObjects->Add(obj); - } // object "branch" loop - } // has userinfo - } // friend loop + TIter next(friendL); + TFriendElement* fe; + while ((fe = (TFriendElement*)next())){ + aodEvent = (AliAODEvent*)(fe->GetTree()->GetUserInfo()->FindObject("AliAODEvent")); + if (!aodEvent) { + printf("No UserInfo on tree \n"); + } else { + + // TList* objL = (TList*)(aodEvent->GetList()->Clone()); + TList* objL = (TList*)aodEvent->GetList(); + printf("Get list of object from tree %d !!\n", objL->GetEntries()); + TIter nextobject(objL); + TObject* obj = 0; + while((obj = nextobject())) + { + printf("Adding object from friend %s !\n", obj->GetName()); + fAODObjects->Add(obj); + } // object "branch" loop + } // has userinfo + } // friend loop } // has friends - - -// set the branch addresses + // set the branch addresses TIter next(fAODObjects); TNamed *el; while((el=(TNamed*)next())){ TString bname(el->GetName()); - // check if branch exists under this Name + // check if branch exists under this Name TBranch *br = tree->GetTree()->GetBranch(bname.Data()); if(br){ - tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el)); + tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el)); } else { - br = tree->GetBranch(Form("%s.",bname.Data())); - if(br){ - tree->SetBranchAddress(Form("%s.",bname.Data()),fAODObjects->GetObjectRef(el)); - } - else{ - printf("%s %d AliAODEvent::ReadFromTree() No Branch found with Name %s. \n", - (char*)__FILE__,__LINE__,bname.Data()); - } + br = tree->GetBranch(Form("%s.",bname.Data())); + if(br){ + tree->SetBranchAddress(Form("%s.",bname.Data()),fAODObjects->GetObjectRef(el)); + } + else{ + printf("%s %d AliAODEvent::ReadFromTree() No Branch found with Name %s. \n", + (char*)__FILE__,__LINE__,bname.Data()); + } } } GetStdContent(); - // when reading back we are not owner of the list - // must not delete it + // when reading back we are not owner of the list + // must not delete it fAODObjects->SetOwner(kTRUE); fAODObjects->SetName("AODObjectsConnectedToTree"); - // we are not owner of the list objects - // must not delete it + // we are not owner of the list objects + // must not delete it tree->GetUserInfo()->Add(fAODObjects); fConnected = kTRUE; }// no aodEvent else { - // we can't get the list from the user data, create standard content - // and set it by hand + // we can't get the list from the user data, create standard content + // and set it by hand CreateStdContent(); TIter next(fAODObjects); TNamed *el; @@ -613,12 +649,12 @@ void AliAODEvent::ReadFromTree(TTree *tree, Option_t* opt /*= ""*/) tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el)); } GetStdContent(); - // when reading back we are not owner of the list - // must not delete it + // when reading back we are not owner of the list + // must not delete it fAODObjects->SetOwner(kTRUE); } } -//______________________________________________________________________________ + //______________________________________________________________________________ Int_t AliAODEvent::GetNumberOfPileupVerticesSPD() const{ // count number of SPD pileup vertices Int_t nVertices=GetNumberOfVertices(); @@ -642,7 +678,7 @@ Int_t AliAODEvent::GetNumberOfPileupVerticesTracks() const{ } //______________________________________________________________________________ AliAODVertex* AliAODEvent::GetPrimaryVertexSPD() const{ - // + // Get SPD primary vertex Int_t nVertices=GetNumberOfVertices(); for(Int_t iVert=0; iVertGetZ(); Double_t distZ=TMath::Abs(z2-z1); Double_t distZdiam=TMath::Abs(z2-GetDiamondZ()); - Double_t cutZdiam=nSigmaDiamZ*GetSigma2DiamondZ(); + Double_t cutZdiam=nSigmaDiamZ*TMath::Sqrt(GetSigma2DiamondZ()); if(GetSigma2DiamondZ()<0.0001)cutZdiam=99999.; //protection for missing z diamond information if(distZ>minZdist && distZdiamGetX(); @@ -746,7 +782,7 @@ void AliAODEvent::Print(Option_t *) const return; } -void AliAODEvent::AssignIDtoCollection(TCollection* col) +void AliAODEvent::AssignIDtoCollection(const TCollection* col) { // Static method which assigns a ID to each object in a collection // In this way the objects are marked as referenced and written with @@ -757,3 +793,11 @@ void AliAODEvent::AssignIDtoCollection(TCollection* col) while ((obj = next())) TProcessID::AssignID(obj); } + +Bool_t AliAODEvent::IsPileupFromSPDInMultBins() const { + Int_t nTracklets=GetTracklets()->GetNumberOfTracklets(); + if(nTracklets<20) return IsPileupFromSPD(3,0.8); + else if(nTracklets<50) return IsPileupFromSPD(4,0.8); + else return IsPileupFromSPD(5,0.8); +} +