00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #include "DQM/L1TMonitor/interface/L1THCALTPGXAna.h"
00069 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00070 #include "DQMServices/Core/interface/DQMStore.h"
00071
00072 #include "TMath.h"
00073
00074 using namespace edm;
00075
00076
00077 const unsigned int RTPBINS = 101;
00078 const float RTPMIN = -0.5;
00079 const float RTPMAX = 100.5;
00080
00081 const unsigned int TPPHIBINS = 72;
00082 const float TPPHIMIN = 0.5;
00083 const float TPPHIMAX = 72.5;
00084
00085 const unsigned int TPETABINS = 65;
00086 const float TPETAMIN = -32.5;
00087 const float TPETAMAX = 32.5;
00088
00089 const unsigned int effBins = 50;
00090 const float effMinHBHE = -0.5;
00091 const float effMaxHBHE = 5.5;
00092 const float effMinHF = -0.5;
00093 const float effMaxHF = 2.5;
00094
00095 const unsigned int ratiobins = 100;
00096 const float ratiomin = 0.0;
00097 const float ratiomax = 1.0;
00098
00099 const unsigned int tvsrecbins = 100;
00100 const float tvsrecmin = 0.0;
00101 const float tvsrecmax = 100.0;
00102
00103 const unsigned int effcombo = 6472;
00104 const float effcombomin = -3272;
00105 const float effcombomax = 3272;
00106
00107 const unsigned int fgbunchbins = 10;
00108 const float fgbunchmin = 0;
00109 const float fgbunchmax = 9;
00110
00111 const unsigned int fgbdiffbins = 20;
00112 const float fgbdiffmin = -10;
00113 const float fgbdiffmax = 10;
00114
00115 const unsigned int fgtdiffbins = 20;
00116 const float fgtdiffmin = -250;
00117 const float fgtdiffmax = 250;
00118
00119
00120 L1THCALTPGXAna::L1THCALTPGXAna(const ParameterSet& ps)
00121 : hcaltpgSource_( ps.getParameter< InputTag >("hcaltpgSource") ),
00122 hbherecoSource_( ps.getParameter< InputTag >("hbherecoSource") ),
00123 hfrecoSource_( ps.getParameter< InputTag >("hfrecoSource") )
00124 {
00125
00126 verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00127 if(verbose_) std::cout << "L1THCALTPGXAna: constructor...." << std::endl;
00128
00129
00130 fakeCut_ = ps.getUntrackedParameter<double>("fakeCut",0.0);
00131
00132
00133 dbe = NULL;
00134 if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
00135 {
00136 dbe = Service<DQMStore>().operator->();
00137 dbe->setVerbose(0);
00138 }
00139
00140 outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
00141 if ( outputFile_.size() != 0 ) {
00142 std::cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << std::endl;
00143 }
00144
00145 bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
00146 if(disable){
00147 outputFile_="";
00148 }
00149
00150
00151 if ( dbe !=NULL ) {
00152 dbe->setCurrentFolder("L1T/L1THCALTPGXAna");
00153 }
00154
00155 }
00156
00157 L1THCALTPGXAna::~L1THCALTPGXAna()
00158 {
00159 }
00160
00161 void L1THCALTPGXAna::beginJob(const EventSetup& iSetup)
00162 {
00163 nev_ = 0;
00164
00165
00166 DQMStore* dbe = 0;
00167 dbe = Service<DQMStore>().operator->();
00168 if ( dbe )
00169 {
00170 dbe->setCurrentFolder("L1T/L1THCALTPGXAna");
00171 dbe->rmdir("L1T/L1THCALTPGXAna");
00172 }
00173
00174 if ( dbe )
00175 {
00176 dbe->setCurrentFolder("L1T/L1THCALTPGXAna");
00177
00178 hcalTpEtEtaPhi_ =
00179 dbe->book2D("HcalTpEtEtaPhi", "HCAL TP E_{T}", TPETABINS, TPETAMIN,
00180 TPETAMAX, TPPHIBINS, TPPHIMIN, TPPHIMAX);
00181 hcalTpOccEtaPhi_ =
00182 dbe->book2D("HcalTpOccEtaPhi", "HCAL TP OCCUPANCY", TPETABINS,
00183 TPETAMIN, TPETAMAX, TPPHIBINS, TPPHIMIN, TPPHIMAX);
00184 hcalTpSat_ =
00185 dbe->book2D("HcalSaturation", "HCAL Satuation", TPETABINS,
00186 TPETAMIN, TPETAMAX, TPPHIBINS, TPPHIMIN, TPPHIMAX);
00187 hcalFakes_ =
00188 dbe->book2D("HcalFakes","Number of Fakes", TPETABINS, TPETAMIN,
00189 TPETAMAX, TPPHIBINS, TPPHIMIN, TPPHIMAX);
00190 hcalNoFire_ =
00191 dbe->book2D("HcalNoFire","Highest Energy with TP = 0", TPETABINS, TPETAMIN,
00192 TPETAMAX, TPPHIBINS, TPPHIMIN, TPPHIMAX);
00193 hcalTpgvsRec1_ =
00194 dbe->book2D("TPGvsREC1", "TPG vs Rec Hit LUT 1", tvsrecbins, tvsrecmin, tvsrecmax,
00195 tvsrecbins, tvsrecmin, tvsrecmax);
00196 hcalTpgvsRec2_ =
00197 dbe->book2D("TPGvsREC2", "TPG vs Rec Hit LUT 2", tvsrecbins, tvsrecmin, tvsrecmax,
00198 tvsrecbins, tvsrecmin, tvsrecmax);
00199 hcalTpgvsRec3_ =
00200 dbe->book2D("TPGvsREC3", "TPG vs Rec Hit LUT 3", tvsrecbins, tvsrecmin, tvsrecmax,
00201 tvsrecbins, tvsrecmin, tvsrecmax);
00202 hcalTpgvsRec4_ =
00203 dbe->book2D("TPGvsREC4", "TPG vs Rec Hit LUT 4", tvsrecbins, tvsrecmin, tvsrecmax,
00204 tvsrecbins, tvsrecmin, tvsrecmax);
00205
00206
00207 hcalTpRank_ =
00208 dbe->book1D("HcalTpRank", "HCAL TP RANK", RTPBINS, RTPMIN, RTPMAX);
00209 hcalEffDen_1_ =
00210 dbe->book1D("HcalAll1","HCAL All Hits - 1",effBins,effMinHBHE,effMaxHBHE);
00211 hcalEffNum_1_ =
00212 dbe->book1D("HcalTP1","HCAL Hits with TP - 1",effBins,effMinHBHE,effMaxHBHE);
00213 hcalEffDen_2_ =
00214 dbe->book1D("HcalAll2","HCAL All Hits - 2",effBins,effMinHBHE,effMaxHBHE);
00215 hcalEffNum_2_ =
00216 dbe->book1D("HcalTP2","HCAL Hits with TP - 2",effBins,effMinHBHE,effMaxHBHE);
00217 hcalEffDen_3_ =
00218 dbe->book1D("HcalAll3","HCAL All Hits - 3",effBins,effMinHBHE,effMaxHBHE);
00219 hcalEffNum_3_ =
00220 dbe->book1D("HcalTP3","HCAL Hits with TP - 3",effBins,effMinHBHE,effMaxHBHE);
00221 hcalEffDen_4_ =
00222 dbe->book1D("HcalAll4","HCAL All Hits - 4",effBins,effMinHF,effMaxHF);
00223 hcalEffNum_4_ =
00224 dbe->book1D("HcalTP4","HCAL Hits with TP - 4",effBins,effMinHF,effMaxHF);
00225 hcalTpgRatiom1_ =
00226 dbe->book1D("HcalTPGRatiom1", "Hcal Ration of E in bin SOI -1", ratiobins, ratiomin, ratiomax);
00227 hcalTpgRatioSOI_ =
00228 dbe->book1D("HcalTPGRatiSOI", "Hcal Ration of E in bin SOI", ratiobins, ratiomin, ratiomax);
00229 hcalTpgRatiop1_ =
00230 dbe->book1D("HcalTPGRatiop1", "Hcal Ration of E in bin SOI +1", ratiobins, ratiomin, ratiomax);
00231 hcalTpgRatiop2_ =
00232 dbe->book1D("HcalTPGRatiop2", "Hcal Ration of E in bin SOI +21", ratiobins, ratiomin, ratiomax);
00233 hcalTpgfgperbunch_ =
00234 dbe->book1D("HcalFGperBunch", "Fine grain per bunch", fgbunchbins, fgbunchmin, fgbunchmax);
00235 hcalTpgfgbindiff_ =
00236 dbe->book1D("HcalFGbindiff", "Fine grain bunch difference", fgbdiffbins, fgbdiffmin, fgbdiffmax);
00237 hcalTpgfgtimediff_ =
00238 dbe->book1D("HcalFGtimediff", "Fine grain time diff", fgtdiffbins, fgtdiffmin, fgtdiffmax);
00239
00240
00241 if (0){
00242 dbe->setCurrentFolder("L1T/L1THCALTPGXAna/EffByChannel");
00243
00244 for (int i=0; i < 56; i++)
00245 {
00246 char hname[20],htitle[20];
00247 char dirname[80];
00248 int ieta, iphi;
00249 if (i<28) ieta = i-28;
00250 else ieta = i-27;
00251 sprintf(dirname,"L1T/L1THCALTPGXAna/EffByChannel/EtaTower%d",ieta);
00252 dbe->setCurrentFolder(dirname);
00253 for (int j=0; j < 72; j++)
00254 {
00255 iphi = j+1;
00256 if (i<28) ieta = i-28;
00257 else ieta = i-27;
00258 sprintf(hname,"eff_%d_%d_num",ieta,iphi);
00259 sprintf(htitle,"Eff Num <%d,%d>",ieta,iphi);
00260 hcalEffNum_HBHE[i][j] = dbe->book1D(hname, htitle, effBins,effMinHBHE,effMaxHBHE);
00261 sprintf(hname,"eff_%d_%d_den",ieta,iphi);
00262 sprintf(htitle,"Eff Den <%d,%d>",ieta,iphi);
00263 hcalEffDen_HBHE[i][j] = dbe->book1D(hname, htitle, effBins,effMinHBHE,effMaxHBHE);
00264 }
00265 }
00266
00267 for (int i=0; i < 8; i++)
00268 {
00269 char hname[20],htitle[20];
00270 char dirname[80];
00271 int ieta, iphi;
00272 if (i<4) ieta = i-32;
00273 else ieta = i+25;
00274 sprintf(dirname,"L1T/L1THCALTPGXAna/EffByChannel/EtaTower%d",ieta);
00275 dbe->setCurrentFolder(dirname);
00276 for (int j=0; j < 18; j++)
00277 {
00278 iphi = j*4+1;
00279 if (i<4) ieta = i-32;
00280 else ieta = i+25;
00281 sprintf(hname,"eff_%d_%d_num",ieta,iphi);
00282 sprintf(htitle,"Eff Num <%d,%d>",ieta,iphi);
00283 hcalEffNum_HF[i][j] = dbe->book1D(hname, htitle, effBins,effMinHF,effMaxHF);
00284 sprintf(hname,"eff_%d_%d_den",ieta,iphi);
00285 sprintf(htitle,"Eff Den <%d,%d>",ieta,iphi);
00286 hcalEffDen_HF[i][j] = dbe->book1D(hname, htitle, effBins,effMinHF,effMaxHF);
00287 }
00288 }
00289 }
00290
00291 }
00292 }
00293
00294
00295 void L1THCALTPGXAna::endJob(void)
00296 {
00297 if(verbose_) std::cout << "L1THCALTPGXAna: end job...." << std::endl;
00298 LogInfo("EndJob") << "analyzed " << nev_ << " events";
00299
00300 if ( outputFile_.size() != 0 && dbe ) dbe->save(outputFile_);
00301
00302 return;
00303 }
00304
00305 void L1THCALTPGXAna::analyze(const Event& iEvent, const EventSetup& iSetup)
00306 {
00307 nev_++;
00308 if(verbose_) std::cout << "L1THCALTPGXAna: analyze...." << std::endl;
00309
00310 edm::Handle<HcalTrigPrimDigiCollection> hcalTpgs;
00311 iEvent.getByLabel(hcaltpgSource_, hcalTpgs);
00312
00313 if (!hcalTpgs.isValid())
00314 {
00315 edm::LogInfo("DataNotFound") << "can't find HCAL TPG's with label "
00316 << hcaltpgSource_.label() ;
00317 return;
00318 }
00319
00320 Handle<HBHERecHitCollection> hbhe_rec;
00321
00322
00323 iEvent.getByLabel(hbherecoSource_, hbhe_rec);
00324
00325 if (!hbhe_rec.isValid())
00326 {
00327 edm::LogInfo("DataNotFound") << "can't find hbhe rec hits's with label "
00328 << hbherecoSource_.label() ;
00329 return;
00330 }
00331
00332 Handle<HFRecHitCollection> hf_rec;
00333 iEvent.getByLabel(hfrecoSource_, hf_rec);
00334
00335 if (!hf_rec.isValid())
00336 {
00337 edm::LogInfo("DataNotFound") << "can't find hf rec hits's with label "
00338 << hfrecoSource_.label() ;
00339 return;
00340 }
00341
00342 std::vector<HcalTrigTowerDetId> towerids;
00343 Rec_towers.clear();
00344 double rec_e, eta1, eta2, et2e, eta_avg, rece_m, rece_p1, rece_p2;
00345 int rank, ieta, iphi, icombo;
00346
00347 for(HBHERecHitCollection::const_iterator hbhe_iter = hbhe_rec->begin(); hbhe_iter != hbhe_rec->end(); ++hbhe_iter)
00348 {
00349 towerids = theTrigTowerGeometry.towerIds(hbhe_iter->id());
00350 assert(towerids.size() == 2 || towerids.size() == 1);
00351 for(unsigned int n = 0; n < towerids.size(); n++)
00352 {
00353 Rec_towers.insert(IdtoEnergy::value_type(towerids[n],hbhe_iter->energy()/towerids.size()));
00354 }
00355 }
00356
00357 for(HFRecHitCollection::const_iterator hf_iter = hf_rec->begin(); hf_iter != hf_rec->end(); ++hf_iter)
00358 {
00359 towerids = theTrigTowerGeometry.towerIds(hf_iter->id());
00360 assert(towerids.size() == 2 || towerids.size() == 1);
00361 for(unsigned int n = 0; n < towerids.size(); n++)
00362 {
00363 Rec_towers.insert(IdtoEnergy::value_type(towerids[n],hf_iter->energy()/towerids.size()));
00364 }
00365 }
00366
00367 numFG=0;
00368 for ( HcalTrigPrimDigiCollection::const_iterator tpg_iter = hcalTpgs->begin(); tpg_iter != hcalTpgs->end(); ++tpg_iter )
00369 {
00370 float ratioTotal = 0;
00371 float ratiom1 = 0;
00372 float ratiosoi= 0;
00373 float ratiop1 = 0;
00374 float ratiop2 = 0;;
00375
00376 rec_e = 0.0;
00377 for(IdtoEnergy::iterator rec_iter = Rec_towers.lower_bound(tpg_iter->id()); rec_iter != Rec_towers.upper_bound(tpg_iter->id()); ++rec_iter)
00378 {
00379 rec_e += rec_iter->second;
00380 }
00381
00382
00383 ieta = tpg_iter->id().ieta();
00384 iphi = tpg_iter->id().iphi();
00385
00386
00387 rank = tpg_iter->SOI_compressedEt();
00388
00389
00390 theTrigTowerGeometry.towerEtaBounds(ieta,eta1,eta2);
00391
00392
00393 eta_avg = find_eta(eta1,eta2);
00394
00395
00396 et2e = TMath::CosH(eta_avg);
00397
00398 if (TMath::Abs(ieta) >= 29) rec_e = rec_e/et2e;
00399
00400 if (0){
00401
00402 if (TMath::Abs(ieta) >= 29)
00403 {
00404 if (ieta <0)
00405 {
00406 hcalEffDen_HF[(ieta+32)][iphi/4]->Fill(rec_e);
00407 if (rank !=0)
00408 {
00409 hcalEffNum_HF[(ieta+32)][iphi/4]->Fill(rec_e);
00410 }
00411 }
00412 else
00413 {
00414 hcalEffDen_HF[(ieta-25)][iphi/4]->Fill(rec_e);
00415 if (rank !=0)
00416 {
00417 hcalEffNum_HF[(ieta-25)][iphi/4]->Fill(rec_e);
00418 }
00419 }
00420 }
00421 else
00422 {
00423
00424 if (ieta < 0)
00425 {
00426 hcalEffDen_HBHE[ieta+28][iphi-1]->Fill(rec_e);
00427 if (rank !=0)
00428 {
00429 hcalEffNum_HBHE[ieta+28][iphi-1]->Fill(rec_e);
00430 }
00431 }
00432 else
00433 {
00434 hcalEffDen_HBHE[ieta+27][iphi-1]->Fill(rec_e);
00435 if (rank !=0)
00436 {
00437 hcalEffNum_HBHE[ieta+27][iphi-1]->Fill(rec_e);
00438 }
00439 }
00440 }
00441 }
00442
00443
00444 if (TMath::Abs(ieta) <= 20)
00445 {
00446 hcalEffDen_1_->Fill(rec_e);
00447 if (rank != 0)
00448 {
00449 hcalEffNum_1_->Fill(rec_e);
00450 hcalTpgvsRec1_->Fill(rec_e,rank);
00451 }
00452 }
00453 else if (TMath::Abs(ieta) <= 26)
00454 {
00455 hcalEffDen_2_->Fill(rec_e);
00456 if (rank != 0)
00457 {
00458 hcalEffNum_2_->Fill(rec_e);
00459 hcalTpgvsRec2_->Fill(rec_e,rank);
00460 }
00461 }
00462 else if (TMath::Abs(ieta) <= 28)
00463 {
00464 hcalEffDen_3_->Fill(rec_e);
00465 if (rank != 0)
00466 {
00467 hcalEffNum_3_->Fill(rec_e);
00468 hcalTpgvsRec3_->Fill(rec_e,rank);
00469 }
00470 }
00471 else
00472 {
00473
00474 if(et2e != 0) { hcalEffDen_4_->Fill(rec_e); }
00475 if (rank != 0)
00476 {
00477 hcalEffNum_4_->Fill(rec_e);
00478 hcalTpgvsRec4_->Fill(rec_e,rank);
00479 }
00480 }
00481
00482 if ( rank != 0 )
00483 {
00484
00485 hcalTpOccEtaPhi_->Fill(ieta,iphi);
00486 hcalTpEtEtaPhi_->Fill(ieta,iphi,rank);
00487 if(rank == 1024)
00488 {
00489 hcalTpSat_->Fill(ieta,iphi);
00490 }
00491
00492 hcalTpRank_->Fill(rank);
00493 if (rec_e < fakeCut_) { hcalFakes_->Fill(ieta,iphi); }
00494 }
00495 else
00496 {
00497
00498 double highest_energy = hcalNoFire_->getBinContent(ieta+33,iphi);
00499 if (highest_energy < rec_e)
00500 {
00501 hcalNoFire_->setBinContent(ieta+33,iphi,rec_e);
00502 }
00503 }
00504
00505 for(int i = 0; i<10; i++)
00506 {
00507 if(tpg_iter->sample(i).fineGrain())
00508 {
00509 hcalTpgfgperbunch_->Fill(i);
00510 numFG++;
00511 if(numFG < 3)
00512 {
00513 if(tpg_iter->id().iphi() < 37) binfg2 = i;
00514 else binfg1 = i;
00515 }
00516
00517 }
00518 }
00519
00520 if (verbose_)
00521 {
00522 std::cout << "size " << tpg_iter->size() << std::endl;
00523 std::cout << "iphi " << tpg_iter->id().iphi() << std::endl;
00524 std::cout << "ieta " << tpg_iter->id().ieta() << std::endl;
00525 std::cout << "compressed Et " << tpg_iter->SOI_compressedEt() << std::endl;
00526 std::cout << "FG bit " << tpg_iter->SOI_fineGrain() << std::endl;
00527 std::cout << "raw " << tpg_iter->t0().raw() << std::endl;
00528 std::cout << "raw Et " << tpg_iter->t0().compressedEt() << std::endl;
00529 std::cout << "raw FG " << tpg_iter->t0().fineGrain() << std::endl;
00530 std::cout << "raw slb " << tpg_iter->t0().slb() << std::endl;
00531 std::cout << "raw slbChan " << tpg_iter->t0().slbChan() << std::endl;
00532 std::cout << "raw slbAndChan " << tpg_iter->t0().slbAndChan() << std::endl;
00533 std::cout << "reco energy " << rec_e << std::endl;
00534 std::cout << "tower eta " << eta_avg << std::endl;
00535 }
00536 }
00537 }
00538
00539 double find_eta(double eta_start, double eta_end)
00540 {
00541 double theta_avg = TMath::ATan(TMath::Exp(-eta_start)) + TMath::ATan(TMath::Exp(-eta_end));
00542 double average = -TMath::Log(TMath::Tan(theta_avg/2.0));
00543 return average;
00544 }