|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | +// |
| 11 | +// Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no |
| 12 | +// |
| 13 | +#include "Framework/runDataProcessing.h" |
| 14 | +#include "Framework/AnalysisTask.h" |
| 15 | +#include "Framework/AnalysisDataModel.h" |
| 16 | +#include "Framework/ASoAHelpers.h" |
| 17 | +#include "Analysis/Multiplicity.h" |
| 18 | +#include "Analysis/EventSelection.h" |
| 19 | +#include "Analysis/Centrality.h" |
| 20 | +#include "Analysis/TriggerAliases.h" |
| 21 | +#include "Analysis/ReducedInfoTables.h" |
| 22 | +#include "Analysis/VarManager.h" |
| 23 | +#include "Analysis/HistogramManager.h" |
| 24 | +#include "Analysis/AnalysisCut.h" |
| 25 | +#include "Analysis/AnalysisCompositeCut.h" |
| 26 | +#include "PID/PIDResponse.h" |
| 27 | +#include "Analysis/TrackSelectionTables.h" |
| 28 | +#include <iostream> |
| 29 | + |
| 30 | +using std::cout; |
| 31 | +using std::endl; |
| 32 | + |
| 33 | +using namespace o2; |
| 34 | +using namespace o2::framework; |
| 35 | +//using namespace o2::framework::expressions; |
| 36 | +using namespace o2::aod; |
| 37 | + |
| 38 | +using MyEvents = soa::Join<aod::Collisions, aod::EvSels>; |
| 39 | + |
| 40 | +// HACK: In order to be able to deduce which kind of aod object is transmitted to the templated VarManager::Fill functions |
| 41 | +// a constexpr static bit map must be defined and sent as template argument |
| 42 | +// The user has to include in this bit map all the tables needed in analysis, as defined in VarManager::ObjTypes |
| 43 | +// Additionally, one should make sure that the requested tables are actually provided in the process() function, |
| 44 | +// otherwise a compile time error will be thrown. |
| 45 | +// This is a temporary fix until the arrow/ROOT issues are solved, at which point it will be possible |
| 46 | +// to automatically detect the object types transmitted to the VarManager |
| 47 | +constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; |
| 48 | + |
| 49 | +struct TableMakerMuon_pp { |
| 50 | + |
| 51 | + Produces<ReducedEvents> event; |
| 52 | + Produces<ReducedEventsExtended> eventExtended; |
| 53 | + Produces<ReducedEventsVtxCov> eventVtxCov; |
| 54 | + Produces<ReducedTracks> trackBasic; |
| 55 | + Produces<ReducedMuons> muonBasic; |
| 56 | + Produces<ReducedMuonsExtended> muonExtended; |
| 57 | + |
| 58 | + float* fValues; |
| 59 | + |
| 60 | + OutputObj<THashList> fOutputList{"output"}; |
| 61 | + HistogramManager* fHistMan; |
| 62 | + |
| 63 | + // TODO: Filters should be used to make lowest level selection. The additional more restrictive cuts should be defined via the AnalysisCuts |
| 64 | + // TODO: Multiple event selections can be applied and decisions stored in the reducedevent::tag |
| 65 | + AnalysisCompositeCut* fEventCut; |
| 66 | + // TODO: Multiple track selections can be applied and decisions stored in the reducedtrack::filteringFlags |
| 67 | + |
| 68 | + // TODO a few of the important muon variables in the central data model are dynamic columns so not usable in expressions (e.g. eta, phi) |
| 69 | + // Update the data model to have them as expression columns |
| 70 | + Partition<aod::Muons> muonSelectedTracks = o2::aod::muon::pt >= 0.5f; // For pp collisions a 0.5 GeV/c pp cuts is defined |
| 71 | + |
| 72 | + void init(o2::framework::InitContext&) |
| 73 | + { |
| 74 | + fValues = new float[VarManager::kNVars]; |
| 75 | + VarManager::SetDefaultVarNames(); |
| 76 | + fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); |
| 77 | + fHistMan->SetUseDefaultVariableNames(kTRUE); |
| 78 | + fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); |
| 79 | + |
| 80 | + DefineHistograms("Event_BeforeCuts;Event_AfterCuts;"); // define all histograms |
| 81 | + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill |
| 82 | + fOutputList.setObject(fHistMan->GetMainHistogramList()); |
| 83 | + DefineCuts(); |
| 84 | + } |
| 85 | + |
| 86 | + void DefineCuts() |
| 87 | + { |
| 88 | + fEventCut = new AnalysisCompositeCut(true); |
| 89 | + AnalysisCut* eventVarCut = new AnalysisCut(); |
| 90 | + eventVarCut->AddCut(VarManager::kVtxZ, -10.0, 10.0); |
| 91 | + eventVarCut->AddCut(VarManager::kIsINT7, 0.5, 1.5); // require kINT7 |
| 92 | + fEventCut->AddCut(eventVarCut); |
| 93 | + |
| 94 | + VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill |
| 95 | + } |
| 96 | + |
| 97 | + void process(MyEvents::iterator const& collision, aod::MuonClusters const& clustersMuon, aod::Muons const& tracksMuon, aod::BCs const& bcs) |
| 98 | + { |
| 99 | + uint64_t tag = 0; |
| 100 | + uint32_t triggerAliases = 0; |
| 101 | + for (int i = 0; i < kNaliases; i++) { |
| 102 | + if (collision.alias()[i] > 0) { |
| 103 | + triggerAliases |= (uint32_t(1) << i); |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + VarManager::ResetValues(0, VarManager::kNEventWiseVariables, fValues); |
| 108 | + VarManager::FillEvent<gkEventFillMap>(collision, fValues); // extract event information and place it in the fgValues array |
| 109 | + fHistMan->FillHistClass("Event_BeforeCuts", fValues); // automatically fill all the histograms in the class Event |
| 110 | + |
| 111 | + if (!fEventCut->IsSelected(fValues)) { |
| 112 | + return; |
| 113 | + } |
| 114 | + |
| 115 | + fHistMan->FillHistClass("Event_AfterCuts", fValues); |
| 116 | + |
| 117 | + event(tag, collision.bc().runNumber(), collision.posX(), collision.posY(), collision.posZ(), collision.numContrib()); |
| 118 | + eventExtended(collision.bc().globalBC(), collision.bc().triggerMask(), triggerAliases, 0.0f); |
| 119 | + eventVtxCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); |
| 120 | + |
| 121 | + uint64_t trackFilteringTag = 0; |
| 122 | + |
| 123 | + muonBasic.reserve(muonSelectedTracks.size()); |
| 124 | + muonExtended.reserve(muonSelectedTracks.size()); |
| 125 | + for (auto& muon : muonSelectedTracks) { |
| 126 | + // TODO: add proper information for muon tracks |
| 127 | + if (muon.bcId() != collision.bcId()) { |
| 128 | + continue; |
| 129 | + } |
| 130 | + // TODO: the trackFilteringTag will not be needed to encode whether the track is a muon since there is a dedicated table for muons |
| 131 | + trackFilteringTag |= (uint64_t(1) << 0); // this is a MUON arm track |
| 132 | + muonBasic(event.lastIndex(), trackFilteringTag, muon.pt(), muon.eta(), muon.phi(), muon.charge()); |
| 133 | + muonExtended(muon.inverseBendingMomentum(), muon.thetaX(), muon.thetaY(), muon.zMu(), muon.bendingCoor(), muon.nonBendingCoor(), muon.chi2(), muon.chi2MatchTrigger()); |
| 134 | + } |
| 135 | + } |
| 136 | + |
| 137 | + void DefineHistograms(TString histClasses) |
| 138 | + { |
| 139 | + const int kNRuns = 2; |
| 140 | + int runs[kNRuns] = {244918, 244919}; |
| 141 | + TString runsStr; |
| 142 | + for (int i = 0; i < kNRuns; i++) { |
| 143 | + runsStr += Form("%d;", runs[i]); |
| 144 | + } |
| 145 | + VarManager::SetRunNumbers(kNRuns, runs); |
| 146 | + |
| 147 | + TObjArray* arr = histClasses.Tokenize(";"); |
| 148 | + for (Int_t iclass = 0; iclass < arr->GetEntries(); ++iclass) { |
| 149 | + TString classStr = arr->At(iclass)->GetName(); |
| 150 | + |
| 151 | + if (classStr.Contains("Event")) { |
| 152 | + fHistMan->AddHistClass(classStr.Data()); |
| 153 | + fHistMan->AddHistogram(classStr.Data(), "VtxZ", "Vtx Z", false, 60, -15.0, 15.0, VarManager::kVtxZ); // TH1F histogram |
| 154 | + fHistMan->AddHistogram(classStr.Data(), "VtxZ_Run", "Vtx Z", true, |
| 155 | + kNRuns, 0.5, 0.5 + kNRuns, VarManager::kRunId, 60, -15.0, 15.0, VarManager::kVtxZ, 10, 0., 0., VarManager::kNothing, runsStr.Data()); // TH1F histogram |
| 156 | + fHistMan->AddHistogram(classStr.Data(), "VtxX_VtxY", "Vtx X vs Vtx Y", false, 100, 0.055, 0.08, VarManager::kVtxX, 100, 0.31, 0.35, VarManager::kVtxY); // TH2F histogram |
| 157 | + fHistMan->AddHistogram(classStr.Data(), "VtxX_VtxY_VtxZ", "vtx x - y - z", false, 100, 0.055, 0.08, VarManager::kVtxX, 100, 0.31, 0.35, VarManager::kVtxY, 60, -15.0, 15.0, VarManager::kVtxZ); // TH3F histogram |
| 158 | + fHistMan->AddHistogram(classStr.Data(), "NContrib_vs_VtxZ_prof", "Vtx Z vs ncontrib", true, 30, -15.0, 15.0, VarManager::kVtxZ, 10, -1., 1., VarManager::kVtxNcontrib); // TProfile histogram |
| 159 | + fHistMan->AddHistogram(classStr.Data(), "VtxZ_vs_VtxX_VtxY_prof", "Vtx Z vs (x,y)", true, 100, 0.055, 0.08, VarManager::kVtxX, 100, 0.31, 0.35, VarManager::kVtxY, 10, -1., 1., VarManager::kVtxZ); // TProfile2D histogram |
| 160 | + fHistMan->AddHistogram(classStr.Data(), "Ncontrib_vs_VtxZ_VtxX_VtxY_prof", "n-contrib vs (x,y,z)", true, |
| 161 | + 100, 0.055, 0.08, VarManager::kVtxX, 100, 0.31, 0.35, VarManager::kVtxY, 30, -15., 15., VarManager::kVtxZ, |
| 162 | + "", "", "", VarManager::kVtxNcontrib); // TProfile3D |
| 163 | + } |
| 164 | + } // end loop over histogram classes |
| 165 | + } |
| 166 | +}; |
| 167 | + |
| 168 | +WorkflowSpec defineDataProcessing(ConfigContext const&) |
| 169 | +{ |
| 170 | + return WorkflowSpec{ |
| 171 | + adaptAnalysisTask<TableMakerMuon_pp>("table-maker-muon-pp")}; |
| 172 | +} |
0 commit comments