Belle II Software  release-06-02-00
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 
15 using namespace Belle2;
16 using namespace std;
17 using namespace SoftwareTrigger;
18 
19 REG_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.",
26  m_shapersStoreArrayName);
27  addParam("skipHLTRejectedEvents", m_skipRejectedEvents, "If TRUE skip events rejected by HLT", bool(true));
28 }
29 
31 {
32  m_shapers.isRequired(m_shapersStoreArrayName);
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 
56  m_hHits = new SVDAPVHistograms<TH1F>(hHits);
57 
58 }
59 
60 
62 {
63 
64  if (m_skipRejectedEvents && (m_resultStoreObjectPointer.isValid())) {
65  const bool eventAccepted = FinalTriggerDecisionCalculator::getFinalTriggerDecision(*m_resultStoreObjectPointer);
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
The module is used to create a TTree to study the number of strips fired per event per APV chip.
void initialize() override
Register input and output data.
void event() override
Compute the variables and fill the tree.
void terminate() override
Write the TTrees to the file.
void beginRun() override
Define APVHistogram.
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:213
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
#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.