X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=JETAN%2FAliAnalysisTaskJets.cxx;h=a9bb38bea9d22c87e142cd61a30046976f9f7ed4;hb=2d9bb9098fa13736e8b2e3d7fe0d6d346c37517f;hp=b34436e68f7f46df7297a62d8d2fb5d1b1e81da0;hpb=8838ab7ab4663d7ad4117ce1b692143175fa0d4e;p=u%2Fmrichter%2FAliRoot.git diff --git a/JETAN/AliAnalysisTaskJets.cxx b/JETAN/AliAnalysisTaskJets.cxx index b34436e68f7..a9bb38bea9d 100644 --- a/JETAN/AliAnalysisTaskJets.cxx +++ b/JETAN/AliAnalysisTaskJets.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include "AliAnalysisTaskJets.h" #include "AliAnalysisManager.h" @@ -32,6 +33,7 @@ #include "AliESDEvent.h" #include "AliESD.h" #include "AliAODEvent.h" +#include "AliAODJetEventBackground.h" #include "AliAODHandler.h" #include "AliMCEventHandler.h" #include "AliESDInputHandler.h" @@ -47,11 +49,16 @@ AliAnalysisTaskJets::AliAnalysisTaskJets(): AliAnalysisTaskSE(), fConfigFile("ConfigJetAnalysis.C"), fNonStdBranch(""), + fNonStdFile(""), fJetFinder(0x0), fHistos(0x0), + fAODExtension(0x0), fListOfHistos(0x0), fChain(0x0), - fOpt(0) + fOpt(0), + fReadAODFromOutput(0), + fUseAODBackground(kFALSE), + fFilterPt(0.) { // Default constructor } @@ -60,11 +67,16 @@ AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name): AliAnalysisTaskSE(name), fConfigFile("ConfigJetAnalysis.C"), fNonStdBranch(""), + fNonStdFile(""), fJetFinder(0x0), fHistos(0x0), + fAODExtension(0x0), fListOfHistos(0x0), fChain(0x0), - fOpt(0) + fOpt(0), + fReadAODFromOutput(0), + fUseAODBackground(kFALSE), + fFilterPt(0.) { // Default constructor DefineOutput(1, TList::Class()); @@ -74,11 +86,16 @@ AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name, TChain* chain): AliAnalysisTaskSE(name), fConfigFile("ConfigJetAnalysis.C"), fNonStdBranch(""), + fNonStdFile(""), fJetFinder(0x0), fHistos(0x0), + fAODExtension(0x0), fListOfHistos(0x0), fChain(chain), - fOpt(0) + fOpt(0), + fReadAODFromOutput(0), + fUseAODBackground(kFALSE), + fFilterPt(0.) { // Default constructor DefineOutput(1, TList::Class()); @@ -90,10 +107,21 @@ void AliAnalysisTaskJets::UserCreateOutputObjects() // Create the output container // if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n"); - + + AliJetHeader *fH = fJetFinder->GetHeader(); + if(fNonStdBranch.Length()==0) { // Connec default AOD to jet finder + // create a new branch for the background + + if(fUseAODBackground){ + if(!AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())){ + AliAODJetEventBackground* evBkg = new AliAODJetEventBackground(); + evBkg->SetName(AliAODJetEventBackground::StdBranchName()); + AddAODBranch("AliAODJetEventBackground",&evBkg); + } + } fJetFinder->ConnectAOD(AODEvent()); } else @@ -101,20 +129,62 @@ void AliAnalysisTaskJets::UserCreateOutputObjects() // Create a new branch for jets... // how is this reset? -> cleared in the UserExec.... // Can this be handled by the framework? + // here we can also have the case that the brnaches are written to a separate file + TClonesArray *tca = new TClonesArray("AliAODJet", 0); - tca->SetName(fNonStdBranch); - AddAODBranch("TClonesArray",&tca); - fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data()); + tca->SetName(fNonStdBranch.Data()); + AddAODBranch("TClonesArray",&tca,fNonStdFile.Data()); + if(fUseAODBackground){ + if(!AODEvent() || !AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){ + AliAODJetEventBackground* evBkg = new AliAODJetEventBackground(); + evBkg->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())); + AddAODBranch("AliAODJetEventBackground",&evBkg,fNonStdFile.Data()); + } + } + if(fNonStdFile.Length()!=0){ + // + // case that we have an AOD extension we need to fetch the jets from the extended output + // we identifay the extension aod event by looking for the branchname + AliAODHandler *aodH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); + fAODExtension = 0; + if(aodH){ + TObjArray* extArray = aodH->GetExtensions(); + if (extArray) { + TIter next(extArray); + while ((fAODExtension=(AliAODExtension*)next())){ + TObject *obj = fAODExtension->GetAOD()->FindListObject(fNonStdBranch.Data()); + if(fDebug>10){ + Printf("%s:%d Dumping..",(char*)__FILE__,__LINE__); + fAODExtension->GetAOD()->Dump(); + } + if(obj){ + if(fDebug>1)Printf("AODExtension found for %s",fNonStdBranch.Data()); + break; + } + fAODExtension = 0; + } + } + } + if(fAODExtension)fJetFinder->ConnectAODNonStd(fAODExtension->GetAOD(), fNonStdBranch.Data()); + } + else{ + if (fDebug > 1) printf("Connecting Non Std Branch AOD %p %s \n",AODEvent(),fNonStdBranch.Data()); + fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data()); + } } - + + // do not add the histograms in the directory + // all handled by the list + Bool_t oldStatus = TH1::AddDirectoryStatus(); + TH1::AddDirectory(kFALSE); + + // Histograms - OpenFile(1); fListOfHistos = new TList(); fHistos = new AliJetHistos(); fHistos->AddHistosToList(fListOfHistos); // Add the JetFinderInformation to the Outputlist - AliJetHeader *fH = fJetFinder->GetHeader(); // Compose a characteristic output name // with the name of the output branch @@ -126,7 +196,12 @@ void AliAnalysisTaskJets::UserCreateOutputObjects() fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data())); } } - OutputTree()->GetUserInfo()->Add(fH); + + TH1::AddDirectory(oldStatus); + + + if(!fAODExtension)OutputTree()->GetUserInfo()->Add(fH); + else fAODExtension->GetTree()->GetUserInfo()->Add(fH); } //---------------------------------------------------------------- @@ -146,11 +221,9 @@ void AliAnalysisTaskJets::Init() // Initialise Jet Analysis if(fOpt == 0) fJetFinder->Init(); else fJetFinder->InitTask(fChain); // V2 - - // Write header information to local file - fJetFinder->WriteHeaders(); } + //---------------------------------------------------------------- void AliAnalysisTaskJets::UserExec(Option_t */*option*/) { @@ -158,24 +231,59 @@ void AliAnalysisTaskJets::UserExec(Option_t */*option*/) // // Fill control histos TClonesArray* jarray = 0; + AliAODJetEventBackground* evBkg = 0; + + // only need this once + static AliAODHandler *aodH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); if(fNonStdBranch.Length()==0) { jarray = AODEvent()->GetJets(); + if(fUseAODBackground){ + evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())); + evBkg->Reset(); + } } else { - jarray = dynamic_cast(AODEvent()->FindListObject(fNonStdBranch.Data())); - jarray->Delete(); // this is our responsibility, clear before filling again + if(AODEvent())jarray = (TClonesArray*)(AODEvent()->FindListObject(fNonStdBranch.Data())); + if(!jarray)jarray = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(fNonStdBranch.Data())); + if(jarray)jarray->Delete(); // this is our responsibility, clear before filling again + if(fUseAODBackground){ + if(AODEvent())evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))); + if(!evBkg) evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))); + if(evBkg)evBkg->Reset(); + } } - fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent()); + if (dynamic_cast(InputEvent()) != 0 && !fReadAODFromOutput) { +// AOD is input event..........................................V + fJetFinder->GetReader()->SetInputEvent(InputEvent(), InputEvent(), MCEvent()); + } else { +// AOD is read from output ....................................V + fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent()); + } + + + if(fOpt==0) fJetFinder->ProcessEvent(); else fJetFinder->ProcessEvent2(); // V2 // Fill control histos - fHistos->FillHistos(jarray); + if(jarray)fHistos->FillHistos(jarray); + + + if(jarray&&aodH&&fFilterPt>0){ + if(jarray->GetEntries()>0){ + AliAODJet *jet = (AliAODJet*)jarray->At(0); + if(jet->Pt()>fFilterPt){ + // aodH->EnableFillAODforEvent(); + aodH->SetFillAOD(kTRUE); + } + } + } // Post the data PostData(1, fListOfHistos); + return; }