CMS 3D CMS Logo

L1RCTInputProducer.cc
Go to the documentation of this file.
2 
5 
10 
13 
16 
19 
22 
23 #include <vector>
24 using std::vector;
25 
26 #include <iostream>
27 using std::cout;
28 using std::endl;
29 
31  : rctLookupTables(new L1RCTLookupTables), rct(new L1RCT(rctLookupTables)),
32  useEcal(conf.getParameter<bool>("useEcal")),
33  useHcal(conf.getParameter<bool>("useHcal")),
34  ecalDigisLabel(conf.getParameter<edm::InputTag>("ecalDigisLabel")),
35  hcalDigisLabel(conf.getParameter<edm::InputTag>("hcalDigisLabel")) {
36  produces<std::vector<unsigned short>>("rctCrate");
37  produces<std::vector<unsigned short>>("rctCard");
38  produces<std::vector<unsigned short>>("rctTower");
39  produces<std::vector<unsigned int>>("rctEGammaET");
40  produces<std::vector<bool>>("rctHoEFGVetoBit");
41  produces<std::vector<unsigned int>>("rctJetMETET");
42  produces<std::vector<bool>>("rctTowerActivityBit");
43  produces<std::vector<bool>>("rctTowerMIPBit");
44  produces<std::vector<unsigned short>>("rctHFCrate");
45  produces<std::vector<unsigned short>>("rctHFRegion");
46  produces<std::vector<unsigned int>>("rctHFET");
47  produces<std::vector<bool>>("rctHFFG");
48 }
49 
51  if (rct != nullptr)
52  delete rct;
53  if (rctLookupTables != nullptr)
54  delete rctLookupTables;
55 }
56 
58  const edm::EventSetup &eventSetup) {
59 
60  // Refresh configuration information every event
61  // Hopefully, this does not take too much time
62  // There should be a call back function in future to
63  // handle changes in configuration
64 
65  edm::ESHandle<L1RCTParameters> rctParameters;
66  eventSetup.get<L1RCTParametersRcd>().get(rctParameters);
67  const L1RCTParameters *r = rctParameters.product();
69  eventSetup.get<L1RCTChannelMaskRcd>().get(channelMask);
70  const L1RCTChannelMask *c = channelMask.product();
72  eventSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
73  const L1CaloEcalScale *e = ecalScale.product();
75  eventSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
76  const L1CaloHcalScale *h = hcalScale.product();
78  eventSetup.get<L1EmEtScaleRcd>().get(emScale);
79  const L1CaloEtScale *s = emScale.product();
80 
86 
89 
90  if (useEcal) {
91  event.getByLabel(ecalDigisLabel, ecal);
92  }
93  if (useHcal) {
94  event.getByLabel(hcalDigisLabel, hcal);
95  }
96 
99  if (ecal.isValid()) {
100  ecalColl = *ecal;
101  }
102  if (hcal.isValid()) {
103  hcalColl = *hcal;
104  }
105 
106  rct->digiInput(ecalColl, hcalColl);
107 
108  // Stuff to create
109 
110  std::unique_ptr<std::vector<unsigned short>> rctCrate(
111  new std::vector<unsigned short>);
112  std::unique_ptr<std::vector<unsigned short>> rctCard(
113  new std::vector<unsigned short>);
114  std::unique_ptr<std::vector<unsigned short>> rctTower(
115  new std::vector<unsigned short>);
116  std::unique_ptr<std::vector<unsigned int>> rctEGammaET(
117  new std::vector<unsigned int>);
118  std::unique_ptr<std::vector<bool>> rctHoEFGVetoBit(new std::vector<bool>);
119  std::unique_ptr<std::vector<unsigned int>> rctJetMETET(
120  new std::vector<unsigned int>);
121  std::unique_ptr<std::vector<bool>> rctTowerActivityBit(new std::vector<bool>);
122  std::unique_ptr<std::vector<bool>> rctTowerMIPBit(new std::vector<bool>);
123 
124  for (int crate = 0; crate < 18; crate++) {
125  for (int card = 0; card < 7; card++) {
126  for (int tower = 0; tower < 32; tower++) {
127  unsigned short ecalCompressedET =
128  rct->ecalCompressedET(crate, card, tower);
129  unsigned short ecalFineGrainBit =
130  rct->ecalFineGrainBit(crate, card, tower);
131  unsigned short hcalCompressedET =
132  rct->hcalCompressedET(crate, card, tower);
133  unsigned int lutBits =
134  rctLookupTables->lookup(ecalCompressedET, hcalCompressedET,
135  ecalFineGrainBit, crate, card, tower);
136  unsigned int eGammaETCode = lutBits & 0x0000007F;
137  bool hOeFGVetoBit = (lutBits >> 7) & 0x00000001;
138  unsigned int jetMETETCode = (lutBits >> 8) & 0x000001FF;
139  bool activityBit = (lutBits >> 17) & 0x00000001;
140  if (eGammaETCode > 0 || jetMETETCode > 0 || hOeFGVetoBit ||
141  activityBit) {
142  rctCrate->push_back(crate);
143  rctCard->push_back(card);
144  rctTower->push_back(tower);
145  rctEGammaET->push_back(eGammaETCode);
146  rctHoEFGVetoBit->push_back(hOeFGVetoBit);
147  rctJetMETET->push_back(jetMETETCode);
148  rctTowerActivityBit->push_back(activityBit);
149  rctTowerMIPBit->push_back(false); // FIXME: MIP bit is not yet defined
150  }
151  }
152  }
153  }
154 
155  std::unique_ptr<std::vector<unsigned short>> rctHFCrate(
156  new std::vector<unsigned short>);
157  std::unique_ptr<std::vector<unsigned short>> rctHFRegion(
158  new std::vector<unsigned short>);
159  std::unique_ptr<std::vector<unsigned int>> rctHFET(
160  new std::vector<unsigned int>);
161  std::unique_ptr<std::vector<bool>> rctHFFG(new std::vector<bool>);
162  for (int crate = 0; crate < 18; crate++) {
163  for (int hfRegion = 0; hfRegion < 8; hfRegion++) {
164  unsigned short hfCompressedET = rct->hfCompressedET(crate, hfRegion);
165  unsigned int hfETCode =
166  rctLookupTables->lookup(hfCompressedET, crate, 999, hfRegion);
167  if (hfETCode > 0) {
168  rctHFCrate->push_back(crate);
169  rctHFRegion->push_back(hfRegion);
170  rctHFET->push_back(hfETCode);
171  rctHFFG->push_back(false); // FIXME: HF FG is not yet defined
172  }
173  }
174  }
175 
176  // putting stuff back into event
177  event.put(std::move(rctCrate), "rctCrate");
178  event.put(std::move(rctCard), "rctCard");
179  event.put(std::move(rctTower), "rctTower");
180  event.put(std::move(rctEGammaET), "rctEGammaET");
181  event.put(std::move(rctHoEFGVetoBit), "rctHoEFGVetoBit");
182  event.put(std::move(rctJetMETET), "rctJetMETET");
183  event.put(std::move(rctTowerActivityBit), "rctTowerActivityBit");
184  event.put(std::move(rctTowerMIPBit), "rctTowerMIPBit");
185  event.put(std::move(rctHFCrate), "rctHFCrate");
186  event.put(std::move(rctHFRegion), "rctHFRegion");
187  event.put(std::move(rctHFET), "rctHFET");
188  event.put(std::move(rctHFFG), "rctHFFG");
189 }
void produce(edm::Event &e, const edm::EventSetup &c) override
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
unsigned short hcalCompressedET(int crate, int card, int tower)
Definition: L1RCT.h:74
unsigned short hfCompressedET(int crate, int tower)
Definition: L1RCT.h:80
edm::InputTag ecalDigisLabel
L1RCTInputProducer(const edm::ParameterSet &ps)
void setHcalScale(const L1CaloHcalScale *hcalScale)
~L1RCTInputProducer() override
unsigned short ecalFineGrainBit(int crate, int card, int tower)
Definition: L1RCT.h:71
unsigned short ecalCompressedET(int crate, int card, int tower)
Definition: L1RCT.h:68
bool isValid() const
Definition: HandleBase.h:74
void setL1CaloEtScale(const L1CaloEtScale *etScale)
edm::InputTag hcalDigisLabel
void setEcalScale(const L1CaloEcalScale *ecalScale)
void setRCTParameters(const L1RCTParameters *rctParameters)
HLT enums.
void digiInput(const EcalTrigPrimDigiCollection &ecalCollection, const HcalTrigPrimDigiCollection &hcalCollection)
Definition: L1RCT.cc:109
T get() const
Definition: EventSetup.h:71
L1RCTLookupTables * rctLookupTables
Definition: L1RCT.h:20
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
void setChannelMask(const L1RCTChannelMask *channelMask)
Definition: event.py:1
unsigned int lookup(unsigned short ecalInput, unsigned short hcalInput, unsigned short fgbit, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const