1 #ifndef L1Trigger_L1TCalorimeter_L1TStage2CaloLayer2Comp 2 #define L1Trigger_L1TCalorimeter_L1TStage2CaloLayer2Comp 205 void accuSort(std::vector<l1t::Jet> *
jets);
206 void accuSort(std::vector<l1t::Tau> *
taus);
207 void accuSort(std::vector<l1t::EGamma> *egs);
208 void accuSort(std::vector<l1t::L1Candidate> & jets);
210 void dumpEventToFile();
237 const unsigned int currBx = 0;
239 bool dumpTowers =
false;
240 bool dumpWholeEvent =
false;
245 ps.getParameter<
edm::InputTag>(
246 "calol2JetCollectionData"))),
248 ps.getParameter<
edm::InputTag>(
249 "calol2JetCollectionEmul"))),
251 ps.getParameter<
edm::InputTag>(
252 "calol2EGammaCollectionData"))),
254 ps.getParameter<
edm::InputTag>(
255 "calol2EGammaCollectionEmul"))),
257 ps.getParameter<
edm::InputTag>(
258 "calol2TauCollectionData"))),
260 ps.getParameter<
edm::InputTag>(
261 "calol2TauCollectionEmul"))),
263 ps.getParameter<
edm::InputTag>(
264 "calol2EtSumCollectionData"))),
266 ps.getParameter<
edm::InputTag>(
267 "calol2EtSumCollectionEmul"))),
269 ps.getParameter<
edm::InputTag>(
270 "calol2CaloTowerCollectionData"))),
272 ps.getParameter<
edm::InputTag>(
273 "calol2CaloTowerCollectionEmul")))
275 produces<l1t::JetBxCollection> (
"dataJet").setBranchAlias(
"dataJets");
276 produces<l1t::JetBxCollection> (
"emulJet").setBranchAlias(
"emulJets");
277 produces<l1t::EGammaBxCollection> (
"dataEg").setBranchAlias(
"dataEgs");
278 produces<l1t::EGammaBxCollection> (
"emulEg").setBranchAlias(
"emulEgs");
279 produces<l1t::TauBxCollection> (
"dataTau").setBranchAlias(
"dataTaus");
280 produces<l1t::TauBxCollection> (
"emulTau").setBranchAlias(
"emulTaus");
281 produces<l1t::EtSumBxCollection> (
"dataEtSum").setBranchAlias(
"dataEtSums");
282 produces<l1t::EtSumBxCollection> (
"emulEtSum").setBranchAlias(
"emulEtSums");
283 produces<l1t::CaloTowerBxCollection> (
"dataCaloTower").setBranchAlias(
"dataCaloTowers");
284 produces<l1t::CaloTowerBxCollection> (
"emulCaloTower").setBranchAlias(
"emulCaloTowers");
294 bool eventGood =
true;
309 <<
"Processing event " << e.
id() << std::endl;
313 <<
"Empty caloTowers. Skipping event " << std::endl;
344 <<
"Bad event! " << std::endl;
354 bool eventGood =
true;
356 std::vector<l1t::Jet> *
jets =
new std::vector<l1t::Jet>;
357 std::vector<l1t::Jet>::iterator dataIt;
365 jets->emplace_back(*dataBxIt);
373 dataIt = jets->begin();
379 <<
"Jet collection size difference: " 380 <<
"data = " << jets->size()
386 if (dataIt != jets->end() ||
398 if (dataIt->hwPt() != emulBxIt->hwPt()) {
404 if (dataIt->hwPhi() != emulBxIt->hwPhi()){
409 if (dataIt->hwEta() != emulBxIt->hwEta()) {
414 if(etGood && !posGood){
417 for(emulItCheckSort = emulCol->
begin(
currBx) ; emulItCheckSort != emulCol->
end(
currBx) ; ++emulItCheckSort) {
418 for (dataItCheckSort = jets->begin(); dataItCheckSort != jets->end(); ++dataItCheckSort){
420 if(dataItCheckSort->hwEta() > 0) ++nPos;
421 if(dataItCheckSort->hwEta() < 0) ++nNeg;
423 if(dataIt->hwPt() == emulItCheckSort->hwPt()
424 && dataIt->hwPhi() == emulItCheckSort->hwPhi()
425 && dataIt->hwEta() == emulItCheckSort->hwEta())
431 if(etGood && dataIt->hwEta() > 0 && ((
distance(dataIt, jets->end())-nNeg) < 5))
433 if(etGood && dataIt->hwEta() < 0 && (
distance(dataIt, jets->end()) < 5))
436 if(!posGood) eventGood =
false;
439 if (!etGood || !posGood) {
441 <<
"Jet Problem (data emul): " 442 <<
"\tEt = " << dataIt->hwPt() <<
" " << emulBxIt->hwPt()
443 <<
"\teta = " << dataIt->hwEta() <<
" " << emulBxIt->hwEta()
444 <<
"\tphi = " << dataIt->hwPhi() <<
" " << emulBxIt->hwPhi()
452 if (dataIt == jets->end() ||
457 if (!jets->empty() || emulCol->
size(
currBx) != 0)
471 bool eventGood =
true;
473 std::vector<l1t::EGamma> *egs =
new std::vector<l1t::EGamma>;
474 std::vector<l1t::EGamma>::iterator dataIt;
482 egs->emplace_back(*dataBxIt);
489 dataIt = egs->begin();
495 <<
"EG collection size difference: " 496 <<
"data = " << egs->size()
503 if (dataIt != egs->end() ||
515 if (dataIt->hwPt() != emulBxIt->hwPt()) {
521 if (dataIt->hwPhi() != emulBxIt->hwPhi()) {
526 if (dataIt->hwEta() != emulBxIt->hwEta()) {
531 if(etGood && !posGood){
534 for(emulItCheckSort = emulCol->
begin(
currBx); emulItCheckSort != emulCol->
end(
currBx); ++emulItCheckSort) {
535 for (dataItCheckSort = egs->begin(); dataItCheckSort != egs->end(); ++dataItCheckSort){
537 if(dataItCheckSort->hwEta() > 0) ++nPos;
538 if(dataItCheckSort->hwEta() < 0) ++nNeg;
540 if(dataIt->hwPt() == emulItCheckSort->hwPt()
541 && dataIt->hwPhi() == emulItCheckSort->hwPhi()
542 && dataIt->hwEta() == emulItCheckSort->hwEta())
548 if(etGood && dataIt->hwEta() > 0 && ((
distance(dataIt, egs->end())-nNeg) < 5))
550 if(etGood && dataIt->hwEta() < 0 && (
distance(dataIt, egs->end()) < 5))
553 if(!posGood) eventGood =
false;
556 if (!posGood || !etGood) {
558 <<
"EG Problem (data emul): " 559 <<
"\tEt = " << dataIt->hwPt() <<
" " << emulBxIt->hwPt()
560 <<
"\teta = " << dataIt->hwEta() <<
" " << emulBxIt->hwEta()
561 <<
"\tphi = " << dataIt->hwPhi() <<
" " << emulBxIt->hwPhi()
569 if (dataIt == egs->end() ||
574 if (!egs->empty() || emulCol->
size(
currBx) != 0)
588 bool eventGood =
true;
590 std::vector<l1t::Tau> *
taus =
new std::vector<l1t::Tau>;
591 std::vector<l1t::Tau>::iterator dataIt;
599 taus->emplace_back(*dataBxIt);
606 dataIt = taus->begin();
612 <<
"Tau collection size difference: " 613 <<
"data = " << taus->size()
620 if (dataIt != taus->end() ||
632 if (dataIt->hwPt() != emulBxIt->hwPt()) {
638 if (dataIt->hwPhi() != emulBxIt->hwPhi()) {
643 if (dataIt->hwEta() != emulBxIt->hwEta()) {
648 if(etGood && !posGood){
651 for(emulItCheckSort = emulCol->
begin(
currBx); emulItCheckSort != emulCol->
end(
currBx); ++emulItCheckSort) {
652 for (dataItCheckSort = taus->begin(); dataItCheckSort != taus->end(); ++dataItCheckSort){
654 if(dataItCheckSort->hwEta() > 0) ++nPos;
655 if(dataItCheckSort->hwEta() < 0) ++nNeg;
657 if(dataIt->hwPt() == emulItCheckSort->hwPt()
658 && dataIt->hwPhi() == emulItCheckSort->hwPhi()
659 && dataIt->hwEta() == emulItCheckSort->hwEta())
665 if(etGood && dataIt->hwEta() > 0 && ((
distance(dataIt, taus->end())-nNeg) < 5))
667 if(etGood && dataIt->hwEta() < 0 && (
distance(dataIt, taus->end()) < 5))
670 if(!posGood) eventGood =
false;
673 if (!posGood || !etGood) {
675 <<
"Tau Problem (data emul): " 676 <<
"\tEt = " << dataIt->hwPt() <<
" " << emulBxIt->hwPt()
677 <<
"\teta = " << dataIt->hwEta() <<
" " << emulBxIt->hwEta()
678 <<
"\tphi = " << dataIt->hwPhi() <<
" " << emulBxIt->hwPhi()
686 if (dataIt == taus->end() ||
691 if (!taus->empty() || emulCol->
size(
currBx) != 0)
705 bool eventGood =
true;
715 <<
"EtSum collection size difference: " 732 <<
"EtSum type problem (data emul): " 737 dataEt = dataSum.
hwPt();
738 emulEt = emulSum.
hwPt();
740 if (dataEt != emulEt) {
743 <<
"EtSum problem (data emul):\tType = " << emulSum.
getType()
744 <<
"\tEt = " << dataEt <<
" " << emulEt
758 l1t::Jet tempJet (emptyP4, 0, 0, 0, 0);
759 std::vector< std::vector<l1t::Jet> > jetEtaPos( 41 , std::vector<l1t::Jet>(18, tempJet));
760 std::vector< std::vector<l1t::Jet> > jetEtaNeg( 41 , std::vector<l1t::Jet>(18, tempJet));
762 for (
unsigned int iJet = 0; iJet < jets->size(); iJet++) {
763 if (jets->at(iJet).hwEta() > 0) jetEtaPos.at(jets->at(iJet).hwEta()-1).at((jets->at(iJet).hwPhi()-1)/4) = jets->at(iJet);
764 else jetEtaNeg.at(-(jets->at(iJet).hwEta()+1)).at((jets->at(iJet).hwPhi()-1)/4) = jets->at(iJet);
769 std::vector<l1t::Jet> accumEtaPos;
770 std::vector<l1t::Jet> accumEtaNeg;
772 for(
int ieta = 0 ; ieta < 41 ; ++ieta) {
774 std::vector<l1t::Jet>::iterator start_, end_;
775 start_ = jetEtaPos.at(ieta).begin();
776 end_ = jetEtaPos.at(ieta).end();
777 BitonicSort<l1t::Jet>(
down, start_, end_);
778 etaPosSorter.
Merge( jetEtaPos.at(ieta) , accumEtaPos );
781 start_ = jetEtaNeg.at(ieta).begin();
782 end_ = jetEtaNeg.at(ieta).end();
783 BitonicSort<l1t::Jet>(
down, start_, end_);
784 etaNegSorter.
Merge( jetEtaNeg.at(ieta) , accumEtaNeg );
789 if(accumEtaPos.at(6).hwPt()==accumEtaPos.at(5).hwPt() && accumEtaPos.at(6).hwEta()==accumEtaPos.at(5).hwEta()
790 && accumEtaPos.at(6).hwPhi() > accumEtaPos.at(5).hwPhi()){
791 accumEtaPos.at(5)=accumEtaPos.at(6);
793 if(accumEtaNeg.at(6).hwPt()==accumEtaNeg.at(5).hwPt() && accumEtaNeg.at(6).hwEta()==accumEtaNeg.at(5).hwEta()
794 && accumEtaNeg.at(6).hwPhi() > accumEtaNeg.at(5).hwPhi()){
795 accumEtaNeg.at(5)=accumEtaNeg.at(6);
799 accumEtaPos.resize(6);
800 accumEtaNeg.resize(6);
804 for (
l1t::Jet accjet : accumEtaPos) {
805 if (accjet.hwPt() > 0) jets->push_back(accjet);
807 for (
l1t::Jet accjet : accumEtaNeg) {
808 if (accjet.hwPt() > 0) jets->push_back(accjet);
817 std::vector< std::vector<l1t::EGamma> > jetEtaPos( 41 , std::vector<l1t::EGamma>(18, tempEGamma));
818 std::vector< std::vector<l1t::EGamma> > jetEtaNeg( 41 , std::vector<l1t::EGamma>(18, tempEGamma));
820 for (
unsigned int iEGamma = 0; iEGamma < egs->size(); iEGamma++) {
821 if (egs->at(iEGamma).hwEta() > 0) jetEtaPos.at(egs->at(iEGamma).hwEta()-1).at((egs->at(iEGamma).hwPhi()-1)/4) = egs->at(iEGamma);
822 else jetEtaNeg.at(-(egs->at(iEGamma).hwEta()+1)).at((egs->at(iEGamma).hwPhi()-1)/4) = egs->at(iEGamma);
827 std::vector<l1t::EGamma> accumEtaPos;
828 std::vector<l1t::EGamma> accumEtaNeg;
830 for(
int ieta = 0 ; ieta < 41 ; ++ieta) {
832 std::vector<l1t::EGamma>::iterator start_, end_;
833 start_ = jetEtaPos.at(ieta).begin();
834 end_ = jetEtaPos.at(ieta).end();
835 BitonicSort<l1t::EGamma>(
down, start_, end_);
836 etaPosSorter.
Merge( jetEtaPos.at(ieta) , accumEtaPos );
839 start_ = jetEtaNeg.at(ieta).begin();
840 end_ = jetEtaNeg.at(ieta).end();
841 BitonicSort<l1t::EGamma>(
down, start_, end_);
842 etaNegSorter.
Merge( jetEtaNeg.at(ieta) , accumEtaNeg );
847 if(accumEtaPos.at(6).hwPt()==accumEtaPos.at(5).hwPt() && accumEtaPos.at(6).hwEta()==accumEtaPos.at(5).hwEta()
848 && accumEtaPos.at(6).hwPhi() > accumEtaPos.at(5).hwPhi()){
849 accumEtaPos.at(5)=accumEtaPos.at(6);
851 if(accumEtaNeg.at(6).hwPt()==accumEtaNeg.at(5).hwPt() && accumEtaNeg.at(6).hwEta()==accumEtaNeg.at(5).hwEta()
852 && accumEtaNeg.at(6).hwPhi() > accumEtaNeg.at(5).hwPhi()){
853 accumEtaNeg.at(5)=accumEtaNeg.at(6);
857 accumEtaPos.resize(6);
858 accumEtaNeg.resize(6);
863 if (accjet.hwPt() > 0) egs->push_back(accjet);
866 if (accjet.hwPt() > 0) egs->push_back(accjet);
875 l1t::Tau tempTau (emptyP4, 0, 0, 0, 0);
876 std::vector< std::vector<l1t::Tau> > jetEtaPos( 41 , std::vector<l1t::Tau>(18, tempTau));
877 std::vector< std::vector<l1t::Tau> > jetEtaNeg( 41 , std::vector<l1t::Tau>(18, tempTau));
879 for (
unsigned int iTau = 0; iTau < taus->size(); iTau++) {
880 if (taus->at(iTau).hwEta() > 0) jetEtaPos.at(taus->at(iTau).hwEta()-1).at((taus->at(iTau).hwPhi()-1)/4) = taus->at(iTau);
881 else jetEtaNeg.at(-(taus->at(iTau).hwEta()+1)).at((taus->at(iTau).hwPhi()-1)/4) = taus->at(iTau);
886 std::vector<l1t::Tau> accumEtaPos;
887 std::vector<l1t::Tau> accumEtaNeg;
889 for(
int ieta = 0 ; ieta < 41 ; ++ieta) {
891 std::vector<l1t::Tau>::iterator start_, end_;
892 start_ = jetEtaPos.at(ieta).begin();
893 end_ = jetEtaPos.at(ieta).end();
894 BitonicSort<l1t::Tau>(
down, start_, end_);
895 etaPosSorter.
Merge( jetEtaPos.at(ieta) , accumEtaPos );
898 start_ = jetEtaNeg.at(ieta).begin();
899 end_ = jetEtaNeg.at(ieta).end();
900 BitonicSort<l1t::Tau>(
down, start_, end_);
901 etaNegSorter.
Merge( jetEtaNeg.at(ieta) , accumEtaNeg );
906 if(accumEtaPos.at(6).hwPt()==accumEtaPos.at(5).hwPt() && accumEtaPos.at(6).hwEta()==accumEtaPos.at(5).hwEta()
907 && accumEtaPos.at(6).hwPhi() > accumEtaPos.at(5).hwPhi()){
908 accumEtaPos.at(5)=accumEtaPos.at(6);
910 if(accumEtaNeg.at(6).hwPt()==accumEtaNeg.at(5).hwPt() && accumEtaNeg.at(6).hwEta()==accumEtaNeg.at(5).hwEta()
911 && accumEtaNeg.at(6).hwPhi() > accumEtaNeg.at(5).hwPhi()){
912 accumEtaNeg.at(5)=accumEtaNeg.at(6);
916 accumEtaPos.resize(6);
917 accumEtaNeg.resize(6);
921 for (
l1t::Tau accjet : accumEtaPos) {
922 if (accjet.hwPt() > 0) taus->push_back(accjet);
924 for (
l1t::Tau accjet : accumEtaNeg) {
925 if (accjet.hwPt() > 0) taus->push_back(accjet);
932 <<
"==== Problems found, dumping full event contents ====" << std::endl;
935 <<
"==== Event contents in data: ====" << std::endl;
939 <<
"==== Towers: ====" << std::endl;
943 <<
"Tower: Et = " << tower->hwPt() <<
", " 944 <<
"eta = " << tower->hwEta() <<
", " 945 <<
"phi = " << tower->hwPhi() << std::endl;
949 <<
"==== Jets: ====" << std::endl;
952 <<
"Jet: Et = " <<
jet->hwPt() <<
", " 953 <<
"eta = " <<
jet->hwEta() <<
", " 954 <<
"phi = " <<
jet->hwPhi() << std::endl;
957 <<
"==== EGs: ====" << std::endl;
960 <<
"EG: Et = " << eg->hwPt() <<
", " 961 <<
"eta = " << eg->hwEta() <<
", " 962 <<
"phi = " << eg->hwPhi() << std::endl;
965 <<
"==== Taus: ====" << std::endl;
968 <<
"Tau: Et = " <<
tau->hwPt() <<
", " 969 <<
"eta = " <<
tau->hwEta() <<
", " 970 <<
"phi = " <<
tau->hwPhi() << std::endl;
973 <<
"==== Sums: ====" << std::endl;
976 <<
"Sum: type = " << sum->getType() <<
" " 977 <<
"Et = " << sum->hwPt() <<
", " 978 <<
"eta = " << sum->hwEta() <<
", " 979 <<
"phi = " << sum->hwPhi() << std::endl;
982 <<
"==== Event contents in emul: ====" << std::endl;
986 <<
"==== Towers: ====" << std::endl;
990 <<
"Tower: Et = " << tower->hwPt() <<
", " 991 <<
"eta = " << tower->hwEta() <<
", " 992 <<
"phi = " << tower->hwPhi() << std::endl;
996 <<
"==== Jets: ====" << std::endl;
999 <<
"Jet: Et = " <<
jet->hwPt() <<
", " 1000 <<
"eta = " <<
jet->hwEta() <<
", " 1001 <<
"phi = " <<
jet->hwPhi() << std::endl;
1004 <<
"==== EGs: ====" << std::endl;
1007 <<
"EG: Et = " << eg->hwPt() <<
", " 1008 <<
"eta = " << eg->hwEta() <<
", " 1009 <<
"phi = " << eg->hwPhi() << std::endl;
1012 <<
"==== Taus: ====" << std::endl;
1015 <<
"Tau: Et = " <<
tau->hwPt() <<
", " 1016 <<
"eta = " <<
tau->hwEta() <<
", " 1017 <<
"phi = " <<
tau->hwPhi() << std::endl;
1020 <<
"==== Sums: ====" << std::endl;
1023 <<
"Sum: type = " << sum->getType() <<
" " 1024 <<
"Et = " << sum->hwPt() <<
", " 1025 <<
"eta = " << sum->hwEta() <<
", " 1026 <<
"phi = " << sum->hwPhi() << std::endl;
1038 mpjets_data->push_back(0, (*
jet));
1040 mpjets_emul->push_back(0, (*
jet));
1050 mpEGammas_data->push_back(0, (*eg));
1052 mpEGammas_emul->push_back(0, (*eg));
1062 mptaus_data->push_back(0, (*
tau));
1064 mptaus_emul->push_back(0, (*
tau));
1074 mpsums_data->push_back(0, (*sum));
1076 mpsums_emul->push_back(0, (*sum));
1086 mptowers_data->push_back(0, (*tower));
1088 mptowers_emul->push_back(0, (*tower));
void accuSort(std::vector< l1t::Jet > *jets)
BXVector< EGamma > EGammaBxCollection
edm::Handle< l1t::EGammaBxCollection > egDataCol
const_iterator end(int bx) const
edm::EDGetToken calol2EtSumCollectionEmul
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
unsigned size(int bx) const
bool compareSums(const edm::Handle< l1t::EtSumBxCollection > &dataCol, const edm::Handle< l1t::EtSumBxCollection > &emulCol)
edm::Handle< l1t::EtSumBxCollection > sumDataCol
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void Merge(const std::vector< T > &aInput, std::vector< T > &aOutput)
bool compareJets(const edm::Handle< l1t::JetBxCollection > &dataCol, const edm::Handle< l1t::JetBxCollection > &emulCol)
edm::Handle< l1t::EtSumBxCollection > sumEmulCol
edm::EDGetToken calol2EGammaCollectionEmul
bool isEmpty(int bx) const
BXVector< Tau > TauBxCollection
edm::EDGetToken calol2JetCollectionData
edm::Handle< l1t::JetBxCollection > jetDataCol
edm::Handle< l1t::TauBxCollection > tauDataCol
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
BXVector< EtSum > EtSumBxCollection
edm::Handle< l1t::CaloTowerBxCollection > caloTowerEmulCol
#define DEFINE_FWK_MODULE(type)
edm::EDGetToken calol2EGammaCollectionData
compareCands< edm::Handle< L1GctJetCandCollection > > compareJets
edm::EDGetToken calol2TauCollectionEmul
edm::Handle< l1t::EGammaBxCollection > egEmulCol
edm::EDGetToken calol2TauCollectionData
bool compareEGs(const edm::Handle< l1t::EGammaBxCollection > &dataCol, const edm::Handle< l1t::EGammaBxCollection > &emulCol)
edm::EDGetToken calol2CaloTowerCollectionData
edm::EDGetToken calol2EtSumCollectionData
void dumpEventToEDM(edm::Event &e)
edm::EDGetToken calol2JetCollectionEmul
BXVector< Jet > JetBxCollection
BXVector< CaloTower > CaloTowerBxCollection
L1TStage2CaloLayer2Comp(const edm::ParameterSet &ps)
const unsigned int currBx
edm::EDGetToken calol2CaloTowerCollectionEmul
bool operator>(const l1t::Jet &a, l1t::Jet &b)
edm::Handle< l1t::TauBxCollection > tauEmulCol
EtSumType getType() const
edm::Handle< l1t::CaloTowerBxCollection > caloTowerDataCol
const_iterator begin(int bx) const
edm::Handle< l1t::JetBxCollection > jetEmulCol
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< T >::const_iterator const_iterator
bool compareTaus(const edm::Handle< l1t::TauBxCollection > &dataCol, const edm::Handle< l1t::TauBxCollection > &emulCol)
const T & at(int bx, unsigned i) const