CMS 3D CMS Logo

L1TExtCondProducer.cc
Go to the documentation of this file.
1 
10 
11 // system include files
12 #include <boost/shared_ptr.hpp>
13 
14 // user include files
15 
26 
30 
33 
34 //#include <vector>
36 
38 
39 using namespace std;
40 using namespace edm;
41 using namespace l1t;
42 
43  //
44  // class declaration
45  //
46 
48  public:
49  explicit L1TExtCondProducer(const ParameterSet&);
50  ~L1TExtCondProducer() override;
51 
52  static void fillDescriptions(ConfigurationDescriptions& descriptions);
53 
54  private:
55  void produce(edm::Event&, const edm::EventSetup&) override;
56 
57  // ----------member data ---------------------------
58  // unsigned long long m_paramsCacheId; // Cache-ID from current parameters, to check if needs to be updated.
59  //boost::shared_ptr<const CaloParams> m_dbpars; // Database parameters for the trigger, to be updated as needed.
60  //boost::shared_ptr<const FirmwareVersion> m_fwv;
61  //boost::shared_ptr<FirmwareVersion> m_fwv; //not const during testing.
62 
63  // BX parameters
64  int bxFirst_;
65  int bxLast_;
66 
70  bool setBptxOR_;
71 
72  unsigned long long m_l1GtMenuCacheID;
73  std::map<std::string, unsigned int> m_extBitMap;
74  };
75 
76  //
77  // constructors and destructor
78  //
80  bxFirst_ (iConfig.getParameter<int>("bxFirst")),
81  bxLast_ (iConfig.getParameter<int>("bxLast")),
82  setBptxAND_ (iConfig.getParameter<bool>("setBptxAND")),
83  setBptxPlus_ (iConfig.getParameter<bool>("setBptxPlus")),
84  setBptxMinus_ (iConfig.getParameter<bool>("setBptxMinus")),
85  setBptxOR_ (iConfig.getParameter<bool>("setBptxOR"))
86  {
87  // register what you produce
88  produces<GlobalExtBlkBxCollection>();
89 
90  // Initialize parameters
91  m_l1GtMenuCacheID = 0ULL;
92  }
93 
94 
96  {
97  }
98 
99 
100 
101  //
102  // member functions
103  //
104 
105  // ------------ method called to produce the data ------------
106  void
108  {
109 
110  LogDebug("L1TExtCondProducer") << "L1TExtCondProducer::produce function called...\n";
111 
112  // get / update the trigger menu from the EventSetup
113  // local cache & check on cacheIdentifier
114  unsigned long long l1GtMenuCacheID = iSetup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
115 
116  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
117 
119  iSetup.get< L1TUtmTriggerMenuRcd>().get(l1GtMenu) ;
120  const L1TUtmTriggerMenu* utml1GtMenu = l1GtMenu.product();
121 
122  // Instantiate Parser
124 
125  std::map<std::string, unsigned int> extBitMap = gtParser.getExternalSignals(utml1GtMenu);
126 
127  m_l1GtMenuCacheID = l1GtMenuCacheID;
128  m_extBitMap = extBitMap;
129  }
130 
131  // Setup vectors
132  GlobalExtBlk extCond_bx;
133 
134  //outputs
135  std::unique_ptr<GlobalExtBlkBxCollection> extCond( new GlobalExtBlkBxCollection(0,bxFirst_,bxLast_));
136 
137  bool foundBptxAND = ( m_extBitMap.find("BPTX_plus_AND_minus.v0")!=m_extBitMap.end() );
138  bool foundBptxPlus = ( m_extBitMap.find("BPTX_plus.v0")!=m_extBitMap.end() );
139  bool foundBptxMinus = ( m_extBitMap.find("BPTX_minus.v0")!=m_extBitMap.end() );
140  bool foundBptxOR = ( m_extBitMap.find("BPTX_plus_OR_minus.v0")!=m_extBitMap.end() );
141 
142  // Fill in some external conditions for testing
143  if( setBptxAND_ && foundBptxAND ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_plus_AND_minus.v0"],true);
144  if( setBptxPlus_ && foundBptxPlus ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_plus.v0"],true);
145  if( setBptxMinus_ && foundBptxMinus ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_minus.v0"],true);
146  if( setBptxOR_ && foundBptxOR ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_plus_OR_minus.v0"],true);
147 
148  //check for updated Bptx names as well
149  foundBptxAND = ( m_extBitMap.find("ZeroBias_BPTX_AND_VME")!=m_extBitMap.end() );
150  foundBptxPlus = ( m_extBitMap.find("BPTX_B1_VME")!=m_extBitMap.end() );
151  foundBptxMinus = ( m_extBitMap.find("BPTX_B2_VME")!=m_extBitMap.end() );
152  foundBptxOR = ( m_extBitMap.find("BPTX_OR_VME")!=m_extBitMap.end() );
153 
154  // Fill in some external conditions for testing
155  if( setBptxAND_ && foundBptxAND ) extCond_bx.setExternalDecision(m_extBitMap["ZeroBias_BPTX_AND_VME"],true);
156  if( setBptxPlus_ && foundBptxPlus ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_B1_VME"],true);
157  if( setBptxMinus_ && foundBptxMinus ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_B2_VME"],true);
158  if( setBptxOR_ && foundBptxOR ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_OR_VME"],true);
159 
160  // Fill Externals
161  for( int iBx=bxFirst_; iBx<=bxLast_; iBx++ ){
162  extCond->push_back(iBx, extCond_bx);
163  }
164 
165 
166  iEvent.put(std::move(extCond));
167 
168  }
169 
170  // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
171  void
173  // simGtExtFakeProd
175  desc.add<bool>("setBptxMinus", true);
176  desc.add<bool>("setBptxAND", true);
177  desc.add<int>("bxFirst", -2);
178  desc.add<bool>("setBptxOR", true);
179  desc.add<int>("bxLast", 2);
180  desc.add<bool>("setBptxPlus", true);
181  descriptions.add("simGtExtFakeProd", desc);
182  }
183 
184 
185 
186 //define this as a plug-in
#define LogDebug(id)
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
Definition: GlobalExtBlk.h:30
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
~L1TExtCondProducer() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
delete x;
Definition: CaloConfig.h:22
std::map< std::string, unsigned int > getExternalSignals(const L1TUtmTriggerMenu *utmMenu)
int iEvent
Definition: GenABIO.cc:230
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
L1TExtCondProducer(const ParameterSet &)
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
Definition: GlobalExtBlk.cc:52
unsigned long long m_l1GtMenuCacheID
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
T get() const
Definition: EventSetup.h:68
std::map< std::string, unsigned int > m_extBitMap
T const * product() const
Definition: ESHandle.h:84
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511