Skip to content

Commit 4990b31

Browse files
gvolpe79Giacomo Volpe
andauthored
First HMP clusters QC implemention (#1107)
* First HMP clusters QC implemention * CMakeList fixed Co-authored-by: Giacomo Volpe <gvolpe@pcgvolpe.ba.infn.it>
1 parent 98080ab commit 4990b31

4 files changed

Lines changed: 232 additions & 1 deletion

File tree

Modules/HMPID/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
add_library(O2QcHMPID)
44

55
target_sources(O2QcHMPID PRIVATE src/HmpidTask.cxx
6-
src/HmpidTaskDigits.cxx)
6+
src/HmpidTaskDigits.cxx
7+
src/HmpidTaskClusters.cxx)
78

89
target_include_directories(
910
O2QcHMPID
@@ -29,6 +30,7 @@ add_root_dictionary(O2QcHMPID
2930
HEADERS
3031
include/HMPID/HmpidTask.h
3132
include/HMPID/HmpidTaskDigits.h
33+
include/HMPID/HmpidTaskClusters.h
3234
LINKDEF include/HMPID/LinkDef.h
3335
BASENAME O2QcHMPID)
3436

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 HmpidTaskClusters.h
14+
/// \author Annalisa Mastroserio
15+
///
16+
17+
#ifndef QC_MODULE_HMPID_HMPIDTASKCLUSTERS_H
18+
#define QC_MODULE_HMPID_HMPIDTASKCLUSTERS_H
19+
#include <Framework/InputRecord.h>
20+
#include "QualityControl/TaskInterface.h"
21+
#include <TH1.h>
22+
#include <TProfile.h>
23+
#include <TH2.h>
24+
#include <THnSparse.h>
25+
26+
class TH1F;
27+
28+
using namespace o2::quality_control::core;
29+
30+
namespace o2::quality_control_modules::hmpid
31+
{
32+
33+
class HmpidTaskClusters : public TaskInterface
34+
{
35+
36+
public:
37+
HmpidTaskClusters();
38+
~HmpidTaskClusters() override;
39+
40+
void initialize(o2::framework::InitContext& ctx) override;
41+
void startOfActivity(Activity& activity) override;
42+
void startOfCycle() override;
43+
void monitorData(o2::framework::ProcessingContext& ctx) override;
44+
void endOfCycle() override;
45+
void endOfActivity(Activity& activity) override;
46+
void reset() override;
47+
48+
private:
49+
void BookHistograms();
50+
void getJsonParameters();
51+
52+
// monitoring histos
53+
TProfile* ThClusMult;
54+
TH1F* hClusMultEv;
55+
TH1F* hHMPIDchargeClus[7];
56+
TH2F* hHMPIDpositionClus[7];
57+
58+
std::vector<TObject*> mPublishedObjects;
59+
};
60+
} // namespace o2::quality_control_modules::hmpid
61+
62+
#endif

Modules/HMPID/include/HMPID/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
#pragma link C++ class o2::quality_control_modules::hmpid::HmpidTask+;
77
#pragma link C++ class o2::quality_control_modules::hmpid::HmpidTaskDigits+;
8+
#pragma link C++ class o2::quality_control_modules::hmpid::HmpidTaskClusters+;
89
#endif
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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

Comments
 (0)