00001 #ifndef GlobalTriggerAnalyzer_L1GtUtils_h
00002 #define GlobalTriggerAnalyzer_L1GtUtils_h
00003
00020
00021 #include <string>
00022 #include <utility>
00023
00024
00025
00026 #include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/EventSetup.h"
00030 #include "FWCore/Framework/interface/Run.h"
00031
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 #include "FWCore/Utilities/interface/InputTag.h"
00034
00035 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
00036
00037
00038 class L1GtStableParameters;
00039 class L1GtPrescaleFactors;
00040 class L1GtTriggerMask;
00041 class L1GtTriggerMenu;
00042
00043 class L1GlobalTriggerReadoutRecord;
00044 class L1GlobalTriggerRecord;
00045
00046
00047
00048 class L1GtUtils {
00049
00050 public:
00051
00053 explicit L1GtUtils();
00054
00056 virtual ~L1GtUtils();
00057
00058 public:
00059
00060 enum TriggerCategory {
00061 AlgorithmTrigger = 0, TechnicalTrigger = 1
00062 };
00063
00079 class LogicalExpressionL1Results {
00080
00081 public:
00083
00086 explicit LogicalExpressionL1Results(const std::string&, L1GtUtils&);
00087
00090 explicit LogicalExpressionL1Results(const std::string&, L1GtUtils&,
00091 const edm::InputTag&, const edm::InputTag&);
00092
00094 ~LogicalExpressionL1Results();
00095
00096 public:
00097
00099 inline bool isValid() {
00100 return m_validLogicalExpression;
00101 }
00102
00105 const int logicalExpressionRunUpdate(const edm::Run&,
00106 const edm::EventSetup&, const std::string&);
00107
00109 const int logicalExpressionRunUpdate(const edm::Run&,
00110 const edm::EventSetup&);
00111
00113
00114 inline const std::vector<L1GtLogicParser::OperandToken>& expL1Triggers() {
00115 return m_expL1Triggers;
00116 }
00117 const std::vector<std::pair<std::string, bool> >& decisionsBeforeMask();
00118 const std::vector<std::pair<std::string, bool> >& decisionsAfterMask();
00119 const std::vector<std::pair<std::string, int> >& prescaleFactors();
00120 const std::vector<std::pair<std::string, int> >& triggerMasks();
00121
00122 const std::vector<std::pair<std::string, int> >& errorCodes(
00123 const edm::Event&);
00124
00125 private:
00126
00129 bool initialize();
00130
00132 void reset(const std::vector<std::pair<std::string, bool> >&) const;
00133 void reset(const std::vector<std::pair<std::string, int> >&) const;
00134
00135 void
00136 l1Results(const edm::Event& iEvent,
00137 const edm::InputTag& l1GtRecordInputTag,
00138 const edm::InputTag& l1GtReadoutRecordInputTag);
00139
00140 private:
00141
00143
00145 std::string m_logicalExpression;
00146
00147 L1GtUtils& m_l1GtUtils;
00148
00149 edm::InputTag m_l1GtRecordInputTag;
00150 edm::InputTag m_l1GtReadoutRecordInputTag;
00151
00152 private:
00153
00154
00155
00157 int m_l1ConfCode;
00158
00160 bool m_validL1Configuration;
00161
00163 bool m_validLogicalExpression;
00164
00167 bool m_l1GtInputTagsFromProv;
00168
00170 bool m_l1ResultsAlreadyCalled;
00171
00172 std::vector<L1GtLogicParser::OperandToken> m_expL1Triggers;
00173 size_t m_expL1TriggersSize;
00174
00176 std::vector<L1GtUtils::TriggerCategory> m_expTriggerCategory;
00177
00179 bool m_expBitsTechTrigger;
00180
00183 std::vector<bool> m_expTriggerInMenu;
00184
00186 std::vector<std::pair<std::string, bool> > m_decisionsBeforeMask;
00187 std::vector<std::pair<std::string, bool> > m_decisionsAfterMask;
00188 std::vector<std::pair<std::string, int> > m_prescaleFactors;
00189 std::vector<std::pair<std::string, int> > m_triggerMasks;
00190 std::vector<std::pair<std::string, int> > m_errorCodes;
00191
00192 };
00193
00194 public:
00195
00197
00198
00199 const std::string triggerCategory(const TriggerCategory&) const;
00200
00202 void retrieveL1EventSetup(const edm::EventSetup&);
00203
00205
00208 void retrieveL1GtTriggerMenuLite(const edm::Run&, const edm::InputTag&);
00209
00211
00214 void getL1GtRunCache(const edm::Run&, const edm::EventSetup&, const bool,
00215 const bool, const edm::InputTag&);
00217 void getL1GtRunCache(const edm::Run&, const edm::EventSetup&, const bool,
00218 const bool);
00219
00222 void getL1GtRunCache(const edm::Event&, const edm::EventSetup&, const bool,
00223 const bool, const edm::InputTag&);
00225 void getL1GtRunCache(const edm::Event&, const edm::EventSetup&, const bool,
00226 const bool);
00227
00231 void getL1GtRecordInputTag(const edm::Event& iEvent,
00232 edm::InputTag& l1GtRecordInputTag,
00233 edm::InputTag& l1GtReadoutRecordInputTag) const;
00234
00236 void getL1GtTriggerMenuLiteInputTag(const edm::Run& iRun,
00237 edm::InputTag& l1GtTriggerMenuLiteInputTag) const;
00238
00240 inline const edm::InputTag& provL1GtRecordInputTag() {
00241 return m_provL1GtRecordInputTag;
00242 }
00243
00244 inline const edm::InputTag& provL1GtReadoutRecordInputTag() {
00245 return m_provL1GtReadoutRecordInputTag;
00246 }
00247
00248 inline const edm::InputTag& provL1GtTriggerMenuLiteInputTag() {
00249 return m_provL1GtTriggerMenuLiteInputTag;
00250 }
00251
00260
00261 const bool l1AlgoTechTrigBitNumber(const std::string& nameAlgoTechTrig,
00262 TriggerCategory& trigCategory, int& bitNumber) const;
00263
00269
00270 const bool l1TriggerNameFromBit(const int& bitNumber,
00271 const TriggerCategory& trigCategory, std::string& aliasL1Trigger,
00272 std::string& nameL1Trigger) const;
00273
00286
00287 const int
00288 l1Results(const edm::Event& iEvent,
00289 const edm::InputTag& l1GtRecordInputTag,
00290 const edm::InputTag& l1GtReadoutRecordInputTag,
00291 const std::string& nameAlgoTechTrig,
00292 bool& decisionBeforeMask, bool& decisionAfterMask,
00293 int& prescaleFactor, int& triggerMask) const;
00294
00306
00307 const int
00308 l1Results(const edm::Event& iEvent,
00309 const std::string& nameAlgoTechTrig,
00310 bool& decisionBeforeMask, bool& decisionAfterMask,
00311 int& prescaleFactor, int& triggerMask) const;
00312
00327
00329 const bool decisionBeforeMask(const edm::Event& iEvent,
00330 const edm::InputTag& l1GtRecordInputTag,
00331 const edm::InputTag& l1GtReadoutRecordInputTag,
00332 const std::string& nameAlgoTechTrig, int& errorCode) const;
00333
00334 const bool decisionBeforeMask(const edm::Event& iEvent,
00335 const std::string& nameAlgoTechTrig, int& errorCode) const;
00336
00338 const bool decisionAfterMask(const edm::Event& iEvent,
00339 const edm::InputTag& l1GtRecordInputTag,
00340 const edm::InputTag& l1GtReadoutRecordInputTag,
00341 const std::string& nameAlgoTechTrig, int& errorCode) const;
00342
00343 const bool decisionAfterMask(const edm::Event& iEvent,
00344 const std::string& nameAlgoTechTrig, int& errorCode) const;
00345
00348 const bool decision(const edm::Event& iEvent,
00349 const edm::InputTag& l1GtRecordInputTag,
00350 const edm::InputTag& l1GtReadoutRecordInputTag,
00351 const std::string& nameAlgoTechTrig, int& errorCode) const;
00352
00353 const bool decision(const edm::Event& iEvent,
00354 const std::string& nameAlgoTechTrig, int& errorCode) const;
00355
00357 const int prescaleFactor(const edm::Event& iEvent,
00358 const edm::InputTag& l1GtRecordInputTag,
00359 const edm::InputTag& l1GtReadoutRecordInputTag,
00360 const std::string& nameAlgoTechTrig, int& errorCode) const;
00361
00362 const int prescaleFactor(const edm::Event& iEvent,
00363 const std::string& nameAlgoTechTrig, int& errorCode) const;
00364
00366 const int triggerMask(const edm::Event& iEvent,
00367 const edm::InputTag& l1GtRecordInputTag,
00368 const edm::InputTag& l1GtReadoutRecordInputTag,
00369 const std::string& nameAlgoTechTrig, int& errorCode) const;
00370
00371 const int triggerMask(const edm::Event& iEvent,
00372 const std::string& nameAlgoTechTrig, int& errorCode) const;
00373
00376 const int
00377 triggerMask(const std::string& nameAlgoTechTrig, int& errorCode) const;
00378
00383
00384 const int prescaleFactorSetIndex(const edm::Event& iEvent,
00385 const edm::InputTag& l1GtRecordInputTag,
00386 const edm::InputTag& l1GtReadoutRecordInputTag,
00387 const TriggerCategory& trigCategory, int& errorCode) const;
00388
00389 const int prescaleFactorSetIndex(const edm::Event& iEvent,
00390 const TriggerCategory& trigCategory, int& errorCode) const;
00391
00392
00396
00397 const std::vector<int>& prescaleFactorSet(const edm::Event& iEvent,
00398 const edm::InputTag& l1GtRecordInputTag,
00399 const edm::InputTag& l1GtReadoutRecordInputTag,
00400 const TriggerCategory& trigCategory, int& errorCode);
00401
00402 const std::vector<int>& prescaleFactorSet(const edm::Event& iEvent,
00403 const TriggerCategory& trigCategory, int& errorCode);
00404
00405
00408 const std::vector<unsigned int>& triggerMaskSet(
00409 const TriggerCategory& trigCategory, int& errorCode);
00410
00411
00413 const std::string& l1TriggerMenu() const;
00414
00416 const std::string& l1TriggerMenuImplementation() const;
00417
00419 const L1GtTriggerMenu* ptrL1TriggerMenuEventSetup(int& errorCode);
00420
00422 const L1GtTriggerMenuLite* ptrL1GtTriggerMenuLite(int& errorCode);
00423
00426 const bool availableL1Configuration(int& errorCode, int& l1ConfCode) const;
00427
00428 private:
00429
00430 static const std::string EmptyString;
00431 static const int L1GtNotValidError;
00432
00436 const bool trigResult(const DecisionWord& decWord, const int bitNumber,
00437 const std::string& nameAlgoTechTrig,
00438 const TriggerCategory& trigCategory, int& errorCode) const;
00439
00440 private:
00441
00443
00445 const L1GtStableParameters* m_l1GtStablePar;
00446 unsigned long long m_l1GtStableParCacheID;
00447
00449 unsigned int m_numberAlgorithmTriggers;
00450
00452 unsigned int m_numberTechnicalTriggers;
00453
00455 const L1GtPrescaleFactors* m_l1GtPfAlgo;
00456 unsigned long long m_l1GtPfAlgoCacheID;
00457
00458 const L1GtPrescaleFactors* m_l1GtPfTech;
00459 unsigned long long m_l1GtPfTechCacheID;
00460
00461 const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
00462 const std::vector<std::vector<int> >* m_prescaleFactorsTechTrig;
00463
00465 const L1GtTriggerMask* m_l1GtTmAlgo;
00466 unsigned long long m_l1GtTmAlgoCacheID;
00467
00468 const L1GtTriggerMask* m_l1GtTmTech;
00469 unsigned long long m_l1GtTmTechCacheID;
00470
00471 const L1GtTriggerMask* m_l1GtTmVetoAlgo;
00472 unsigned long long m_l1GtTmVetoAlgoCacheID;
00473
00474 const L1GtTriggerMask* m_l1GtTmVetoTech;
00475 unsigned long long m_l1GtTmVetoTechCacheID;
00476
00477 const std::vector<unsigned int>* m_triggerMaskAlgoTrig;
00478 const std::vector<unsigned int>* m_triggerMaskTechTrig;
00479
00480 const std::vector<unsigned int>* m_triggerMaskVetoAlgoTrig;
00481 const std::vector<unsigned int>* m_triggerMaskVetoTechTrig;
00482
00483
00484 const L1GtTriggerMenu* m_l1GtMenu;
00485 unsigned long long m_l1GtMenuCacheID;
00486
00487 const AlgorithmMap* m_algorithmMap;
00488 const AlgorithmMap* m_algorithmAliasMap;
00489 const AlgorithmMap* m_technicalTriggerMap;
00490
00491 bool m_l1EventSetupValid;
00492
00494
00495
00497 const L1GtTriggerMenuLite* m_l1GtMenuLite;
00498
00499 const L1GtTriggerMenuLite::L1TriggerMap* m_algorithmMapLite;
00500 const L1GtTriggerMenuLite::L1TriggerMap* m_algorithmAliasMapLite;
00501 const L1GtTriggerMenuLite::L1TriggerMap* m_technicalTriggerMapLite;
00502
00503 const std::vector<unsigned int>* m_triggerMaskAlgoTrigLite;
00504 const std::vector<unsigned int>* m_triggerMaskTechTrigLite;
00505
00506 const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrigLite;
00507 const std::vector<std::vector<int> >* m_prescaleFactorsTechTrigLite;
00508
00509 bool m_l1GtMenuLiteValid;
00510
00512 bool m_beginRunCache;
00513
00515
00516 mutable edm::InputTag m_provL1GtRecordInputTag;
00517 mutable edm::InputTag m_provL1GtReadoutRecordInputTag;
00518 mutable edm::InputTag m_provL1GtTriggerMenuLiteInputTag;
00519
00521 edm::RunID m_runIDCache;
00522 edm::RunID m_provRunIDCache;
00523
00524
00525 private:
00526
00528 unsigned int m_physicsDaqPartition;
00529
00530 std::vector<unsigned int> m_triggerMaskSet;
00531 std::vector<int> m_prescaleFactorSet;
00532
00534 bool m_retrieveL1EventSetup;
00535 bool m_retrieveL1GtTriggerMenuLite;
00536
00537 };
00538
00539 #endif