|
| 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 | + |
| 12 | +/// |
| 13 | +/// \file TaskClusters.cxx |
| 14 | +/// \author Annalisa Mastroserio |
| 15 | +/// |
| 16 | + |
| 17 | +#include "QualityControl/QcInfoLogger.h" |
| 18 | +#include "DataFormatsHMP/Cluster.h" |
| 19 | +#include "DataFormatsHMP/Trigger.h" |
| 20 | +#include "HMPID/HmpidTaskClusters.h" |
| 21 | + |
| 22 | +#include <sstream> |
| 23 | +#include <TCanvas.h> |
| 24 | +#include <DataFormatsParameters/GRPObject.h> |
| 25 | + |
| 26 | +#include <Framework/InputRecord.h> |
| 27 | + |
| 28 | +#ifdef WITH_OPENMP |
| 29 | +#include <omp.h> |
| 30 | +#endif |
| 31 | + |
| 32 | +// using namespace o2::hmpid; |
| 33 | + |
| 34 | +namespace o2::quality_control_modules::hmpid |
| 35 | +{ |
| 36 | + |
| 37 | +HmpidTaskClusters::HmpidTaskClusters() : TaskInterface() {} |
| 38 | + |
| 39 | +HmpidTaskClusters::~HmpidTaskClusters() |
| 40 | +{ |
| 41 | + ILOG(Info, Support) << "destructor called" << ENDM; |
| 42 | + delete hClusMultEv; |
| 43 | + delete ThClusMult; |
| 44 | + for (Int_t iCh = 0; iCh < 7; iCh++) { |
| 45 | + delete hHMPIDchargeClus[iCh]; |
| 46 | + delete hHMPIDpositionClus[iCh]; |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +void HmpidTaskClusters::initialize(o2::framework::InitContext& /*ctx*/) |
| 51 | +{ |
| 52 | + |
| 53 | + ILOG(Info, Support) << "initialize TaskClusters" << ENDM; |
| 54 | + |
| 55 | + // getJsonParameters(); |
| 56 | + |
| 57 | + BookHistograms(); |
| 58 | + |
| 59 | + // publish histograms (Q: why publishing in initalize?) |
| 60 | + getObjectsManager()->startPublishing(hClusMultEv); |
| 61 | + getObjectsManager()->startPublishing(ThClusMult); |
| 62 | + for (Int_t iCh = 0; iCh < 7; iCh++) { |
| 63 | + getObjectsManager()->startPublishing(hHMPIDchargeClus[iCh]); |
| 64 | + getObjectsManager()->startPublishing(hHMPIDpositionClus[iCh]); |
| 65 | + } |
| 66 | + |
| 67 | + ILOG(Info, Support) << "START DOING QC HMPID Cluster" << ENDM; |
| 68 | + |
| 69 | + // here do the QC |
| 70 | +} |
| 71 | + |
| 72 | +void HmpidTaskClusters::startOfActivity(Activity& /*activity*/) |
| 73 | +{ |
| 74 | + ILOG(Info, Support) << "startOfActivity" << ENDM; |
| 75 | + reset(); |
| 76 | +} |
| 77 | + |
| 78 | +void HmpidTaskClusters::startOfCycle() |
| 79 | +{ |
| 80 | + ILOG(Info, Support) << "startOfCycle" << ENDM; |
| 81 | +} |
| 82 | + |
| 83 | +void HmpidTaskClusters::monitorData(o2::framework::ProcessingContext& ctx) |
| 84 | +{ |
| 85 | + ILOG(Info, Support) << "monitorData" << ENDM; |
| 86 | + |
| 87 | + // Get HMPID triggers |
| 88 | + const auto triggers = ctx.inputs().get<std::vector<o2::hmpid::Trigger>>("intrecord"); |
| 89 | + |
| 90 | + // Get HMPID clusters |
| 91 | + auto clusters = ctx.inputs().get<std::vector<o2::hmpid::Cluster>>("clusters"); |
| 92 | + |
| 93 | + int nEvents = triggers.size(); |
| 94 | + |
| 95 | + for (int i = 0; i < nEvents; i++) { // events loop |
| 96 | + |
| 97 | + double nClusters = triggers[i].getLastEntry() - triggers[i].getFirstEntry(); |
| 98 | + hClusMultEv->Fill(nClusters); |
| 99 | + |
| 100 | + Int_t nClusCh[7] = { 0, 0, 0, 0, 0, 0, 0 }; |
| 101 | + |
| 102 | + for (int j = triggers[i].getFirstEntry(); j <= triggers[i].getLastEntry(); j++) { // cluster loop on the same event |
| 103 | + |
| 104 | + int chamber = clusters[j].ch(); |
| 105 | + nClusCh[chamber]++; |
| 106 | + |
| 107 | + if (chamber <= 6 && chamber >= 0) { |
| 108 | + hHMPIDchargeClus[chamber]->Fill(clusters[j].q()); |
| 109 | + hHMPIDpositionClus[chamber]->Fill(clusters[j].x(), clusters[j].y()); |
| 110 | + } |
| 111 | + } // cluster loop |
| 112 | + for (Int_t ich = 0; ich < 7; ich++) { |
| 113 | + ThClusMult->Fill(ich, nClusCh[ich]); |
| 114 | + } |
| 115 | + } // events loop |
| 116 | +} |
| 117 | + |
| 118 | +void HmpidTaskClusters::endOfCycle() |
| 119 | +{ |
| 120 | + |
| 121 | + ILOG(Info, Support) << "endOfCycle" << ENDM; |
| 122 | +} |
| 123 | + |
| 124 | +void HmpidTaskClusters::endOfActivity(Activity& /*activity*/) |
| 125 | +{ |
| 126 | + ILOG(Info, Support) << "endOfActivity" << ENDM; |
| 127 | +} |
| 128 | + |
| 129 | +void HmpidTaskClusters::BookHistograms() |
| 130 | +{ |
| 131 | + hClusMultEv = new TH1F("ClusMultEve", "HMPID Cluster multiplicity per event", 500, 0, 500); |
| 132 | + |
| 133 | + ThClusMult = new TProfile("ClusMult", "HMPID Cluster multiplicity per chamber;Chamber Id;# of clusters", 16, -1, 7, 0, 500); |
| 134 | + ThClusMult->Sumw2(); |
| 135 | + ThClusMult->SetOption("P"); |
| 136 | + ThClusMult->SetMinimum(0); |
| 137 | + ThClusMult->SetMarkerStyle(20); |
| 138 | + ThClusMult->SetMarkerColor(kBlack); |
| 139 | + ThClusMult->SetLineColor(kBlack); |
| 140 | + |
| 141 | + for (Int_t iCh = 0; iCh < 7; iCh++) { |
| 142 | + hHMPIDchargeClus[iCh] = new TH1F(Form("CluQ%i", iCh), Form("Cluster Q in HMPID Chamber %i ; Q (ADC)", iCh), 50, 0, 50); |
| 143 | + hHMPIDpositionClus[iCh] = new TH2F(Form("ClusterPoistion%i", iCh), Form("Cluster Position in HMPID Chamber %i; X (cm); Y (cm)", iCh), 532, -1, 131, 500, -1, 124); // cmxcm |
| 144 | + } |
| 145 | + // |
| 146 | +} |
| 147 | + |
| 148 | +void HmpidTaskClusters::reset() |
| 149 | +{ |
| 150 | + ILOG(Info, Support) << "Resetting the histogram" << ENDM; |
| 151 | + |
| 152 | + hClusMultEv->Reset(); |
| 153 | + ThClusMult->Reset(); |
| 154 | + |
| 155 | + for (Int_t iCh = 0; iCh < 7; iCh++) { |
| 156 | + hHMPIDchargeClus[iCh]->Reset(); |
| 157 | + hHMPIDpositionClus[iCh]->Reset(); |
| 158 | + } |
| 159 | +} |
| 160 | + |
| 161 | +void HmpidTaskClusters::getJsonParameters() |
| 162 | +{ |
| 163 | + ILOG(Info, Support) << "GetJsonParams" << ENDM; |
| 164 | +} |
| 165 | + |
| 166 | +} // namespace o2::quality_control_modules::hmpid |
0 commit comments