test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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&);
51 
52  static void fillDescriptions(ConfigurationDescriptions& descriptions);
53 
54  private:
55  virtual 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
123  TriggerMenuParser gtParser = TriggerMenuParser();
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::auto_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  // Fill Externals
149  for( int iBx=bxFirst_; iBx<=bxLast_; iBx++ ){
150  extCond->push_back(iBx, extCond_bx);
151  }
152 
153 
154  iEvent.put(extCond);
155 
156  }
157 
158  // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
159  void
161  // simGtExtFakeProd
163  desc.add<bool>("setBptxMinus", true);
164  desc.add<bool>("setBptxAND", true);
165  desc.add<int>("bxFirst", -2);
166  desc.add<bool>("setBptxOR", true);
167  desc.add<int>("bxLast", 2);
168  desc.add<bool>("setBptxPlus", true);
169  descriptions.add("simGtExtFakeProd", desc);
170  }
171 
172 
173 
174 //define this as a plug-in
#define LogDebug(id)
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
Definition: GlobalExtBlk.h:30
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::map< std::string, unsigned int > getExternalSignals(const L1TUtmTriggerMenu *utmMenu)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::map< std::string, unsigned int > m_extBitMap
virtual void produce(edm::Event &, const edm::EventSetup &) override