84 std::ifstream userfile;
86 userfile.open(userfileName.c_str());
87 static const int etabound = 32;
88 static const int tpgmax = 256;
89 for (
int i=0;
i<tpgmax;
i++) {
90 for(
int j = 1;
j <=etabound;
j++) {
98 for (
int i=0;
i<396;
i++)
133 edm::LogInfo(
"FastL1GlobalAlgo::CaloTowersDump") <<
"Start!";
140 edm::LogInfo(
"FastL1GlobalAlgo::CaloTowersDump") <<
"End!";
149 return (a.
et()>b.
et());
161 for (
int i=0;
i<396;
i++) {
169 double eta = p.first;
170 double phi = p.second;
213 double et =
m_Regions.at(iRgn).GetJetEt();
215 double eta = p.first;
216 double phi = p.second;
225 double ex = et*
cos(phi);
226 double ey = et*
sin(phi);
229 double e = ex/
sin(theta)/
cos(phi);
230 double ez = e*
cos(theta);
272 for (
int i=0;
i<396;
i++) {
276 if (cnd->emEt()<0.01 && cnd->hadEt()<0.01)
continue;
290 }
else if (emTag==2) {
332 }
else if (emTag==2) {
355 double sum_hade = 0.0;
356 double sum_hadet = 0.0;
357 double sum_hadex = 0.0;
358 double sum_hadey = 0.0;
359 double sum_hadez = 0.0;
375 double eme = candidate->emEt();
376 double hade = candidate->hadEt();
386 if(
std::abs(candidate->eta())<2.322) {
392 if(
std::abs(candidate->eta())<2.322) {
399 double emScale = 1.0;
400 double hadScale = 1.0;
405 if (
std::abs(candidate->eta()<1.3050)) {
412 if (eme>=EThres || hade>=HThres) {
413 double phi = candidate->phi();
414 double eta = candidate->eta();
424 et += candidate->emEt();
425 e += candidate->emEnergy();
428 et += candidate->hadEt();
429 e += candidate->hadEnergy();
430 had_et += candidate->hadEt();
431 had_e += candidate->hadEnergy();
436 sum_ex += et*
cos(phi);
437 sum_ey += et*
sin(phi);
441 sum_e += et/
sin(theta);
442 sum_ez += et*
cos(theta)/
sin(theta);
445 sum_hadex += had_et*
cos(phi);
446 sum_hadey += had_et*
sin(phi);
450 sum_hade += had_et/
sin(theta);
451 sum_hadez += had_et*
cos(theta)/
sin(theta);
472 for (
int i=0;
i<396;
i++) {
474 double phi = etaphi.second;
486 sum_ex += et*
cos(phi);
487 sum_ey += et*
sin(phi);
500 sum_et =
std::sqrt(sum_ex*sum_ex + sum_ey*sum_ey);
514 m_Regions = std::vector<FastL1Region>(396);
517 for (
int i=0;
i<396;
i++) {
523 for (
int twrid=0; twrid<16; twrid++) {
550 int hEtV [396][16] = {{0}};
552 int hiEtaV[396][16] = {{0}};
553 int hiPhiV[396][16] = {{0}};
555 hTP!=HTPinput->end(); hTP++) {
560 int hiphi = hTP->id().iphi();
561 int hieta = hTP->id().ieta();
587 if(rgnid < 396 && twrid < 16){
588 hEtV[rgnid][twrid] = (int)hTP->SOI_compressedEt();
590 hiEtaV[rgnid][twrid] = hieta;
591 hiPhiV[rgnid][twrid] = hiphi;
596 int emEtV [396][16] = {{0}};
597 int emFGV [396][16] = {{0}};
598 int emiEtaV[396][16] = {{0}};
599 int emiPhiV[396][16] = {{0}};
602 eTP!=ETPinput->end(); eTP++) {
604 int eieta = eTP->id().ieta();
606 if(
abs(eieta)> 28)
continue;
608 int eiphi = eTP->id().iphi();
634 if(rgnid < 396 && twrid < 16){
635 emEtV[rgnid][twrid] = (int)eTP->compressedEt();
636 emFGV[rgnid][twrid] = (int)eTP->fineGrain();
637 emiEtaV[rgnid][twrid] = eieta;
638 emiPhiV[rgnid][twrid] = eiphi;
659 for (
int i=0;
i<396;
i++) {
660 for (
int j=0;
j<16;
j++) {
661 if (emEtV[
i][
j]>0 || hEtV[
i][
j]>0) {
664 std::pair<double, double>
etaphi
666 double eta = etaphi.first;
667 double phi = etaphi.second;
674 double hadEt = ((double )
hcaletValue(iAbsTwrEta, hEtV[
i][j]));
682 double et = emEt + hadEt;
705 m_Regions[
i].FillTower_Scaled(t,j,
true,cGeom);
798 rgnid = pep.second*22 + pep.first;
804 if (rgnid<396 && twrid<16) {
805 m_Regions[rgnid].FillTower_Scaled(*cnd,twrid,
true,cGeom);
814 for (
int i=0;
i<396;
i++) {
817 m_Regions[
i].FillEMCrystals(theTowerConstituentsMap,
835 for (
int i=0;
i<396;
i++) {
846 if ((cRgn%22)<4 || (cRgn%22)>17)
849 int shower_shape = 0;
850 int et_isolation = 0;
892 if ( (cRgn%22)>4 && (cRgn%22)<17){
893 if (nwid==999 || neid==999 || nid==999 || swid==999 || seid==999 || sid==999 || wid==999 ||
911 if (et_isolation == 1) {
914 m_Regions[cRgn].BitInfo.setIsolationVeto(
true);
916 m_Regions[cRgn].BitInfo.setIsolationVeto(
false);
924 if (et_isolation == 1 || shower_shape == 1)
return false;
939 if ((crgn%22)<4 || (crgn%22)>17)
return 0;
940 if (crgn>395 || crgn < 0 || ctwr > 15 || ctwr < 0)
return 0;
943 double cenEt = c[ctwr].et();
951 double cenEta = crpos.first;
952 double cenPhi = crpos.second;
954 double cenFGbit =
m_Regions.at(crgn).GetFGBit(ctwr);
955 double cenHOEbit =
m_Regions.at(crgn).GetHOEBit(ctwr);
960 if (cenFGbit)
return 0;
963 if (cenHOEbit)
return 0;
974 if (no.first>29 || no.first<-29 || no.second>72 || no.second<0)
return 0;
975 if (so.first>29 || so.first<-29 || so.second>72 || so.second<0)
return 0;
976 if (we.first>29 || we.first<-29 || we.second>72 || we.second<0)
return 0;
977 if (ea.first>29 || ea.first<-29 || ea.second>72 || ea.second<0)
return 0;
978 if (nw.first>29 || nw.first<-29 || nw.second>72 || nw.second<0)
return 0;
979 if (ne.first>29 || ne.first<-29 || ne.second>72 || ne.second<0)
return 0;
980 if (sw.first>29 || sw.first<-29 || sw.second>72 || sw.second<0)
return 0;
981 if (se.first>29 || se.first<-29 || se.second>72 || se.second<0)
return 0;
1001 if (norgn>395 || norgn < 0 || notwr > 15 || notwr < 0)
return 0;
1003 double noEt = c[notwr].et();
1007 bool noFGbit =
m_Regions[norgn].GetFGBit(notwr);
1009 bool noHOEbit =
m_Regions[norgn].GetHOEBit(notwr);
1012 if (sorgn>395 || sorgn < 0 || sotwr > 15 || sotwr < 0)
return 0;
1014 double soEt = c[sotwr].et();
1018 bool soFGbit =
m_Regions[sorgn].GetFGBit(sotwr);
1020 bool soHOEbit =
m_Regions[sorgn].GetHOEBit(sotwr);
1023 if (wergn>395 || wergn < 0 || wetwr > 15 || wetwr < 0)
return 0;
1025 double weEt = c[wetwr].et();
1029 bool weFGbit =
m_Regions[wergn].GetFGBit(wetwr);
1031 bool weHOEbit =
m_Regions[wergn].GetHOEBit(wetwr);
1034 if (eargn>395 || eargn < 0 || eatwr > 15 || eatwr < 0)
return 0;
1036 double eaEt = c[eatwr].et();
1040 bool eaFGbit =
m_Regions[eargn].GetFGBit(eatwr);
1042 bool eaHOEbit =
m_Regions[eargn].GetHOEBit(eatwr);
1045 if (nwrgn>395 || nwrgn < 0 || nwtwr > 15 || nwtwr < 0)
return 0;
1047 double nwEt = c[nwtwr].et();
1051 bool nwFGbit =
m_Regions[nwrgn].GetFGBit(nwtwr);
1053 bool nwHOEbit =
m_Regions[nwrgn].GetHOEBit(nwtwr);
1056 if (nergn>395 || nergn < 0 || netwr > 15 || netwr < 0)
return 0;
1058 double neEt = c[netwr].et();
1062 bool neFGbit =
m_Regions[nergn].GetFGBit(netwr);
1064 bool neHOEbit =
m_Regions[nergn].GetHOEBit(netwr);
1067 if (swrgn>395 || swrgn < 0 || swtwr > 15 || swtwr < 0)
return 0;
1069 double swEt = c[swtwr].et();
1073 bool swFGbit =
m_Regions[swrgn].GetFGBit(swtwr);
1075 bool swHOEbit =
m_Regions[swrgn].GetHOEBit(swtwr);
1078 if (sergn>395 || sergn < 0 || setwr > 15 || setwr < 0)
return 0;
1080 double seEt = c[setwr].et();
1084 bool seFGbit =
m_Regions[sergn].GetFGBit(setwr);
1086 bool seHOEbit =
m_Regions[sergn].GetHOEBit(setwr);
1090 bool isHit = ( cenEt > noEt && cenEt >= soEt && cenEt > weEt &&
1091 cenEt >= eaEt && cenEt > nwEt && cenEt > neEt &&
1092 cenEt >= swEt && cenEt >= seEt );
1093 if (!isHit)
return 0;
1096 double hitEt = cenEt;
1107 double emet = (hitEt+maxEt);
1119 if ((emet)<emEtThres)
return 0;
1121 double emtheta = 2.*atan(
exp(-cenEta));
1123 double emex = emet*
cos(cenPhi);
1124 double emey = emet*
sin(cenPhi);
1127 double eme = emex/
sin(emtheta)/
cos(cenPhi);
1128 double emez = eme*
cos(emtheta);
1148 if (noFGbit || soFGbit || weFGbit || eaFGbit ||
1149 nwFGbit || neFGbit || swFGbit || seFGbit ||
1150 noHOEbit || soHOEbit || weHOEbit || eaHOEbit ||
1151 nwHOEbit || neHOEbit || swHOEbit || seHOEbit)
1158 bool isoVeto1 =
false,isoVeto2 =
false,isoVeto3 =
false,isoVeto4 =
false;
1159 if (swEt>quietThres || weEt>quietThres || nwEt>quietThres || noEt>quietThres || neEt>quietThres ) {
1163 if (neEt>quietThres || eaEt>quietThres || seEt>quietThres || soEt>quietThres || swEt>quietThres ) {
1167 if (nwEt>quietThres || noEt>quietThres || neEt>quietThres || eaEt>quietThres || seEt>quietThres ) {
1171 if (seEt>quietThres || soEt>quietThres || swEt>quietThres || weEt>quietThres || nwEt>quietThres ) {
1175 if (isoVeto1 && isoVeto2 && isoVeto3 && isoVeto4)
1186 int nwid =
m_Regions.at(crgn).GetNWId();
1187 int nid =
m_Regions.at(crgn).GetNorthId();
1188 int neid =
m_Regions.at(crgn).GetNEId();
1189 int wid =
m_Regions.at(crgn).GetWestId();
1190 int eid =
m_Regions.at(crgn).GetEastId();
1191 int swid =
m_Regions.at(crgn).GetSWId();
1192 int sid =
m_Regions.at(crgn).GetSouthId();
1193 int seid =
m_Regions.at(crgn).GetSEId();
1198 if ((crgn%22)==21) {
1200 if (nwid==999 || nid==999 || swid==999 || sid==999 || wid==999 ) {
1204 double cenet =
m_Regions.at(crgn).SumEt();
1211 if ( cenet > nwet && cenet > noet &&
1212 cenet >= weet && cenet >= soet &&
1216 double cene =
m_Regions.at(crgn).SumE();
1225 double jE = cene + nwe + noe + wee + swe + soe;
1226 double jEt = cenet + nwet + noet + weet + swet + soet;
1236 }
else {
return false; }
1244 if (neid==999 || nid==999 || seid==999 || sid==999 || eid==999 ) {
1248 double cenet =
m_Regions.at(crgn).SumEt();
1255 if ( cenet > neet && cenet > noet &&
1256 cenet >= eaet && cenet >= soet &&
1260 double cene =
m_Regions.at(crgn).SumE();
1269 double jE = cene + nee + noe + eae + see + soe;
1270 double jEt = cenet + neet + noet + eaet + seet + soet;
1279 }
else {
return false; }
1284 if (nwid==999 || neid==999 || nid==999 || swid==999 || seid==999 || sid==999 || wid==999 ||
1294 double cenet =
m_Regions.at(crgn).SumEt();
1304 if ( cenet > nwet && cenet > noet &&
1305 cenet > neet && cenet >= eaet &&
1306 cenet > weet && cenet >= soet &&
1307 cenet >= swet && cenet >= seet )
1310 double cene =
m_Regions.at(crgn).SumE();
1322 double jE = cene + nwe + noe + nee + wee + eae + swe + soe + see;
1323 double jEt = cenet + nwet + noet + neet + weet + eaet + swet + soet + seet;
1333 }
else {
return false; }
1342 for (
int j=1;
j<=72;
j++) {
1343 for (
int i=-28;
i<=28;
i++) {
1351 std::cout<<
"---------------------------------------------------------------------------"<<std::endl;
1352 std::cout<<
"Region: "<<iRgn<<
" | "<<RgnEtaPhi.first<<
", "<<RgnEtaPhi.second*180./3.141<<std::endl;
1353 std::cout<<
" - "<<iRgnEtaPhi.first<<
", "<<iRgnEtaPhi.second<<std::endl;
1354 std::cout<<
" - "<<iRgnEtaPhi2.first<<
", "<<iRgnEtaPhi2.second<<std::endl;
1373 if ((cRgn%22)<4 || (cRgn%22)>17)
return false;
1376 int shower_shape = 0;
1377 int et_isolation = 0;
1378 unsigned int iso_count = 0;
1394 if((cRgn%22)==4 || (cRgn%22)==17 ) {
1397 if(
m_Regions[neid].SumEt() > iso_threshold){
1399 if (
m_Regions[neid].GetTauBit()) iso_count++;
1401 if(
m_Regions[nid].SumEt() > iso_threshold){
1403 if (
m_Regions[nid].GetTauBit()) iso_count++;
1405 if(
m_Regions[eid].SumEt() > iso_threshold){
1407 if (
m_Regions[eid].GetTauBit()) iso_count++;
1409 if(
m_Regions[seid].SumEt() > iso_threshold){
1411 if (
m_Regions[seid].GetTauBit()) iso_count++;
1413 if(
m_Regions[sid].SumEt() > iso_threshold){
1415 if (
m_Regions[sid].GetTauBit()) iso_count++;
1420 if ((cRgn%22)==17) {
1421 if(
m_Regions[nwid].SumEt() > iso_threshold){
1423 if (
m_Regions[nwid].GetTauBit()) iso_count++;
1425 if(
m_Regions[nid].SumEt() > iso_threshold){
1427 if (
m_Regions[nid].GetTauBit()) iso_count++;
1429 if(
m_Regions[wid].SumEt() > iso_threshold){
1431 if (
m_Regions[wid].GetTauBit()) iso_count++;
1433 if(
m_Regions[swid].SumEt() > iso_threshold){
1435 if (
m_Regions[swid].GetTauBit()) iso_count++;
1437 if(
m_Regions[sid].SumEt() > iso_threshold){
1439 if (
m_Regions[sid].GetTauBit()) iso_count++;
1445 if ( (cRgn%22)>4 && (cRgn%22)<17){
1446 if (nwid==999 || neid==999 || nid==999 || swid==999 || seid==999 || sid==999 || wid==999 ||
1451 if(
m_Regions[neid].SumEt() > iso_threshold){
1453 if (
m_Regions[neid].GetTauBit()) iso_count++;
1455 if(
m_Regions[nid].SumEt() > iso_threshold){
1457 if (
m_Regions[nid].GetTauBit()) iso_count++;
1459 if(
m_Regions[eid].SumEt() > iso_threshold){
1461 if (
m_Regions[eid].GetTauBit()) iso_count++;
1463 if(
m_Regions[seid].SumEt() > iso_threshold){
1465 if (
m_Regions[seid].GetTauBit()) iso_count++;
1467 if(
m_Regions[sid].SumEt() > iso_threshold){
1469 if (
m_Regions[sid].GetTauBit()) iso_count++;
1471 if(
m_Regions[nwid].SumEt() > iso_threshold){
1473 if (
m_Regions[nwid].GetTauBit()) iso_count++;
1475 if(
m_Regions[wid].SumEt() > iso_threshold){
1477 if (
m_Regions[wid].GetTauBit()) iso_count++;
1479 if(
m_Regions[swid].SumEt() > iso_threshold){
1481 if (
m_Regions[swid].GetTauBit()) iso_count++;
1486 if (iso_count >= 2 ){
1494 if (et_isolation == 1)
1495 m_Regions[cRgn].BitInfo.setIsolationVeto (
true);
1497 m_Regions[cRgn].BitInfo.setIsolationVeto (
false);
1500 if (et_isolation == 1 || shower_shape == 1)
return false;
T getParameter(std::string const &) const
double corrJetEt(double et, double eta)
l1extra::L1JetParticleCollection m_TauJets
std::pair< int, int > GetTowerNEEtaPhi(int ieta, int iphi)
std::pair< int, int > GetTowerNWEtaPhi(int ieta, int iphi)
std::pair< int, int > GetTowerSEEtaPhi(int ieta, int iphi)
FastL1BitInfoCollection m_BitInfos
FastL1GlobalAlgo(const edm::ParameterSet &)
virtual double et() const =0
transverse energy
double QuietRegionThreshold
std::vector< edm::InputTag > EmInputs
static FastL1RegionMap * getFastL1RegionMap()
int getRegionIndex(int ieta, int iphi)
std::pair< double, double > getRegionCenterEtaPhi(int iRgn)
Sin< T >::type sin(const T &t)
std::vector< CaloTower >::const_iterator const_iterator
Geom::Theta< T > theta() const
std::vector< FastL1Region > m_Regions
int isEMCand(CaloTowerDetId cid, l1extra::L1EmParticle *p, const edm::Event &e)
int getRegionTowerIndex(std::pair< int, int > iEtaPhi)
std::pair< int, int > GetTowerSWEtaPhi(int ieta, int iphi)
void FillEgammas(edm::Event const &)
l1extra::L1JetParticleCollection m_CenJets
std::pair< int, int > GetTowerWestEtaPhi(int ieta, int iphi)
void FillEgammasTP(edm::Event const &)
static std::string const input
void CaloTowersDump(edm::Event const &e)
std::pair< int, int > GetTowerSouthEtaPhi(int ieta, int iphi)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
double CrystalEBThreshold
double JetSeedEtThreshold
Cos< T >::type cos(const T &t)
bool isMaxEtRgn_Window33(int rgnid)
int iphi() const
get the tower iphi
std::pair< T, T > etaphi(T x, T y, T z)
Abs< T >::type abs(const T &t)
double m_hcaluncomp[33][256]
edm::InputTag HcalTPInput
int convertFromECal_to_HCal_iphi(int iphi_ecal)
bool TauIsolation(int rgnid)
double GCTEnergyTrunc(double et, double LSB=1., bool doEM=false)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::InputTag EcalTPInput
l1extra::L1EtMissParticleCollection m_METs
bool greaterEt(const reco::Candidate &a, const reco::Candidate &b)
void FillL1RegionsTP(edm::Event const &e, const edm::EventSetup &c)
const_iterator end() const
double corrEmEt(double et, int eta)
void FillL1Regions(edm::Event const &e, const edm::EventSetup &c)
double hcaletValue(const int ieta, const int compET)
T const * product() const
l1extra::L1EmParticleCollection m_isoEgammas
std::pair< int, int > GetTowerNorthEtaPhi(int ieta, int iphi)
l1extra::L1EmParticleCollection m_Egammas
void addJet(int rgnId, bool taubit)
double CrystalEEThreshold
l1extra::L1JetParticleCollection m_ForJets
double RCTEnergyTrunc(double et, double Resol=1., double thres=1024.)
std::pair< int, int > GetTowerEastEtaPhi(int ieta, int iphi)
std::string fullPath() const
int ieta() const
get the tower ieta
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::pair< int, int > getRegionEtaPhiIndex(std::pair< int, int > iEtaPhi)
const_iterator begin() const