Skip to content

Commit

Permalink
Merge pull request #24194 from bsunanda/Phase2-hgx135
Browse files Browse the repository at this point in the history
Phase2-hgx135 Update the validation code with correct reference of layers
  • Loading branch information
cmsbuild committed Aug 7, 2018
2 parents c04c595 + 29d1778 commit ab93559
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 70 deletions.
34 changes: 20 additions & 14 deletions Validation/HGCalValidation/plugins/HGCalDigiValidation.cc
Expand Up @@ -80,7 +80,7 @@ class HGCalDigiValidation : public DQMEDAnalyzer {
edm::EDGetToken digiSource_;
bool ifHCAL_;
int verbosity_, SampleIndx_;
int layers_;
int layers_, firstLayer_;

std::map<int, int> OccupancyMap_plus_;
std::map<int, int> OccupancyMap_minus_;
Expand All @@ -92,14 +92,14 @@ class HGCalDigiValidation : public DQMEDAnalyzer {
std::vector<MonitorElement*> DigiOccupancy_Minus_;
MonitorElement* MeanDigiOccupancy_Plus_;
MonitorElement* MeanDigiOccupancy_Minus_;
static const int emptyScintLayer = 8;
};

HGCalDigiValidation::HGCalDigiValidation(const edm::ParameterSet& iConfig) :
nameDetector_(iConfig.getParameter<std::string>("DetectorName")),
ifHCAL_(iConfig.getParameter<bool>("ifHCAL")),
verbosity_(iConfig.getUntrackedParameter<int>("Verbosity",0)),
SampleIndx_(iConfig.getUntrackedParameter<int>("SampleIndx",5)) {
SampleIndx_(iConfig.getUntrackedParameter<int>("SampleIndx",5)),
firstLayer_(1) {

auto temp = iConfig.getParameter<edm::InputTag>("DigiSource");
if (nameDetector_ == "HGCalEESensitive" || nameDetector_ == "HGCalHESiliconSensitive" || nameDetector_ == "HGCalHEScintillatorSensitive") {
Expand Down Expand Up @@ -196,7 +196,7 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent,
DetId detId = it.id();
int layer = ((geomType == 0) ? HGCalDetId(detId).layer() :
((geomType == 1) ? HGCSiliconDetId(detId).layer() :
HGCScintillatorDetId(detId).layer()+emptyScintLayer));
HGCScintillatorDetId(detId).layer()));
const HGCSample& hgcSample = it.sample(SampleIndx_);
uint16_t gain = hgcSample.toa();
uint16_t adc = hgcSample.data();
Expand Down Expand Up @@ -280,7 +280,8 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent,

template<class T1, class T2>
void HGCalDigiValidation::digiValidation(const T1& detId, const T2* geom,
int layer, uint16_t adc, double charge) {
int layer, uint16_t adc,
double charge) {

if (verbosity_>1) edm::LogVerbatim("HGCalValidation") << std::hex
<< detId.rawId()
Expand All @@ -298,7 +299,7 @@ void HGCalDigiValidation::digiValidation(const T1& detId, const T2* geom,
hinfo.z = global1.z();
hinfo.adc = adc;
hinfo.charge = charge; //charges[0];
hinfo.layer = std::min(layer,layers_);
hinfo.layer = layer-firstLayer_;

if (verbosity_>1)
edm::LogVerbatim("HGCalValidation") << "gx = " << hinfo.x
Expand All @@ -307,18 +308,19 @@ void HGCalDigiValidation::digiValidation(const T1& detId, const T2* geom,

fillDigiInfo(hinfo);

if (global1.eta() > 0) fillOccupancyMap(OccupancyMap_plus_, hinfo.layer -1);
else fillOccupancyMap(OccupancyMap_minus_, hinfo.layer -1);
if (global1.eta() > 0) fillOccupancyMap(OccupancyMap_plus_, hinfo.layer);
else fillOccupancyMap(OccupancyMap_minus_, hinfo.layer);

}

void HGCalDigiValidation::fillOccupancyMap(std::map<int, int>& OccupancyMap, int layer) {
void HGCalDigiValidation::fillOccupancyMap(std::map<int, int>& OccupancyMap,
int layer) {
if (OccupancyMap.find(layer) != OccupancyMap.end()) OccupancyMap[layer] ++;
else OccupancyMap[layer] = 1;
}

void HGCalDigiValidation::fillDigiInfo(digiInfo& hinfo) {
int ilayer = hinfo.layer -1;
int ilayer = hinfo.layer;
charge_.at(ilayer)->Fill(hinfo.charge);
DigiOccupancy_XY_.at(ilayer)->Fill(hinfo.x, hinfo.y);
ADC_.at(ilayer)->Fill(hinfo.adc);
Expand Down Expand Up @@ -348,13 +350,16 @@ void HGCalDigiValidation::dqmBeginRun(const edm::Run&,
edm::ESHandle<HGCalDDDConstants> pHGDC;
iSetup.get<IdealGeometryRecord>().get(nameDetector_, pHGDC);
const HGCalDDDConstants & hgcons_ = (*pHGDC);
layers_ = hgcons_.layers(true);
layers_ = hgcons_.layers(true);
firstLayer_ = hgcons_.firstLayer();
}

if (verbosity_>0)
edm::LogVerbatim("HGCalValidation") << "current DQM directory: "
<< "HGCAL/HGCalDigisV/" << nameDetector_
<< " layer = "<< layers_;
<< "HGCAL/HGCalDigisV/"
<< nameDetector_ << " layer = "
<< layers_ << " with the first one at "
<< firstLayer_;
}

void HGCalDigiValidation::bookHistograms(DQMStore::IBooker& iB,
Expand All @@ -364,7 +369,8 @@ void HGCalDigiValidation::bookHistograms(DQMStore::IBooker& iB,
iB.setCurrentFolder("HGCAL/HGCalDigisV/"+nameDetector_);

std::ostringstream histoname;
for (int ilayer = 0; ilayer < layers_; ilayer++ ) {
for (int il = 0; il < layers_; ++il) {
int ilayer = firstLayer_ + il;
histoname.str(""); histoname << "charge_"<< "layer_" << ilayer;
charge_.push_back(iB.book1D(histoname.str().c_str(),"charge_",100,-25,25));

Expand Down
57 changes: 30 additions & 27 deletions Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc
Expand Up @@ -77,6 +77,7 @@ class HGCalRecHitValidation : public DQMEDAnalyzer {
bool ifHCAL_;
int verbosity_;
unsigned int layers_;
int firstLayer_;
std::map<int, int> OccupancyMap_plus;
std::map<int, int> OccupancyMap_minus;

Expand All @@ -87,13 +88,13 @@ class HGCalRecHitValidation : public DQMEDAnalyzer {
std::vector<MonitorElement*> HitOccupancy_Minus_;
MonitorElement* MeanHitOccupancy_Plus_;
MonitorElement* MeanHitOccupancy_Minus_;
static const int emptyScintLayer = 8;
};

HGCalRecHitValidation::HGCalRecHitValidation(const edm::ParameterSet& iConfig):
nameDetector_(iConfig.getParameter<std::string>("DetectorName")),
ifHCAL_(iConfig.getParameter<bool>("ifHCAL")),
verbosity_(iConfig.getUntrackedParameter<int>("Verbosity",0)) {
verbosity_(iConfig.getUntrackedParameter<int>("Verbosity",0)),
firstLayer_(1) {

auto temp = iConfig.getParameter<edm::InputTag>("RecHitSource");
if (nameDetector_ == "HGCalEESensitive" ||
Expand Down Expand Up @@ -136,7 +137,6 @@ void HGCalRecHitValidation::analyze(const edm::Event& iEvent,
<< "Object for " << nameDetector_;
} else {
const CaloGeometry* geom0 = geom.product();

if (ifHCAL_) {
edm::Handle<HBHERecHitCollection> hbhecoll;
iEvent.getByToken(recHitSource_, hbhecoll);
Expand All @@ -156,15 +156,15 @@ void HGCalRecHitValidation::analyze(const edm::Event& iEvent,
}
} else {
ok = false;
edm::LogVerbatim("HGCalValidation") << "HBHERecHitCollection Handle does not "
<< "exist !!!";
edm::LogVerbatim("HGCalValidation") << "HBHERecHitCollection Handle "
<< "does not exist !!!";
}
} else {
edm::Handle<HGChebRecHitCollection> hbhecoll;
iEvent.getByToken(recHitSource_, hbhecoll);
if (hbhecoll.isValid()) {
if (verbosity_>0)
edm::LogVerbatim("HGCalValidation") << nameDetector_ << " with "
edm::LogVerbatim("HGCalValidation") << nameDetector_ << " with "
<< hbhecoll->size()
<< " element(s)";
for (const auto & it : *(hbhecoll.product())) {
Expand All @@ -175,17 +175,17 @@ void HGCalRecHitValidation::analyze(const edm::Event& iEvent,
}
} else {
ok = false;
edm::LogVerbatim("HGCalValidation") << "HGChebRecHitCollection Handle does not "
<< "exist !!!";
edm::LogVerbatim("HGCalValidation") << "HGChebRecHitCollection "
<< "Handle does not exist !!!";
}
}
}
} else {
edm::ESHandle<HGCalGeometry> geom;
iSetup.get<IdealGeometryRecord>().get(nameDetector_, geom);
if (!geom.isValid()) {
edm::LogVerbatim("HGCalValidation") << "Cannot get valid HGCalGeometry Object for "
<< nameDetector_;
edm::LogVerbatim("HGCalValidation") << "Cannot get valid HGCalGeometry "
<< "Object for " << nameDetector_;
} else {
const HGCalGeometry* geom0 = geom.product();
HGCalGeometryMode::GeometryMode mode = geom0->topology().geomMode();
Expand All @@ -205,13 +205,13 @@ void HGCalRecHitValidation::analyze(const edm::Event& iEvent,
DetId detId = it.id();
int layer = ((geomType == 0) ? HGCalDetId(detId).layer() :
((geomType == 1) ? HGCSiliconDetId(detId).layer() :
HGCScintillatorDetId(detId).layer()+emptyScintLayer));
HGCScintillatorDetId(detId).layer()));
recHitValidation(detId, layer, geom0, &it);
}
} else {
ok = false;
edm::LogVerbatim("HGCalValidation") << "HGCRecHitCollection Handle does not "
<< "exist !!!";
edm::LogVerbatim("HGCalValidation") << "HGCRecHitCollection Handle "
<< "does not exist !!!";
}
}
}
Expand All @@ -237,7 +237,7 @@ void HGCalRecHitValidation::recHitValidation(DetId & detId, int layer,
hinfo.x = globalx;
hinfo.y = globaly;
hinfo.z = globalz;
hinfo.layer = std::min((unsigned)layer,layers_);
hinfo.layer = layer-firstLayer_;
hinfo.phi = global.phi();
hinfo.eta = global.eta();

Expand All @@ -250,35 +250,36 @@ void HGCalRecHitValidation::recHitValidation(DetId & detId, int layer,

fillHitsInfo(hinfo);

if (hinfo.eta > 0) fillOccupancyMap(OccupancyMap_plus, hinfo.layer -1);
else fillOccupancyMap(OccupancyMap_minus, hinfo.layer -1);
if (hinfo.eta > 0) fillOccupancyMap(OccupancyMap_plus, hinfo.layer);
else fillOccupancyMap(OccupancyMap_minus, hinfo.layer);

}

void HGCalRecHitValidation::fillOccupancyMap(std::map<int, int>& OccupancyMap, int layer){
void HGCalRecHitValidation::fillOccupancyMap(std::map<int, int>& OccupancyMap,
int layer) {
if (OccupancyMap.find(layer) != OccupancyMap.end()) OccupancyMap[layer]++;
else OccupancyMap[layer] = 1;
}

void HGCalRecHitValidation::fillHitsInfo() {

for (auto itr = OccupancyMap_plus.begin() ; itr != OccupancyMap_plus.end(); ++itr) {
int layer = (*itr).first;
int occupancy = (*itr).second;
for (auto const& itr : OccupancyMap_plus) {
int layer = itr.first;
int occupancy = itr.second;
HitOccupancy_Plus_.at(layer)->Fill(occupancy);
}

for (auto itr = OccupancyMap_minus.begin() ; itr != OccupancyMap_minus.end(); ++itr) {
int layer = (*itr).first;
int occupancy = (*itr).second;
for (auto const & itr : OccupancyMap_minus) {
int layer = itr.first;
int occupancy = itr.second;
HitOccupancy_Minus_.at(layer)->Fill(occupancy);
}

}

void HGCalRecHitValidation::fillHitsInfo(HitsInfo& hits) {

unsigned int ilayer = hits.layer -1;
unsigned int ilayer = hits.layer;
energy_.at(ilayer)->Fill(hits.energy);

EtaPhi_Plus_.at(ilayer)->Fill(hits.eta , hits.phi);
Expand All @@ -287,7 +288,7 @@ void HGCalRecHitValidation::fillHitsInfo(HitsInfo& hits) {
}

void HGCalRecHitValidation::dqmBeginRun(const edm::Run&,
const edm::EventSetup& iSetup) {
const edm::EventSetup& iSetup) {

if (nameDetector_ == "HCal") {
edm::ESHandle<HcalDDDRecConstants> pHRNDC;
Expand All @@ -298,7 +299,8 @@ void HGCalRecHitValidation::dqmBeginRun(const edm::Run&,
edm::ESHandle<HGCalDDDConstants> pHGDC;
iSetup.get<IdealGeometryRecord>().get(nameDetector_, pHGDC);
const HGCalDDDConstants & hgcons_ = (*pHGDC);
layers_ = hgcons_.layers(true);
layers_ = hgcons_.layers(true);
firstLayer_ = hgcons_.firstLayer();
}
}

Expand All @@ -308,7 +310,8 @@ void HGCalRecHitValidation::bookHistograms(DQMStore::IBooker& iB,

iB.setCurrentFolder("HGCAL/HGCalRecHitsV/"+nameDetector_);
std::ostringstream histoname;
for (unsigned int ilayer = 0; ilayer < layers_; ilayer++ ) {
for (unsigned int il=0; il<layers_; ++il) {
int ilayer = firstLayer_ + (int)(il);
histoname.str(""); histoname << "HitOccupancy_Plus_layer_" << ilayer;
HitOccupancy_Plus_.push_back(iB.book1D( histoname.str().c_str(), "RecHitOccupancy_Plus", 100, 0, 10000));
histoname.str(""); histoname << "HitOccupancy_Minus_layer_" << ilayer;
Expand Down

0 comments on commit ab93559

Please sign in to comment.