Belle II Software development
SVDMaxStripTTreeModule.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 <svd/modules/svdPerformance/SVDMaxStripTTreeModule.h>
10#include <hlt/softwaretrigger/core/FinalTriggerDecisionCalculator.h>
11
12#include <vxd/dataobjects/VxdID.h>
13#include <vxd/geometry/GeoCache.h>
14
15using namespace Belle2;
16using namespace std;
17using namespace SoftwareTrigger;
18
19REG_MODULE(SVDMaxStripTTree);
20
22{
23 setDescription("The module is used to create a TTree to study the number of strips per APV per event.");
24 addParam("outputFileName", m_rootFileName, "Name of output root file.", std::string("SVDMaxStripTTree.root"));
25 addParam("ShaperDigits", m_shapersStoreArrayName, "StoreArray name of the input ShaperDigits.",
27 addParam("skipHLTRejectedEvents", m_skipRejectedEvents, "If TRUE skip events rejected by HLT", bool(true));
28}
29
31{
33
34 m_rootFilePtr = new TFile(m_rootFileName.c_str(), "RECREATE");
35
36 //Tree for SVD u and v strips
37 m_t = new TTree("tree", "Tree for SVD u/v-strips");
38 m_t->Branch("evt", &m_event, "evt/i");
39 m_t->Branch("svdLayer", &m_svdLayer, "svdLayer/i");
40 m_t->Branch("svdLadder", &m_svdLadder, "svdLadder/i");
41 m_t->Branch("svdSensor", &m_svdSensor, "svdSensor/i");
42 m_t->Branch("svdSide", &m_svdSide, "svdSide/i");
43 m_t->Branch("svdChip", &m_svdChip, "svdChip/i");
44 m_t->Branch("svdHits", &m_svdHits, "svdHits/i");
45
46 m_event = 0;
47}
48
50{
51
52 TH1F hHits("nHits_L@layerL@ladderS@sensor@view@apv",
53 "Number of Hits per Event in @layer.@ladder.@sensor chip @apv on the @view/@side side",
54 2, -0.5, 1.5);
55
57
58}
59
60
62{
63
66 if (!eventAccepted) return;
67 }
68
69 //count the number of strips per APV in the event
70 for (const auto& shaper : m_shapers)
71 m_hHits->fill(shaper.getSensorID(), shaper.isUStrip(), shaper.getCellID() / 128, 0);
72
73 //loop on geometry and fill the tree for this event
75
76 for (auto layer : geoCache.getLayers(VXD::SensorInfoBase::SVD))
77 for (auto ladder : geoCache.getLadders(layer))
78 for (Belle2::VxdID sensor : geoCache.getSensors(ladder))
79 for (int view = SVDAPVHistograms<TH1F>::VIndex ; view < SVDAPVHistograms<TH1F>::UIndex + 1; view++)
80 for (int apv = 0; apv < 6; apv ++) {
81 m_svdLayer = sensor.getLayerNumber();
82 m_svdLadder = sensor.getLadderNumber();
83 m_svdSensor = sensor.getSensorNumber();
84 m_svdSide = view;
85 m_svdChip = apv;
86 m_svdHits = (m_hHits->getHistogram(sensor, view, apv))->GetEntries();
87 m_t->Fill();
88
89 //reset the histogram used as counters
90 (m_hHits->getHistogram(sensor, view, apv))->Reset();
91
92 }
93
94 m_event++;
95}
96
97
99{
100
101 if (m_rootFilePtr != nullptr) {
102 m_rootFilePtr->cd();
103 m_t->Write();
104 m_rootFilePtr->Close();
105 }
106}
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
template class for the APV Histograms
H * getHistogram(const VxdID &vxdID, int view, int apv)
get a reference to the histogram for
void fill(const VxdID &vxdID, int view, int apv, Types ... args)
fill the histogram for
std::string m_rootFileName
root file name
std::string m_shapersStoreArrayName
storeArray name of the input ShaperDigits
bool m_skipRejectedEvents
if true skip events rejected by HLT
void initialize() override
Register input and output data.
unsigned int m_svdHits
APV hits per event.
StoreArray< SVDShaperDigit > m_shapers
array of SVDShaperDigits
void event() override
Compute the variables and fill the tree.
void terminate() override
Write the TTrees to the file.
SVDAPVHistograms< TH1F > * m_hHits
hits per APV
void beginRun() override
Define APVHistogram.
unsigned int m_event
event number
StoreObjPtr< SoftwareTriggerResult > m_resultStoreObjectPointer
Store Object to read the trigger decision.
TTree * m_t
tree containing info related to the U and V side strips
TFile * m_rootFilePtr
pointer at root file used for storing histograms
static bool getFinalTriggerDecision(const SoftwareTriggerResult &result, bool forgetTotalResult=false)
Calculate the final cut decision using all "total_results" of all sub triggers in the software trigge...
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
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.