CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
HcalGeomCheck Class Reference
Inheritance diagram for HcalGeomCheck:
edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  hitsinfo
 

Public Member Functions

 HcalGeomCheck (const edm::ParameterSet &)
 
 ~HcalGeomCheck () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) override
 
void beginJob () override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Private Member Functions

void analyzeHits (int, const std::string &, const std::vector< PCaloHit > &)
 

Private Attributes

const std::string caloHitSource_
 
const int depthMax_
 
std::vector< TH1D * > h_E_
 
std::map< int, TH1D * > h_eta_
 
std::map< std::pair< int, int >, TH1D * > h_phi_
 
TH2D * h_RZ_
 
std::vector< TH1D * > h_T_
 
const HcalDDDRecConstantshcons_
 
const int ietaMax_
 
const int ietaMin_
 
const int nbinR_
 
const int nbinZ_
 
const double rmax_
 
const double rmin_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_hits_
 
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecordtok_HRNDC_
 
const int verbosity_
 
const double zmax_
 
const double zmin_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Detailed Description

Definition at line 40 of file HcalGeomCheck.cc.

Constructor & Destructor Documentation

◆ HcalGeomCheck()

HcalGeomCheck::HcalGeomCheck ( const edm::ParameterSet iConfig)
explicit

Definition at line 76 of file HcalGeomCheck.cc.

References TFileService::kSharedResource.

77  : caloHitSource_(iConfig.getParameter<std::string>("caloHitSource")),
78  ietaMin_(iConfig.getUntrackedParameter<int>("ietaMin", -41)),
79  ietaMax_(iConfig.getUntrackedParameter<int>("ietaMax", 41)),
80  depthMax_(iConfig.getUntrackedParameter<int>("depthMax", 7)),
81  rmin_(iConfig.getUntrackedParameter<double>("rMin", 0.0)),
82  rmax_(iConfig.getUntrackedParameter<double>("rMax", 5500.0)),
83  zmin_(iConfig.getUntrackedParameter<double>("zMin", -12500.0)),
84  zmax_(iConfig.getUntrackedParameter<double>("zMax", 12500.0)),
85  nbinR_(iConfig.getUntrackedParameter<int>("nBinR", 550)),
86  nbinZ_(iConfig.getUntrackedParameter<int>("nBinZ", 2500)),
87  verbosity_(iConfig.getUntrackedParameter<int>("verbosity", 0)),
88  tok_hits_(consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", caloHitSource_))),
89  tok_HRNDC_(esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>()) {
90  usesResource(TFileService::kSharedResource);
91 }
static const std::string kSharedResource
Definition: TFileService.h:76
const double rmax_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const int ietaMin_
const int depthMax_
const int nbinR_
T getUntrackedParameter(std::string const &, T const &) const
const int ietaMax_
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_HRNDC_
const double zmin_
const int nbinZ_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
const std::string caloHitSource_
const double rmin_
const double zmax_
const int verbosity_

◆ ~HcalGeomCheck()

HcalGeomCheck::~HcalGeomCheck ( )
overridedefault

Member Function Documentation

◆ analyze()

void HcalGeomCheck::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 109 of file HcalGeomCheck.cc.

References funct::cos(), hcalRecHitTable_cff::depth, hcalRecHitTable_cff::detId, hcalRecHitTable_cff::energy, fastmath::etaphi(), HcalDDDRecConstants::getEtaPhi(), HcalDDDRecConstants::getRZ(), h_E_, h_eta_, h_phi_, h_RZ_, h_T_, hcons_, hit::id, hcalRecHitTable_cff::ieta, iEvent, hcalRecHitTable_cff::iphi, edm::HandleBase::isValid(), edm::Handle< T >::product(), HcalHitRelabeller::relabel(), funct::sin(), nnet::tanh(), hcalRecHitTable_cff::time, tok_hits_, and verbosity_.

109  {
110  //Now the hits
111  const edm::Handle<edm::PCaloHitContainer>& theCaloHitContainer = iEvent.getHandle(tok_hits_);
112  if (theCaloHitContainer.isValid()) {
113  if (verbosity_ > 0)
114  edm::LogVerbatim("HcalValidation") << " PcalohitItr = " << theCaloHitContainer->size();
115 
116  //Merge hits for the same DetID
117  std::map<HcalDetId, hitsinfo> map_hits;
118  for (auto const& hit : *(theCaloHitContainer.product())) {
119  unsigned int id = hit.id();
121  double energy = hit.energy();
122  double time = hit.time();
123  int subdet = detId.subdet();
124  int ieta = detId.ieta();
125  int iphi = detId.iphi();
126  int depth = detId.depth();
127  std::pair<double, double> etaphi = hcons_->getEtaPhi(subdet, ieta, iphi);
128  double rz = hcons_->getRZ(subdet, ieta, depth);
129  if (verbosity_ > 2)
130  edm::LogVerbatim("HcalValidation") << "i/p " << subdet << ":" << ieta << ":" << iphi << ":" << depth << " o/p "
131  << etaphi.first << ":" << etaphi.second << ":" << rz;
132  HepGeom::Point3D<float> gcoord = HepGeom::Point3D<float>(rz * cos(etaphi.second) / cosh(etaphi.first),
133  rz * sin(etaphi.second) / cosh(etaphi.first),
134  rz * tanh(etaphi.first));
135  double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
136  if (verbosity_ > 1)
137  edm::LogVerbatim("HcalValidation")
138  << "Detector " << subdet << " ieta = " << ieta << " iphi = " << iphi << " depth = " << depth
139  << " positon = " << gcoord << " energy = " << energy << " time = " << time << ":" << tof;
140  time -= tof;
141  if (time < 0)
142  time = 0;
143  hitsinfo hinfo;
144  if (map_hits.count(detId) != 0) {
145  hinfo = map_hits[detId];
146  } else {
147  hinfo.phi = gcoord.getPhi();
148  hinfo.eta = gcoord.getEta();
149  hinfo.time = time;
150  }
151  hinfo.energy += energy;
152  map_hits[detId] = hinfo;
153 
154  h_RZ_->Fill(gcoord.z(), gcoord.rho());
155  }
156 
157  //Fill in histograms
158  for (auto const& hit : map_hits) {
159  hitsinfo hinfo = hit.second;
160  int subdet = hit.first.subdet();
161  if (subdet > 0 && subdet < static_cast<int>(h_E_.size())) {
162  int depth = hit.first.depth();
163  int ieta = hit.first.ieta();
164  int iphi = hit.first.iphi();
165  if (verbosity_ > 1)
166  edm::LogVerbatim("HGCalValidation")
167  << " ---------------------- eta = " << ieta << ":" << hinfo.eta << " phi = " << iphi << ":" << hinfo.phi
168  << " depth = " << depth << " E = " << hinfo.energy << " T = " << hinfo.time;
169  h_E_[subdet]->Fill(hinfo.energy);
170  h_T_[subdet]->Fill(hinfo.time);
171  auto itr1 = h_phi_.find(std::pair<int, int>(ieta, depth));
172  if (itr1 != h_phi_.end())
173  itr1->second->Fill(iphi);
174  auto itr2 = h_eta_.find(depth);
175  if (itr2 != h_eta_.end())
176  itr2->second->Fill(ieta);
177  }
178  }
179  } else if (verbosity_ > 0) {
180  edm::LogVerbatim("HcalValidation") << "PCaloHitContainer does not "
181  << "exist for HCAL";
182  }
183 }
std::pair< T, T > etaphi(T x, T y, T z)
Definition: FastMath.h:162
Log< level::Info, true > LogVerbatim
double getRZ(const int &subdet, const int &ieta, const int &depth) const
std::vector< TH1D * > h_T_
void tanh(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T const * product() const
Definition: Handle.h:70
const HcalDDDRecConstants * hcons_
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
int iEvent
Definition: GenABIO.cc:224
std::map< std::pair< int, int >, TH1D * > h_phi_
std::map< int, TH1D * > h_eta_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< TH1D * > h_E_
DetId relabel(const uint32_t testId) const
unsigned int id
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
bool isValid() const
Definition: HandleBase.h:70
const int verbosity_

◆ analyzeHits()

void HcalGeomCheck::analyzeHits ( int  ,
const std::string &  ,
const std::vector< PCaloHit > &   
)
private

◆ beginJob()

void HcalGeomCheck::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 193 of file HcalGeomCheck.cc.

References hcalRecHitTable_cff::depth, depthMax_, compareTotals::fs, h_E_, h_eta_, h_phi_, h_RZ_, h_T_, hcalRecHitTable_cff::ieta, ietaMax_, ietaMin_, Skims_PA_cff::name, nbinR_, nbinZ_, rmax_, rmin_, runGCPTkAlMap::title, verbosity_, zmax_, and zmin_.

193  {
194  if (verbosity_ > 2)
195  edm::LogVerbatim("HcalValidation") << "HcalGeomCheck:: Enter beginJob";
197  h_RZ_ = fs->make<TH2D>("RZ", "R vs Z", nbinZ_, zmin_, zmax_, nbinR_, rmin_, rmax_);
198  if (verbosity_ > 2)
199  edm::LogVerbatim("HcalValidation") << "HcalGeomCheck: booked scatterplot RZ";
200  char name[20], title[100];
201  for (int depth = 1; depth < depthMax_; ++depth) {
202  for (int ieta = ietaMin_; ieta <= ietaMax_; ++ieta) {
203  sprintf(name, "phi%d%d", ieta, depth);
204  sprintf(title, "i#phi (i#eta = %d, depth = %d)", ieta, depth);
205  h_phi_[std::pair<int, int>(ieta, depth)] = fs->make<TH1D>(name, title, 400, -20, 380);
206  if (verbosity_ > 2)
207  edm::LogVerbatim("HcalValidation") << "HcalGeomCheck: books " << title;
208  }
209  sprintf(name, "eta%d", depth);
210  sprintf(title, "i#eta (depth = %d)", depth);
211  h_eta_[depth] = fs->make<TH1D>(name, title, 100, -50, 50);
212  if (verbosity_ > 2)
213  edm::LogVerbatim("HcalValidation") << "HcalGeomCheck: books " << title;
214  }
215 
216  std::vector<std::string> dets = {"HCAL", "HB", "HE", "HF", "HO"};
217  for (unsigned int ih = 0; ih < dets.size(); ++ih) {
218  sprintf(name, "E_%s", dets[ih].c_str());
219  sprintf(title, "Energy deposit in %s (MeV)", dets[ih].c_str());
220  h_E_.emplace_back(fs->make<TH1D>(name, title, 1000, 0.0, 1.0));
221  if (verbosity_ > 2)
222  edm::LogVerbatim("HcalValidation") << "HcalGeomCheck: books " << title;
223  sprintf(name, "T_%s", dets[ih].c_str());
224  sprintf(title, "Time of hit in %s (ns)", dets[ih].c_str());
225  h_T_.emplace_back(fs->make<TH1D>(name, title, 1000, 0.0, 200.0));
226  if (verbosity_ > 2)
227  edm::LogVerbatim("HcalValidation") << "HcalGeomCheck: books " << title;
228  }
229 }
Log< level::Info, true > LogVerbatim
const double rmax_
std::vector< TH1D * > h_T_
const int ietaMin_
const int depthMax_
const int nbinR_
const int ietaMax_
std::map< std::pair< int, int >, TH1D * > h_phi_
std::map< int, TH1D * > h_eta_
const double zmin_
std::vector< TH1D * > h_E_
const int nbinZ_
const double rmin_
const double zmax_
const int verbosity_

◆ beginRun()

void HcalGeomCheck::beginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
)
overrideprotected

Definition at line 186 of file HcalGeomCheck.cc.

References edm::EventSetup::getData(), hcons_, tok_HRNDC_, and verbosity_.

186  {
187  const auto& pHRNDC = iSetup.getData(tok_HRNDC_);
188  hcons_ = &pHRNDC;
189  if (verbosity_ > 0)
190  edm::LogVerbatim("HcalValidation") << "Obtain HcalDDDRecConstants from Event Setup";
191 }
Log< level::Info, true > LogVerbatim
const HcalDDDRecConstants * hcons_
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_HRNDC_
const int verbosity_

◆ endRun()

void HcalGeomCheck::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprotected

Definition at line 55 of file HcalGeomCheck.cc.

55 {}

◆ fillDescriptions()

void HcalGeomCheck::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 93 of file HcalGeomCheck.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

93  {
95  desc.add<std::string>("caloHitSource", "HcalHits");
96  desc.addUntracked<int>("ietaMin", -41);
97  desc.addUntracked<int>("ietaMax", 41);
98  desc.addUntracked<int>("depthMax", 7);
99  desc.addUntracked<double>("rMin", 0.0);
100  desc.addUntracked<double>("rMax", 5500.0);
101  desc.addUntracked<double>("zMin", -12500.0);
102  desc.addUntracked<double>("zMax", 12500.0);
103  desc.addUntracked<int>("nBinR", 550);
104  desc.addUntracked<int>("nBinZ", 250);
105  desc.addUntracked<int>("verbosity", 0);
106  descriptions.add("hcalGeomCheck", desc);
107 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ caloHitSource_

const std::string HcalGeomCheck::caloHitSource_
private

Definition at line 61 of file HcalGeomCheck.cc.

◆ depthMax_

const int HcalGeomCheck::depthMax_
private

Definition at line 62 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ h_E_

std::vector<TH1D*> HcalGeomCheck::h_E_
private

Definition at line 73 of file HcalGeomCheck.cc.

Referenced by analyze(), and beginJob().

◆ h_eta_

std::map<int, TH1D*> HcalGeomCheck::h_eta_
private

Definition at line 72 of file HcalGeomCheck.cc.

Referenced by analyze(), and beginJob().

◆ h_phi_

std::map<std::pair<int, int>, TH1D*> HcalGeomCheck::h_phi_
private

Definition at line 71 of file HcalGeomCheck.cc.

Referenced by analyze(), and beginJob().

◆ h_RZ_

TH2D* HcalGeomCheck::h_RZ_
private

Definition at line 70 of file HcalGeomCheck.cc.

Referenced by analyze(), and beginJob().

◆ h_T_

std::vector<TH1D*> HcalGeomCheck::h_T_
private

Definition at line 73 of file HcalGeomCheck.cc.

Referenced by analyze(), and beginJob().

◆ hcons_

const HcalDDDRecConstants* HcalGeomCheck::hcons_
private

Definition at line 67 of file HcalGeomCheck.cc.

Referenced by analyze(), and beginRun().

◆ ietaMax_

const int HcalGeomCheck::ietaMax_
private

Definition at line 62 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ ietaMin_

const int HcalGeomCheck::ietaMin_
private

Definition at line 62 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ nbinR_

const int HcalGeomCheck::nbinR_
private

Definition at line 64 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ nbinZ_

const int HcalGeomCheck::nbinZ_
private

Definition at line 64 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ rmax_

const double HcalGeomCheck::rmax_
private

Definition at line 63 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ rmin_

const double HcalGeomCheck::rmin_
private

Definition at line 63 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ tok_hits_

const edm::EDGetTokenT<edm::PCaloHitContainer> HcalGeomCheck::tok_hits_
private

Definition at line 65 of file HcalGeomCheck.cc.

Referenced by analyze().

◆ tok_HRNDC_

const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> HcalGeomCheck::tok_HRNDC_
private

Definition at line 66 of file HcalGeomCheck.cc.

Referenced by beginRun().

◆ verbosity_

const int HcalGeomCheck::verbosity_
private

Definition at line 64 of file HcalGeomCheck.cc.

Referenced by analyze(), beginJob(), and beginRun().

◆ zmax_

const double HcalGeomCheck::zmax_
private

Definition at line 63 of file HcalGeomCheck.cc.

Referenced by beginJob().

◆ zmin_

const double HcalGeomCheck::zmin_
private

Definition at line 63 of file HcalGeomCheck.cc.

Referenced by beginJob().