Belle II Software  release-08-01-10
BeamBkgHitRateMonitorModule.h
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 #pragma once
10 
11 #include <framework/core/Module.h>
12 #include <framework/datastore/StoreObjPtr.h>
13 #include <framework/dataobjects/EventMetaData.h>
14 #include <framework/dataobjects/FileMetaData.h>
15 #include <mdst/dataobjects/TRGSummary.h>
16 #include <background/modules/BeamBkgHitRateMonitor/HitRateBase.h>
17 
18 #include <string>
19 #include <vector>
20 #include <map>
21 #include <TFile.h>
22 #include <TTree.h>
23 #include <TH1F.h>
24 
25 namespace Belle2 {
36 
37  public:
38 
43 
48 
53  virtual void initialize() override;
54 
58  virtual void beginRun() override;
59 
63  virtual void event() override;
64 
68  virtual void endRun() override;
69 
74  virtual void terminate() override;
75 
76  private:
77 
82  bool isEventSelected();
83 
88  void collectFileMetaData();
89 
94  void setFileMetaData();
95 
96  // steering parameters
97  std::string m_outputFileName;
98  std::string m_treeName;
99  std::vector<int> m_trgTypes;
103  std::string m_svdShaperDigitsName;
104  double m_svdThrCharge;
107  std::map<std::string, std::string> m_additionalDataDescription;
116  // collections
121  // output file and tree
122  TFile* m_file = 0;
123  TTree* m_tree = 0;
125  // tree variables
126  int m_run = 0;
127  int m_numEvents = 0;
128  unsigned m_timeStamp = 0;
129  int m_time = 0;
131  // control histograms
132  TH1F* m_trgAll = 0;
133  TH1F* m_trgSel = 0;
135  // buffers
136  std::map<unsigned, int> m_eventCounts;
138  // rate monitoring classes: these provide additional buffers and tree branches
139  std::vector<Background::HitRateBase*> m_monitors;
141  // other
142  unsigned m_numEventsSelected = 0;
143  std::map<TRGSummary::ETimingType, unsigned> m_trgTypesCount;
144  unsigned m_utimeFirst = 0;
145  unsigned m_utimeMin = 0;
146  unsigned m_utimeMax = 0;
148  // output file meta data
149  TTree* m_persistent = 0;
151  std::vector<std::string> m_parentLfns;
152  unsigned long m_experimentLow = 1;
153  unsigned long m_runLow = 0;
154  unsigned long m_eventLow = 0;
155  unsigned long m_experimentHigh = 0;
156  unsigned long m_runHigh = 0;
157  unsigned long m_eventHigh = 0;
158  unsigned m_allEventsSelected = 0;
160  };
161 
163 } // Belle2 namespace
164 
A module to monitor detector hit rates of beam background Output is to a flat ntuple.
unsigned m_numEventsSelected
number of selected events in a run
unsigned long m_experimentLow
Lowest experiment number.
unsigned long m_experimentHigh
Highest experiment number.
unsigned long m_eventLow
Lowest event number in lowest run.
int m_cdcTimeWindowLowerEdgeNormalCell
CDC: lower edge of the time window for normal cells [tdc count = ns].
unsigned m_allEventsSelected
number of selected events in all runs
std::string m_svdShaperDigitsName
SVD: name of the SVDShaperDigits collection.
unsigned m_utimeFirst
unix time of the first event in the run input stream
double m_topTimeWindow
TOP: time window in which to count hits [ns].
std::vector< Background::HitRateBase * > m_monitors
rate monitors
virtual void initialize() override
Initialize the Module.
unsigned long m_runLow
Lowest run number.
unsigned m_utimeMax
maximal unix time of events in the run
bool m_cdcEnableMarkBackgroundHit
CDC: flag to enable to mark background flag on CDCHit (set 0x100 bit for CDCHit::m_status).
virtual void event() override
Event processor.
TH1F * m_trgAll
trigger types of all events
bool m_cdcEnableBadWireTreatment
CDC: flag to enable the bad wire treatment.
virtual void endRun() override
End-of-run action.
StoreObjPtr< TRGSummary > m_trgSummary
trigger summary
virtual void terminate() override
Termination action.
FileMetaData m_outputFileMetaData
output file meta data branch
bool m_svdIgnoreHotStripsPayload
SVD: count hot strips as active.
unsigned long m_runHigh
Highest run number.
StoreObjPtr< EventMetaData > m_eventMetaData
event meta data object
int m_numEvents
number of events in the time stamp
std::vector< int > m_trgTypes
trigger types to be selected
int m_cdcTimeWindowUpperEdgeNormalCell
CDC: upper edge of the time window for normal cells [tdc count = ns].
virtual void beginRun() override
Called when entering a new run.
void setFileMetaData()
Set output FileMetaData object.
unsigned m_timeStamp
time stamp (unix time)
double m_svdThrCharge
SVD: energy cut on cluster charge.
bool m_writeEmptyTimeStamps
if true write to ntuple also empty time stamps
int m_time
time in seconds w.r.t the first event of the run
int m_cdcTimeWindowUpperEdgeSmallCell
CDC: upper edge of the time window for small cells [tdc count = ns].
void collectFileMetaData()
Collect file meta data: LFN's, low and high experiment, run and event numbers.
TH1F * m_trgSel
trigger types of selected events
int m_cdcTimeWindowLowerEdgeSmallCell
CDC: lower edge of the time window for small cells [tdc count = ns].
bool m_svdIgnoreMaskedStripsPayload
SVD: count FADC-masked strips as active.
bool m_cdcEnableBackgroundHitFilter
CDC: flag to enable the CDC background hit (crosstakl, noise) filter.
std::map< unsigned, int > m_eventCounts
number of events in time stamps
unsigned long m_eventHigh
Highest event number in highest run.
std::map< std::string, std::string > m_additionalDataDescription
additional metadata description
std::map< TRGSummary::ETimingType, unsigned > m_trgTypesCount
trigger type counters
std::vector< std::string > m_parentLfns
Vector of parent file LFNs.
double m_topTimeOffset
TOP: time offset of hits [ns].
unsigned m_utimeMin
minimal unix time of events in the run
StoreObjPtr< FileMetaData > m_fileMetaData
file metadata
TTree * m_persistent
root tree pointer (for FileMetaData)
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:60
Metadata information about a file.
Definition: FileMetaData.h:29
Base class for Modules.
Definition: Module.h:72
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.