CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
9  produces<L1DataEmulResultBxCollection>();
10 
11  JetDataToken_ = consumes<JetBxCollection>(ps.getParameter<InputTag>("JetData"));
12  JetEmulToken_ = consumes<JetBxCollection>(ps.getParameter<InputTag>("JetEmul"));
13  EGammaDataToken_ = consumes<EGammaBxCollection>(ps.getParameter<InputTag>("EGammaData"));
14  EGammaEmulToken_ = consumes<EGammaBxCollection>(ps.getParameter<InputTag>("EGammaEmul"));
15  TauDataToken_ = consumes<TauBxCollection>(ps.getParameter<InputTag>("TauData"));
16  TauEmulToken_ = consumes<TauBxCollection>(ps.getParameter<InputTag>("TauEmul"));
17  EtSumDataToken_ = consumes<EtSumBxCollection>(ps.getParameter<InputTag>("EtSumData"));
18  EtSumEmulToken_ = consumes<EtSumBxCollection>(ps.getParameter<InputTag>("EtSumEmul"));
19  CaloTowerDataToken_ = consumes<CaloTowerBxCollection>(ps.getParameter<InputTag>("CaloTowerData"));
20  CaloTowerEmulToken_ = consumes<CaloTowerBxCollection>(ps.getParameter<InputTag>("CaloTowerEmul"));
21  bxMax_ = ps.getParameter<int>("bxMax");
22  bxMin_ = ps.getParameter<int>("bxMin");
23  doLayer2_ = ps.getParameter<bool>("doLayer2");
24  doLayer1_ = ps.getParameter<bool>("doLayer1");
25 }
26 
27 L1ComparatorRun2::~L1ComparatorRun2(){}
28 
29 void
30 L1ComparatorRun2::produce(Event& iEvent, const EventSetup& iSetup)
31 {
32  auto_ptr<L1DataEmulResultBxCollection> RESULT (new L1DataEmulResultBxCollection);
33 
34  if(doLayer2_){
35 
36  for(int bx = bxMin_; bx<=bxMax_; bx++){
37 
38  Handle<JetBxCollection> jet_data;
39  Handle<JetBxCollection> jet_emul;
40 
41  iEvent.getByToken(JetDataToken_,jet_data);
42  iEvent.getByToken(JetEmulToken_,jet_emul);
43 
44  int size = (jet_data->size(bx)>jet_emul->size(bx)) ? jet_data->size(bx) : jet_emul->size(bx);
45 
46  int dataonly = size-jet_emul->size(bx);
47  int emulonly = size-jet_data->size(bx);
48 
49  int ptgood = 0;
50  int locgood = 0;
51  int good = 0;
52  int compared = 0;
53 
54  for (JetBxCollection::const_iterator itd = jet_data->begin(bx); itd!=jet_data->end(bx); itd++){
55  for (JetBxCollection::const_iterator ite = jet_emul->begin(bx); ite!=jet_emul->end(bx); ite++){
56  if(distance(jet_data->begin(bx), itd)==distance(jet_emul->begin(bx), ite)){
57  compared+=1;
58  if (itd->hwPt() == ite->hwPt()) ptgood +=1;
59  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi()) locgood +=1;
60  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi()) good +=1;
61  }
62  }
63  }
64 
65  int ptbad = compared-ptgood;
66  int locbad = compared-locgood;
67  int bad = size-good;
68 
69  bool flag = (bad==0) ? true : false;
70 
71  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "JetBxCollection");
72 
73  RESULT->push_back(bx, result);
74  }
75  }
76 
79 
80  iEvent.getByToken(EGammaDataToken_,eg_data);
81  iEvent.getByToken(EGammaEmulToken_,eg_emul);
82 
83  if(doLayer2_){
84 
85  for(int bx = bxMin_; bx<=bxMax_; bx++){
86 
87  int size = (eg_data->size(bx)>eg_emul->size(bx)) ? eg_data->size(bx) : eg_emul->size(bx);
88 
89  int dataonly = size-eg_emul->size(bx);
90  int emulonly = size-eg_data->size(bx);
91 
92  int ptgood = 0;
93  int locgood = 0;
94  int good = 0;
95  int compared = 0;
96 
97  for (EGammaBxCollection::const_iterator itd = eg_data->begin(bx); itd!=eg_data->end(bx); itd++){
98  for (EGammaBxCollection::const_iterator ite = eg_emul->begin(bx); ite!=eg_emul->end(bx); ite++){
99  if(distance(eg_data->begin(bx), itd)==distance(eg_emul->begin(bx), ite)){
100  compared+=1;
101  if (itd->hwPt() == ite->hwPt()) ptgood +=1;
102  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi()) locgood +=1;
103  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() && itd->hwIso()==ite->hwIso()) 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 
128  for(int bx = bxMin_; bx<=bxMax_; bx++){
129 
130  int size = (tau_data->size(bx)>tau_emul->size(bx)) ? tau_data->size(bx) : tau_emul->size(bx);
131 
132  int dataonly = size-tau_emul->size(bx);
133  int emulonly = size-tau_data->size(bx);
134 
135  int ptgood = 0;
136  int locgood = 0;
137  int good = 0;
138  int compared = 0;
139 
140  for (TauBxCollection::const_iterator itd = tau_data->begin(bx); itd!=tau_data->end(bx); itd++){
141  for (TauBxCollection::const_iterator ite = tau_emul->begin(bx); ite!=tau_emul->end(bx); ite++){
142  if(distance(tau_data->begin(bx), itd)==distance(tau_emul->begin(bx), ite)){
143  compared+=1;
144  if (itd->hwPt() == ite->hwPt()) ptgood +=1;
145  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi()) locgood +=1;
146  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() && itd->hwIso()==ite->hwIso()) good +=1;
147  }
148  }
149  }
150 
151  int ptbad = compared-ptgood;
152  int locbad = compared-locgood;
153  int bad = size-good;
154 
155  bool flag = (bad==0) ? true : false;
156 
157  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "TauBxCollection");
158 
159  RESULT->push_back(bx, result);
160  }
161  }
162 
165 
166  iEvent.getByToken(EtSumDataToken_,et_data);
167  iEvent.getByToken(EtSumEmulToken_,et_emul);
168 
169  if(doLayer2_){
170 
171  for(int bx = bxMin_; bx<=bxMax_; bx++){
172 
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()) ptgood +=1;
188  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi()) locgood +=1;
189  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() && itd->getType()==ite->getType()) good +=1;
190  }
191  }
192  }
193 
194  int ptbad = compared-ptgood;
195  int locbad = compared-locgood;
196  int bad = size-good;
197 
198  bool flag = (bad==0) ? true : false;
199 
200  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "EtSumBxCollection");
201 
202  RESULT->push_back(bx, result);
203  }
204  }
205 
208 
209  iEvent.getByToken(CaloTowerDataToken_,tower_data);
210  iEvent.getByToken(CaloTowerEmulToken_,tower_emul);
211 
212  if(doLayer1_){
213 
214  for(int bx = bxMin_; bx<=bxMax_; bx++){
215 
216  int size = (tower_data->size(bx)>tower_emul->size(bx)) ? tower_data->size(bx) : tower_emul->size(bx);
217 
218  int dataonly = size-tower_emul->size(bx);
219  int emulonly = size-tower_data->size(bx);
220 
221  int ptgood = 0;
222  int locgood = 0;
223  int good = 0;
224  int compared = 0;
225  int hcalgood = 0;
226  int ecalgood = 0;
227 
228  for (CaloTowerBxCollection::const_iterator itd = tower_data->begin(bx); itd!=tower_data->end(bx); itd++){
229  for (CaloTowerBxCollection::const_iterator ite = tower_emul->begin(bx); ite!=tower_emul->end(bx); ite++){
230  if(distance(tower_data->begin(bx), itd)==distance(tower_emul->begin(bx), ite)){
231  compared+=1;
232  if (itd->hwPt() == ite->hwPt()) ptgood +=1;
233  if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi()) locgood +=1;
234  if (itd->hwEtHad() == ite->hwEtHad()) hcalgood +=1;
235  if (itd->hwEtEm() == ite->hwEtEm()) ecalgood +=1;
236  if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() && itd->hwEtEm()==ite->hwEtEm() && itd->hwEtHad()==ite->hwEtHad()) good +=1;
237  }
238  }
239  }
240 
241  int ptbad = compared-ptgood;
242  int locbad = compared-locgood;
243  int bad = size-good;
244  int hcalbad = compared-hcalgood;
245  int ecalbad = compared-ecalgood;
246 
247  bool flag = (bad==0) ? true : false;
248 
249  L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, hcalbad, ecalbad, "CaloTowerBxCollection");
250 
251  RESULT->push_back(bx, result);
252  }
253  }
254 
255  iEvent.put(RESULT);
256 }
257 
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
tuple result
Definition: mps_fire.py:95
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
tuple size
Write out results.
std::vector< Jet >::const_iterator const_iterator
Definition: BXVector.h:20