CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1ComparatorRun2.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace edm;
5 using namespace l1t;
6 
7 L1ComparatorRun2::L1ComparatorRun2(const ParameterSet& ps) {
8  produces<L1DataEmulResultBxCollection>();
9 
10  JetDataToken_ = consumes<JetBxCollection>(ps.getParameter<InputTag>("JetData"));
11  JetEmulToken_ = consumes<JetBxCollection>(ps.getParameter<InputTag>("JetEmul"));
12  EGammaDataToken_ = consumes<EGammaBxCollection>(ps.getParameter<InputTag>("EGammaData"));
13  EGammaEmulToken_ = consumes<EGammaBxCollection>(ps.getParameter<InputTag>("EGammaEmul"));
14  TauDataToken_ = consumes<TauBxCollection>(ps.getParameter<InputTag>("TauData"));
15  TauEmulToken_ = consumes<TauBxCollection>(ps.getParameter<InputTag>("TauEmul"));
16  EtSumDataToken_ = consumes<EtSumBxCollection>(ps.getParameter<InputTag>("EtSumData"));
17  EtSumEmulToken_ = consumes<EtSumBxCollection>(ps.getParameter<InputTag>("EtSumEmul"));
18  CaloTowerDataToken_ = consumes<CaloTowerBxCollection>(ps.getParameter<InputTag>("CaloTowerData"));
19  CaloTowerEmulToken_ = consumes<CaloTowerBxCollection>(ps.getParameter<InputTag>("CaloTowerEmul"));
20  bxMax_ = ps.getParameter<int>("bxMax");
21  bxMin_ = ps.getParameter<int>("bxMin");
22  doLayer2_ = ps.getParameter<bool>("doLayer2");
23  doLayer1_ = ps.getParameter<bool>("doLayer1");
24 }
25 
26 L1ComparatorRun2::~L1ComparatorRun2() {}
27 
28 void L1ComparatorRun2::produce(Event& iEvent, const EventSetup& iSetup) {
29  unique_ptr<L1DataEmulResultBxCollection> RESULT(new L1DataEmulResultBxCollection);
30 
31  if (doLayer2_) {
32  for (int bx = bxMin_; bx <= bxMax_; bx++) {
33  Handle<JetBxCollection> jet_data;
34  Handle<JetBxCollection> jet_emul;
35 
36  iEvent.getByToken(JetDataToken_, jet_data);
37  iEvent.getByToken(JetEmulToken_, jet_emul);
38 
39  int size = (jet_data->size(bx) > jet_emul->size(bx)) ? jet_data->size(bx) : jet_emul->size(bx);
40 
41  int dataonly = size - jet_emul->size(bx);
42  int emulonly = size - jet_data->size(bx);
43 
44  int ptgood = 0;
45  int locgood = 0;
46  int good = 0;
47  int compared = 0;
48 
49  for (JetBxCollection::const_iterator itd = jet_data->begin(bx); itd != jet_data->end(bx); itd++) {
50  for (JetBxCollection::const_iterator ite = jet_emul->begin(bx); ite != jet_emul->end(bx); ite++) {
51  if (distance(jet_data->begin(bx), itd) == distance(jet_emul->begin(bx), ite)) {
52  compared += 1;
53  if (itd->hwPt() == ite->hwPt())
54  ptgood += 1;
55  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
56  locgood += 1;
57  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
58  good += 1;
59  }
60  }
61  }
62 
63  int ptbad = compared - ptgood;
64  int locbad = compared - locgood;
65  int bad = size - good;
66 
67  bool flag = (bad == 0) ? true : false;
68 
69  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "JetBxCollection");
70 
71  RESULT->push_back(bx, result);
72  }
73  }
74 
77 
78  iEvent.getByToken(EGammaDataToken_, eg_data);
79  iEvent.getByToken(EGammaEmulToken_, eg_emul);
80 
81  if (doLayer2_) {
82  for (int bx = bxMin_; bx <= bxMax_; bx++) {
83  int size = (eg_data->size(bx) > eg_emul->size(bx)) ? eg_data->size(bx) : eg_emul->size(bx);
84 
85  int dataonly = size - eg_emul->size(bx);
86  int emulonly = size - eg_data->size(bx);
87 
88  int ptgood = 0;
89  int locgood = 0;
90  int good = 0;
91  int compared = 0;
92 
93  for (EGammaBxCollection::const_iterator itd = eg_data->begin(bx); itd != eg_data->end(bx); itd++) {
94  for (EGammaBxCollection::const_iterator ite = eg_emul->begin(bx); ite != eg_emul->end(bx); ite++) {
95  if (distance(eg_data->begin(bx), itd) == distance(eg_emul->begin(bx), ite)) {
96  compared += 1;
97  if (itd->hwPt() == ite->hwPt())
98  ptgood += 1;
99  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
100  locgood += 1;
101  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
102  itd->hwIso() == ite->hwIso())
103  good += 1;
104  }
105  }
106  }
107 
108  int ptbad = compared - ptgood;
109  int locbad = compared - locgood;
110  int bad = size - good;
111 
112  bool flag = (bad == 0) ? true : false;
113 
114  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "EGammaBxCollection");
115 
116  RESULT->push_back(bx, result);
117  }
118  }
119 
120  Handle<TauBxCollection> tau_data;
121  Handle<TauBxCollection> tau_emul;
122 
123  iEvent.getByToken(TauDataToken_, tau_data);
124  iEvent.getByToken(TauEmulToken_, tau_emul);
125 
126  if (doLayer2_) {
127  for (int bx = bxMin_; bx <= bxMax_; bx++) {
128  int size = (tau_data->size(bx) > tau_emul->size(bx)) ? tau_data->size(bx) : tau_emul->size(bx);
129 
130  int dataonly = size - tau_emul->size(bx);
131  int emulonly = size - tau_data->size(bx);
132 
133  int ptgood = 0;
134  int locgood = 0;
135  int good = 0;
136  int compared = 0;
137 
138  for (TauBxCollection::const_iterator itd = tau_data->begin(bx); itd != tau_data->end(bx); itd++) {
139  for (TauBxCollection::const_iterator ite = tau_emul->begin(bx); ite != tau_emul->end(bx); ite++) {
140  if (distance(tau_data->begin(bx), itd) == distance(tau_emul->begin(bx), ite)) {
141  compared += 1;
142  if (itd->hwPt() == ite->hwPt())
143  ptgood += 1;
144  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
145  locgood += 1;
146  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
147  itd->hwIso() == ite->hwIso())
148  good += 1;
149  }
150  }
151  }
152 
153  int ptbad = compared - ptgood;
154  int locbad = compared - locgood;
155  int bad = size - good;
156 
157  bool flag = (bad == 0) ? true : false;
158 
159  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "TauBxCollection");
160 
161  RESULT->push_back(bx, result);
162  }
163  }
164 
167 
168  iEvent.getByToken(EtSumDataToken_, et_data);
169  iEvent.getByToken(EtSumEmulToken_, et_emul);
170 
171  if (doLayer2_) {
172  for (int bx = bxMin_; bx <= bxMax_; bx++) {
173  int size = (et_data->size(bx) > et_emul->size(bx)) ? et_data->size(bx) : et_emul->size(bx);
174 
175  int dataonly = size - et_emul->size(bx);
176  int emulonly = size - et_data->size(bx);
177 
178  int ptgood = 0;
179  int locgood = 0;
180  int good = 0;
181  int compared = 0;
182 
183  for (EtSumBxCollection::const_iterator itd = et_data->begin(bx); itd != et_data->end(bx); itd++) {
184  for (EtSumBxCollection::const_iterator ite = et_emul->begin(bx); ite != et_emul->end(bx); ite++) {
185  if (distance(et_data->begin(bx), itd) == distance(et_emul->begin(bx), ite)) {
186  compared += 1;
187  if (itd->hwPt() == ite->hwPt())
188  ptgood += 1;
189  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
190  locgood += 1;
191  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
192  itd->getType() == ite->getType())
193  good += 1;
194  }
195  }
196  }
197 
198  int ptbad = compared - ptgood;
199  int locbad = compared - locgood;
200  int bad = size - good;
201 
202  bool flag = (bad == 0) ? true : false;
203 
204  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "EtSumBxCollection");
205 
206  RESULT->push_back(bx, result);
207  }
208  }
209 
212 
213  iEvent.getByToken(CaloTowerDataToken_, tower_data);
214  iEvent.getByToken(CaloTowerEmulToken_, tower_emul);
215 
216  if (doLayer1_) {
217  for (int bx = bxMin_; bx <= bxMax_; bx++) {
218  int size = (tower_data->size(bx) > tower_emul->size(bx)) ? tower_data->size(bx) : tower_emul->size(bx);
219 
220  int dataonly = size - tower_emul->size(bx);
221  int emulonly = size - tower_data->size(bx);
222 
223  int ptgood = 0;
224  int locgood = 0;
225  int good = 0;
226  int compared = 0;
227  int hcalgood = 0;
228  int ecalgood = 0;
229 
230  for (CaloTowerBxCollection::const_iterator itd = tower_data->begin(bx); itd != tower_data->end(bx); itd++) {
231  for (CaloTowerBxCollection::const_iterator ite = tower_emul->begin(bx); ite != tower_emul->end(bx); ite++) {
232  if (distance(tower_data->begin(bx), itd) == distance(tower_emul->begin(bx), ite)) {
233  compared += 1;
234  if (itd->hwPt() == ite->hwPt())
235  ptgood += 1;
236  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
237  locgood += 1;
238  if (itd->hwEtHad() == ite->hwEtHad())
239  hcalgood += 1;
240  if (itd->hwEtEm() == ite->hwEtEm())
241  ecalgood += 1;
242  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
243  itd->hwEtEm() == ite->hwEtEm() && itd->hwEtHad() == ite->hwEtHad())
244  good += 1;
245  }
246  }
247  }
248 
249  int ptbad = compared - ptgood;
250  int locbad = compared - locgood;
251  int bad = size - good;
252  int hcalbad = compared - hcalgood;
253  int ecalbad = compared - ecalgood;
254 
255  bool flag = (bad == 0) ? true : false;
256 
257  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, hcalbad, ecalbad, "CaloTowerBxCollection");
258 
259  RESULT->push_back(bx, result);
260  }
261  }
262 
263  iEvent.put(std::move(RESULT));
264 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
tuple result
Definition: mps_fire.py:311
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
auto const good
min quality of good
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
tuple size
Write out results.