CMS 3D CMS Logo

L1GlobaTriggerRecordProducer.cc
Go to the documentation of this file.
1 
16 // this class header
18 
19 // system include files
20 #include <iostream>
21 
22 // user include files
24 
27 
30 
33 
37 
38 // constructor(s)
40 {
41 
42  produces<L1GlobalTriggerRecord>();
43 
44  // input tag for DAQ GT record
45  m_l1GtReadoutRecordTag = consumes<L1GlobalTriggerReadoutRecord>(parSet.getParameter<edm::InputTag>("L1GtReadoutRecordTag"));
46 
47  LogDebug("L1GlobalTriggerRecordProducer").log([&parSet](auto& l) {
48  l<< "\nInput tag for L1 GT DAQ record: "
49  << parSet.getParameter<edm::InputTag>("L1GtReadoutRecordTag");
50  });
51 
52  // initialize cached IDs
53 
54  m_l1GtTmAlgoCacheID = 0ULL;
55  m_l1GtTmTechCacheID = 0ULL;
56 
57 }
58 
59 // destructor
61 {
62 
63  // empty
64 
65 }
66 
67 
68 // member functions
69 
70 // method called to produce the data
72 {
73 
74  // produce the L1GlobalTriggerRecord
75  std::unique_ptr<L1GlobalTriggerRecord> gtRecord(new L1GlobalTriggerRecord());
76 
77  // get L1GlobalTriggerReadoutRecord
79  iEvent.getByToken(m_l1GtReadoutRecordTag, gtReadoutRecord);
80 
81  if (!gtReadoutRecord.isValid()) {
82 
83  LogDebug("L1GlobalTriggerRecordProducer").log([this](auto& l) {
84  l << "\n\n Error: no L1GlobalTriggerReadoutRecord found with input tag ";
86  labelsForToken(m_l1GtReadoutRecordTag,labels);
87  l << labels.module<<" "<<labels.productInstance<<" "<<labels.process
88  << "\n Returning empty L1GlobalTriggerRecord.\n\n";
89  });
90  iEvent.put(std::move(gtRecord));
91  return;
92  }
93 
94  //
95  cms_uint16_t gtFinalOR = gtReadoutRecord->finalOR();
96  int physicsDaqPartition = 0;
97  bool gtDecision = static_cast<bool> (gtFinalOR & (1 << physicsDaqPartition));
98 
99  DecisionWord algoDecisionWord = gtReadoutRecord->decisionWord();
100  TechnicalTriggerWord techDecisionWord = gtReadoutRecord->technicalTriggerWord();
101 
102  // get / update the trigger mask from the EventSetup
103  // local cache & check on cacheIdentifier
104 
105  unsigned long long l1GtTmAlgoCacheID =
106  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
107 
108  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
109 
111  evSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
112  m_l1GtTmAlgo = l1GtTmAlgo.product();
113 
115 
116  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
117 
118  }
119 
120 
121  unsigned long long l1GtTmTechCacheID =
122  evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
123 
124  if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
125 
127  evSetup.get< L1GtTriggerMaskTechTrigRcd >().get( l1GtTmTech );
128  m_l1GtTmTech = l1GtTmTech.product();
129 
131 
132  m_l1GtTmTechCacheID = l1GtTmTechCacheID;
133 
134  }
135 
138  gtRecord->setDecisionWordBeforeMask(algoDecisionWord);
139  gtRecord->setTechnicalTriggerWordBeforeMask(techDecisionWord);
140 
141  // mask the required bits for DAQ partition 0 (Physics Partition)
142 
143  int iDaq = 0;
144 
145  // algorithm trigger mask
146 
147  int iBit = -1; // bit counter
148 
149  for (std::vector<bool>::iterator
150  itBit = algoDecisionWord.begin(); itBit != algoDecisionWord.end(); ++itBit) {
151 
152  iBit++;
153 
154  int triggerMaskAlgoTrigBit = m_triggerMaskAlgoTrig[iBit] & (1 << iDaq);
155  //LogTrace("L1GlobalTriggerFDL")
156  //<< "\nAlgorithm trigger bit: " << iBit
157  //<< " mask = " << triggerMaskAlgoTrigBit
158  //<< " DAQ partition " << iDaq
159  //<< std::endl;
160 
161  if (triggerMaskAlgoTrigBit) {
162  *itBit = false;
163 
164  //LogTrace("L1GlobalTriggerFDL")
165  //<< "\nMasked algorithm trigger: " << iBit << ". Result set to false"
166  //<< std::endl;
167  }
168  }
169 
170  // mask the technical trigger
171 
172  iBit = -1; // bit counter
173 
174  for (std::vector<bool>::iterator
175  itBit = techDecisionWord.begin(); itBit != techDecisionWord.end(); ++itBit) {
176 
177  iBit++;
178 
179  int triggerMaskTechTrigBit = m_triggerMaskTechTrig[iBit] & (1 << iDaq);
180  //LogTrace("L1GlobalTriggerFDL")
181  //<< "\nTechnical trigger bit: " << iBit
182  //<< " mask = " << triggerMaskTechTrigBit
183  //<< " DAQ partition " << iDaq
184  //<< std::endl;
185 
186  if (triggerMaskTechTrigBit) {
187  *itBit = false;
188 
189  //LogTrace("L1GlobalTriggerFDL")
190  //<< "\nMasked technical trigger: " << iBit << ". Result set to false"
191  //<< std::endl;
192  }
193  }
194 
195 
196 
197 
198  // set global decision, decision word and technical trigger word
199  // for bunch cross with L1Accept (BxInEvent = 0) after applying the trigger masks
200  gtRecord->setDecision(gtDecision);
201  gtRecord->setDecisionWord(algoDecisionWord);
202  gtRecord->setTechnicalTriggerWord(techDecisionWord);
203 
204  // get/set index of the set of prescale factors
205  unsigned int pfIndexTech =
206  static_cast<unsigned int> ((gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech());
207  unsigned int pfIndexAlgo =
208  static_cast<unsigned int> ((gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo());
209 
210  gtRecord->setGtPrescaleFactorIndexTech(pfIndexTech);
211  gtRecord->setGtPrescaleFactorIndexAlgo(pfIndexAlgo);
212 
213  if ( edm::isDebugEnabled() ) {
214  std::ostringstream myCoutStream;
215  gtRecord->print(myCoutStream);
216  LogTrace("L1GlobalTriggerRecordProducer")
217  << "\n The following L1 GT record was produced.\n"
218  << myCoutStream.str() << "\n"
219  << std::endl;
220  }
221 
222  // put records into event
223  iEvent.put(std::move(gtRecord));
224 
225 }
226 
227 // static class members
228 
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtReadoutRecordTag
InputTag for the L1 Global Trigger DAQ readout record.
const TechnicalTriggerWord & technicalTriggerWord(int bxInEventValue) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< unsigned int > m_triggerMaskAlgoTrig
const cms_uint16_t finalOR(int bxInEventValue) const
~L1GlobalTriggerRecordProducer() override
destructor
char const * process
Definition: ProductLabels.h:7
const L1GtTriggerMask * m_l1GtTmAlgo
cached stuff
int iEvent
Definition: GenABIO.cc:224
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
std::vector< bool > DecisionWord
typedefs
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
unsigned short cms_uint16_t
Definition: typedefs.h:13
bool isValid() const
Definition: HandleBase.h:74
char const * module
Definition: ProductLabels.h:5
std::vector< unsigned int > m_triggerMaskTechTrig
#define LogTrace(id)
const DecisionWord & decisionWord(int bxInEventValue) const
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
char const * productInstance
Definition: ProductLabels.h:6
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
L1GlobalTriggerRecordProducer(const edm::ParameterSet &)
constructor(s)
def move(src, dest)
Definition: eostools.py:511