Belle II Software  release-06-02-00
SVDDQMHitTimeModule.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/svdDQM/SVDDQMHitTimeModule.h>
10 #include <framework/core/HistoModule.h>
11 #include <mdst/dataobjects/TRGSummary.h>
12 #include <TDirectory.h>
13 
14 using namespace Belle2;
15 
16 REG_MODULE(SVDDQMHitTime)
17 
18 //---------------------------------
20 {
21  setPropertyFlags(c_ParallelProcessingCertified); // parallel processing
22  setDescription("Make data quality monitoring plots for SVD Hit Time for bhabha, mu mu, and hadron samples seeded by different trigger times (ECL, CDC).");
23  addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed.",
24  std::string("SVDHitTime"));
25  addParam("Clusters", m_storeSVDClustersName, "SVDCluster StoreArray name.",
26  std::string(""));
27  addParam("EventInfo", m_storeSVDEventInfoName, "SVDEventInfo StoreObjPtr name.",
28  std::string(""));
29  addParam("desynchronizeSVDTime", m_desynchSVDTime,
30  "if True, svd time back in SVD time reference", bool(false));
31 
32 }
33 
34 //---------------------------------
36 
37 
38 //---------------------------------
40 {
41 
42  TDirectory* oldDir = gDirectory;
43  oldDir->mkdir(m_histogramDirectoryName.c_str())->cd();
44 
45  int nBins = 300 ;
46  double minT0 = -150 ;
47  double maxT0 = 150 ;
48 
49  TString refFrame = "in FTSW reference";
50  if (m_desynchSVDTime)
51  refFrame = "in SVD reference";
52 
53  m_l3v_bhabha_L1_ECLTRG = new TH1F("SVDTime_L3V_bhabha_ECLTRG",
54  Form("SVD L3 V-Side Cluster Time %s: bhabhas, ECLTRG time", refFrame.Data()),
55  nBins, minT0, maxT0);
56  m_l3v_bhabha_L1_ECLTRG->GetXaxis()->SetTitle("cluster time (ns)");
57  m_l3vEvtT0_bhabha_L1_ECLTRG = new TH1F("SVDTimeEvtT0_L3V_bhabha_ECLTRG",
58  "SVD L3 V-Side Cluster Time - EventT0 : bhabhas, ECLTRG time",
59  nBins, minT0, maxT0);
60  m_l3vEvtT0_bhabha_L1_ECLTRG->GetXaxis()->SetTitle("cluster time - EventT0 (ns)");
61 
62  m_l3v_hadron_L1_ECLTRG = new TH1F("SVDTime_L3V_hadron_ECLTRG",
63  Form("SVD L3 V-Side Cluster Time %s: hadrons, ECLTRG time", refFrame.Data()),
64  nBins, minT0, maxT0);
65  m_l3v_hadron_L1_ECLTRG->GetXaxis()->SetTitle("cluster time (ns)");
66  m_l3vEvtT0_hadron_L1_ECLTRG = new TH1F("SVDTimeEvtT0_L3V_hadron_ECLTRG",
67  "SVD L3 V-Side Cluster Time - EventT0 : hadrons, ECLTRG time",
68  nBins, minT0, maxT0);
69  m_l3vEvtT0_hadron_L1_ECLTRG->GetXaxis()->SetTitle("cluster time - EventT0 (ns)");
70 
71  m_l3v_mumu_L1_ECLTRG = new TH1F("SVDTime_L3V_mumu_ECLTRG",
72  Form("SVD L3 V-Side Cluster Time %s: mumus, ECLTRG time", refFrame.Data()),
73  nBins, minT0, maxT0);
74  m_l3v_mumu_L1_ECLTRG->GetXaxis()->SetTitle("cluster time (ns)");
75  m_l3vEvtT0_mumu_L1_ECLTRG = new TH1F("SVDTimeEvtT0_L3V_mumu_ECLTRG",
76  "SVD L3 V-Side Cluster Time - EventT0 : mumus, ECLTRG time",
77  nBins, minT0, maxT0);
78  m_l3vEvtT0_mumu_L1_ECLTRG->GetXaxis()->SetTitle("cluster time - EventT0 (ns)");
79 
80  m_l3v_bhabha_L1_CDCTRG = new TH1F("SVDTime_L3V_bhabha_CDCTRG",
81  Form("SVD L3 V-Side Cluster Time %s: bhabhas, CDCTRG time", refFrame.Data()),
82  nBins, minT0, maxT0);
83  m_l3v_bhabha_L1_CDCTRG->GetXaxis()->SetTitle("cluster time (ns)");
84  m_l3vEvtT0_bhabha_L1_CDCTRG = new TH1F("SVDTimeEvtT0_L3V_bhabha_CDCTRG",
85  "SVD L3 V-Side Cluster Time - EventT0 : bhabhas, CDCTRG time",
86  nBins, minT0, maxT0);
87  m_l3vEvtT0_bhabha_L1_CDCTRG->GetXaxis()->SetTitle("cluster time - EventT0 (ns)");
88 
89  m_l3v_hadron_L1_CDCTRG = new TH1F("SVDTime_L3V_hadron_CDCTRG",
90  Form("SVD L3 V-Side Cluster Time %s: hadrons, CDCTRG time", refFrame.Data()),
91  nBins, minT0, maxT0);
92  m_l3v_hadron_L1_CDCTRG->GetXaxis()->SetTitle("cluster time (ns)");
93  m_l3vEvtT0_hadron_L1_CDCTRG = new TH1F("SVDTimeEvtT0_L3V_hadron_CDCTRG",
94  "SVD L3 V-Side Cluster Time - EventT0 : hadrons, CDCTRG time",
95  nBins, minT0, maxT0);
96  m_l3vEvtT0_hadron_L1_CDCTRG->GetXaxis()->SetTitle("cluster time - EventT0 (ns)");
97 
98  m_l3v_mumu_L1_CDCTRG = new TH1F("SVDTime_L3V_mumu_CDCTRG",
99  Form("SVD L3 V-Side Cluster Time %s: mumus, CDCTRG time", refFrame.Data()),
100  nBins, minT0, maxT0);
101  m_l3v_mumu_L1_CDCTRG->GetXaxis()->SetTitle("cluster time (ns)");
102  m_l3vEvtT0_mumu_L1_CDCTRG = new TH1F("SVDTimeEvtT0_L3V_mumu_CDCTRG",
103  "SVD L3 V-Side Cluster Time - EventT0 : mumus, CDCTRG time",
104  nBins, minT0, maxT0);
105  m_l3vEvtT0_mumu_L1_CDCTRG->GetXaxis()->SetTitle("cluster time - EventT0 (ns)");
106 
107  oldDir->cd();
108 
109 }
110 
111 
112 //---------------------------------
114 {
115 
116  m_TrgResult.isOptional();
117  m_eventT0.isOptional();
120 
121  REG_HISTOGRAM
122 
123 }
124 
125 
126 
127 //---------------------------------
129 {
130 
131  m_l3v_bhabha_L1_ECLTRG->Reset();
133  m_l3v_hadron_L1_ECLTRG->Reset();
135  m_l3v_mumu_L1_ECLTRG->Reset();
136  m_l3vEvtT0_mumu_L1_ECLTRG->Reset();
137 
138  m_l3v_bhabha_L1_CDCTRG->Reset();
140  m_l3v_hadron_L1_CDCTRG->Reset();
142  m_l3v_mumu_L1_CDCTRG->Reset();
143  m_l3vEvtT0_mumu_L1_CDCTRG->Reset();
144 
145 }
146 
147 
148 //---------------------------------
150 {
151 
152  if (!m_TrgResult.isValid()) {
153  B2WARNING("Missing TRGSummary, SVDDQMHitTime is skipped.");
154  return;
155  }
156  if (!m_svdEventInfo.isValid()) {
157  B2WARNING("Missing SVDEventInfo, SVDDQMHitTime is skipped.");
158  return;
159  }
160 
161 
162 
163  if (!m_clusters.isValid()) {
164  B2WARNING("Missing SVDClusters, SVDDQMHitTime is skipped.");
165  return;
166  }
167 
168 
169  if (!m_objTrgSummary.isValid()) {
170  B2WARNING("TRGSummary object not available but required to indicate which detector provided the L1 trigger time");
171  return;
172  } else {
173  m_L1TimingSrc = m_objTrgSummary->getTimType();
174  }
175 
176  bool Is_ECL_L1TriggerSource = false ;
177  bool Is_CDC_L1TriggerSource = false ;
178  if (m_L1TimingSrc == TRGSummary::ETimingType::TTYP_ECL) { // for L1 timing source is "ecl trigger"
179  Is_ECL_L1TriggerSource = true ;
180  } else if (m_L1TimingSrc == TRGSummary::ETimingType::TTYP_CDC) { // for L1 timing source is "cdc trigger"
181  Is_CDC_L1TriggerSource = true ;
182  }
183  // else if(m_L1TimingSrc==ETimingType::TTYP_DPHY){ // for L1 timing source is "delayed Bhabha" }
184  B2DEBUG(20, "Is_ECL_L1TriggerSource = " << Is_ECL_L1TriggerSource) ;
185  B2DEBUG(20, "Is_CDC_L1TriggerSource= " << Is_CDC_L1TriggerSource) ;
186 
187 
188  if (!m_TrgResult.isValid()) {
189  B2WARNING("SoftwareTriggerResult object not available but require to select bhabha/mumu/hadron events for this module");
190  return;
191  }
192 
193  const std::map<std::string, int>& fresults = m_TrgResult->getResults();
194  if ((fresults.find("software_trigger_cut&skim&accept_bhabha") == fresults.end()) ||
195  (fresults.find("software_trigger_cut&skim&accept_mumu_2trk") == fresults.end()) ||
196  (fresults.find("software_trigger_cut&skim&accept_hadron") == fresults.end())) {
197  B2WARNING("SVDDQMHitTimeModule: Can't find required bhabha or mumu or hadron trigger identifier");
198  return;
199  }
200 
201 
202 
203  // determine if the event was part of the hadron skim or bhabha skim or mumu skim
204  const bool IsEvtAcceptedBhabha = (m_TrgResult->getResult("software_trigger_cut&skim&accept_bhabha") ==
206  const bool IsEvtAcceptedHadron = (m_TrgResult->getResult("software_trigger_cut&skim&accept_hadron") ==
208  const bool IsEvtAcceptedMumu = (m_TrgResult->getResult("software_trigger_cut&skim&accept_mumu_2trk") ==
210 
211 
212  B2DEBUG(20, "bhabha trigger result = " << static_cast<std::underlying_type<SoftwareTriggerCutResult>::type>
213  (m_TrgResult->getResult("software_trigger_cut&skim&accept_bhabha"))) ;
214  B2DEBUG(20, "hadron trigger result = " << static_cast<std::underlying_type<SoftwareTriggerCutResult>::type>
215  (m_TrgResult->getResult("software_trigger_cut&skim&accept_hadron"))) ;
216  B2DEBUG(20, "mu mu trigger result = " << static_cast<std::underlying_type<SoftwareTriggerCutResult>::type>
217  (m_TrgResult->getResult("software_trigger_cut&skim&accept_mumu_2trk"))) ;
218  B2DEBUG(20, "bhabha trigger comparison bool = " << IsEvtAcceptedBhabha) ;
219  B2DEBUG(20, "hadron trigger comparison bool = " << IsEvtAcceptedHadron) ;
220  B2DEBUG(20, "mumu trigger comparison bool = " << IsEvtAcceptedMumu) ;
221 
222 
223  // get EventT0 if present and valid
224  double eventT0 = -1000;
225  if (m_eventT0.isValid())
226  if (m_eventT0->hasEventT0())
227  eventT0 = m_eventT0->getEventT0();
228 
229  // if svd time in SVD time reference is shown, eventT0 is also synchronized with SVD reference frame, firstFrame = 0
230  if (m_desynchSVDTime && m_svdEventInfo.isValid())
231  eventT0 = eventT0 - m_svdEventInfo->getSVD2FTSWTimeShift(0);
232 
233  //loop on clusters
234  for (const SVDCluster& cluster : m_clusters) {
235 
236  //skip all non-L3 clusters
237  if (cluster.getSensorID().getLayerNumber() != 3) continue;
238  //skip all U-side clusters
239  if (cluster.isUCluster()) continue;
240 
241  double time = cluster.getClsTime();
242 
243  //if svd time is shown in SVD time reference we need to desynchronize (eventT0 is, instead, synchronized, see a few lines above
244  if (m_desynchSVDTime && m_svdEventInfo.isValid())
245  time = time - m_svdEventInfo->getSVD2FTSWTimeShift(cluster.getFirstFrame());
246 
247  // Fill the plots that used the ECL trigger as the L1 timing source
248  if (Is_ECL_L1TriggerSource) {
249  if (IsEvtAcceptedBhabha) {
250  m_l3v_bhabha_L1_ECLTRG->Fill(time);
251  m_l3vEvtT0_bhabha_L1_ECLTRG->Fill(time - eventT0);
252  }
253  if (IsEvtAcceptedHadron) {
254  m_l3v_hadron_L1_ECLTRG->Fill(time);
255  m_l3vEvtT0_hadron_L1_ECLTRG->Fill(time - eventT0);
256  }
257  if (IsEvtAcceptedMumu) {
258  m_l3v_mumu_L1_ECLTRG->Fill(time);
259  m_l3vEvtT0_mumu_L1_ECLTRG->Fill(time - eventT0);
260  }
261  }
262 
263  // Fill the plots that used the CDC trigger as the L1 timing source
264  else if (Is_CDC_L1TriggerSource) {
265  if (IsEvtAcceptedBhabha) {
266  m_l3v_bhabha_L1_CDCTRG->Fill(time);
267  m_l3vEvtT0_bhabha_L1_CDCTRG->Fill(time - eventT0);
268  }
269  if (IsEvtAcceptedHadron) {
270  m_l3v_hadron_L1_CDCTRG->Fill(time);
271  m_l3vEvtT0_hadron_L1_CDCTRG->Fill(time - eventT0);
272  }
273  if (IsEvtAcceptedMumu) {
274  m_l3v_mumu_L1_CDCTRG->Fill(time);
275  m_l3vEvtT0_mumu_L1_CDCTRG->Fill(time - eventT0);
276  }
277  }
278 
279  B2DEBUG(20, "eventT0 = " << eventT0 << " ns" << ", SVD HitTime = " << time << " ns") ;
280 
281  } //close loop on clusters
282 }
283 
284 
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:28
This module to design collect the svd hit time for different detectors trigger timing and physics pro...
virtual ~SVDDQMHitTimeModule()
Destructor.
StoreObjPtr< EventT0 > m_eventT0
EventT0 data object.
TH1F * m_l3v_mumu_L1_ECLTRG
svd time histogram for mu mu events wrt the ECL trigger time
virtual void initialize() override
Initialize the module.
StoreObjPtr< SVDEventInfo > m_svdEventInfo
SVDEventInfo data object.
virtual void event() override
This method is called for each event.
TH1F * m_l3vEvtT0_mumu_L1_ECLTRG
svd time histogram for mu mu events wrt the ECL trigger time
StoreArray< SVDCluster > m_clusters
Store array for clusters.
TH1F * m_l3v_hadron_L1_CDCTRG
svd time histogram for hadronic events wrt the CDC trigger time
TH1F * m_l3vEvtT0_mumu_L1_CDCTRG
svd time histogram for mu mu events wrt the CDC trigger time
TH1F * m_l3vEvtT0_hadron_L1_CDCTRG
svd time histogram for hadronic events wrt the CDC trigger time
TH1F * m_l3v_hadron_L1_ECLTRG
svd time histogram for hadronic events wrt the ECL trigger time
TH1F * m_l3vEvtT0_hadron_L1_ECLTRG
svd time histogram for hadronic events wrt the ECL trigger time
StoreObjPtr< TRGSummary > m_objTrgSummary
Trigger Summary data object.
virtual void beginRun() override
This method is called for each run.
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
TH1F * m_l3v_bhabha_L1_ECLTRG
svd time histogram for bhabha events wrt the ECL trigger time
TH1F * m_l3vEvtT0_bhabha_L1_CDCTRG
svd time histogram for bhabha events wrt the CDC trigger time
TH1F * m_l3v_mumu_L1_CDCTRG
svd time histogram for mu mu events wrt the CDC trigger time
bool m_desynchSVDTime
if TRUE: svdTime back in SVD time reference
TH1F * m_l3v_bhabha_L1_CDCTRG
svd time histogram for bhabha events wrt the CDC trigger time
int m_L1TimingSrc
L1 timing source from getTimeType() in TRGSummary See ETimingTYpe in mdst/dataobjects/include/TRGSumm...
std::string m_storeSVDClustersName
SVDClusters StoreArray name.
std::string m_storeSVDEventInfoName
SVDEventInfo StoreObjPtry name.
StoreObjPtr< SoftwareTriggerResult > m_TrgResult
Trigger selection data object.
TH1F * m_l3vEvtT0_bhabha_L1_ECLTRG
svd time histogram for bhabha events wrt the ECL trigger time
virtual void defineHisto() override
Definition of histograms.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
bool isValid() const
Check wether the array was registered.
Definition: StoreArray.h:288
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
@ c_accept
Accept this event.
Abstract base class for different kinds of events.