//====================================================================
AliCentralMultiplicityTask::AliCentralMultiplicityTask(const char* name)
- : AliAnalysisTaskSE(name),
- fInspector("centralEventInspector"),
- fList(0),
+ : AliBaseESDTask(name, "AliCentralMultiplicityTask",
+ &(AliCentralCorrectionManager::Instance())),
+ fInspector("event"),
fAODCentral(kFALSE),
fUseSecondary(true),
fUseAcceptance(true),
- fFirstEventSeen(false),
fIvz(0),
fNClusterTracklet(0),
- fClusterPerTracklet(0),
- fNCluster(0),
+ fClusterPerTracklet(0),
+ fNCluster(0),
fNTracklet(0),
fVtxList(0),
fStore(false),
- fCorrManager(0)
+ fHData(0)
{
//
// Constructor
//
DGUARD(fDebug, 3,"Named CTOR of AliCentralMultiplicityTask: %s", name);
- DefineOutput(1, TList::Class());
-
- fCorrManager = &(AliCentralCorrectionManager::Instance());
fBranchNames =
"ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
"SPDVertex.,PrimaryVertex.";
}
//____________________________________________________________________
AliCentralMultiplicityTask::AliCentralMultiplicityTask()
- : AliAnalysisTaskSE(),
+ : AliBaseESDTask(),
fInspector(),
- fList(0),
fAODCentral(),
fUseSecondary(true),
fUseAcceptance(true),
- fFirstEventSeen(false),
fIvz(0),
fNClusterTracklet(0),
fClusterPerTracklet(0),
fNTracklet(0),
fVtxList(0),
fStore(false),
- fCorrManager(0)
+ fHData(0)
{
//
// Constructor
//
DGUARD(fDebug, 3,"Default CTOR of AliCentralMultiplicityTask");
}
-//____________________________________________________________________
-AliCentralMultiplicityTask::AliCentralMultiplicityTask(const AliCentralMultiplicityTask& o)
- : AliAnalysisTaskSE(o),
- fInspector(o.fInspector),
- fList(o.fList),
- fAODCentral(o.fAODCentral),
- fUseSecondary(o.fUseSecondary),
- fUseAcceptance(o.fUseAcceptance),
- fFirstEventSeen(o.fFirstEventSeen),
- fIvz(o.fIvz),
- fNClusterTracklet(o.fNClusterTracklet),
- fClusterPerTracklet(o.fClusterPerTracklet),
- fNCluster(o.fNCluster),
- fNTracklet(o.fNTracklet),
- fVtxList(o.fVtxList),
- fStore(o.fStore),
- fCorrManager(o.fCorrManager)
-{
- //
- // Copy constructor
- //
- DGUARD(fDebug, 3,"COPY CTOR of AliCentralMultiplicityTask");
-}
//____________________________________________________________________
-AliCentralMultiplicityTask&
-AliCentralMultiplicityTask::operator=(const AliCentralMultiplicityTask& o)
-{
- //
- // Assignment operator
- //
- DGUARD(fDebug,3,"Assignment of AliCentralMultiplicityTask");
- if (&o == this) return *this;
- fInspector = o.fInspector;
- fList = o.fList;
- fAODCentral = o.fAODCentral;
- fUseSecondary = o.fUseSecondary;
- fUseAcceptance = o.fUseAcceptance;
- fFirstEventSeen = o.fFirstEventSeen;
- fIvz = o.fIvz;
- fNClusterTracklet = o.fNClusterTracklet;
- fClusterPerTracklet= o.fClusterPerTracklet;
- fNCluster = o.fNCluster;
- fNTracklet = o.fNTracklet;
- fVtxList = o.fVtxList;
- fCorrManager = o.fCorrManager;
- fStore = o.fStore;
- return *this;
-}
-//____________________________________________________________________
-Bool_t
-AliCentralMultiplicityTask::Configure(const char* macro)
-{
- // --- Configure the task ------------------------------------------
- TString macroPath(gROOT->GetMacroPath());
- if (!macroPath.Contains("$(ALICE_ROOT)/PWGLF/FORWARD/analysis2")) {
- macroPath.Append(":$(ALICE_ROOT)/PWGLF/FORWARD/analysis2");
- gROOT->SetMacroPath(macroPath);
- }
- TString mac(macro);
- if (mac.EqualTo("-default-"))
- mac = "$(ALICE_ROOT)/PWGLF/FORWARD/analysis2/CentralAODConfig.C";
-
- const char* config = gSystem->Which(gROOT->GetMacroPath(),mac.Data());
- if (!config) {
- AliWarningF("%s not found in %s", macro, gROOT->GetMacroPath());
- return false;
- }
-
- AliInfoF("Loading configuration of '%s' from %s", ClassName(), config);
- gROOT->Macro(Form("%s((AliCentralMultiplicityTask*)%p)", config, this));
- delete config;
-
- return true;
-}
-
-//____________________________________________________________________
-void AliCentralMultiplicityTask::UserCreateOutputObjects()
+void
+AliCentralMultiplicityTask::CreateBranches(AliAODHandler* ah)
{
//
// Create output objects
//
DGUARD(fDebug,1,"Create user output in AliCentralMultiplicityTask");
- AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
- AliAODHandler* ah =
- dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
- if (ah) {
+ if (!ah)
//AliFatal("No AOD output handler set in analysis manager");
- TObject* obj = &fAODCentral;
- ah->AddBranch("AliAODCentralMult", &obj);
- }
-
- fList = new TList();
- fList->SetOwner();
-
- fInspector.CreateOutputObjects(fList);
+ return;
- PostData(1,fList);
+ TObject* obj = &fAODCentral;
+ ah->AddBranch("AliAODCentralMult", &obj);
}
-
//____________________________________________________________________
-AliESDEvent*
-AliCentralMultiplicityTask::GetESDEvent()
+Bool_t
+AliCentralMultiplicityTask::Book()
{
- //
- // Get the ESD event. IF this is the first event, initialise
- //
- DGUARD(fDebug,1,"Get ESD event in AliCentralMultiplicityTask");
- if (IsZombie()) return 0;
- AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
- if (!esd) {
- AliWarning("No ESD event found for input event");
- return 0;
- }
-
- // Load in the data needed
- LoadBranches();
+ fNeededCorrections = (AliCentralCorrectionManager::kSecondaryMap|
+ AliCentralCorrectionManager::kAcceptance);
+ return true;
+}
- // IF we've read the first event already, just return the event
- if (fFirstEventSeen) return esd;
+//____________________________________________________________________
+Bool_t
+AliCentralMultiplicityTask::PreData(const TAxis& vertex, const TAxis& eta)
+{
+ // FindEtaLimits();
+ // unsigned short s = 1;
+ TH2D* hCoverage = new TH2D("coverage", "#eta coverage per v_{z}",
+ eta.GetNbins(), eta.GetXmin(), eta.GetXmax(),
+ vertex.GetNbins(),vertex.GetXmin(),
+ vertex.GetXmax());
+ hCoverage->SetDirectory(0);
+ hCoverage->SetXTitle("#eta");
+ hCoverage->SetYTitle("v_{z} [cm]");
+ hCoverage->SetZTitle("n_{bins}");
- // Read the details of the rung
- fInspector.ReadRunDetails(esd);
-
- // If we weren't initialised before (i.e., in the setup), do so now.
- AliCentralCorrectionManager& ccm =
- AliCentralCorrectionManager::Instance();
-
- if (!ccm.Init(fInspector.GetRunNumber(),
- fInspector.GetCollisionSystem(),
- fInspector.GetEnergy(),
- fInspector.GetField())) {
- AliWarning("Failed to intialize correction mananger");
- }
- //AliInfo("Manager of corrections in AliCentralMultiplicityTask init");
- Bool_t ok = true;
- if (/*fUseSecondary &&*/ !ccm.GetSecondaryMap()) {
- ok = false;
- AliError("No secondary correction defined!");
- }
- if (/*fUseAcceptance &&*/ !ccm.GetAcceptance()) {
- ok = false;
- AliError("No acceptance correction defined!");
- }
- // If the corrections are not seen, make this a zombie, and prevent
- // further execution of this task.
- if (!ok) {
- AliError("Missing corrections, make this a zombie");
- SetZombie(true);
- esd = 0;
- fFirstEventSeen = true;
- return esd;
+ fAODCentral.Init(eta);
+
+ UShort_t nVz = vertex.GetNbins();
+ fVtxList = new TObjArray(nVz, 1);
+ fVtxList->SetName("centMultVtxBins");
+ fVtxList->SetOwner();
+
+ // Bool_t store = false;
+ for (Int_t v = 1; v <= nVz; v++) {
+ VtxBin* bin = new VtxBin(v, vertex.GetBinLowEdge(v),
+ vertex.GetBinUpEdge(v));
+ bin->SetupForData(fList, hCoverage, fStore);
+ fVtxList->AddAt(bin, v);
}
+ fList->Add(hCoverage);
- // Check for existence and get secondary map
- const AliCentralCorrSecondaryMap* secMap = ccm.GetSecondaryMap();
- const TAxis& vaxis = secMap->GetVertexAxis();
-
- FindEtaLimits();
-
+ // Bins are
+ TArrayD bins;
+ // N-bins, loweset order, higest order, return array
+ AliForwardUtil::MakeLogScale(300, 0, 5, bins);
fNClusterTracklet = new TH2D("nClusterVsnTracklet",
"Total number of cluster vs number of tracklets",
- 100, 0, 10000, 100, 0, 10000);
+ bins.GetSize()-1, bins.GetArray(),
+ bins.GetSize()-1, bins.GetArray());
fNClusterTracklet->SetDirectory(0);
- fNClusterTracklet->SetXTitle("# of free clusters");
- fNClusterTracklet->SetYTitle("# of tracklets");
+ fNClusterTracklet->SetXTitle("N_{free cluster}");
+ fNClusterTracklet->SetYTitle("N_{tracklet}");
fNClusterTracklet->SetStats(0);
fList->Add(fNClusterTracklet);
fNTracklet->SetDirectory(0);
fNTracklet->Sumw2();
+ fList->Add(AliForwardUtil::MakeParameter("secondary", fUseSecondary));
+ fList->Add(AliForwardUtil::MakeParameter("acceptance", fUseAcceptance));
+
+ fHData = static_cast<TH2D*>(fAODCentral.GetHistogram().Clone("d2Ndetadphi"));
+ fHData->SetStats(0);
+ fHData->SetDirectory(0);
+ fList->Add(fHData);
+
// Initialize the inspecto
- fInspector.SetupForData(vaxis);
- fFirstEventSeen = kTRUE;
+ // fInspector.SetupForData(vertex);
- // Print some information
- Print("R");
+ fAODCentral.SetBit(AliAODCentralMult::kSecondary, fUseSecondary);
+ fAODCentral.SetBit(AliAODCentralMult::kAcceptance, fUseAcceptance);
- return esd;
-}
-//____________________________________________________________________
-void
-AliCentralMultiplicityTask::MarkEventForStore() const
-{
- // Make sure the AOD tree is filled
- DGUARD(fDebug,1,"Mark AOD event for store in AliCentralMultiplicityTask");
- AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
- AliAODHandler* ah =
- dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
- if (ah) {
- //AliFatal("No AOD output handler set in analysis manager");
- ah->SetFillAOD(kTRUE);
- }
+ return true;
}
-
//____________________________________________________________________
-void AliCentralMultiplicityTask::FindEtaLimits()
+Bool_t
+AliCentralMultiplicityTask::PreEvent()
{
- // Find our pseudo-rapidity limits
- //
- // Uses the secondary map to do so.
- DGUARD(fDebug,1,"Find eta limits in AliCentralMultiplicityTask");
- AliCentralCorrectionManager& ccm =
- AliCentralCorrectionManager::Instance();
- const AliCentralCorrSecondaryMap* secMap = ccm.GetSecondaryMap();
- const TAxis& vaxis = secMap->GetVertexAxis();
-
- unsigned short s = 1;
- TH2D* hCoverage = new TH2D("coverage", "#eta coverage per v_{z}",
- secMap->GetCorrection(s)->GetXaxis()->GetNbins(),
- secMap->GetCorrection(s)->GetXaxis()->GetXmin(),
- secMap->GetCorrection(s)->GetXaxis()->GetXmax(),
- vaxis.GetNbins(),vaxis.GetXmin(),vaxis.GetXmax());
- hCoverage->SetDirectory(0);
- hCoverage->SetXTitle("#eta");
- hCoverage->SetYTitle("v_{z} [cm]");
- hCoverage->SetZTitle("n_{bins}");
-
- fAODCentral.Init(*(secMap->GetCorrection(s)->GetXaxis()));
-
- UShort_t nVz = vaxis.GetNbins();
- fVtxList = new TObjArray(nVz, 1);
- fVtxList->SetName("centMultVtxBins");
- fVtxList->SetOwner();
-
- // Bool_t store = false;
- for (Int_t v = 1; v <= nVz; v++) {
- VtxBin* bin = new VtxBin(v, vaxis.GetBinLowEdge(v), vaxis.GetBinUpEdge(v));
- bin->SetupForData(fList, hCoverage, fStore);
- fVtxList->AddAt(bin, v);
- }
- fList->Add(hCoverage);
+ fAODCentral.Clear("");
+ return true;
}
-
//____________________________________________________________________
-void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/)
+Bool_t
+AliCentralMultiplicityTask::Event(AliESDEvent& esd)
{
//
// Process each event
// option Not used
//
DGUARD(fDebug,1,"Process event in AliCentralMultiplicityTask");
- fAODCentral.Clear("");
-
- AliESDEvent* esd = GetESDEvent();
- if (!esd) return;
-
fIvz = 0;
Bool_t lowFlux = kFALSE;
UInt_t triggers = 0;
TVector3 ip;
Double_t cent = -1;
UShort_t nClusters = 0;
- UInt_t found = fInspector.Process(esd, triggers, lowFlux,
+ UInt_t found = fInspector.Process(&esd, triggers, lowFlux,
ivz, ip, cent, nClusters);
// No event or no trigger
- if (found & AliFMDEventInspector::kNoEvent) return;
- if (found & AliFMDEventInspector::kNoTriggers) return;
+ if (found & AliFMDEventInspector::kNoEvent) return false;
+ if (found & AliFMDEventInspector::kNoTriggers) return false;
// Make sure AOD is filled
MarkEventForStore();
- if (found == AliFMDEventInspector::kNoSPD) return;
- if (found == AliFMDEventInspector::kNoVertex) return;
- if (triggers & AliAODForwardMult::kPileUp) return;
- if (found == AliFMDEventInspector::kBadVertex) return; // Out of range
+ if (found & AliFMDEventInspector::kNoSPD) return false;
+ if (found & AliFMDEventInspector::kNoVertex) return false;
+ if (triggers & AliAODForwardMult::kPileUp) return false;
+ if (found & AliFMDEventInspector::kBadVertex) return false;
//Doing analysis
- const AliMultiplicity* spdmult = esd->GetMultiplicity();
+ const AliMultiplicity* spdmult = esd.GetMultiplicity();
TH2D& aodHist = fAODCentral.GetHistogram();
- ProcessESD(aodHist, spdmult);
VtxBin* bin = static_cast<VtxBin*>(fVtxList->At(ivz));
- if (!bin) return;
+ if (!bin) return false;
+
+ ProcessESD(aodHist, spdmult);
bin->Correct(aodHist, fUseSecondary, fUseAcceptance);
- PostData(1,fList);
+ if (triggers & AliAODForwardMult::kInel)
+ fHData->Add(&(fAODCentral.GetHistogram()));
+
+ return true;
}
//____________________________________________________________________
void
}
//____________________________________________________________________
-void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/)
+Bool_t
+AliCentralMultiplicityTask::Finalize()
{
//
// End of job
// option Not used
//
DGUARD(fDebug,1,"Process merged output in AliCentralMultiplicityTask");
+
+ Double_t nTr = 0, nTrVtx = 0, nAcc = 0;
+ MakeSimpledNdeta(fList, fResults, nTr, nTrVtx, nAcc);
+ AliInfoF("\n"
+ "\t# events w/trigger: %f\n"
+ "\t# events w/trigger+vertex: %f\n"
+ "\t# events accepted by cuts: %f",
+ nTr, nTrVtx, nAcc);
+ return true;
}
+
+//____________________________________________________________________
+Bool_t
+AliCentralMultiplicityTask::MakeSimpledNdeta(const TList* input,
+ TList* output,
+ Double_t& nTr,
+ Double_t& nTrVtx,
+ Double_t& nAcc)
+{
+ // Get our histograms from the container
+ TH1I* hEventsTr = 0;
+ TH1I* hEventsTrVtx = 0;
+ TH1I* hEventsAcc = 0;
+ TH1I* hTriggers = 0;
+ if (!GetEventInspector().FetchHistograms(input,
+ hEventsTr,
+ hEventsTrVtx,
+ hEventsAcc,
+ hTriggers)) {
+ AliError(Form("Didn't get histograms from event selector "
+ "(hEventsTr=%p,hEventsTrVtx=%p,hEventsAcc=%p,hTriggers=%p)",
+ hEventsTr, hEventsTrVtx, hEventsAcc, hTriggers));
+ input->ls();
+ return false;
+ }
+ nTr = hEventsTr->Integral();
+ nTrVtx = hEventsTrVtx->Integral();
+ nAcc = hEventsAcc->Integral();
+ Double_t vtxEff = nTrVtx / nTr;
+ TH2D* hData = static_cast<TH2D*>(input->FindObject("d2Ndetadphi"));
+ if (!hData) {
+ AliError(Form("Couldn't get our summed histogram from output "
+ "list %s (d2Ndetadphi=%p)", input->GetName(), hData));
+ input->ls();
+ return false;
+ }
+
+ Int_t nY = hData->GetNbinsY();
+ TH1D* dNdeta = hData->ProjectionX("dNdeta", 1, nY, "e");
+ TH1D* dNdeta_ = hData->ProjectionX("dNdeta_", 1, nY, "e");
+ TH1D* norm = hData->ProjectionX("norm", 0, 0, "");
+ TH1D* phi = hData->ProjectionX("phi", nY+1, nY+1, "");
+ dNdeta->SetTitle("dN_{ch}/d#eta in the forward regions");
+ dNdeta->SetYTitle("#frac{1}{N}#frac{dN_{ch}}{d#eta}");
+ dNdeta->SetMarkerColor(kRed+1);
+ dNdeta->SetMarkerStyle(20);
+ dNdeta->SetDirectory(0);
+
+ dNdeta_->SetTitle("dN_{ch}/d#eta in the forward regions");
+ dNdeta_->SetYTitle("#frac{1}{N}#frac{dN_{ch}}{d#eta}");
+ dNdeta_->SetMarkerColor(kMagenta+1);
+ dNdeta_->SetMarkerStyle(21);
+ dNdeta_->SetDirectory(0);
+
+ norm->SetTitle("Normalization to #eta coverage");
+ norm->SetYTitle("#eta coverage");
+ norm->SetLineColor(kBlue+1);
+ norm->SetMarkerColor(kBlue+1);
+ norm->SetMarkerStyle(21);
+ norm->SetFillColor(kBlue+1);
+ norm->SetFillStyle(3005);
+ norm->SetDirectory(0);
+
+ phi->SetTitle("Normalization to #phi acceptance");
+ phi->SetYTitle("#phi acceptance");
+ phi->SetLineColor(kGreen+1);
+ phi->SetMarkerColor(kGreen+1);
+ phi->SetMarkerStyle(20);
+ phi->SetFillColor(kGreen+1);
+ phi->SetFillStyle(3004);
+ // phi->Scale(1. / nAcc);
+ phi->SetDirectory(0);
+
+ // dNdeta->Divide(norm);
+ dNdeta->Divide(phi);
+ dNdeta->SetStats(0);
+ dNdeta->Scale(vtxEff, "width");
+
+ dNdeta_->Divide(norm);
+ dNdeta_->SetStats(0);
+ dNdeta_->Scale(vtxEff, "width");
+
+ output->Add(dNdeta);
+ output->Add(dNdeta_);
+ output->Add(norm);
+ output->Add(phi);
+
+ return true;
+}
+
+#define PF(N,V,...) \
+ AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
+#define PFB(N,FLAG) \
+ do { \
+ AliForwardUtil::PrintName(N); \
+ std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
+ } while(false)
+#define PFV(N,VALUE) \
+ do { \
+ AliForwardUtil::PrintName(N); \
+ std::cout << (VALUE) << std::endl; } while(false)
+
//____________________________________________________________________
void
AliCentralMultiplicityTask::Print(Option_t* option) const
// Parameters:
// option Not used
//
-
- std::cout << ClassName() << ": " << GetName() << "\n"
- << std::boolalpha
- << " Use secondary correction: " << fUseSecondary << '\n'
- << " Use acceptance correction: " << fUseAcceptance << '\n'
- << " Off-line trigger mask: 0x"
- << std::hex << std::setfill('0')
- << std::setw (8) << fOfflineTriggerMask
- << std::dec << std::setfill (' ')
- << std::noboolalpha << std::endl;
+ AliBaseESDTask::Print(option);
+ PFB("Use secondary correction", fUseSecondary);
+ PFB("Use acceptance correction", fUseAcceptance);
AliCentralCorrectionManager& ccm =
AliCentralCorrectionManager::Instance();
const AliCentralCorrSecondaryMap* secMap = ccm.GetSecondaryMap();
if (secMap) {
const TAxis& vaxis = secMap->GetVertexAxis();
- fVtxList->ls();
+ // fVtxList->ls();
std::cout << " Eta ranges:\n"
<< " Vertex | Eta bins\n"
<< " bin range | \n"
gROOT->IncreaseDirLevel();
ccm.Print(option);
- fInspector.Print(option);
+ // fInspector.Print(option);
gROOT->DecreaseDirLevel();
}
if (ix < fEtaMin || ix > fEtaMax) fiducial = false;
// Bool_t etabinSeen = kFALSE;
- Float_t accCor = fAcc->GetBinContent(ix);
+ Double_t eta = aodHist.GetXaxis()->GetBinCenter(ix);
+ Int_t iax = fAcc->GetXaxis()->FindBin(eta);
+ Float_t accCor = fAcc->GetBinContent(iax);
// For test
// Float_t accErr = fAcc->GetBinError(ix);
aodHist.SetBinError(ix,iy, 0);
continue;
}
- if (useAcceptance) continue;
+ if (!useAcceptance) continue;
// Acceptance correction
- if (accCor < 0.000001) accCor = 1;
- Float_t aodNew = aodValue / accCor ;
+ Float_t accTmp = accCor;
+ if (accTmp < 0.000001) accTmp = 1;
+ Float_t aodNew = aodValue / accTmp ;
aodHist.SetBinContent(ix,iy, aodNew);
aodHist.SetBinError(ix,iy,aodErr);
// - Test -
//Filling underflow bin if we eta bin is in range
if (fiducial) {
aodHist.SetBinContent(ix,0, 1.);
- aodHist.SetBinContent(ix,nY+1, 1.);
+ aodHist.SetBinContent(ix,nY+1, accCor);
}
} // for (ix)
if (sum && fHits) fHits->Add(&aodHist);