Skip to content

Commit

Permalink
code-checks and format
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangcg123 committed Jun 30, 2022
1 parent 4d66b33 commit ba76379
Show file tree
Hide file tree
Showing 7 changed files with 551 additions and 415 deletions.
27 changes: 12 additions & 15 deletions DQM/L1TMonitor/interface/L1TStage2CPPF.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,24 @@

// class decleration

class L1TStage2CPPF: public DQMEDAnalyzer {

class L1TStage2CPPF : public DQMEDAnalyzer {
public:

// class constructor
L1TStage2CPPF(const edm::ParameterSet & ps);
// class destructor
// class constructor
L1TStage2CPPF(const edm::ParameterSet& ps);
// class destructor
~L1TStage2CPPF() override;

// member functions
edm::ESHandle <RPCGeometry> rpcGeom;
// member functions
edm::ESHandle<RPCGeometry> rpcGeom;

protected:
virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
virtual void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override ;

// data members
private:
void analyze(const edm::Event&, const edm::EventSetup&) override;
void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override;

// data members
private:
std::string monitorDir;
bool verbose ;
bool verbose;
float global_phi;
const edm::EDGetTokenT<l1t::CPPFDigiCollection> cppfDigiToken_;
int EMTF_sector;
Expand All @@ -103,7 +100,7 @@ class L1TStage2CPPF: public DQMEDAnalyzer {
std::vector<int> EMTFsector5bins;
std::vector<int> EMTFsector6bins;

std::map<int , std::vector<int>> fill_info;
std::map<int, std::vector<int>> fill_info;

MonitorElement* Occupancy_EMTFSector;
MonitorElement* Track_Bx;
Expand Down
14 changes: 4 additions & 10 deletions DQM/L1TMonitor/interface/L1TdeStage2CPPF.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@

#include "DataFormats/L1TMuon/interface/CPPFDigi.h"


class L1TdeStage2CPPF : public DQMEDAnalyzer {

public:
public:
L1TdeStage2CPPF(const edm::ParameterSet& ps);
~L1TdeStage2CPPF() override;

protected:

protected:
void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override;
void analyze(const edm::Event&, const edm::EventSetup&) override;

private:
private:
int occupancy_value(int region_, int station_, int ring_);
int bx_value(int region_, int emtfsector_);
int GetSubsector(int emtfsector_, int lsubsector_);
Expand All @@ -51,13 +48,10 @@ class L1TdeStage2CPPF : public DQMEDAnalyzer {
MonitorElement* h2_Matching_SameKey_OnTheta_phi_Ce_phi_Cu_bx;
MonitorElement* h2_Matching_SameKey_OnTheta_theta_Ce_theta_Cu_bx;
MonitorElement* h2_Matching_SameKey_OnTheta_zone_Ce_zone_Cu_bx;

MonitorElement* h2_Matching_SameKey_OffTheta_phi_Ce_phi_Cu_bx;
MonitorElement* h2_Matching_SameKey_OffTheta_theta_Ce_theta_Cu_bx;
MonitorElement* h2_Matching_SameKey_OffTheta_zone_Ce_zone_Cu_bx;



};

#endif
186 changes: 89 additions & 97 deletions DQM/L1TMonitor/src/L1TStage2CPPF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,141 +6,133 @@

#include "DQM/L1TMonitor/interface/L1TStage2CPPF.h"

L1TStage2CPPF::L1TStage2CPPF(const edm::ParameterSet & ps):
monitorDir(ps.getUntrackedParameter<std::string>("monitorDir","")),
// cppfdigiLabel(ps.getParameter<edm::InputTag>("cppfdigiLabel")),
verbose(ps.getUntrackedParameter<bool>("verbose", false)),
global_phi(-1000),
cppfDigiToken_(consumes<l1t::CPPFDigiCollection>(ps.getParameter<edm::InputTag>("cppfSource")))
{
L1TStage2CPPF::L1TStage2CPPF(const edm::ParameterSet& ps)
: monitorDir(ps.getUntrackedParameter<std::string>("monitorDir", "")),
// cppfdigiLabel(ps.getParameter<edm::InputTag>("cppfdigiLabel")),
verbose(ps.getUntrackedParameter<bool>("verbose", false)),
global_phi(-1000),
cppfDigiToken_(consumes<l1t::CPPFDigiCollection>(ps.getParameter<edm::InputTag>("cppfSource"))) {}

}

L1TStage2CPPF::~L1TStage2CPPF()
{
}
L1TStage2CPPF::~L1TStage2CPPF() {}

void L1TStage2CPPF::bookHistograms(DQMStore::IBooker &ibooker, const edm::Run& iRun, const edm::EventSetup& eveSetup)
{
void L1TStage2CPPF::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& iRun, const edm::EventSetup& eveSetup) {
ibooker.setCurrentFolder(monitorDir);

Occupancy_EMTFSector = ibooker.book2D("Occupancy_EMTFSector", "Occupancy_EMTFSector", 36, 1., 37., 12, 1.,13.);
Track_Bx = ibooker.book2D("Track_Bx","Track_Bx", 12, 1., 13., 7,-3.,4.);

Occupancy_EMTFSector = ibooker.book2D("Occupancy_EMTFSector", "Occupancy_EMTFSector", 36, 1., 37., 12, 1., 13.);
Track_Bx = ibooker.book2D("Track_Bx", "Track_Bx", 12, 1., 13., 7, -3., 4.);
}

void L1TStage2CPPF::analyze(const edm::Event & eve, const edm::EventSetup & eveSetup)
{
void L1TStage2CPPF::analyze(const edm::Event& eve, const edm::EventSetup& eveSetup) {
if (verbose) {
edm::LogInfo("L1TStage2CPPF") << "L1TStage2CPPF: analyze...." << std::endl;
}

edm::Handle<l1t::CPPFDigiCollection> CppfDigis;
eve.getByToken(cppfDigiToken_, CppfDigis);


//Fill the specific bin for each EMTF sector
for(int i = 1; i < 7; i++ ){
//Fill the specific bin for each EMTF sector
for (int i = 1; i < 7; i++) {
EMTFsector1bins.push_back(i);
EMTFsector2bins.push_back(i+6);
EMTFsector3bins.push_back(i+12);
EMTFsector4bins.push_back(i+18);
EMTFsector5bins.push_back(i+24);
EMTFsector6bins.push_back(i+30);
EMTFsector2bins.push_back(i + 6);
EMTFsector3bins.push_back(i + 12);
EMTFsector4bins.push_back(i + 18);
EMTFsector5bins.push_back(i + 24);
EMTFsector6bins.push_back(i + 30);
}
//FIll the map for each EMTF sector
//FIll the map for each EMTF sector
fill_info[1] = EMTFsector1bins;
fill_info[2] = EMTFsector2bins;
fill_info[3] = EMTFsector3bins;
fill_info[4] = EMTFsector4bins;
fill_info[5] = EMTFsector5bins;
fill_info[6] = EMTFsector6bins;

for(auto& cppf_digis : *CppfDigis){

for (auto& cppf_digis : *CppfDigis) {
RPCDetId rpcId = cppf_digis.rpcId();
int ring = rpcId.ring();
int station = rpcId.station();
int region = rpcId.region();
int subsector = rpcId.subsector();

//TOBECHECKED why rpcId.sector() sometimes return 7 ?
if (cppf_digis.emtf_sector() != -99) {
std::cout << " L1TStage2CPPF::analyze cppf_digis.emtf_sector=" << cppf_digis.emtf_sector() << std::endl;
}
if (rpcId.sector() >= 7 or rpcId.sector() < 1) {
std::cout << " L1TStage2CPPF::analyze rpcId.sector=" << rpcId.sector()
<< " emtf_sector=" << cppf_digis.emtf_sector() << std::endl;
continue;
}

//TOBECHECKED why rpcId.sector() sometimes return 7 ?
if(cppf_digis.emtf_sector()!=-99) {std::cout<<" L1TStage2CPPF::analyze cppf_digis.emtf_sector="<<cppf_digis.emtf_sector()<<std::endl;}
if(rpcId.sector()>=7 or rpcId.sector()<1) { std::cout<<" L1TStage2CPPF::analyze rpcId.sector="<<rpcId.sector()<<" emtf_sector="<<cppf_digis.emtf_sector()<<std::endl; continue;}

//Region -
if(region == -1){

//Region -
if (region == -1) {
//for Occupancy
//EMTF_sector = cppf_digis.emtf_sector(); // TOBECHECKED it returns -99, seems not filled
EMTF_sector = rpcId.sector();

EMTF_subsector = fill_info[EMTF_sector][subsector-1];

if((station == 4) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 1);
else if((station == 4) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 2);
else if((station == 3) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 3);
else if((station == 3) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 4);
else if((station == 2) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 5);
else if((station == 1) && (ring == 2))

//for Track_Bx
EMTF_bx = cppf_digis.bx();
if(EMTF_sector==1)
Track_Bx->Fill(6,EMTF_bx);
else if(EMTF_sector==2)
Track_Bx->Fill(5,EMTF_bx);
else if(EMTF_sector==3)
Track_Bx->Fill(4,EMTF_bx);
else if(EMTF_sector==4)
Track_Bx->Fill(3,EMTF_bx);
else if(EMTF_sector==5)
Track_Bx->Fill(2,EMTF_bx);
else if(EMTF_sector==6)
Track_Bx->Fill(1,EMTF_bx);

EMTF_subsector = fill_info[EMTF_sector][subsector - 1];

if ((station == 4) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 1);
else if ((station == 4) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 2);
else if ((station == 3) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 3);
else if ((station == 3) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 4);
else if ((station == 2) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 5);
else if ((station == 1) && (ring == 2))

//for Track_Bx
EMTF_bx = cppf_digis.bx();
if (EMTF_sector == 1)
Track_Bx->Fill(6, EMTF_bx);
else if (EMTF_sector == 2)
Track_Bx->Fill(5, EMTF_bx);
else if (EMTF_sector == 3)
Track_Bx->Fill(4, EMTF_bx);
else if (EMTF_sector == 4)
Track_Bx->Fill(3, EMTF_bx);
else if (EMTF_sector == 5)
Track_Bx->Fill(2, EMTF_bx);
else if (EMTF_sector == 6)
Track_Bx->Fill(1, EMTF_bx);
}
//Region +
if(region == 1){

//Region +
if (region == 1) {
//for Occupancy
//EMTF_sector = cppf_digis.emtf_sector(); // TOBECHECKED it returns -99, seems not filled
EMTF_sector = rpcId.sector();
EMTF_subsector = fill_info[EMTF_sector][subsector-1];
if((station == 1) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 7);
else if((station == 2) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 8);
else if((station == 3) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 9);
else if((station == 3) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 10);
else if((station == 4) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 11);
else if((station == 4) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 12);
EMTF_subsector = fill_info[EMTF_sector][subsector - 1];

if ((station == 1) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 7);
else if ((station == 2) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 8);
else if ((station == 3) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 9);
else if ((station == 3) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 10);
else if ((station == 4) && (ring == 2))
Occupancy_EMTFSector->Fill(EMTF_subsector, 11);
else if ((station == 4) && (ring == 3))
Occupancy_EMTFSector->Fill(EMTF_subsector, 12);

//for Track_Bx
EMTF_bx = cppf_digis.bx();
if(EMTF_sector==1)
Track_Bx->Fill(7,EMTF_bx);
else if(EMTF_sector==2)
Track_Bx->Fill(8,EMTF_bx);
else if(EMTF_sector==3)
Track_Bx->Fill(9,EMTF_bx);
else if(EMTF_sector==4)
Track_Bx->Fill(10,EMTF_bx);
else if(EMTF_sector==5)
Track_Bx->Fill(11,EMTF_bx);
else if(EMTF_sector==6)
Track_Bx->Fill(12,EMTF_bx);
if (EMTF_sector == 1)
Track_Bx->Fill(7, EMTF_bx);
else if (EMTF_sector == 2)
Track_Bx->Fill(8, EMTF_bx);
else if (EMTF_sector == 3)
Track_Bx->Fill(9, EMTF_bx);
else if (EMTF_sector == 4)
Track_Bx->Fill(10, EMTF_bx);
else if (EMTF_sector == 5)
Track_Bx->Fill(11, EMTF_bx);
else if (EMTF_sector == 6)
Track_Bx->Fill(12, EMTF_bx);
}
} //loop over CPPFDigis
} //loop over CPPFDigis
}
Loading

0 comments on commit ba76379

Please sign in to comment.