Skip to content

Commit

Permalink
Use edm::Log in the code rather than cout
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Apr 18, 2019
1 parent 7f05de1 commit a706095
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 244 deletions.
22 changes: 8 additions & 14 deletions Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc
Expand Up @@ -6,30 +6,24 @@
#include "Geometry/Records/interface/MuonNumberingRecord.h"
#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h"

#include <iostream>

using namespace std;
using namespace cms;
using namespace edm;

class DDTestMuonNumbering : public one::EDAnalyzer<> {
class DDTestMuonNumbering : public edm::one::EDAnalyzer<> {
public:
explicit DDTestMuonNumbering(const ParameterSet&){}
explicit DDTestMuonNumbering(const edm::ParameterSet&){}

void beginJob() override {}
void analyze(Event const& iEvent, EventSetup const&) override;
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}
};

void
DDTestMuonNumbering::analyze(const Event&, const EventSetup& iEventSetup)
DDTestMuonNumbering::analyze(const edm::Event&, const edm::EventSetup& iEventSetup)
{
LogVerbatim("Geometry") << "DDTestMuonNumbering::analyze";
ESTransientHandle<MuonNumbering> numbering;
edm::LogVerbatim("Geometry") << "DDTestMuonNumbering::analyze";
edm::ESTransientHandle<cms::MuonNumbering> numbering;
iEventSetup.get<MuonNumberingRecord>().get(numbering);

LogVerbatim("Geometry") << "MuonNumbering size: " << numbering->values().size();
LogVerbatim("Geometry").log([&numbering](auto& log) {
edm::LogVerbatim("Geometry") << "MuonNumbering size: " << numbering->values().size();
edm::LogVerbatim("Geometry").log([&numbering](auto& log) {
for(const auto& i: numbering->values()) {
log << " " << i.first << " = " << i.second;
log << '\n';
Expand Down
21 changes: 8 additions & 13 deletions Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc
Expand Up @@ -17,7 +17,6 @@
//

#include <memory>
#include <iostream>

#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
Expand All @@ -28,25 +27,21 @@
#include "Geometry/Records/interface/DDSpecParRegistryRcd.h"
#include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h"

using namespace std;
using namespace cms;
using namespace edm;

class MuonNumberingESProducer : public ESProducer {
class MuonNumberingESProducer : public edm::ESProducer {
public:
MuonNumberingESProducer(const ParameterSet&);
MuonNumberingESProducer(const edm::ParameterSet&);
~MuonNumberingESProducer() override;

using ReturnType = unique_ptr<MuonNumbering>;
using ReturnType = std::unique_ptr<cms::MuonNumbering>;

ReturnType produce(const MuonNumberingRecord&);

private:
const string m_label;
const string m_key;
const std::string m_label;
const std::string m_key;
};

MuonNumberingESProducer::MuonNumberingESProducer(const ParameterSet& iConfig)
MuonNumberingESProducer::MuonNumberingESProducer(const edm::ParameterSet& iConfig)
: m_label(iConfig.getParameter<std::string>("label")),
m_key(iConfig.getParameter<std::string>("key"))

Expand All @@ -61,9 +56,9 @@ MuonNumberingESProducer::ReturnType
MuonNumberingESProducer::produce(const MuonNumberingRecord& iRecord)
{
LogDebug("Geometry") << "MuonNumberingESProducer::produce from " << m_label << " with " << m_key;
auto product = make_unique<MuonNumbering>();
auto product = std::make_unique<cms::MuonNumbering>();

ESHandle<DDSpecParRegistry> registry;
edm::ESHandle<cms::DDSpecParRegistry> registry;
iRecord.getRecord<DDSpecParRegistryRcd>().get(m_label, registry);
auto it = registry->specpars.find(m_key);
if(it != end(registry->specpars)) {
Expand Down
44 changes: 19 additions & 25 deletions Geometry/MuonNumbering/src/CSCNumberingScheme.cc
Expand Up @@ -4,8 +4,6 @@
#include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <iostream>

//#define LOCAL_DEBUG

CSCNumberingScheme::CSCNumberingScheme( const MuonDDDConstants& muonConstants ) {
Expand All @@ -27,23 +25,24 @@ void CSCNumberingScheme::initMe ( const MuonDDDConstants& muonConstants ) {
theRingLevel=muonConstants.getValue("me_ring")/theLevelPart;
theLayerLevel=muonConstants.getValue("me_layer")/theLevelPart;
#ifdef LOCAL_DEBUG
std::cout << "Initialize CSCNumberingScheme" << std::endl;
std::cout << "theRegionLevel " << theRegionLevel <<std::endl;
std::cout << "theStationLevel " << theStationLevel <<std::endl;
std::cout << "theSubringLevel " << theSubringLevel <<std::endl;
std::cout << "theSectorLevel " << theSectorLevel <<std::endl;
std::cout << "theRingLevel " << theRingLevel <<std::endl;
std::cout << "theLayerLevel " << theLayerLevel <<std::endl;
edm::LogVerbatim("CSCNumbering")
<< "Initialize CSCNumberingScheme"
<< "\ntheRegionLevel " << theRegionLevel
<< "\ntheStationLevel " << theStationLevel
<< "\ntheSubringLevel " << theSubringLevel
<< "\ntheSectorLevel " << theSectorLevel
<< "\ntheRingLevel " << theRingLevel
<< "\ntheLayerLevel " << theLayerLevel;
#endif
}

int CSCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num){

#ifdef LOCAL_DEBUG
std::cout << "CSCNumbering "<<num.getLevels()<<std::endl;
edm::LogVerbatim("CSCNumbering") << "CSCNumbering " << num.getLevels();
for (int level=1;level<=num.getLevels();level++) {
std::cout << level << " " << num.getSuperNo(level)
<< " " << num.getBaseNo(level) << std::endl;
edm::LogVerbatim("CSCNumbering")
<< level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
}
#endif

Expand Down Expand Up @@ -121,30 +120,25 @@ int CSCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num){
// find appropriate chamber label

int chamber_id=chamberIndex(station_id, ring_id,
subring_id, sector_id);
subring_id, sector_id);

// convert into raw id of appropriate DetId

int intIndex=CSCDetId::rawIdMaker(fwbw_id, station_id, ring_id,
chamber_id, layer_id);
chamber_id, layer_id);

#ifdef LOCAL_DEBUG
std::cout << "CSCNumberingScheme : ";
std::cout << " fw/bw " << fwbw_id;
std::cout << " station " << station_id;
std::cout << " ring " << ring_id;
std::cout << " subring " << subring_id;
std::cout << " chamber " << chamber_id;
std::cout << " sector " << sector_id;
std::cout << " layer " << layer_id;
std::cout << std::endl;
edm::LogVerbatim("CSCNumbering")
<< "CSCNumberingScheme : fw/bw " << fwbw_id << " station " << station_id
<< " ring " << ring_id << " subring " << subring_id << " chamber "
<< chamber_id << " sector " << sector_id << " layer " << layer_id;
#endif

return intIndex;
}

int CSCNumberingScheme::chamberIndex(int station_id,
int ring_id, int subring_id, int sector_id) const {
int CSCNumberingScheme::chamberIndex(int station_id, int ring_id, int subring_id,
int sector_id) const {

int chamber_id=0;

Expand Down
21 changes: 9 additions & 12 deletions Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc
Expand Up @@ -2,10 +2,7 @@
#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <iostream>

using namespace cms;
using namespace std;
using namespace edm;

const MuonBaseNumber
Expand All @@ -19,20 +16,20 @@ MuonNumbering::geoHistoryToBaseNumber(const cms::ExpandedNodes &nodes) const {

// some consistency checks
if(basePart != 1) {
LogError("Geometry") << "MuonNumbering finds unusual base constant:"
<< basePart;
edm::LogError("Geometry") << "MuonNumbering finds unusual base constant:"
<< basePart;
}
if(superPart < 100) {
LogError("Geometry") << "MuonNumbering finds unusual super constant:"
<< superPart;
edm::LogError("Geometry") << "MuonNumbering finds unusual super constant:"
<< superPart;
}
if(levelPart < 10*superPart) {
LogError("Geometry") << "MuonNumbering finds unusual level constant:"
<< levelPart;
edm::LogError("Geometry") << "MuonNumbering finds unusual level constant:"
<< levelPart;
}
if((startCopyNo !=0 ) && (startCopyNo != 1)) {
LogError("Geometry") << "MuonNumbering finds unusual start value for copy numbers:"
<< startCopyNo;
edm::LogError("Geometry") << "MuonNumbering finds unusual start value for copy numbers:"
<< startCopyNo;
}
int ctr(0);
for(auto const& it : nodes.tags) {
Expand All @@ -58,7 +55,7 @@ MuonNumbering::get(const char* key) const {
}

void
MuonNumbering::put(string_view str, int num) {
MuonNumbering::put(std::string_view str, int num) {
values_.emplace(str, num);
}

Expand Down
31 changes: 16 additions & 15 deletions Geometry/MuonNumbering/src/DTNumberingScheme.cc
Expand Up @@ -2,7 +2,7 @@
#include "DataFormats/MuonDetId/interface/DTWireId.h"
#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
#include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
#include <iostream>
#include "FWCore/MessageLogger/interface/MessageLogger.h"

//#define LOCAL_DEBUG

Expand All @@ -24,30 +24,31 @@ void DTNumberingScheme::initMe ( const MuonDDDConstants& muonConstants ) {
theLayerLevel=muonConstants.getValue("mb_layer")/theLevelPart;
theWireLevel=muonConstants.getValue("mb_wire")/theLevelPart;
#ifdef LOCAL_DEBUG
std::cout << "Initialize DTNumberingScheme" << std::endl;
std::cout << "theRegionLevel " << theRegionLevel <<std::endl;
std::cout << "theWheelLevel " << theWheelLevel <<std::endl;
std::cout << "theStationLevel " << theStationLevel <<std::endl;
std::cout << "theSuperLayerLevel " << theSuperLayerLevel <<std::endl;
std::cout << "theLayerLevel " << theLayerLevel <<std::endl;
std::cout << "theWireLevel " << theWireLevel <<std::endl;
edm::LogVerbatim("DTNumberingScheme")
<< "Initialize DTNumberingScheme"
<< "\ntheRegionLevel " << theRegionLevel
<< "\ntheWheelLevel " << theWheelLevel
<< "\ntheStationLevel " << theStationLevel
<< "\ntheSuperLayerLevel " << theSuperLayerLevel
<< "\ntheLayerLevel " << theLayerLevel
<< "\ntheWireLevel " << theWireLevel;
#endif

}

int DTNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num){

#ifdef LOCAL_DEBUG
std::cout << "DTNumbering "<<num.getLevels()<<std::endl;
edm::LogVerbatim("DTNumberingScheme") << "DTNumbering " << num.getLevels();
for (int level=1;level<=num.getLevels();level++) {
std::cout << level << " " << num.getSuperNo(level)
<< " " << num.getBaseNo(level) << std::endl;
edm::LogVerbatim("DTNumberingScheme")
<< level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
}
#endif
if (num.getLevels()!=theWireLevel) {
std::cout << "DTNS::BNToUN "
<< "BaseNumber has " << num.getLevels() << " levels,"
<< "need "<<theWireLevel<<std::endl;
edm::LogWarning("DTNumberingScheme")
<< "DTNumberingScheme::BNToUN: BaseNumber has " << num.getLevels()
<< " levels, need "<< theWireLevel;
return 0;
}

Expand Down Expand Up @@ -117,7 +118,7 @@ int DTNumberingScheme::getDetId(const MuonBaseNumber& num) const {
DTWireId id(wheel_id,station_id,sector_id,superlayer_id,layer_id,wire_id);

#ifdef LOCAL_DEBUG
std::cout << "DTNumberingScheme: " << id << std::endl;
edm::LogVerbatim("DTNumberingScheme") << "DTNumberingScheme: " << id;
#endif

return id.rawId();
Expand Down
41 changes: 22 additions & 19 deletions Geometry/MuonNumbering/src/GEMNumberingScheme.cc
Expand Up @@ -2,7 +2,7 @@
#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
#include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
#include "DataFormats/MuonDetId/interface/GEMDetId.h"
#include <iostream>
#include "FWCore/MessageLogger/interface/MessageLogger.h"

//#define LOCAL_DEBUG

Expand All @@ -23,30 +23,31 @@ void GEMNumberingScheme::initMe ( const MuonDDDConstants& muonConstants ) {
theSectorLevel = muonConstants.getValue("mg_sector")/theLevelPart;
theRollLevel = muonConstants.getValue("mg_roll")/theLevelPart;
#ifdef LOCAL_DEBUG
std::cout << "Initialize GEMNumberingScheme" <<std::endl;
std::cout << "theRegionLevel " << theRegionLevel <<std::endl;
std::cout << "theStationLevel "<< theStationLevel<<std::endl;
std::cout << "theRingLevel " << theRingLevel <<std::endl;
std::cout << "theSectorLevel " << theSectorLevel <<std::endl;
std::cout << "theRollLevel " << theRollLevel <<std::endl;
edm::LogVerbatim("GEMNumberingScheme")
<< "Initialize GEMNumberingScheme"
<< "\ntheRegionLevel " << theRegionLevel
<< "\ntheStationLevel "<< theStationLevel
<< "\ntheRingLevel " << theRingLevel
<< "\ntheSectorLevel " << theSectorLevel
<< "\ntheRollLevel " << theRollLevel;
#endif
}

int GEMNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) {

#ifdef LOCAL_DEBUG
std::cout << "GEMNumbering "<<num.getLevels()<<std::endl;
edm::LogVerbatim("GEMNumberingScheme") << "GEMNumbering " << num.getLevels();
for (int level=1;level<=num.getLevels();level++) {
std::cout << level << " " << num.getSuperNo(level)
<< " " << num.getBaseNo(level) << std::endl;
edm::LogVerbatim("GEMNumberingScheme")
<< level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
}
#endif

int maxLevel = theRollLevel;
if (num.getLevels()!=maxLevel) {
std::cout << "MuonGEMNS::BNToUN "
<< "BaseNumber has " << num.getLevels() << " levels,"
<< "need "<<maxLevel<<std::endl;
edm::LogWarning("GEMNumberingScheme")
<< "MuonGEMNumberingScheme::BNToUN: BaseNumber has " << num.getLevels()
<< " levels, need " << maxLevel;
return 0;
}

Expand All @@ -66,8 +67,9 @@ int GEMNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) {
ring = 1;
station = num.getSuperNo(theStationLevel);
#ifdef LOCAL_DEBUG
std::cout << "GEMNumbering: Ring " << ring << " Station "
<< num.getSuperNo(theStationLevel) << ":" << station << std::endl;
edm::LogVerbatim("GEMNumberingScheme")
<< "GEMNumbering: Ring " << ring << " Station "
<< num.getSuperNo(theStationLevel) << ":" << station;
#endif

roll = num.getBaseNo(theRollLevel)+1;
Expand All @@ -94,17 +96,18 @@ int GEMNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) {
// collect all info

#ifdef LOCAL_DEBUG
std::cout << "GEMNumberingScheme: Region " << region << " Ring "
<< ring << " Station " << station << " Layer " << layer
<< " Chamber " << chamber << " Roll " << roll << std::endl;
edm::LogVerbatim("GEMNumberingScheme")
<< "GEMNumberingScheme: Region " << region << " Ring "
<< ring << " Station " << station << " Layer " << layer
<< " Chamber " << chamber << " Roll " << roll;
#endif

// Build the actual numbering
GEMDetId id(region,ring,station,layer,chamber, roll);


#ifdef LOCAL_DEBUG
std::cout << id.rawId() << " DetId " << id << std::endl;
edm::LogVerbatim("GEMNumberingScheme") << id.rawId() << " DetId " << id;
#endif

return id.rawId();
Expand Down

0 comments on commit a706095

Please sign in to comment.