Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-01 01:02:08

0001 #include "L1Trigger/HardwareValidation/interface/L1ComparatorRun2.h"
0002 
0003 using namespace std;
0004 using namespace edm;
0005 using namespace l1t;
0006 
0007 L1ComparatorRun2::L1ComparatorRun2(const ParameterSet& ps) {
0008   produces<L1DataEmulResultBxCollection>();
0009 
0010   JetDataToken_ = consumes<JetBxCollection>(ps.getParameter<InputTag>("JetData"));
0011   JetEmulToken_ = consumes<JetBxCollection>(ps.getParameter<InputTag>("JetEmul"));
0012   EGammaDataToken_ = consumes<EGammaBxCollection>(ps.getParameter<InputTag>("EGammaData"));
0013   EGammaEmulToken_ = consumes<EGammaBxCollection>(ps.getParameter<InputTag>("EGammaEmul"));
0014   TauDataToken_ = consumes<TauBxCollection>(ps.getParameter<InputTag>("TauData"));
0015   TauEmulToken_ = consumes<TauBxCollection>(ps.getParameter<InputTag>("TauEmul"));
0016   EtSumDataToken_ = consumes<EtSumBxCollection>(ps.getParameter<InputTag>("EtSumData"));
0017   EtSumEmulToken_ = consumes<EtSumBxCollection>(ps.getParameter<InputTag>("EtSumEmul"));
0018   CaloTowerDataToken_ = consumes<CaloTowerBxCollection>(ps.getParameter<InputTag>("CaloTowerData"));
0019   CaloTowerEmulToken_ = consumes<CaloTowerBxCollection>(ps.getParameter<InputTag>("CaloTowerEmul"));
0020   bxMax_ = ps.getParameter<int>("bxMax");
0021   bxMin_ = ps.getParameter<int>("bxMin");
0022   doLayer2_ = ps.getParameter<bool>("doLayer2");
0023   doLayer1_ = ps.getParameter<bool>("doLayer1");
0024 }
0025 
0026 L1ComparatorRun2::~L1ComparatorRun2() {}
0027 
0028 void L1ComparatorRun2::produce(StreamID, Event& iEvent, const EventSetup& iSetup) const {
0029   unique_ptr<L1DataEmulResultBxCollection> RESULT(new L1DataEmulResultBxCollection);
0030 
0031   if (doLayer2_) {
0032     for (int bx = bxMin_; bx <= bxMax_; bx++) {
0033       Handle<JetBxCollection> jet_data;
0034       Handle<JetBxCollection> jet_emul;
0035 
0036       iEvent.getByToken(JetDataToken_, jet_data);
0037       iEvent.getByToken(JetEmulToken_, jet_emul);
0038 
0039       int size = (jet_data->size(bx) > jet_emul->size(bx)) ? jet_data->size(bx) : jet_emul->size(bx);
0040 
0041       int dataonly = size - jet_emul->size(bx);
0042       int emulonly = size - jet_data->size(bx);
0043 
0044       int ptgood = 0;
0045       int locgood = 0;
0046       int good = 0;
0047       int compared = 0;
0048 
0049       for (JetBxCollection::const_iterator itd = jet_data->begin(bx); itd != jet_data->end(bx); itd++) {
0050         for (JetBxCollection::const_iterator ite = jet_emul->begin(bx); ite != jet_emul->end(bx); ite++) {
0051           if (distance(jet_data->begin(bx), itd) == distance(jet_emul->begin(bx), ite)) {
0052             compared += 1;
0053             if (itd->hwPt() == ite->hwPt())
0054               ptgood += 1;
0055             if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
0056               locgood += 1;
0057             if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
0058               good += 1;
0059           }
0060         }
0061       }
0062 
0063       int ptbad = compared - ptgood;
0064       int locbad = compared - locgood;
0065       int bad = size - good;
0066 
0067       bool flag = (bad == 0) ? true : false;
0068 
0069       L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "JetBxCollection");
0070 
0071       RESULT->push_back(bx, result);
0072     }
0073   }
0074 
0075   Handle<EGammaBxCollection> eg_data;
0076   Handle<EGammaBxCollection> eg_emul;
0077 
0078   iEvent.getByToken(EGammaDataToken_, eg_data);
0079   iEvent.getByToken(EGammaEmulToken_, eg_emul);
0080 
0081   if (doLayer2_) {
0082     for (int bx = bxMin_; bx <= bxMax_; bx++) {
0083       int size = (eg_data->size(bx) > eg_emul->size(bx)) ? eg_data->size(bx) : eg_emul->size(bx);
0084 
0085       int dataonly = size - eg_emul->size(bx);
0086       int emulonly = size - eg_data->size(bx);
0087 
0088       int ptgood = 0;
0089       int locgood = 0;
0090       int good = 0;
0091       int compared = 0;
0092 
0093       for (EGammaBxCollection::const_iterator itd = eg_data->begin(bx); itd != eg_data->end(bx); itd++) {
0094         for (EGammaBxCollection::const_iterator ite = eg_emul->begin(bx); ite != eg_emul->end(bx); ite++) {
0095           if (distance(eg_data->begin(bx), itd) == distance(eg_emul->begin(bx), ite)) {
0096             compared += 1;
0097             if (itd->hwPt() == ite->hwPt())
0098               ptgood += 1;
0099             if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
0100               locgood += 1;
0101             if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
0102                 itd->hwIso() == ite->hwIso())
0103               good += 1;
0104           }
0105         }
0106       }
0107 
0108       int ptbad = compared - ptgood;
0109       int locbad = compared - locgood;
0110       int bad = size - good;
0111 
0112       bool flag = (bad == 0) ? true : false;
0113 
0114       L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "EGammaBxCollection");
0115 
0116       RESULT->push_back(bx, result);
0117     }
0118   }
0119 
0120   Handle<TauBxCollection> tau_data;
0121   Handle<TauBxCollection> tau_emul;
0122 
0123   iEvent.getByToken(TauDataToken_, tau_data);
0124   iEvent.getByToken(TauEmulToken_, tau_emul);
0125 
0126   if (doLayer2_) {
0127     for (int bx = bxMin_; bx <= bxMax_; bx++) {
0128       int size = (tau_data->size(bx) > tau_emul->size(bx)) ? tau_data->size(bx) : tau_emul->size(bx);
0129 
0130       int dataonly = size - tau_emul->size(bx);
0131       int emulonly = size - tau_data->size(bx);
0132 
0133       int ptgood = 0;
0134       int locgood = 0;
0135       int good = 0;
0136       int compared = 0;
0137 
0138       for (TauBxCollection::const_iterator itd = tau_data->begin(bx); itd != tau_data->end(bx); itd++) {
0139         for (TauBxCollection::const_iterator ite = tau_emul->begin(bx); ite != tau_emul->end(bx); ite++) {
0140           if (distance(tau_data->begin(bx), itd) == distance(tau_emul->begin(bx), ite)) {
0141             compared += 1;
0142             if (itd->hwPt() == ite->hwPt())
0143               ptgood += 1;
0144             if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
0145               locgood += 1;
0146             if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
0147                 itd->hwIso() == ite->hwIso())
0148               good += 1;
0149           }
0150         }
0151       }
0152 
0153       int ptbad = compared - ptgood;
0154       int locbad = compared - locgood;
0155       int bad = size - good;
0156 
0157       bool flag = (bad == 0) ? true : false;
0158 
0159       L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "TauBxCollection");
0160 
0161       RESULT->push_back(bx, result);
0162     }
0163   }
0164 
0165   Handle<EtSumBxCollection> et_data;
0166   Handle<EtSumBxCollection> et_emul;
0167 
0168   iEvent.getByToken(EtSumDataToken_, et_data);
0169   iEvent.getByToken(EtSumEmulToken_, et_emul);
0170 
0171   if (doLayer2_) {
0172     for (int bx = bxMin_; bx <= bxMax_; bx++) {
0173       int size = (et_data->size(bx) > et_emul->size(bx)) ? et_data->size(bx) : et_emul->size(bx);
0174 
0175       int dataonly = size - et_emul->size(bx);
0176       int emulonly = size - et_data->size(bx);
0177 
0178       int ptgood = 0;
0179       int locgood = 0;
0180       int good = 0;
0181       int compared = 0;
0182 
0183       for (EtSumBxCollection::const_iterator itd = et_data->begin(bx); itd != et_data->end(bx); itd++) {
0184         for (EtSumBxCollection::const_iterator ite = et_emul->begin(bx); ite != et_emul->end(bx); ite++) {
0185           if (distance(et_data->begin(bx), itd) == distance(et_emul->begin(bx), ite)) {
0186             compared += 1;
0187             if (itd->hwPt() == ite->hwPt())
0188               ptgood += 1;
0189             if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
0190               locgood += 1;
0191             if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
0192                 itd->getType() == ite->getType())
0193               good += 1;
0194           }
0195         }
0196       }
0197 
0198       int ptbad = compared - ptgood;
0199       int locbad = compared - locgood;
0200       int bad = size - good;
0201 
0202       bool flag = (bad == 0) ? true : false;
0203 
0204       L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, 0, 0, "EtSumBxCollection");
0205 
0206       RESULT->push_back(bx, result);
0207     }
0208   }
0209 
0210   Handle<CaloTowerBxCollection> tower_data;
0211   Handle<CaloTowerBxCollection> tower_emul;
0212 
0213   iEvent.getByToken(CaloTowerDataToken_, tower_data);
0214   iEvent.getByToken(CaloTowerEmulToken_, tower_emul);
0215 
0216   if (doLayer1_) {
0217     for (int bx = bxMin_; bx <= bxMax_; bx++) {
0218       int size = (tower_data->size(bx) > tower_emul->size(bx)) ? tower_data->size(bx) : tower_emul->size(bx);
0219 
0220       int dataonly = size - tower_emul->size(bx);
0221       int emulonly = size - tower_data->size(bx);
0222 
0223       int ptgood = 0;
0224       int locgood = 0;
0225       int good = 0;
0226       int compared = 0;
0227       int hcalgood = 0;
0228       int ecalgood = 0;
0229 
0230       for (CaloTowerBxCollection::const_iterator itd = tower_data->begin(bx); itd != tower_data->end(bx); itd++) {
0231         for (CaloTowerBxCollection::const_iterator ite = tower_emul->begin(bx); ite != tower_emul->end(bx); ite++) {
0232           if (distance(tower_data->begin(bx), itd) == distance(tower_emul->begin(bx), ite)) {
0233             compared += 1;
0234             if (itd->hwPt() == ite->hwPt())
0235               ptgood += 1;
0236             if (itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi())
0237               locgood += 1;
0238             if (itd->hwEtHad() == ite->hwEtHad())
0239               hcalgood += 1;
0240             if (itd->hwEtEm() == ite->hwEtEm())
0241               ecalgood += 1;
0242             if (itd->hwPt() == ite->hwPt() && itd->hwEta() == ite->hwEta() && itd->hwPhi() == ite->hwPhi() &&
0243                 itd->hwEtEm() == ite->hwEtEm() && itd->hwEtHad() == ite->hwEtHad())
0244               good += 1;
0245           }
0246         }
0247       }
0248 
0249       int ptbad = compared - ptgood;
0250       int locbad = compared - locgood;
0251       int bad = size - good;
0252       int hcalbad = compared - hcalgood;
0253       int ecalbad = compared - ecalgood;
0254 
0255       bool flag = (bad == 0) ? true : false;
0256 
0257       L1DataEmulResult result(flag, ptbad, locbad, bad, dataonly, emulonly, hcalbad, ecalbad, "CaloTowerBxCollection");
0258 
0259       RESULT->push_back(bx, result);
0260     }
0261   }
0262 
0263   iEvent.put(std::move(RESULT));
0264 }