Belle II Software  release-05-01-25
SVDEventInfoSetterModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jarek Wiechczynski *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <svd/modules/svdSimulation/SVDEventInfoSetterModule.h>
12 #include <root/TRandom.h>
13 #include <mdst/dataobjects/TRGSummary.h>
14 
15 using namespace std;
16 using namespace Belle2;
17 
18 //-----------------------------------------------------------------
19 // Register the Module
20 //-----------------------------------------------------------------
21 REG_MODULE(SVDEventInfoSetter)
22 
23 //-----------------------------------------------------------------
24 // Implementation
25 //-----------------------------------------------------------------
26 
28 {
29  //Set module properties
30  setDescription(
31  "Sets the SVD event information. You must use this "
32  "module to fill SVDEventInfo object which tells the digitizer "
33  "the conditions for creating ShaperDigits."
34  );
35 
36  setPropertyFlags(c_ParallelProcessingCertified);
37 
38  //Parameter definition for SVDModeByte, TriggerType and cross-talk
39  addParam("SVDEventInfo", m_svdEventInfoName, "Defines the name of the EventInfo", string("SVDEventInfoSim"));
40  addParam("runType", m_runType, "Defines the run type: raw/transparent/zero-suppressed/z-s+hit time finding", int(2));
41  addParam("eventType", m_eventType, "Defines the event type: TTD event (global run)/standalone event (local run)", int(0));
42  addParam("daqMode", m_daqMode, "Defines the DAQ mode: 1/3/6 samples or 3-mixed-6 samples", int(2));
43  addParam("randomTriggerBin", m_randomTriggerBin, "Trigger bin is randomly chosen between 0/1/2/3.", bool(true));
44  addParam("triggerBin", m_triggerBin, "Trigger bin 0/1/2/3 - useful for timing studies. The default is random.", int(999));
45  addParam("triggerType", m_triggerType, "Defines the trigger type, default: CDC trigger", uint8_t(3));
46  addParam("crossTalk", m_xTalk, "Defines the cross-talk flag for the event", bool(false));
47  addParam("relativeShift", m_relativeShift, "Relative shift between 3- and 6-sample events, in units of APV clock / 4", int(0));
48 
49  // default ModeByte settings: 10 0 10 000 (144)
50 }
51 
52 SVDEventInfoSetterModule::~SVDEventInfoSetterModule() = default;
53 
54 void SVDEventInfoSetterModule::initialize()
55 {
56  //Register the EventInfo in the data store
57  m_svdEventInfoPtr.registerInDataStore(m_svdEventInfoName, DataStore::c_ErrorIfAlreadyRegistered);
58 
59 // TO BE ADDED(?): some functions than can check the validity of the given parameters
60 }
61 
62 void SVDEventInfoSetterModule::event()
63 {
64  if (m_randomTriggerBin) {
65  const int triggerBinsInAPVclock = 4; //hard coded for the moment
66  m_triggerBin = gRandom->Integer(triggerBinsInAPVclock);
67  } else if (m_triggerBin < 0 || m_triggerBin > 3)
68  B2ERROR("the triggerBin value is wrong, it must be an integer between 0 and 3, check and fix");
69 
70  m_SVDModeByte.setRunType(m_runType);
71  m_SVDModeByte.setEventType(m_eventType);
72  m_SVDModeByte.setDAQMode(m_daqMode);
73  m_SVDModeByte.setTriggerBin(m_triggerBin);
74  m_SVDTriggerType.setType(m_triggerType);
75 
76  m_svdEventInfoPtr.create();
77  m_svdEventInfoPtr->setModeByte(m_SVDModeByte);
78  m_svdEventInfoPtr->setMatchModeByte(m_ModeByteMatch);
79  m_svdEventInfoPtr->setTriggerType(m_SVDTriggerType);
80  m_svdEventInfoPtr->setMatchTriggerType(m_TriggerTypeMatch);
81  m_svdEventInfoPtr->setCrossTalk(m_xTalk);
82  m_svdEventInfoPtr->setRelativeShift(m_relativeShift);
83 
84  int nAPVsamples = 6;
85 
86  if (m_daqMode == 1) nAPVsamples = 3;
87  else if (m_daqMode == 3) {
88  if (m_triggerType == TRGSummary::ETimingType::TTYP_TOP or m_triggerType == TRGSummary::ETimingType::TTYP_ECL
89  or m_triggerType == TRGSummary::ETimingType::TTYP_PID1 or m_triggerType == TRGSummary::ETimingType::TTYP_PID2
90  or m_triggerType == TRGSummary::ETimingType::TTYP_PID3) nAPVsamples = 3;
91  }
92 
93  m_svdEventInfoPtr->setNSamples(nAPVsamples);
94 
95 }
96 
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDEventInfoSetterModule
Module to set the SVDEventInfo in the simulation.
Definition: SVDEventInfoSetterModule.h:33