/************************************************************************* * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /////////////////////////////////////////////////////////////////////////// // // // Basic Analysis Task // // // /////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include "AliDielectron.h" #include "AliDielectronHistos.h" #include "AliDielectronCF.h" #include "AliDielectronMC.h" #include "AliAnalysisTaskMultiDielectron.h" ClassImp(AliAnalysisTaskMultiDielectron) //_________________________________________________________________________________ AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron() : AliAnalysisTaskSE(), fListDielectron(), fListHistos(), fListCF(), fSelectPhysics(kFALSE), fTriggerMask(AliVEvent::kMB), fTriggerOnV0AND(kFALSE), fRejectPileup(kFALSE), fTriggerAnalysis(0x0), fEventFilter(0x0), fEventStat(0x0) { // // Constructor // } //_________________________________________________________________________________ AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron(const char *name) : AliAnalysisTaskSE(name), fListDielectron(), fListHistos(), fListCF(), fSelectPhysics(kFALSE), fTriggerMask(AliVEvent::kMB), fTriggerOnV0AND(kFALSE), fRejectPileup(kFALSE), fTriggerAnalysis(0x0), fEventFilter(0x0), fEventStat(0x0) { // // Constructor // DefineInput(0,TChain::Class()); DefineOutput(1, TList::Class()); DefineOutput(2, TList::Class()); DefineOutput(3, TH1D::Class()); fListHistos.SetName("Dielectron_Histos_Multi"); fListCF.SetName("Dielectron_CF_Multi"); fListDielectron.SetOwner(); fListHistos.SetOwner(); fListCF.SetOwner(); } //_________________________________________________________________________________ void AliAnalysisTaskMultiDielectron::UserCreateOutputObjects() { // // Add all histogram manager histogram lists to the output TList // if (!fListHistos.IsEmpty()||!fListCF.IsEmpty()) return; //already initialised AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class(); // Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class(); TIter nextDie(&fListDielectron); AliDielectron *die=0; while ( (die=static_cast(nextDie())) ){ die->Init(); if (die->GetHistogramList()) fListHistos.Add(const_cast(die->GetHistogramList())); if (die->GetCFManagerPair()) fListCF.Add(const_cast(die->GetCFManagerPair()->GetContainer())); } Int_t cuts=fListDielectron.GetEntries(); Int_t nbins=kNbinsEvent+2*cuts; if (!fEventStat){ fEventStat=new TH1D("hEventStat","Event statistics",nbins,0,nbins); fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel."); fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel."); //default names fEventStat->GetXaxis()->SetBinLabel(3,"Bin3 not used"); fEventStat->GetXaxis()->SetBinLabel(4,"Bin4 not used"); fEventStat->GetXaxis()->SetBinLabel(5,"Bin5 not used"); if (fTriggerOnV0AND&&isESD) fEventStat->GetXaxis()->SetBinLabel(3,"V0and triggers"); if (fEventFilter) fEventStat->GetXaxis()->SetBinLabel(4,"After Event Filter"); if (fRejectPileup) fEventStat->GetXaxis()->SetBinLabel(5,"After Pileup rejection"); for (Int_t i=0; iGetXaxis()->SetBinLabel((kNbinsEvent+1)+2*i,Form("#splitline{1 candidate}{%s}",fListDielectron.At(i)->GetName())); fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+2)+2*i,Form("#splitline{With >1 candidate}{%s}",fListDielectron.At(i)->GetName())); } } if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis; fTriggerAnalysis->EnableHistograms(); fTriggerAnalysis->SetAnalyzeMC(AliDielectronMC::Instance()->HasMC()); PostData(1, &fListHistos); PostData(2, &fListCF); PostData(3, fEventStat); } //_________________________________________________________________________________ void AliAnalysisTaskMultiDielectron::UserExec(Option_t *) { // // Main loop. Called for every event // if (fListHistos.IsEmpty()&&fListCF.IsEmpty()) return; AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class(); Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class(); AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); if (!inputHandler) return; if ( inputHandler->GetPIDResponse() ){ AliDielectronVarManager::SetPIDResponse( inputHandler->GetPIDResponse() ); } else { //load esd pid bethe bloch parameters depending on the existance of the MC handler // yes: MC parameters // no: data parameters //ESD case if (isESD){ if (!AliDielectronVarManager::GetESDpid()){ if (AliDielectronMC::Instance()->HasMC()) { AliDielectronVarManager::InitESDpid(); } else { AliDielectronVarManager::InitESDpid(1); } } } //AOD case if (isAOD){ if (!AliDielectronVarManager::GetAODpidUtil()){ if (AliDielectronMC::Instance()->HasMC()) { AliDielectronVarManager::InitAODpidUtil(); } else { AliDielectronVarManager::InitAODpidUtil(1); } } } } // Was event selected ? UInt_t isSelected = AliVEvent::kAny; if( fSelectPhysics && inputHandler && inputHandler->GetEventSelection() ) { isSelected = inputHandler->IsEventSelected(); isSelected&=fTriggerMask; } //Before physics selection fEventStat->Fill(kAllEvents); if (isSelected==0) { PostData(3,fEventStat); return; } //after physics selection fEventStat->Fill(kSelectedEvents); //V0and if (fTriggerOnV0AND&&isESD){ if (!fTriggerAnalysis->IsOfflineTriggerFired(static_cast(InputEvent()), AliTriggerAnalysis::kV0AND)) return; } fEventStat->Fill(kV0andEvents); //event filter if (fEventFilter) { if (!fEventFilter->IsSelected(InputEvent())) return; } fEventStat->Fill(kFilteredEvents); //pileup if (fRejectPileup){ if (InputEvent()->IsPileupFromSPD(3,0.8,3.,2.,5.)) return; } fEventStat->Fill(kPileupEvents); //bz for AliKF Double_t bz = InputEvent()->GetMagneticField(); AliKFParticle::SetField( bz ); AliDielectronPID::SetCorrVal((Double_t)InputEvent()->GetRunNumber()); //Process event in all AliDielectron instances TIter nextDie(&fListDielectron); AliDielectron *die=0; Int_t idie=0; while ( (die=static_cast(nextDie())) ){ die->Process(InputEvent()); if (die->HasCandidates()){ Int_t ncandidates=die->GetPairArray(1)->GetEntriesFast(); if (ncandidates==1) fEventStat->Fill((kNbinsEvent)+2*idie); else if (ncandidates>1) fEventStat->Fill((kNbinsEvent+1)+2*idie); } ++idie; } PostData(1, &fListHistos); PostData(2, &fListCF); PostData(3,fEventStat); } //_________________________________________________________________________________ void AliAnalysisTaskMultiDielectron::FinishTaskOutput() { // // Write debug tree // TIter nextDie(&fListDielectron); AliDielectron *die=0; while ( (die=static_cast(nextDie())) ){ die->SaveDebugTree(); } }