From a56f00c87a5d353d3b8fd80b78f556a3b8eeda05 Mon Sep 17 00:00:00 2001 From: Roumyana Date: Sat, 2 May 2020 16:19:15 +0200 Subject: [PATCH] Code style and quality issues formated --- L1Trigger/L1TMuonCPPF/interface/EmulateCPPF.h | 1 - L1Trigger/L1TMuonCPPF/src/CPPFClusterizer.cc | 2 - .../L1TMuonCPPF/src/CPPFMaskReClusterizer.cc | 4 +- L1Trigger/L1TMuonCPPF/src/EmulateCPPF.cc | 71 +++++----- L1Trigger/L1TMuonCPPF/src/RecHitProcessor.cc | 124 +++++++----------- 5 files changed, 88 insertions(+), 114 deletions(-) diff --git a/L1Trigger/L1TMuonCPPF/interface/EmulateCPPF.h b/L1Trigger/L1TMuonCPPF/interface/EmulateCPPF.h index c09525600244e..a1613d5503f83 100644 --- a/L1Trigger/L1TMuonCPPF/interface/EmulateCPPF.h +++ b/L1Trigger/L1TMuonCPPF/interface/EmulateCPPF.h @@ -7,7 +7,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/DetSetVector.h" - class EmulateCPPF { public: explicit EmulateCPPF(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iConsumes); diff --git a/L1Trigger/L1TMuonCPPF/src/CPPFClusterizer.cc b/L1Trigger/L1TMuonCPPF/src/CPPFClusterizer.cc index fe28580e6afab..29a94f8f2f52c 100644 --- a/L1Trigger/L1TMuonCPPF/src/CPPFClusterizer.cc +++ b/L1Trigger/L1TMuonCPPF/src/CPPFClusterizer.cc @@ -39,5 +39,3 @@ CPPFClusterContainer CPPFClusterizer::doAction(const RPCDigiCollection::Range& d return finalCluster; } - - diff --git a/L1Trigger/L1TMuonCPPF/src/CPPFMaskReClusterizer.cc b/L1Trigger/L1TMuonCPPF/src/CPPFMaskReClusterizer.cc index 197157d317433..e4590c3cc61fa 100644 --- a/L1Trigger/L1TMuonCPPF/src/CPPFMaskReClusterizer.cc +++ b/L1Trigger/L1TMuonCPPF/src/CPPFMaskReClusterizer.cc @@ -7,8 +7,8 @@ #include "CPPFMaskReClusterizer.h" CPPFClusterContainer CPPFMaskReClusterizer::doAction(const RPCDetId& id, - CPPFClusterContainer& initClusters, - const CPPFRollMask& mask) const { + CPPFClusterContainer& initClusters, + const CPPFRollMask& mask) const { CPPFClusterContainer finClusters; if (initClusters.empty()) return finClusters; diff --git a/L1Trigger/L1TMuonCPPF/src/EmulateCPPF.cc b/L1Trigger/L1TMuonCPPF/src/EmulateCPPF.cc index 1fa4549036232..404416aafb04a 100644 --- a/L1Trigger/L1TMuonCPPF/src/EmulateCPPF.cc +++ b/L1Trigger/L1TMuonCPPF/src/EmulateCPPF.cc @@ -11,42 +11,44 @@ #include "Geometry/RPCGeometry/interface/RPCRoll.h" #include "DataFormats/Common/interface/DetSetVector.h" -EmulateCPPF::EmulateCPPF(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iConsumes): - recHit_processors_(), +EmulateCPPF::EmulateCPPF(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iConsumes) + : recHit_processors_(), rpcDigiToken_(iConsumes.consumes(iConfig.getParameter("rpcDigiLabel"))), recHitToken_(iConsumes.consumes(iConfig.getParameter("recHitLabel"))), - rpcDigiSimLinkToken_(iConsumes.consumes >(iConfig.getParameter("rpcDigiSimLinkLabel"))), + rpcDigiSimLinkToken_(iConsumes.consumes >( + iConfig.getParameter("rpcDigiSimLinkLabel"))), cppfSource_(CppfSource::EventSetup), MaxClusterSize_(0) { - MaxClusterSize_ = iConfig.getParameter("MaxClusterSize"); - const std::string cppfSource = iConfig.getParameter("cppfSource"); -// Look up table - if (cppfSource == "File") { - cppfSource_ = CppfSource::File; - edm::FileInPath fp = iConfig.getParameter("cppfvecfile"); - std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in); - if (!inputFile) { - throw cms::Exception("No LUT") << "Error: CPPF look up table file cannot not be opened"; - exit(1); - } - while (inputFile.good()) { - RecHitProcessor::CppfItem Item; - inputFile >> Item.rawId >> Item.strip >> Item.lb >> Item.halfchannel >> Item.int_phi >> Item.int_theta; - if (inputFile.good()) - CppfVec_1.push_back(Item); - } - inputFile.close(); - } -// RPC Geometry - else if (cppfSource == "Geo") { - cppfSource_ = CppfSource::EventSetup; - } -// Error for wrong input - else { - throw cms::Exception("Invalid option") << "Error: Specify in python/emulatorCppfDigis_cfi 'File' for look up table or 'Geo' for RPC Geometry"; - exit(1); - } - } + MaxClusterSize_ = iConfig.getParameter("MaxClusterSize"); + const std::string cppfSource = iConfig.getParameter("cppfSource"); + // Look up table + if (cppfSource == "File") { + cppfSource_ = CppfSource::File; + edm::FileInPath fp = iConfig.getParameter("cppfvecfile"); + std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in); + if (!inputFile) { + throw cms::Exception("No LUT") << "Error: CPPF look up table file cannot not be opened"; + exit(1); + } + while (inputFile.good()) { + RecHitProcessor::CppfItem Item; + inputFile >> Item.rawId >> Item.strip >> Item.lb >> Item.halfchannel >> Item.int_phi >> Item.int_theta; + if (inputFile.good()) + CppfVec_1.push_back(Item); + } + inputFile.close(); + } + // RPC Geometry + else if (cppfSource == "Geo") { + cppfSource_ = CppfSource::EventSetup; + } + // Error for wrong input + else { + throw cms::Exception("Invalid option") + << "Error: Specify in python/emulatorCppfDigis_cfi 'File' for look up table or 'Geo' for RPC Geometry"; + exit(1); + } +} EmulateCPPF::~EmulateCPPF() {} @@ -56,7 +58,8 @@ void EmulateCPPF::process(const edm::Event &iEvent, if (cppfSource_ == CppfSource::File) { // Using the look up table to fill the information cppf_recHit.clear(); for (auto &recHit_processor : recHit_processors_) { - recHit_processor.processLook(iEvent, iSetup, recHitToken_, rpcDigiToken_, rpcDigiSimLinkToken_, CppfVec_1, cppf_recHit, MaxClusterSize_); + recHit_processor.processLook( + iEvent, iSetup, recHitToken_, rpcDigiToken_, rpcDigiSimLinkToken_, CppfVec_1, cppf_recHit, MaxClusterSize_); } } else if (cppfSource_ == CppfSource::EventSetup) { // Clear output collections @@ -80,5 +83,3 @@ void EmulateCPPF::process(const edm::Event &iEvent, } } } // End void EmulateCPPF::process() - - diff --git a/L1Trigger/L1TMuonCPPF/src/RecHitProcessor.cc b/L1Trigger/L1TMuonCPPF/src/RecHitProcessor.cc index 5852ac7df7bbb..2187a3af9ae33 100644 --- a/L1Trigger/L1TMuonCPPF/src/RecHitProcessor.cc +++ b/L1Trigger/L1TMuonCPPF/src/RecHitProcessor.cc @@ -7,7 +7,6 @@ #include "L1Trigger/L1TMuonCPPF/src/CPPFMaskReClusterizer.h" #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" - RecHitProcessor::RecHitProcessor() {} RecHitProcessor::~RecHitProcessor() {} @@ -20,7 +19,6 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, std::vector &CppfVec1, l1t::CPPFDigiCollection &cppfDigis, const int MaxClusterSize) const { - edm::Handle recHits; iEvent.getByToken(recHitToken, recHits); @@ -33,10 +31,11 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, edm::ESHandle rpcGeom; iSetup.get().get(rpcGeom); - for (const auto&& rpcdgIt : (*rpcDigis)) { - const RPCDetId& rpcId = rpcdgIt.first; - const RPCDigiCollection::Range& range = rpcdgIt.second; - if (rpcId.region()==0) continue; + for (const auto &&rpcdgIt : (*rpcDigis)) { + const RPCDetId &rpcId = rpcdgIt.first; + const RPCDigiCollection::Range &range = rpcdgIt.second; + if (rpcId.region() == 0) + continue; CPPFClusterizer clizer; CPPFClusterContainer tcls = clizer.doAction(range); @@ -44,7 +43,7 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, CPPFRollMask mask; CPPFClusterContainer cls = mrclizer.doAction(rpcId, tcls, mask); - for (auto cl : cls){ + for (auto cl : cls) { int isValid = rpcDigis.isValid(); int rawId = rpcId.rawId(); int Bx = cl.bx(); @@ -59,7 +58,7 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, const double y = cl.hasY() ? cl.y() : 0; LocalPoint lPos(centreOfCluster, y, 0); if (roll->id().region() != 0) { - const auto& topo = dynamic_cast(roll->topology()); + const auto &topo = dynamic_cast(roll->topology()); const double angle = topo.stripAngle((firststrip + laststrip) / 2.); const double x = centreOfCluster - y * std::tan(angle); lPos = LocalPoint(x, y, 0); @@ -94,25 +93,21 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, if ((global_phi > 15.) && (global_phi <= 16.3)) { EMTFsector1 = 1; EMTFsector2 = 6; - } - else if ((global_phi > 16.3) && (global_phi <= 53.)) { + } else if ((global_phi > 16.3) && (global_phi <= 53.)) { EMTFsector1 = 1; EMTFsector2 = 0; - } - else if ((global_phi > 53.) && (global_phi <= 75.)) { + } else if ((global_phi > 53.) && (global_phi <= 75.)) { EMTFsector1 = 1; EMTFsector2 = 2; } - // sector 2 + // sector 2 else if ((global_phi > 75.) && (global_phi <= 76.3)) { EMTFsector1 = 1; EMTFsector2 = 2; - } - else if ((global_phi > 76.3) && (global_phi <= 113.)) { + } else if ((global_phi > 76.3) && (global_phi <= 113.)) { EMTFsector1 = 2; EMTFsector2 = 0; - } - else if ((global_phi > 113.) && (global_phi <= 135.)) { + } else if ((global_phi > 113.) && (global_phi <= 135.)) { EMTFsector1 = 2; EMTFsector2 = 3; } @@ -159,12 +154,10 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, else if ((global_phi > -45.) && (global_phi <= -43.7)) { EMTFsector1 = 5; EMTFsector2 = 6; - } - else if ((global_phi > -43.7) && (global_phi <= -7.)) { + } else if ((global_phi > -43.7) && (global_phi <= -7.)) { EMTFsector1 = 6; EMTFsector2 = 0; - } - else if ((global_phi > -7.) && (global_phi <= 15.)) { + } else if ((global_phi > -7.) && (global_phi <= 15.)) { EMTFsector1 = 6; EMTFsector2 = 1; } @@ -196,8 +189,7 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, cppf = (cppf1 - 1); else if (before > after) cppf = (cppf1 + 1); - } - else if (firststrip > 1) { + } else if (firststrip > 1) { if (before < after) cppf = (cppf1 + 1); else if (before > after) @@ -235,12 +227,10 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, if ((EMTFsector1 > 0) && (EMTFsector2 == 0)) { cppfDigis.push_back(*MainVariables1.get()); - } - else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)) { + } else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)) { cppfDigis.push_back(*MainVariables1.get()); cppfDigis.push_back(*MainVariables2.get()); - } - else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) { + } else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) { continue; } } // Geo is true @@ -275,20 +265,18 @@ void RecHitProcessor::processLook(const edm::Event &iEvent, global_theta)); if ((EMTFsector1 > 0) && (EMTFsector2 == 0)) { cppfDigis.push_back(*MainVariables1.get()); - } - else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)) { + } else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)) { cppfDigis.push_back(*MainVariables1.get()); cppfDigis.push_back(*MainVariables2.get()); - } - else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) { + } else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) { continue; } } } // Condition to save the CPPFDigi - }// Loop over the LUTVector - }//end loop over cludters - }//end loop over digis -}//end processlook function + } // Loop over the LUTVector + } //end loop over cludters + } //end loop over digis +} //end processlook function void RecHitProcessor::process(const edm::Event &iEvent, const edm::EventSetup &iSetup, @@ -296,7 +284,6 @@ void RecHitProcessor::process(const edm::Event &iEvent, const edm::EDGetToken &rpcDigiToken, const edm::EDGetToken &rpcDigiSimLinkToken, l1t::CPPFDigiCollection &cppfDigis) const { - // Get the RPC Geometry edm::ESHandle rpcGeom; iSetup.get().get(rpcGeom); @@ -308,10 +295,11 @@ void RecHitProcessor::process(const edm::Event &iEvent, edm::Handle recHits; iEvent.getByToken(recHitToken, recHits); - for (const auto&& rpcdgIt : (*rpcDigis)) { - const RPCDetId& rpcId = rpcdgIt.first; - const RPCDigiCollection::Range& range = rpcdgIt.second; - if (rpcId.region()==0) continue; + for (const auto &&rpcdgIt : (*rpcDigis)) { + const RPCDetId &rpcId = rpcdgIt.first; + const RPCDigiCollection::Range &range = rpcdgIt.second; + if (rpcId.region() == 0) + continue; CPPFClusterizer clizer; CPPFClusterContainer tcls = clizer.doAction(range); @@ -319,10 +307,10 @@ void RecHitProcessor::process(const edm::Event &iEvent, CPPFRollMask mask; CPPFClusterContainer cls = mrclizer.doAction(rpcId, tcls, mask); - for (auto cl : cls){ + for (auto cl : cls) { int region = rpcId.region(); int isValid = rpcDigis.isValid(); -// int rawId = rpcId.rawId(); + // int rawId = rpcId.rawId(); int Bx = cl.bx(); const int firststrip = cl.firstStrip(); const int clustersize = cl.clusterSize(); @@ -335,7 +323,7 @@ void RecHitProcessor::process(const edm::Event &iEvent, const double y = cl.hasY() ? cl.y() : 0; LocalPoint lPos(centreOfCluster, y, 0); if (roll->id().region() != 0) { - const auto& topo = dynamic_cast(roll->topology()); + const auto &topo = dynamic_cast(roll->topology()); const double angle = topo.stripAngle((firststrip + laststrip) / 2.); const double x = centreOfCluster - y * std::tan(angle); lPos = LocalPoint(x, y, 0); @@ -347,14 +335,14 @@ void RecHitProcessor::process(const edm::Event &iEvent, // Endcap region only if (region != 0) { - int int_theta = (region == -1 ? 180. * 32. / 36.5 : 0.) + (float)region * global_theta * 32. / 36.5 - 8.5 * 32 / 36.5; + int int_theta = + (region == -1 ? 180. * 32. / 36.5 : 0.) + (float)region * global_theta * 32. / 36.5 - 8.5 * 32 / 36.5; if (region == 1) { if (global_theta < 8.5) int_theta = 0; if (global_theta > 45.) int_theta = 31; - } - else if (region == -1) { + } else if (region == -1) { if (global_theta < 135.) int_theta = 31; if (global_theta > 171.5) @@ -370,13 +358,11 @@ void RecHitProcessor::process(const edm::Event &iEvent, local_phi = global_phi - 15.; EMTFsector1 = 1; EMTFsector2 = 6; - } - else if ((global_phi > 16.3) && (global_phi <= 53.)) { + } else if ((global_phi > 16.3) && (global_phi <= 53.)) { local_phi = global_phi - 15.; EMTFsector1 = 1; EMTFsector2 = 0; - } - else if ((global_phi > 53.) && (global_phi <= 75.)) { + } else if ((global_phi > 53.) && (global_phi <= 75.)) { local_phi = global_phi - 15.; EMTFsector1 = 1; EMTFsector2 = 2; @@ -386,13 +372,11 @@ void RecHitProcessor::process(const edm::Event &iEvent, local_phi = global_phi - 15.; EMTFsector1 = 1; EMTFsector2 = 2; - } - else if ((global_phi > 76.3) && (global_phi <= 113.)) { + } else if ((global_phi > 76.3) && (global_phi <= 113.)) { local_phi = global_phi - 75.; EMTFsector1 = 2; EMTFsector2 = 0; - } - else if ((global_phi > 113.) && (global_phi <= 135.)) { + } else if ((global_phi > 113.) && (global_phi <= 135.)) { local_phi = global_phi - 75.; EMTFsector1 = 2; EMTFsector2 = 3; @@ -403,13 +387,11 @@ void RecHitProcessor::process(const edm::Event &iEvent, local_phi = global_phi - 75.; EMTFsector1 = 2; EMTFsector2 = 3; - } - else if ((global_phi > 136.3) && (global_phi <= 173.)) { + } else if ((global_phi > 136.3) && (global_phi <= 173.)) { local_phi = global_phi - 135.; EMTFsector1 = 3; EMTFsector2 = 0; - } - else if ((global_phi > 173.) && (global_phi <= 180.)) { + } else if ((global_phi > 173.) && (global_phi <= 180.)) { local_phi = global_phi - 135.; EMTFsector1 = 3; EMTFsector2 = 4; @@ -425,13 +407,11 @@ void RecHitProcessor::process(const edm::Event &iEvent, local_phi = global_phi + 225.; EMTFsector1 = 3; EMTFsector2 = 4; - } - else if ((global_phi > -163.7) && (global_phi <= -127.)) { + } else if ((global_phi > -163.7) && (global_phi <= -127.)) { local_phi = global_phi + 165.; EMTFsector1 = 4; EMTFsector2 = 0; - } - else if ((global_phi > -127.) && (global_phi <= -105.)) { + } else if ((global_phi > -127.) && (global_phi <= -105.)) { local_phi = global_phi + 165.; EMTFsector1 = 4; EMTFsector2 = 5; @@ -441,13 +421,11 @@ void RecHitProcessor::process(const edm::Event &iEvent, local_phi = global_phi + 165.; EMTFsector1 = 4; EMTFsector2 = 5; - } - else if ((global_phi > -103.7) && (global_phi <= -67.)) { + } else if ((global_phi > -103.7) && (global_phi <= -67.)) { local_phi = global_phi + 105.; EMTFsector1 = 5; EMTFsector2 = 0; - } - else if ((global_phi > -67.) && (global_phi <= -45.)) { + } else if ((global_phi > -67.) && (global_phi <= -45.)) { local_phi = global_phi + 105.; EMTFsector1 = 5; EMTFsector2 = 6; @@ -457,13 +435,11 @@ void RecHitProcessor::process(const edm::Event &iEvent, local_phi = global_phi + 105.; EMTFsector1 = 5; EMTFsector2 = 6; - } - else if ((global_phi > -43.7) && (global_phi <= -7.)) { + } else if ((global_phi > -43.7) && (global_phi <= -7.)) { local_phi = global_phi + 45.; EMTFsector1 = 6; EMTFsector2 = 0; - } - else if ((global_phi > -7.) && (global_phi <= 15.)) { + } else if ((global_phi > -7.) && (global_phi <= 15.)) { local_phi = global_phi + 45.; EMTFsector1 = 6; EMTFsector2 = 1; @@ -520,7 +496,7 @@ void RecHitProcessor::process(const edm::Event &iEvent, if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) { continue; } - }// No barrel hits - }//end loop over clusters - }//end loop over digis -}// End function: void RecHitProcessor::process() + } // No barrel hits + } //end loop over clusters + } //end loop over digis +} // End function: void RecHitProcessor::process()