Belle II Software  release-05-02-19
BeamBkgHitRateMonitorModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/core/Module.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/dataobjects/EventMetaData.h>
16 #include <framework/dataobjects/FileMetaData.h>
17 #include <mdst/dataobjects/TRGSummary.h>
18 #include <background/modules/BeamBkgHitRateMonitor/HitRateBase.h>
19 
20 #include <string>
21 #include <vector>
22 #include <map>
23 #include <TFile.h>
24 #include <TTree.h>
25 #include <TH1F.h>
26 
27 namespace Belle2 {
37  class BeamBkgHitRateMonitorModule : public Module {
38 
39  public:
40 
45 
50 
55  virtual void initialize() override;
56 
60  virtual void beginRun() override;
61 
65  virtual void event() override;
66 
70  virtual void endRun() override;
71 
76  virtual void terminate() override;
77 
78  private:
79 
84  bool isEventSelected();
85 
90  void collectFileMetaData();
91 
96  void setFileMetaData();
97 
98  // steering parameters
99  std::string m_outputFileName;
100  std::string m_treeName;
101  std::vector<int> m_trgTypes;
103  double m_topTimeOffset;
104  double m_topTimeWindow;
105  std::string m_svdShaperDigitsName;
106  double m_svdThrCharge;
109  std::map<std::string, std::string> m_additionalDataDescription;
118  // collections
123  // output file and tree
124  TFile* m_file = 0;
125  TTree* m_tree = 0;
127  // tree variables
128  int m_run = 0;
129  int m_numEvents = 0;
130  unsigned m_timeStamp = 0;
131  int m_time = 0;
133  // control histograms
134  TH1F* m_trgAll = 0;
135  TH1F* m_trgSel = 0;
137  // buffers
138  std::map<unsigned, int> m_eventCounts;
140  // rate monitoring classes: these provide additional buffers and tree branches
141  std::vector<Background::HitRateBase*> m_monitors;
143  // other
144  unsigned m_numEventsSelected = 0;
145  std::map<TRGSummary::ETimingType, unsigned> m_trgTypesCount;
146  unsigned m_utimeFirst = 0;
147  unsigned m_utimeMin = 0;
148  unsigned m_utimeMax = 0;
150  // output file meta data
151  TTree* m_persistent = 0;
153  std::vector<std::string> m_parentLfns;
154  unsigned long m_experimentLow = 1;
155  unsigned long m_runLow = 0;
156  unsigned long m_eventLow = 0;
157  unsigned long m_experimentHigh = 0;
158  unsigned long m_runHigh = 0;
159  unsigned long m_eventHigh = 0;
160  unsigned m_allEventsSelected = 0;
162  };
163 
165 } // Belle2 namespace
166 
Belle2::BeamBkgHitRateMonitorModule::m_monitors
std::vector< Background::HitRateBase * > m_monitors
rate monitors
Definition: BeamBkgHitRateMonitorModule.h:149
Belle2::BeamBkgHitRateMonitorModule::m_cdcEnableMarkBackgroundHit
bool m_cdcEnableMarkBackgroundHit
CDC: flag to enable to mark background flag on CDCHit (set 0x100 bit for CDCHit::m_status).
Definition: BeamBkgHitRateMonitorModule.h:124
Belle2::BeamBkgHitRateMonitorModule::m_cdcTimeWindowLowerEdgeSmallCell
int m_cdcTimeWindowLowerEdgeSmallCell
CDC: lower edge of the time window for small cells [tdc count = ns].
Definition: BeamBkgHitRateMonitorModule.h:118
Belle2::BeamBkgHitRateMonitorModule::m_cdcTimeWindowLowerEdgeNormalCell
int m_cdcTimeWindowLowerEdgeNormalCell
CDC: lower edge of the time window for normal cells [tdc count = ns].
Definition: BeamBkgHitRateMonitorModule.h:120
Belle2::BeamBkgHitRateMonitorModule::m_numEvents
int m_numEvents
number of events in the time stamp
Definition: BeamBkgHitRateMonitorModule.h:137
Belle2::BeamBkgHitRateMonitorModule::m_topTimeWindow
double m_topTimeWindow
TOP: time window in which to count hits [ns].
Definition: BeamBkgHitRateMonitorModule.h:112
Belle2::BeamBkgHitRateMonitorModule::m_parentLfns
std::vector< std::string > m_parentLfns
Vector of parent file LFNs.
Definition: BeamBkgHitRateMonitorModule.h:161
Belle2::BeamBkgHitRateMonitorModule::m_utimeMax
unsigned m_utimeMax
maximal unix time of events in the run
Definition: BeamBkgHitRateMonitorModule.h:156
Belle2::BeamBkgHitRateMonitorModule::collectFileMetaData
void collectFileMetaData()
Collect file meta data: LFN's, low and high experiment, run and event numbers.
Definition: BeamBkgHitRateMonitorModule.cc:299
Belle2::BeamBkgHitRateMonitorModule::m_utimeFirst
unsigned m_utimeFirst
unix time of the first event in the run input stream
Definition: BeamBkgHitRateMonitorModule.h:154
Belle2::BeamBkgHitRateMonitorModule::m_runLow
unsigned long m_runLow
Lowest run number.
Definition: BeamBkgHitRateMonitorModule.h:163
Belle2::BeamBkgHitRateMonitorModule::m_svdIgnoreMaskedStripsPayload
bool m_svdIgnoreMaskedStripsPayload
SVD: count FADC-masked strips as active.
Definition: BeamBkgHitRateMonitorModule.h:116
Belle2::BeamBkgHitRateMonitorModule::m_trgTypes
std::vector< int > m_trgTypes
trigger types to be selected
Definition: BeamBkgHitRateMonitorModule.h:109
Belle2::BeamBkgHitRateMonitorModule::m_cdcTimeWindowUpperEdgeSmallCell
int m_cdcTimeWindowUpperEdgeSmallCell
CDC: upper edge of the time window for small cells [tdc count = ns].
Definition: BeamBkgHitRateMonitorModule.h:119
Belle2::BeamBkgHitRateMonitorModule::m_experimentLow
unsigned long m_experimentLow
Lowest experiment number.
Definition: BeamBkgHitRateMonitorModule.h:162
Belle2::BeamBkgHitRateMonitorModule::m_eventMetaData
StoreObjPtr< EventMetaData > m_eventMetaData
event meta data object
Definition: BeamBkgHitRateMonitorModule.h:127
Belle2::BeamBkgHitRateMonitorModule::isEventSelected
bool isEventSelected()
event selection
Definition: BeamBkgHitRateMonitorModule.cc:277
Belle2::BeamBkgHitRateMonitorModule::m_persistent
TTree * m_persistent
root tree pointer (for FileMetaData)
Definition: BeamBkgHitRateMonitorModule.h:159
Belle2::BeamBkgHitRateMonitorModule::m_eventLow
unsigned long m_eventLow
Lowest event number in lowest run.
Definition: BeamBkgHitRateMonitorModule.h:164
Belle2::BeamBkgHitRateMonitorModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: BeamBkgHitRateMonitorModule.cc:184
Belle2::BeamBkgHitRateMonitorModule::m_trgAll
TH1F * m_trgAll
trigger types of all events
Definition: BeamBkgHitRateMonitorModule.h:142
Belle2::BeamBkgHitRateMonitorModule::m_runHigh
unsigned long m_runHigh
Highest run number.
Definition: BeamBkgHitRateMonitorModule.h:166
Belle2::BeamBkgHitRateMonitorModule::m_svdThrCharge
double m_svdThrCharge
SVD: energy cut on cluster charge.
Definition: BeamBkgHitRateMonitorModule.h:114
Belle2::BeamBkgHitRateMonitorModule::m_treeName
std::string m_treeName
output tree name
Definition: BeamBkgHitRateMonitorModule.h:108
Belle2::BeamBkgHitRateMonitorModule::m_cdcTimeWindowUpperEdgeNormalCell
int m_cdcTimeWindowUpperEdgeNormalCell
CDC: upper edge of the time window for normal cells [tdc count = ns].
Definition: BeamBkgHitRateMonitorModule.h:121
Belle2::BeamBkgHitRateMonitorModule::m_cdcEnableBackgroundHitFilter
bool m_cdcEnableBackgroundHitFilter
CDC: flag to enable the CDC background hit (crosstakl, noise) filter.
Definition: BeamBkgHitRateMonitorModule.h:123
Belle2::BeamBkgHitRateMonitorModule::m_trgSel
TH1F * m_trgSel
trigger types of selected events
Definition: BeamBkgHitRateMonitorModule.h:143
Belle2::FileMetaData
Metadata information about a file.
Definition: FileMetaData.h:39
Belle2::BeamBkgHitRateMonitorModule::m_experimentHigh
unsigned long m_experimentHigh
Highest experiment number.
Definition: BeamBkgHitRateMonitorModule.h:165
Belle2::BeamBkgHitRateMonitorModule::event
virtual void event() override
Event processor.
Definition: BeamBkgHitRateMonitorModule.cc:207
Belle2::BeamBkgHitRateMonitorModule::m_svdIgnoreHotStripsPayload
bool m_svdIgnoreHotStripsPayload
SVD: count hot strips as active.
Definition: BeamBkgHitRateMonitorModule.h:115
Belle2::BeamBkgHitRateMonitorModule::~BeamBkgHitRateMonitorModule
virtual ~BeamBkgHitRateMonitorModule()
Destructor.
Definition: BeamBkgHitRateMonitorModule.cc:115
Belle2::BeamBkgHitRateMonitorModule::endRun
virtual void endRun() override
End-of-run action.
Definition: BeamBkgHitRateMonitorModule.cc:229
Belle2::BeamBkgHitRateMonitorModule::m_fileMetaData
StoreObjPtr< FileMetaData > m_fileMetaData
file metadata
Definition: BeamBkgHitRateMonitorModule.h:129
Belle2::BeamBkgHitRateMonitorModule::m_time
int m_time
time in seconds w.r.t the first event of the run
Definition: BeamBkgHitRateMonitorModule.h:139
Belle2::BeamBkgHitRateMonitorModule::m_tree
TTree * m_tree
root tree pointer
Definition: BeamBkgHitRateMonitorModule.h:133
Belle2::BeamBkgHitRateMonitorModule::m_eventCounts
std::map< unsigned, int > m_eventCounts
number of events in time stamps
Definition: BeamBkgHitRateMonitorModule.h:146
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BeamBkgHitRateMonitorModule::m_utimeMin
unsigned m_utimeMin
minimal unix time of events in the run
Definition: BeamBkgHitRateMonitorModule.h:155
Belle2::BeamBkgHitRateMonitorModule::m_outputFileMetaData
FileMetaData m_outputFileMetaData
output file meta data branch
Definition: BeamBkgHitRateMonitorModule.h:160
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::BeamBkgHitRateMonitorModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: BeamBkgHitRateMonitorModule.cc:122
Belle2::BeamBkgHitRateMonitorModule::m_topTimeOffset
double m_topTimeOffset
TOP: time offset of hits [ns].
Definition: BeamBkgHitRateMonitorModule.h:111
Belle2::BeamBkgHitRateMonitorModule::m_numEventsSelected
unsigned m_numEventsSelected
number of selected events in a run
Definition: BeamBkgHitRateMonitorModule.h:152
Belle2::BeamBkgHitRateMonitorModule::m_file
TFile * m_file
root file pointer
Definition: BeamBkgHitRateMonitorModule.h:132
Belle2::BeamBkgHitRateMonitorModule::m_writeEmptyTimeStamps
bool m_writeEmptyTimeStamps
if true write to ntuple also empty time stamps
Definition: BeamBkgHitRateMonitorModule.h:110
Belle2::BeamBkgHitRateMonitorModule::m_outputFileName
std::string m_outputFileName
output file name
Definition: BeamBkgHitRateMonitorModule.h:107
Belle2::BeamBkgHitRateMonitorModule::m_trgSummary
StoreObjPtr< TRGSummary > m_trgSummary
trigger summary
Definition: BeamBkgHitRateMonitorModule.h:128
Belle2::BeamBkgHitRateMonitorModule::m_allEventsSelected
unsigned m_allEventsSelected
number of selected events in all runs
Definition: BeamBkgHitRateMonitorModule.h:168
Belle2::BeamBkgHitRateMonitorModule::BeamBkgHitRateMonitorModule
BeamBkgHitRateMonitorModule()
Constructor.
Definition: BeamBkgHitRateMonitorModule.cc:55
Belle2::DataStore::c_Persistent
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:62
Belle2::BeamBkgHitRateMonitorModule::m_run
int m_run
run number
Definition: BeamBkgHitRateMonitorModule.h:136
Belle2::BeamBkgHitRateMonitorModule::m_svdShaperDigitsName
std::string m_svdShaperDigitsName
SVD: name of the SVDShaperDigits collection.
Definition: BeamBkgHitRateMonitorModule.h:113
Belle2::BeamBkgHitRateMonitorModule::m_cdcEnableBadWireTreatment
bool m_cdcEnableBadWireTreatment
CDC: flag to enable the bad wire treatment.
Definition: BeamBkgHitRateMonitorModule.h:122
Belle2::BeamBkgHitRateMonitorModule::m_additionalDataDescription
std::map< std::string, std::string > m_additionalDataDescription
additional metadata description
Definition: BeamBkgHitRateMonitorModule.h:117
Belle2::BeamBkgHitRateMonitorModule::m_eventHigh
unsigned long m_eventHigh
Highest event number in highest run.
Definition: BeamBkgHitRateMonitorModule.h:167
Belle2::BeamBkgHitRateMonitorModule::setFileMetaData
void setFileMetaData()
Set output FileMetaData object.
Definition: BeamBkgHitRateMonitorModule.cc:335
Belle2::BeamBkgHitRateMonitorModule::terminate
virtual void terminate() override
Termination action.
Definition: BeamBkgHitRateMonitorModule.cc:264
Belle2::BeamBkgHitRateMonitorModule::m_trgTypesCount
std::map< TRGSummary::ETimingType, unsigned > m_trgTypesCount
trigger type counters
Definition: BeamBkgHitRateMonitorModule.h:153
Belle2::BeamBkgHitRateMonitorModule::m_timeStamp
unsigned m_timeStamp
time stamp (unix time)
Definition: BeamBkgHitRateMonitorModule.h:138