CMS 3D CMS Logo

L1GctValidation.cc
Go to the documentation of this file.
2 
6 
9 
12 
16 
18 
20 
21 #include <cmath>
22 
24  : m_gctinp_tag(iConfig.getUntrackedParameter<edm::InputTag>("rctInputTag", edm::InputTag("rctDigis"))),
25  m_energy_tag(iConfig.getUntrackedParameter<edm::InputTag>("gctInputTag", edm::InputTag("gctDigis"))) {}
26 
28  // do anything here that needs to be done at desctruction time
29  // (e.g. close files, deallocate resources etc.)
30 }
31 
32 //
33 // member functions
34 //
35 
36 // ------------ method called to for each event ------------
38  using namespace edm;
39 
40  // Get the scales from the event setup
42  iSetup.get<L1GctJetFinderParamsRcd>().get(jfPars); // which record?
43 
44  double lsbForEt = jfPars.product()->getRgnEtLsbGeV();
45  double lsbForHt = jfPars.product()->getHtLsbGeV();
46 
47  unsigned httJetThreshold = static_cast<int>(jfPars.product()->getHtJetEtThresholdGeV() / lsbForHt);
48  unsigned htmJetThreshold = static_cast<int>(jfPars.product()->getMHtJetEtThresholdGeV() / lsbForHt);
49 
50  ESHandle<L1CaloEtScale> htMissScale;
51  iSetup.get<L1HtMissScaleRcd>().get(htMissScale); // which record?
52  ESHandle<L1CaloEtScale> hfRingEtScale;
53  iSetup.get<L1HfRingEtScaleRcd>().get(hfRingEtScale); // which record?
54 
55  // Get the Gct energy sums from the event
57  iEvent.getByLabel(m_energy_tag, sumEtColl);
59  iEvent.getByLabel(m_energy_tag, sumHtColl);
61  iEvent.getByLabel(m_energy_tag, missEtColl);
63  iEvent.getByLabel(m_energy_tag, missHtColl);
64 
65  // Get the input calo regions from the event (for checking MEt)
67  iEvent.getByLabel(m_gctinp_tag, inputColl);
68 
69  // Get the internal jet data from the event (for checking Ht)
70  Handle<L1GctInternJetDataCollection> internalJetsColl;
71  iEvent.getByLabel(m_energy_tag, internalJetsColl);
72 
73  double etTot = 0.0;
74  for (L1GctEtTotalCollection::const_iterator jbx = sumEtColl->begin(); jbx != sumEtColl->end(); jbx++) {
75  if (jbx->bx() == 0) {
76  etTot = static_cast<double>(jbx->et());
77  }
78  }
79 
80  double etHad = 0.0;
81  for (L1GctEtHadCollection::const_iterator jbx = sumHtColl->begin(); jbx != sumHtColl->end(); jbx++) {
82  if (jbx->bx() == 0) {
83  etHad = static_cast<double>(jbx->et());
84  }
85  }
86 
87  double etMiss = 0.0;
88  double etMAng = 0.0;
89  for (L1GctEtMissCollection::const_iterator jbx = missEtColl->begin(); jbx != missEtColl->end(); jbx++) {
90  if (jbx->bx() == 0) {
91  etMiss = static_cast<double>(jbx->et());
92  int phibin = jbx->phi();
93  if (phibin >= 36)
94  phibin -= 72;
95  double etMPhi = static_cast<double>(phibin);
96 
97  etMAng = (etMPhi + 0.5) * M_PI / 36.;
98  }
99  }
100 
101  double etTotFromRegions = 0.0;
102  double exTotFromRegions = 0.0;
103  double eyTotFromRegions = 0.0;
104  for (L1CaloRegionCollection::const_iterator jrg = inputColl->begin(); jrg != inputColl->end(); jrg++) {
105  if (jrg->bx() == 0) {
106  double rgEt = static_cast<double>(jrg->et()) * lsbForEt;
107  double rgPhibin = static_cast<double>(jrg->id().iphi());
108  double rgPh = (rgPhibin + 0.5) * M_PI / 9.;
109 
110  etTotFromRegions += rgEt;
111  exTotFromRegions += rgEt * cos(rgPh);
112  eyTotFromRegions += rgEt * sin(rgPh);
113  }
114  }
115 
116  double htMissGct = 0.0;
117  double htMissAng = 0.0;
118  double htMissGeV = 0.0;
119  for (L1GctHtMissCollection::const_iterator jbx = missHtColl->begin(); jbx != missHtColl->end(); jbx++) {
120  if (jbx->bx() == 0) {
121  htMissGct = static_cast<double>(jbx->et());
122  htMissGeV = htMissScale->et(jbx->et());
123  int phibin = jbx->phi();
124  if (phibin >= 9)
125  phibin -= 18;
126  double htMPhi = static_cast<double>(phibin);
127  htMissAng = (htMPhi + 0.5) * M_PI / 9.;
128  }
129  }
130 
131  double htFromJets = 0.0;
132  double hxFromJets = 0.0;
133  double hyFromJets = 0.0;
134  for (L1GctInternJetDataCollection::const_iterator jet = internalJetsColl->begin(); jet != internalJetsColl->end();
135  jet++) {
136  if (jet->bx() == 0 && !jet->empty()) {
137  unsigned jetEtGct = jet->et();
138  double jetEt = static_cast<double>(jetEtGct);
139  int phibin = jet->regionId().iphi();
140  if (phibin >= 9)
141  phibin -= 18;
142  // The phi bin centres are at 0, 20, 40, ... degrees
143  double jetAng = (static_cast<double>(phibin)) * M_PI / 9.;
144  if (jetEtGct > httJetThreshold) {
145  htFromJets += jetEt;
146  }
147  if (jetEtGct > htmJetThreshold) {
148  hxFromJets += jetEt * cos(jetAng);
149  hyFromJets += jetEt * sin(jetAng);
150  }
151  }
152  }
153 
154  double dPhiMetMht = deltaPhi(etMAng, htMissAng);
155 
156  theSumEtInLsb->Fill(etTot);
157  theSumHtInLsb->Fill(etHad);
158  theMissEtInLsb->Fill(etMiss);
159  theMissHtInLsb->Fill(htMissGct);
160  theSumEtInGeV->Fill(etTot * lsbForEt);
161  theSumHtInGeV->Fill(etHad * lsbForHt);
162  theMissEtInGeV->Fill(etMiss * lsbForEt);
163  theMissEtAngle->Fill(etMAng);
164  theMissEtVector->Fill(etMiss * lsbForEt * cos(etMAng), etMiss * lsbForEt * sin(etMAng));
165  if (htMissGct < 126.5) {
166  theMissHtInGeV->Fill(htMissGeV);
167  theMissHtAngle->Fill(htMissAng);
168  theMissHtVector->Fill(htMissGeV * cos(htMissAng), htMissGeV * sin(htMissAng));
169  }
170 
171  theSumEtVsInputRegions->Fill(etTot * lsbForEt, etTotFromRegions);
172  theMissEtMagVsInputRegions->Fill(etMiss * lsbForEt,
173  sqrt(exTotFromRegions * exTotFromRegions + eyTotFromRegions * eyTotFromRegions));
174  theMissEtAngleVsInputRegions->Fill(etMAng, atan2(-eyTotFromRegions, -exTotFromRegions));
175  theMissHtMagVsInputRegions->Fill(htMissGeV,
176  sqrt(exTotFromRegions * exTotFromRegions + eyTotFromRegions * eyTotFromRegions));
177 
178  theMissEtVsMissHt->Fill(etMiss * lsbForEt, htMissGeV);
179  theMissEtVsMissHtAngle->Fill(etMAng, htMissAng);
180  theDPhiVsMissEt->Fill(dPhiMetMht, etMiss * lsbForEt);
181  theDPhiVsMissHt->Fill(dPhiMetMht, htMissGeV);
182 
183  theHtVsInternalJetsSum->Fill(etHad * lsbForHt, htFromJets * lsbForHt);
184  if (htMissGct < 126.5) {
185  theMissHtVsInternalJetsSum->Fill(htMissGeV, sqrt(hxFromJets * hxFromJets + hyFromJets * hyFromJets) * lsbForHt);
186  theMissHtPhiVsInternalJetsSum->Fill(htMissAng, atan2(-hyFromJets, -hxFromJets));
187  theMissHxVsInternalJetsSum->Fill(htMissGeV * cos(htMissAng), hxFromJets * lsbForHt);
188  theMissHyVsInternalJetsSum->Fill(htMissGeV * sin(htMissAng), hyFromJets * lsbForHt);
189  }
190 
191  // Get minbias trigger quantities from HF
194  iEvent.getByLabel(m_energy_tag, HFEtSumsColl);
195  iEvent.getByLabel(m_energy_tag, HFCountsColl);
196 
197  for (L1GctHFRingEtSumsCollection::const_iterator es = HFEtSumsColl->begin(); es != HFEtSumsColl->end(); es++) {
198  if (es->bx() == 0) {
199  theHfRing0EtSumPositiveEta->Fill(hfRingEtScale->et(es->etSum(0)));
200  theHfRing0EtSumNegativeEta->Fill(hfRingEtScale->et(es->etSum(1)));
201  theHfRing1EtSumPositiveEta->Fill(hfRingEtScale->et(es->etSum(2)));
202  theHfRing1EtSumNegativeEta->Fill(hfRingEtScale->et(es->etSum(3)));
203  }
204  }
205 
206  for (L1GctHFBitCountsCollection::const_iterator bc = HFCountsColl->begin(); bc != HFCountsColl->end(); bc++) {
207  if (bc->bx() == 0) {
208  theHfRing0CountPositiveEta->Fill(bc->bitCount(0));
209  theHfRing0CountNegativeEta->Fill(bc->bitCount(1));
210  theHfRing1CountPositiveEta->Fill(bc->bitCount(2));
211  theHfRing1CountNegativeEta->Fill(bc->bitCount(3));
212  }
213  }
214 }
215 
216 // ------------ method called once each job just before starting event loop ------------
219 
220  TFileDirectory dir0 = fs->mkdir("L1GctEtSums");
221 
222  theSumEtInLsb = dir0.make<TH1F>("SumEtInLsb", "Total Et (GCT units)", 128, 0., 2048.);
223  theSumHtInLsb = dir0.make<TH1F>("SumHtInLsb", "Total Ht (GCT units)", 128, 0., 2048.);
224  theMissEtInLsb = dir0.make<TH1F>("MissEtInLsb", "Missing Et magnitude (GCT units)", 128, 0., 1024.);
225  theMissHtInLsb = dir0.make<TH1F>("MissHtInLsb", "Missing Ht magnitude (GCT units)", 128, 0., 127.);
226  theSumEtInGeV = dir0.make<TH1F>("SumEtInGeV", "Total Et (in GeV)", 100, 0., 1000.);
227  theSumHtInGeV = dir0.make<TH1F>("SumHtInGeV", "Total Ht (in GeV)", 100, 0., 1000.);
228  theMissEtInGeV = dir0.make<TH1F>("MissEtInGeV", "Missing Et magnitude (in GeV)", 100, 0., 500.);
229  theMissEtAngle = dir0.make<TH1F>("MissEtAngle", "Missing Et angle", 72, -M_PI, M_PI);
230  theMissEtVector = dir0.make<TH2F>("MissEtVector", "Missing Ex vs Missing Ey", 100, -100., 100., 100, -100., 100.);
231  theMissHtInGeV = dir0.make<TH1F>("MissHtInGeV", "Missing Ht magnitude (in GeV)", 100, 0., 500.);
232  theMissHtAngle = dir0.make<TH1F>("MissHtAngle", "Missing Ht angle", 72, -M_PI, M_PI);
233  theMissHtVector = dir0.make<TH2F>("MissHtVector", "Missing Hx vs Missing Hy", 100, -100., 100., 100, -100., 100.);
235  dir0.make<TH2F>("SumEtVsInputRegions", "Total Et vs sum of input regions", 100, 0., 1000., 100, 0., 1000.);
236  theMissEtMagVsInputRegions = dir0.make<TH2F>(
237  "MissEtMagVsInputRegions", "Missing Et magnitude vs sum of input regions", 100, 0., 500., 100, 0., 500.);
238  theMissEtAngleVsInputRegions = dir0.make<TH2F>(
239  "MissEtAngleVsInputRegions", "Missing Et angle vs sum of input regions", 72, -M_PI, M_PI, 72, -M_PI, M_PI);
240  theMissHtMagVsInputRegions = dir0.make<TH2F>(
241  "MissHtMagVsInputRegions", "Missing Ht magnitude vs sum of input regions", 100, 0., 500., 100, 0., 500.);
242  theMissEtVsMissHt = dir0.make<TH2F>("MissEtVsMissHt", "Missing Et vs Missing Ht", 100, 0., 500., 100, 0., 500.);
243  theMissEtVsMissHtAngle = dir0.make<TH2F>(
244  "MissEtVsMissHtAngle", "Angle correlation Missing Et vs Missing Ht", 72, -M_PI, M_PI, 72, -M_PI, M_PI);
246  dir0.make<TH2F>("theDPhiVsMissEt", "Angle difference MET-MHT vs MET magnitude", 72, -M_PI, M_PI, 100, 0., 500.);
248  dir0.make<TH2F>("theDPhiVsMissHt", "Angle difference MET-MHT vs MHT magnitude", 72, -M_PI, M_PI, 100, 0., 500.);
249 
250  theHtVsInternalJetsSum = dir0.make<TH2F>(
251  "HtVsInternalJetsSum", "Ht vs scalar sum of jet Et values (in GeV)", 128, 0., 2048., 128, 0., 2048.);
252  theMissHtVsInternalJetsSum = dir0.make<TH2F>(
253  "MissHtVsInternalJetsSum", "Missing Ht vs vector sum of jet Et values (in GeV)", 128, 0., 512., 128, 0., 512.);
254  theMissHtPhiVsInternalJetsSum = dir0.make<TH2F>("MissHtPhiVsInternalJetsSum",
255  "Angle correlation Missing Ht vs vector sum of jet Et values",
256  72,
257  -M_PI,
258  M_PI,
259  72,
260  -M_PI,
261  M_PI);
262  theMissHxVsInternalJetsSum = dir0.make<TH2F>("MissHxVsInternalJetsSum",
263  "Missing Ht x component vs sum of jet Et values (in GeV)",
264  128,
265  -256.,
266  256.,
267  128,
268  -256.,
269  256.);
270  theMissHyVsInternalJetsSum = dir0.make<TH2F>("MissHyVsInternalJetsSum",
271  "Missing Ht y component vs sum of jet Et values (in GeV)",
272  128,
273  -256.,
274  256.,
275  128,
276  -256.,
277  256.);
278 
279  TFileDirectory dir1 = fs->mkdir("L1GctHfSumsAndJetCounts");
280 
281  // Minimum bias triggers from Hf inner rings
282  theHfRing0EtSumPositiveEta = dir1.make<TH1F>("HfRing0EtSumPositiveEta", "Hf Inner Ring0 Et eta+", 60, 0., 30.);
283  theHfRing0EtSumNegativeEta = dir1.make<TH1F>("HfRing0EtSumNegativeEta", "Hf Inner Ring0 Et eta-", 60, 0., 30.);
284  theHfRing1EtSumPositiveEta = dir1.make<TH1F>("HfRing1EtSumPositiveEta", "Hf Inner Ring1 Et eta+", 60, 0., 30.);
285  theHfRing1EtSumNegativeEta = dir1.make<TH1F>("HfRing1EtSumNegativeEta", "Hf Inner Ring1 Et eta-", 60, 0., 30.);
286  theHfRing0CountPositiveEta = dir1.make<TH1F>("HfRing0CountPositiveEta", "Hf Threshold bits Ring0 eta+", 20, 0., 20.);
287  theHfRing0CountNegativeEta = dir1.make<TH1F>("HfRing0CountNegativeEta", "Hf Threshold bits Ring0 eta-", 20, 0., 20.);
288  theHfRing1CountPositiveEta = dir1.make<TH1F>("HfRing1CountPositiveEta", "Hf Threshold bits Ring1 eta+", 20, 0., 20.);
289  theHfRing1CountNegativeEta = dir1.make<TH1F>("HfRing1CountNegativeEta", "Hf Threshold bits Ring1 eta-", 20, 0., 20.);
290 }
291 
292 // ------------ method called once each job just after ending the event loop ------------
294 
TH1F * theHfRing1EtSumPositiveEta
TH2F * theMissHxVsInternalJetsSum
TH2F * theMissHtVsInternalJetsSum
void endJob() override
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TH2F * theHtVsInternalJetsSum
L1GctValidation(const edm::ParameterSet &)
double getHtLsbGeV() const
double et(const uint16_t rank) const
convert from rank to physically meaningful quantity
TH2F * theMissHyVsInternalJetsSum
TH2F * theMissEtVsMissHt
TH1F * theHfRing1CountPositiveEta
TH1F * theHfRing0EtSumPositiveEta
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TH1F * theHfRing0CountNegativeEta
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double getMHtJetEtThresholdGeV() const
TH2F * theSumEtVsInputRegions
edm::InputTag m_energy_tag
T * make(const Args &...args) const
make new ROOT object
TH2F * theMissEtAngleVsInputRegions
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
TH1F * theHfRing1EtSumNegativeEta
edm::InputTag m_gctinp_tag
#define M_PI
TH1F * theHfRing1CountNegativeEta
void beginJob() override
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
void analyze(const edm::Event &, const edm::EventSetup &) override
double getHtJetEtThresholdGeV() const
~L1GctValidation() override
HLT enums.
T get() const
Definition: EventSetup.h:73
TH1F * theHfRing0CountPositiveEta
double getRgnEtLsbGeV() const
TH2F * theMissHtPhiVsInternalJetsSum
T const * product() const
Definition: ESHandle.h:86
TH1F * theHfRing0EtSumNegativeEta
TH2F * theMissEtVsMissHtAngle
TH2F * theMissEtMagVsInputRegions
TH2F * theMissHtMagVsInputRegions