Skip to content

Commit

Permalink
Merge pull request #39486 from bsunanda/Phase2-hgx325H
Browse files Browse the repository at this point in the history
Phase2-hgx325H Remove unnecessary includes which were used in earlier versions of codes in Validation/HGCalValidation/plugins
  • Loading branch information
cmsbuild authored Sep 27, 2022
2 parents b79b70b + 17884eb commit 4561e8f
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 76 deletions.
161 changes: 152 additions & 9 deletions Validation/HGCalValidation/macros/MakePlots.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,51 @@
// Plots histograms created by HGCalBHValidation
// void hgcalSiliconAnalysisPlots(fname, tag, dtype, save, debug)
// Plots histograms created by HGCalSiliconValidation
// void hgcalMissedHitPlots(fname, tag, dtype, save, debug)
// Plots histograms created by HGCalMissedRecHit
// void ehcalPlots(fname, dirnm, tag, dets, save, debug)
// Plots histograms created by EcalSimHitStudy
//
// where
// fanme (std::string) Input ROOT file name
// ("hfnRecHitD31tt.root" for noseRecHitPlots,
// "roots/hgcSimHitD83tt.root" studyPlots,
// "roots/hgcGeomCheckD83.root" GeomCheck,
// "roots/hgcBHValidD83.root" BHValid)
// "roots/hgcSimHitD83tt.root" hgcalStudyPlots,
// "roots/hgcGeomCheckD83.root" hgcalGeomCheck,
// "roots/hgcBHValidD83.root" hgcalBHValid,
// "roots/hgcSilValidD86.root" hgcalSiliconAnalysis,
// "missedRecHitD88.root" hgcalMissedHitPlots,
// "ecalHitdd4hep.root" ehcalPlot)
// dirnm (std::string) Directory name
// ("hfnoseRecHitStudy" for noseRecHitPlots)
// ("hfnoseRecHitStudy" for noseRecHitPlots
// "hgcGeomCheck" for hgcalGeomCheck,
// "hgcalBHAnalysis" for hgcalBHValid,
// "hgcMissingRecHit" for hgcalMissedHitPlots,
// "EcalSimHitStudy" for ehcalPlot)
// type (int) Type: 0 SimHit; 1 Digi; 2 RecHit (0)
// tag (std::string) Name of the tag for the canvas name
// ("HFNose" for noseRecHitPlots,
// "SimHitD83" for studyPlots,
// "GeomChkD83" for GeomCheck,
// "BHValidD83" for BHValid)
// "SimHitD83" for hgcalStudyPlots,
// "GeomChkD83" for hgcalGeomCheck,
// "BHValidD83" for hgcalBHValid,
// "SilValidD86" for hgcalSiliconAnalysisPlots,
// "MissedHitD88" for hgcalMissedHitPlots,
// "DD4Hep" for ehcalPlots)
// dtype (std::string) Data type added for canvas name
// ("ttbar D83" for studyPlots,
// "#mu D83" for geomCheck, BHValid)
// ("ttbar D83" for hgcalStudyPlots,
// "#mu D83" for hgcalGeomCheck, hgcalBHValid',
// "ttbar D86" for hgcalSiliconAnalysisPlots,
// "#mu D88" for hgcalMissedHitPlots)
// save (bool) Flag to save the canvas (false)
// debug (bool) Debug flag (false)
//
// In addition there is a tree analysis class to study the ROOT tree
// created by HGCHitAnalysis code. To invoke this, one needs to do
// the following steps:
// .L MakePlots.C+g
// hgchits c1(fname);
// c1.Loop();
// c1.saveHistos(outFile);
//
//###########################################################################
//
#include <TROOT.h>
Expand Down Expand Up @@ -566,6 +590,125 @@ void hgcalSiliconAnalysisPlots(std::string fname = "roots/hgcSilValidD86.root",
}
}

void hgcalMissedHitPlots(std::string fname = "missedRecHitD88.root",
std::string tag = "MissedHitD88",
std::string dtype = "#mu D88",
bool save = false,
bool debug = false) {
std::string dirnm = "hgcMissingRecHit";
std::string name0 = "HGCal HE Scintillator";
const int nhist = 24;
std::string name2[nhist] = {"GoodDEHGCalEESensitive",
"MissDEHGCalEESensitive",
"GoodDEHGCalHESiliconSensitive",
"MissDEHGCalHESiliconSensitive",
"GoodDEHGCalHEScintillatorSensitive",
"MissDEHGCalHEScintillatorSensitive",
"GoodREHGCalEESensitive",
"MissREHGCalEESensitive",
"GoodREHGCalHESiliconSensitive",
"MissREHGCalHESiliconSensitive",
"GoodREHGCalHEScintillatorSensitive",
"MissREHGCalHEScintillatorSensitive",
"GoodDTHGCalEESensitive",
"MissDTHGCalEESensitive",
"GoodDTHGCalHESiliconSensitive",
"MissDTHGCalHESiliconSensitive",
"GoodDTHGCalHEScintillatorSensitive",
"MissDTHGCalHEScintillatorSensitive",
"GoodRTHGCalEESensitive",
"MissRTHGCalEESensitive",
"GoodRTHGCalHESiliconSensitive",
"MissRTHGCalHESiliconSensitive",
"GoodRTHGCalHEScintillatorSensitive",
"MissRTHGCalHEScintillatorSensitive"};
std::string xtitl[nhist] = {"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"SimHit Energy (GeV)",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|",
"|#eta|"};
std::string ytitl[nhist] = {"Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits",
"Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits",
"Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits"};
int ibin[nhist] = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
gStyle->SetCanvasBorderMode(0);
gStyle->SetCanvasColor(kWhite);
gStyle->SetPadColor(kWhite);
gStyle->SetFillColor(kWhite);
gStyle->SetOptStat(111110);
if (debug)
std::cout << "File " << fname << " Tags " << tag << " : " << dtype << " Save " << save << "\n";
TFile *file = new TFile(fname.c_str());
if (file) {
char dirx[100];
sprintf(dirx, "%s", dirnm.c_str());
TDirectory *dir = (TDirectory *)file->FindObjectAny(dirx);
if (debug)
std::cout << "Directory " << dirx << " : " << dir << std::endl;
if (dir) {
for (int ih = 0; ih < nhist; ++ih) {
char hname[100];
sprintf(hname, "%s", name2[ih].c_str());
TH1D *hist1 = (TH1D *)dir->FindObjectAny(hname);
if (debug)
std::cout << "Hist " << hname << " : " << hist1 << " Xtitle " << xtitl[ih] << " Ytitle " << ytitl[ih]
<< " ibin " << ibin[ih] << std::endl;
if (hist1 != nullptr) {
char name[100], title[100];
sprintf(name, "%s%s", hname, tag.c_str());
TCanvas *pad = new TCanvas(name, name, 500, 500);
pad->SetRightMargin(0.10);
pad->SetTopMargin(0.10);
sprintf(title, "%s (%s)", hist1->GetTitle(), dtype.c_str());
if (debug)
std::cout << "Pad " << name << " : " << pad << "\n";
hist1->GetYaxis()->SetTitle(ytitl[ih].c_str());
hist1->GetXaxis()->SetTitle(xtitl[ih].c_str());
hist1->SetTitle(title);
pad->SetLogy();
if (ibin[ih] > 0)
hist1->Rebin(ibin[ih]);
hist1->GetYaxis()->SetTitleOffset(1.2);
hist1->Draw();
pad->Update();
TPaveStats *st1 = ((TPaveStats *)hist1->GetListOfFunctions()->FindObject("stats"));
if (st1 != NULL) {
st1->SetY1NDC(0.70);
st1->SetY2NDC(0.90);
st1->SetX1NDC(0.65);
st1->SetX2NDC(0.90);
}
pad->Modified();
pad->Update();
if (save) {
sprintf(name, "c_%s.jpg", pad->GetName());
pad->Print(name);
}
}
}
}
}
}

void ehcalPlots(std::string fname = "ecalHitdd4hep.root",
std::string dirnm = "EcalSimHitStudy",
std::string tag = "DD4Hep",
Expand Down
19 changes: 5 additions & 14 deletions Validation/HGCalValidation/plugins/HGCGeometryValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"

Expand All @@ -22,19 +21,12 @@
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "SimG4CMS/Calo/interface/HGCNumberingScheme.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
#include "SimDataFormats/ValidationFormats/interface/PHGCalValidInfo.h"
#include "SimDataFormats/CaloTest/interface/HGCalTestNumbering.h"

#include "PhysicsTools/HepMCCandAlgos/interface/GenParticlesHelper.h"

#include "CLHEP/Geometry/Point3D.h"
#include "CLHEP/Geometry/Vector3D.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "CLHEP/Units/GlobalPhysicalConstants.h"

const double mmtocm = 0.1;

class HGCGeometryValidation : public DQMEDAnalyzer {
Expand Down Expand Up @@ -90,7 +82,6 @@ void HGCGeometryValidation::fillDescriptions(edm::ConfigurationDescriptions &des
}

void HGCGeometryValidation::dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {
//initiating hgcnumbering
for (size_t i = 0; i < geometrySource_.size(); i++) {
hgcGeometry_.emplace_back(&iSetup.getData(geomToken_[i]));
}
Expand Down Expand Up @@ -166,13 +157,13 @@ void HGCGeometryValidation::analyze(const edm::Event &iEvent, const edm::EventSe
std::vector<float> hitVtxX = infoLayer->hitvtxX();
std::vector<float> hitVtxY = infoLayer->hitvtxY();
std::vector<float> hitVtxZ = infoLayer->hitvtxZ();
std::vector<unsigned int> hitDet = infoLayer->hitDets();
std::vector<unsigned int> hitIdx = infoLayer->hitIndex();
const std::vector<unsigned int> &hitDet = infoLayer->hitDets();
const std::vector<unsigned int> &hitIdx = infoLayer->hitIndex();

//energy information
std::vector<float> edepLayerEE = infoLayer->eehgcEdep();
std::vector<float> edepLayerHE = infoLayer->hefhgcEdep();
std::vector<float> edepLayerHB = infoLayer->hebhgcEdep();
const std::vector<float> &edepLayerEE = infoLayer->eehgcEdep();
const std::vector<float> &edepLayerHE = infoLayer->hefhgcEdep();
const std::vector<float> &edepLayerHB = infoLayer->hebhgcEdep();

unsigned int i;
for (i = 0; i < edepLayerEE.size(); i++) {
Expand Down
3 changes: 0 additions & 3 deletions Validation/HGCalValidation/plugins/HGCalDigiValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include <vector>

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
#include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
#include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
Expand All @@ -26,7 +24,6 @@
#include "FWCore/Utilities/interface/InputTag.h"

#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"

Expand Down
10 changes: 2 additions & 8 deletions Validation/HGCalValidation/plugins/HGCalSimHitStudy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
#include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"

Expand All @@ -29,12 +27,8 @@
#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"

#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
#include "SimDataFormats/CaloTest/interface/HGCalTestNumbering.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"

#include "CLHEP/Geometry/Point3D.h"
#include "CLHEP/Geometry/Transform3D.h"
#include "CLHEP/Geometry/Vector3D.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "CLHEP/Units/GlobalPhysicalConstants.h"

Expand Down Expand Up @@ -201,8 +195,8 @@ void HGCalSimHitStudy::analyzeHits(int ih, std::string const& name, std::vector<
zside = detId.zside();
xy = hgcons_[ih]->locateCellTrap(layer, sector, cell, false);
} else {
HGCalTestNumbering::unpackHexagonIndex(id, subdet, zside, layer, sector, type, cell);
xy = hgcons_[ih]->locateCell(cell, layer, sector, false);
edm::LogError("HGCalValidation") << "HGCalSimHitStudy: Wrong geometry mode " << hgcons_[ih]->geomMode();
continue;
}
double zp = hgcons_[ih]->waferZ(layer, false);
if (zside < 0)
Expand Down
Loading

0 comments on commit 4561e8f

Please sign in to comment.