Belle II Software development
PXDDQMCorrModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include "pxd/modules/pxdDQM/PXDDQMCorrModule.h"
10
11#include <framework/core/HistoModule.h>
12
13#include <vector>
14#include <boost/format.hpp>
15
16#include "TH1F.h"
17#include "TH2F.h"
18#include "TDirectory.h"
19
20using namespace std;
21using boost::format;
22using namespace Belle2;
23
24//-----------------------------------------------------------------
25// Register the Module
26//-----------------------------------------------------------------
27REG_MODULE(PXDDQMCorr);
28
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
35{
36 //Set module properties
37 setDescription("PXD DQM Correlation module");
38 setPropertyFlags(c_ParallelProcessingCertified); // specify this flag if you need parallel processing
39 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed",
40 std::string("pxd"));
41}
42
43
44//------------------------------------------------------------------
45// Function to define histograms
46//-----------------------------------------------------------------
47
49{
50 // Create a separate histogram directory and cd into it.
51 TDirectory* oldDir = gDirectory;
52 if (m_histogramDirectoryName != "") {
53 oldDir->mkdir(m_histogramDirectoryName.c_str());// do not use return value with ->cd(), its ZERO if dir already exists
54 oldDir->cd(m_histogramDirectoryName.c_str());
55 }
56 //----------------------------------------------------------------
57
58 int nPixelsU1 = 1;//getInfo(0).getUCells();// we need an actual sensor ID to use that
59 int nPixelsV1 = 3;//getInfo(0).getVCells();
60 int nPixelsU2 = 1;//getInfo(1).getUCells();
61 int nPixelsV2 = 3;//getInfo(1).getVCells();
62 m_CorrelationU = new TH2F("CorrelationU", "Correlation of U;U1/cm;U2/cm", 25, -nPixelsU1, nPixelsU1, 25, nPixelsU2, nPixelsU2);
63 m_CorrelationV = new TH2F("CorrelationV", "Correlation of V;V1/cm;V2/cm", 50, -nPixelsV1, nPixelsV1, 50, nPixelsV2, nPixelsV2);
64 m_DeltaU = new TH1F("DeltaU", "Correlation of U2-U1;Udiff/cm", 100, -nPixelsU1, nPixelsU2);
65 m_DeltaV = new TH1F("DeltaV", "Correlation of V2-V1;Vdiff/cm", 200, -nPixelsV1, nPixelsV2);
66
67 // cd back to root directory
68 oldDir->cd();
69}
70
71
73{
74 // Register histograms (calls back defineHisto)
75 REG_HISTOGRAM
76
77 //Register collections
79}
80
82{
83 // Just to make sure, reset all the histograms.
84 m_CorrelationU->Reset();
85 m_CorrelationV->Reset();
86 m_DeltaU->Reset();
87 m_DeltaV->Reset();
88}
89
90
92{
93
94 // If there are no clusters, leave
96
97 for (const PXDCluster& cluster1 : m_storeClusters) {
98 int iPlane1 = cluster1.getSensorID().getLayerNumber();
99 if (iPlane1 == 0) {
100 for (const PXDCluster& cluster2 : m_storeClusters) {
101 int iPlane2 = cluster2.getSensorID().getLayerNumber();
102 if (iPlane2 == 1) {
103 m_CorrelationU->Fill(cluster1.getU(), cluster2.getU());
104 m_CorrelationV->Fill(cluster1.getV(), cluster2.getV());
105 m_DeltaU->Fill(cluster2.getU() - cluster1.getU());
106 m_DeltaV->Fill(cluster2.getV() - cluster1.getV());
107 }
108 }
109 }
110 }
111}
112
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
TH2F * m_CorrelationV
Correlation Sensor 1 vs 2.
void initialize() override final
Initialize.
StoreArray< PXDCluster > m_storeClusters
Storearray for clusters
void defineHisto() override final
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
void event() override final
Event.
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
TH2F * m_CorrelationU
Correlation Sensor 1 vs 2.
TH1F * m_DeltaV
Correlation Sensor 1 vs 2.
std::string m_storeClustersName
PXDClusters StoreArray name.
void beginRun() override final
Begin run.
TH1F * m_DeltaU
Correlation Sensor 1 vs 2.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.