|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +/// \file eventNormalizationTask.cxx |
| 13 | +/// \brief task to produce histogram with event counter information |
| 14 | +/// \author Joshua Konig, joshua.konig@cern.ch |
| 15 | + |
| 16 | +#include "PWGEM/PhotonMeson/DataModel/EventTables.h" |
| 17 | + |
| 18 | +#include <Framework/AnalysisDataModel.h> |
| 19 | +#include <Framework/AnalysisTask.h> |
| 20 | +#include <Framework/HistogramRegistry.h> |
| 21 | +#include <Framework/HistogramSpec.h> |
| 22 | +#include <Framework/InitContext.h> |
| 23 | +#include <Framework/runDataProcessing.h> |
| 24 | + |
| 25 | +#include <TH1D.h> |
| 26 | + |
| 27 | +#include <string_view> |
| 28 | + |
| 29 | +using namespace o2; |
| 30 | +using namespace o2::aod; |
| 31 | +using namespace o2::framework; |
| 32 | +using namespace o2::framework::expressions; |
| 33 | +using namespace o2::soa; |
| 34 | + |
| 35 | +struct EventNormalizationTask { |
| 36 | + |
| 37 | + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; |
| 38 | + |
| 39 | + void init(InitContext& /*context*/) |
| 40 | + { |
| 41 | + // Names derived from EventAcceptance bits in EventTables.h |
| 42 | + std::vector<std::string> vecLabelNames = { |
| 43 | + "all", |
| 44 | + "has MC coll", |
| 45 | + "good zVtx", |
| 46 | + "is FT0AND", |
| 47 | + "No TFB", |
| 48 | + "ITS ROFB", |
| 49 | + "Same bunch Pileup", |
| 50 | + "ZVtxFT0PV", |
| 51 | + "No coll in time range", |
| 52 | + "good track occi", |
| 53 | + "Good FT0 occupancy", |
| 54 | + "kTVXinEMC", |
| 55 | + "Good centrality", |
| 56 | + "Good RCT", |
| 57 | + "Good Sel8"}; |
| 58 | + fRegistry.add("EventNormalization/hEventCounter", "Event Counter;category;#it{N}_{evt}", kTH1D, {{static_cast<int>(vecLabelNames.size()), -0.5, -0.5 + static_cast<int>(vecLabelNames.size())}}, false); |
| 59 | + for (size_t i = 0; i < vecLabelNames.size(); ++i) { |
| 60 | + fRegistry.get<TH1>(HIST("EventNormalization/hEventCounter"))->GetXaxis()->SetBinLabel(i + 1, vecLabelNames[i].c_str()); |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + // Process function only takes the entries and fills them into the histogram. This is done per DF and not per collision |
| 65 | + void processNorm(o2::aod::PMEvSelBit const& evSelBit) |
| 66 | + { |
| 67 | + |
| 68 | + auto vecEvSelBits = evSelBit.eventSelectionBit(); |
| 69 | + for (size_t i = 0; i < vecEvSelBits.size(); ++i) { |
| 70 | + fRegistry.fill(HIST("EventNormalization/hEventCounter"), i, vecEvSelBits[i]); |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + PROCESS_SWITCH(EventNormalizationTask, processNorm, "run event normalization task", true); |
| 75 | +}; |
| 76 | + |
| 77 | +WorkflowSpec defineDataProcessing(ConfigContext const& context) |
| 78 | +{ |
| 79 | + return WorkflowSpec{ |
| 80 | + adaptAnalysisTask<EventNormalizationTask>(context, TaskName{"event-normalization-task"})}; |
| 81 | +} |
0 commit comments