Belle II Software  release-08-01-10
TRGGDLCosmicRunModule.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 #include "trg/gdl/modules/trggdl/TRGGDLCosmicRunModule.h"
9 
10 using namespace std;
11 using namespace Belle2;
12 
13 //this line registers the module with the framework and actually makes it available
14 //in steering files or the the module list (basf2 -m).
15 REG_MODULE(TRGGDLCosmicRun);
16 
17 TRGGDLCosmicRunModule::TRGGDLCosmicRunModule() : Module::Module()
18 {
20  "Module that returns true, if the trigger condition "
21  "for the 2017 cosmic runs is fulfilled.\n"
22  "trigger conditions:\n"
23  " with back-to-back: two back-to-back track segments in superlayer 2 "
24  "plus one ECL hit\n"
25  " without back-to-back: on track segment in superlayer 2 "
26  "plus one ECL hit"
27  );
28 
29  addParam("tsHitCollectionName", m_tsHitCollectionName,
30  "Name of the input StoreArray of CDCTriggerSegmentHits.",
31  string(""));
32  addParam("BackToBack", m_backToBack,
33  "Switch to turn back-to-back requirement on or off.",
34  true);
35  addParam("skipECL", m_skipECL,
36  "Switch to turn off the ECL part of the cosmic trigger.",
37  false);
38 }
39 
40 void
42 {
44  if (!m_skipECL) m_tchit.isRequired();
45 }
46 
47 void
49 {
50  bool TSinMerger[12] = {false};
51  bool TSinSL2 = false;
52  for (int its = 0; its < m_segmentHits.getEntries(); ++its) {
53  if (m_segmentHits[its]->getISuperLayer() == 2) {
54  // SegmentID in SuperLayer 2 starts at 320
55  // One merger corresponds to 16 segments
56  unsigned mergerID = (m_segmentHits[its]->getSegmentID() - 320) / 16;
57  TSinMerger[mergerID] = true;
58  TSinSL2 = true;
59  }
60  }
61  bool BackToBack = false;
62  for (unsigned i = 0; i < 6; ++i) {
63  BackToBack |= (TSinMerger[i] && TSinMerger[i + 6]);
64  }
65 
66  bool TCHit = false;
67  if (!m_skipECL) {
68  for (int itchit = 0; itchit < m_tchit.getEntries(); itchit++) {
69  if ((m_tchit[itchit] -> getNofTCHit()) > 0) {
70  TCHit = true;
71  }
72  }
73  }
74 
75  if (m_backToBack)
76  setReturnValue(BackToBack && (TCHit || m_skipECL));
77  else
78  setReturnValue(TSinSL2 && (TCHit || m_skipECL));
79 }
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
StoreArray< TRGECLTrg > m_tchit
list of ECL trigger hits
virtual void initialize() override
Initialize the module.
virtual void event() override
Check the trigger condition and set return value.
StoreArray< CDCTriggerSegmentHit > m_segmentHits
list of track segment hits
bool m_skipECL
switch for turning off the ECL part
std::string m_tsHitCollectionName
name of track segment hit list
bool m_backToBack
switch for back-to-back condition
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.