From dcc1f876236ec49e6c8593e792f438349fdbbed4 Mon Sep 17 00:00:00 2001 From: agheata Date: Mon, 7 Feb 2011 14:16:44 +0000 Subject: [PATCH] some fixes wrt to the AliAODExtension behavior (Laurent) --- ANALYSIS/AliAnalysisManager.cxx | 17 ++- ANALYSIS/AliAnalysisTask.cxx | 3 +- ANALYSIS/AliAnalysisTask.h | 2 +- ANALYSIS/macros/AnalysisTrainNewFilterAOD.C | 24 ++-- PWG3/muon/AliAnalysisTaskESDMuonFilter.cxx | 46 ++++--- STEER/AliAODHandler.cxx | 125 +++++++++++++++----- STEER/AliAODHandler.h | 9 +- 7 files changed, 158 insertions(+), 68 deletions(-) diff --git a/ANALYSIS/AliAnalysisManager.cxx b/ANALYSIS/AliAnalysisManager.cxx index 7dd8d10e564..e34b957b518 100644 --- a/ANALYSIS/AliAnalysisManager.cxx +++ b/ANALYSIS/AliAnalysisManager.cxx @@ -1402,7 +1402,7 @@ void AliAnalysisManager::AddBranches(const char *branches) fRequestedBranches += obj->GetName(); } } - if (arr) delete arr; + delete arr; } //______________________________________________________________________________ @@ -1425,6 +1425,7 @@ void AliAnalysisManager::CheckBranches(Bool_t load) fTable.Add(br); if (load && br->GetReadEntry()!=GetCurrentEntry()) br->GetEntry(GetCurrentEntry()); } + delete arr; } //______________________________________________________________________________ @@ -1442,8 +1443,22 @@ void AliAnalysisManager::PrintStatus(Option_t *option) const AliAnalysisTask *task; while ((task=(AliAnalysisTask*)next())) task->PrintTask(option); + if (!fAutoBranchHandling && !fRequestedBranches.IsNull()) printf("Requested input branches:\n%s\n", fRequestedBranches.Data()); + + TString sopt(option); + sopt.ToUpper(); + + if (sopt.Contains("ALL")) + { + if ( fOutputEventHandler ) + { + cout << TString('_',78) << endl; + cout << "OutputEventHandler:" << endl; + fOutputEventHandler->Print(" "); + } + } } //______________________________________________________________________________ diff --git a/ANALYSIS/AliAnalysisTask.cxx b/ANALYSIS/AliAnalysisTask.cxx index 47edc46945a..17fb82b5822 100644 --- a/ANALYSIS/AliAnalysisTask.cxx +++ b/ANALYSIS/AliAnalysisTask.cxx @@ -554,7 +554,6 @@ Bool_t AliAnalysisTask::CheckCircularDeps() void AliAnalysisTask::PrintTask(Option_t *option, Int_t indent) const { // Print task info. - AliAnalysisTask *thistask = (AliAnalysisTask*)this; TString opt(option); opt.ToLower(); Bool_t dep = (opt.Contains("dep"))?kTRUE:kFALSE; @@ -565,7 +564,7 @@ void AliAnalysisTask::PrintTask(Option_t *option, Int_t indent) const if (!dep || (dep && IsChecked())) { printf("______________________________________________________________________________\n"); printf("%s\n", Form("%stask: %s ACTIVE=%i POST_LOOP=%i", ind.Data(), GetName(),IsActive(),IsPostEventLoop())); - if (dep) thistask->SetChecked(kFALSE); + if (dep) const_cast(this)->SetChecked(kFALSE); else { for (islot=0; islotGetName())); diff --git a/ANALYSIS/AliAnalysisTask.h b/ANALYSIS/AliAnalysisTask.h index c478cf3fd92..7b8cc92cbd8 100644 --- a/ANALYSIS/AliAnalysisTask.h +++ b/ANALYSIS/AliAnalysisTask.h @@ -125,7 +125,7 @@ public: Bool_t IsUsed() const {return TObject::TestBit(kTaskUsed);} Bool_t IsZombie() const {return TObject::TestBit(kTaskZombie);} Bool_t HasBranches() const {return !fBranchNames.IsNull();} - void PrintTask(Option_t *option="all", Int_t indent=0) const; + virtual void PrintTask(Option_t *option="all", Int_t indent=0) const; void PrintContainers(Option_t *option="all", Int_t indent=0) const; void SetBranches(const char *names) {fBranchNames = names;} void SetChecked(Bool_t flag=kTRUE) {TObject::SetBit(kTaskChecked,flag);} diff --git a/ANALYSIS/macros/AnalysisTrainNewFilterAOD.C b/ANALYSIS/macros/AnalysisTrainNewFilterAOD.C index 742bb0b7524..c670a0955d5 100644 --- a/ANALYSIS/macros/AnalysisTrainNewFilterAOD.C +++ b/ANALYSIS/macros/AnalysisTrainNewFilterAOD.C @@ -38,9 +38,9 @@ TString proof_outdir = ""; // ### Settings that make sense when using the Alien plugin //============================================================================== Int_t runOnData = 1; // Set to 1 if processing real data -Int_t iCollision = 0; // 0=pp, 1=Pb-Pb +Int_t iCollision = 1; // 0=pp, 1=Pb-Pb Bool_t usePLUGIN = kTRUE; // do not change -Bool_t useProductionMode = kTRUE; // use the plugin in production mode +Bool_t useProductionMode = kFALSE; // use the plugin in production mode // Usage of par files ONLY in grid mode and ONLY if the code is not available // in the deployed AliRoot versions. Par file search path: local dir, if not there $ALICE_ROOT. // To refresh par files, remove the ones in the workdir, then do "make " in @@ -48,7 +48,7 @@ Bool_t useProductionMode = kTRUE; // use the plugin in production mode Bool_t usePAR = kFALSE; // use par files for extra libs Bool_t useCPAR = kFALSE; // use par files for common libs TString root_version = "v5-27-06b"; // *CHANGE ME IF MORE RECENT IN GRID* -TString aliroot_version = "v4-21-13-AN"; // *CHANGE ME IF MORE RECENT IN GRID* +TString aliroot_version = "v4-21-14-AN"; // *CHANGE ME IF MORE RECENT IN GRID* // Change production base directory here (test mode) TString alien_datadir = "/alice/data/2010/LHC10h"; // Work directory in GRID (DON'T CHANGE) @@ -110,13 +110,14 @@ Bool_t saveProofToAlien = kFALSE; // save proof outputs in AliEn Int_t iAODanalysis = 0; // Analysis on input AOD's Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's Int_t iESDfilter = 1; // ESD to AOD filter (barrel + muon tracks) -Int_t iMUONcopyAOD = 0; // Task that copies only muon events in a separate AOD (PWG3) +Int_t iMUONcopyAOD = 1; // Task that copies only muon events in a separate AOD (PWG3) +Int_t iMakeDimuonAOD = 0; // AliAOD.Dimuons.root Int_t iJETAN = 1; // Jet analysis (PWG4) Int_t iJETANdelta = 0; // Jet delta AODs Int_t iPWG4partcorr = 0; // Gamma-hadron correlations task (PWG4) Int_t iPWG4gammaconv = 0; // Gamma conversion analysis (PWG4) Int_t iPWG4omega3pi = 0; // Omega to 3 pi analysis (PWG4) -Int_t iPWG3vertexing = 1; // Vertexing HF task (PWG3) +Int_t iPWG3vertexing = 0;//1 // Vertexing HF task (PWG3) Int_t iPWG3hfe = 0; // Electrons analysis (PWG3) Int_t iPWG3JPSIfilter = 0; // JPSI filtering (PWG3) Int_t iPWG3JPSI = 0; // JPSI analysis (PWG3) @@ -384,10 +385,13 @@ void AddAnalysisTasks() if (iMUONcopyAOD) { printf("Registering delta AOD file\n"); mgr->RegisterExtraFile("AliAOD.Muons.root"); - mgr->RegisterExtraFile("AliAOD.Dimuons.root"); - AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kTRUE, kTRUE, usePhysicsSelection, kFALSE, AliESDpid::kTOF_T0, kTRUE); + if ( iMakeDimuonAOD ) + { + mgr->RegisterExtraFile("AliAOD.Dimuons.root"); + } + AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kTRUE,(iMakeDimuonAOD==1), usePhysicsSelection, kFALSE, AliESDpid::kTOF_T0, kTRUE); } else { - AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kFALSE, kFALSE, usePhysicsSelection,kFALSE, AliESDpid::kTOF_T0, kTRUE); + AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kFALSE, kFALSE, usePhysicsSelection,kFALSE, AliESDpid::kTOF_T0, kTRUE); } } @@ -693,7 +697,9 @@ void StartAnalysis(const char *mode, TChain *chain) { ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain"); return; } - mgr->StartAnalysis(mode, chain); + mgr->SetNSysInfo(1); + mgr->StartAnalysis(mode, chain); + AliCodeTimer::Instance()->Print(); return; case 1: if (!proof_dataset.Length()) { diff --git a/PWG3/muon/AliAnalysisTaskESDMuonFilter.cxx b/PWG3/muon/AliAnalysisTaskESDMuonFilter.cxx index 719733db56f..55dd806b778 100644 --- a/PWG3/muon/AliAnalysisTaskESDMuonFilter.cxx +++ b/PWG3/muon/AliAnalysisTaskESDMuonFilter.cxx @@ -28,29 +28,30 @@ // (see AddFilteredAOD method) // -#include -#include -#include - #include "AliAnalysisTaskESDMuonFilter.h" -#include "AliAnalysisManager.h" -#include "AliESDEvent.h" + +#include "AliAODDimuon.h" #include "AliAODEvent.h" -#include "AliESDInputHandler.h" #include "AliAODHandler.h" +#include "AliAODMCParticle.h" +#include "AliAODMuonReplicator.h" +#include "AliAODVertex.h" #include "AliAnalysisFilter.h" -#include "AliESDtrack.h" +#include "AliAnalysisManager.h" +#include "AliCodeTimer.h" +#include "AliESDEvent.h" +#include "AliESDInputHandler.h" #include "AliESDMuonTrack.h" #include "AliESDVertex.h" -#include "AliMultiplicity.h" +#include "AliESDtrack.h" #include "AliLog.h" -#include "AliStack.h" #include "AliMCEvent.h" #include "AliMCEventHandler.h" -#include "AliAODMCParticle.h" -#include "AliAODDimuon.h" -#include "AliAODMuonReplicator.h" -#include "AliAODVertex.h" +#include "AliMultiplicity.h" +#include "AliStack.h" +#include +#include +#include ClassImp(AliAnalysisTaskESDMuonFilter) ClassImp(AliAnalysisNonMuonTrackCuts) @@ -169,21 +170,13 @@ void AliAnalysisTaskESDMuonFilter::AddFilteredAOD(const char* aodfilename, const if ( fOnlyMuon ) { - ext->FilterBranch("cascades",0x0); - ext->FilterBranch("v0s",0x0); - ext->FilterBranch("kinks",0x0); - ext->FilterBranch("jets",0x0); - ext->FilterBranch("emcalCells",0x0); - ext->FilterBranch("phosCells",0x0); - ext->FilterBranch("caloClusters",0x0); - ext->FilterBranch("fmdClusters",0x0); - ext->FilterBranch("pmdClusters",0x0); - ext->FilterBranch("tracklets",0x0); - AliAODBranchReplicator* murep = new AliAODMuonReplicator("MuonReplicator", "remove non muon tracks and non primary or pileup vertices", new AliAnalysisNonMuonTrackCuts, new AliAnalysisNonPrimaryVertices); + + ext->DropUnspecifiedBranches(); // all branches not part of a FilterBranch call (below) will be dropped + ext->FilterBranch("tracks",murep); ext->FilterBranch("vertices",murep); ext->FilterBranch("dimuons",murep); @@ -214,6 +207,9 @@ void AliAnalysisTaskESDMuonFilter::UserExec(Option_t */*option*/) void AliAnalysisTaskESDMuonFilter::ConvertESDtoAOD() { // ESD Muon Filter analysis task executed for each event + + AliCodeTimerAuto("",0); + AliESDEvent* esd = dynamic_cast(InputEvent()); // Fetch Stack for debuggging if available diff --git a/STEER/AliAODHandler.cxx b/STEER/AliAODHandler.cxx index 75191ba8b0a..2c7c4f5c493 100644 --- a/STEER/AliAODHandler.cxx +++ b/STEER/AliAODHandler.cxx @@ -722,6 +722,7 @@ fObjectList(0x0) TObject::SetBit(kFilteredAOD); printf("####### Added AOD filter %s\n", name); } else printf("####### Added AOD extension %s\n", name); + KeepUnspecifiedBranches(); } //______________________________________________________________________________ @@ -750,32 +751,57 @@ void AliAODExtension::AddBranch(const char* cname, void* addobj) // Error("AddBranch", "Not allowed to add branched to filtered AOD's."); // return; // } + AliCodeTimerAuto(GetName(),0); - if (!fAODEvent) { - char type[20]; - gROOT->ProcessLine(Form("TString s_tmp; AliAnalysisManager::GetAnalysisManager()->GetAnalysisTypeString(s_tmp); sprintf((char*)%p, \"%%s\", s_tmp.Data());", type)); - Init(type); - } - TDirectory *owd = gDirectory; - if (fFileE) { - fFileE->cd(); + if (!fAODEvent) { + char type[20]; + gROOT->ProcessLine(Form("TString s_tmp; AliAnalysisManager::GetAnalysisManager()->GetAnalysisTypeString(s_tmp); sprintf((char*)%p, \"%%s\", s_tmp.Data());", type)); + Init(type); + } + TDirectory *owd = gDirectory; + if (fFileE) { + fFileE->cd(); + } + char** apointer = (char**) addobj; + TObject* obj = (TObject*) *apointer; + + fAODEvent->AddObject(obj); + + TString bname(obj->GetName()); + + if (!fTreeE->FindBranch(bname.Data())) + { + Bool_t acceptAdd(kTRUE); + + if ( TestBit(kDropUnspecifiedBranches) ) + { + // check that this branch is in our list of specified ones... + // otherwise do not add it ! + TIter next(fRepFiMap); + TObjString* p; + + acceptAdd=kFALSE; + + while ( ( p = static_cast(next()) ) && !acceptAdd ) + { + if ( p->String() == bname ) acceptAdd=kTRUE; + } } - char** apointer = (char**) addobj; - TObject* obj = (TObject*) *apointer; - - fAODEvent->AddObject(obj); - - const Int_t kSplitlevel = 99; // default value in TTree::Branch() - const Int_t kBufsize = 32000; // default value in TTree::Branch() - - if (!fTreeE->FindBranch(obj->GetName())) { + + if ( acceptAdd ) + { // Do the same as if we book via // TTree::Branch(TCollection*) - fTreeE->Bronch(obj->GetName(), cname, fAODEvent->GetList()->GetObjectRef(obj), - kBufsize, kSplitlevel - 1); + + const Int_t kSplitlevel = 99; // default value in TTree::Branch() + const Int_t kBufsize = 32000; // default value in TTree::Branch() + + fTreeE->Bronch(bname.Data(), cname, fAODEvent->GetList()->GetObjectRef(obj), + kBufsize, kSplitlevel - 1); } - owd->cd(); + } + owd->cd(); } //______________________________________________________________________________ @@ -838,7 +864,17 @@ Bool_t AliAODExtension::Init(Option_t *option) while ( ( o = next() ) ) { - if ( fRepFiMap ) + Bool_t mustKeep(kFALSE); + + TString test(o->ClassName()); + test.ToUpper(); + if (test.Contains("HEADER")) + { + // do not allow to drop header branch + mustKeep=kTRUE; + } + + if ( fRepFiMap && !mustKeep ) { TObject* specified = fRepFiMap->FindObject(o->GetName()); if (specified) @@ -868,14 +904,20 @@ Bool_t AliAODExtension::Init(Option_t *option) } else { - fObjectList->Add(o); + if ( !TestBit(kDropUnspecifiedBranches) ) + { + // object o will be transmitted to the output AOD, unchanged + fObjectList->Add(o); + } } } else { - // no replicator / filter map created, so works as before, i.e. - // assume we copy everything. - fObjectList->Add(o); + if ( mustKeep || !TestBit(kDropUnspecifiedBranches) ) + { + // object o will be transmitted to the output AOD, unchanged + fObjectList->Add(o); + } } } @@ -884,7 +926,24 @@ Bool_t AliAODExtension::Init(Option_t *option) while ( ( o = next() ) ) { TObject* out = fObjectList->FindObject(o->GetName()); - AliInfo(Form("OBJECT IN %20s %p -> OUT %p %s",o->GetName(),o,out,((out!=o && out) ? "REPLICATED":"-"))); + + TString status; + + if ( out != o && out ) + { + status = "REPLICATED"; + } + else if ( out ) + { + status = "COPIED AS IS"; + } + else + { + status = "DROPPED"; + } + + AliInfo(Form("OBJECT IN %20s %p -> OUT %p %s", + o->GetName(),o,out,status.Data())); } if (fEnableReferences) fTreeE->BranchRef(); @@ -902,7 +961,14 @@ void AliAODExtension::Print(Option_t* opt) const // Print info about this extension cout << opt << Form("AliAODExtension - %s - %s",GetName(),GetTitle()) << endl; - cout << opt << opt << Form("References are %s enabled",fEnableReferences ? "" : "not") << endl; + if ( !fEnableReferences ) + { + cout << opt << opt << "References are disabled ! Hope you know what you are doing !" << endl; + } + if ( TestBit(kDropUnspecifiedBranches) ) + { + cout << opt << opt << "All branches not explicitely specified will be dropped" << endl; + } TIter next(fRepFiMap); TObjString* s; @@ -918,10 +984,11 @@ void AliAODExtension::Print(Option_t* opt) const skipped += ' '; } } - + + if ( skipped.Length() ) { - cout << opt << opt << "Branches that will be skipped altogether : " << skipped.Data() << endl; + cout << opt << opt << "Specified branches that will be skipped altogether : " << skipped.Data() << endl; } next.Reset(); diff --git a/STEER/AliAODHandler.h b/STEER/AliAODHandler.h index c5032017a15..905633472cc 100644 --- a/STEER/AliAODHandler.h +++ b/STEER/AliAODHandler.h @@ -143,7 +143,8 @@ class AliAODExtension : public TNamed { public: enum EAliAODExtensionFlags { - kFilteredAOD = BIT(14) + kFilteredAOD = BIT(14), + kDropUnspecifiedBranches = BIT(15) }; AliAODExtension(); @@ -166,6 +167,12 @@ enum EAliAODExtensionFlags { void Print(Option_t* opt="") const; + // Branches not specified in any FilterBranch call will be dropped by default + void DropUnspecifiedBranches() { TObject::SetBit(kDropUnspecifiedBranches); } + + // Branches not specified in any FilterBranch call will be kept by default + void KeepUnspecifiedBranches() { TObject::ResetBit(kDropUnspecifiedBranches); } + void FilterBranch(const char* branchName, AliAODBranchReplicator* replicator=0x0); /* Use DisableReferences if and only if the output AOD contains no TRef or TRefArray, -- 2.43.0