CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HGCalRecHitValidation Class Reference
Inheritance diagram for HGCalRecHitValidation:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Classes

struct  energysum
 
struct  HitsInfo
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
void dqmBeginRun (const edm::Run &, const edm::EventSetup &) override
 
 HGCalRecHitValidation (const edm::ParameterSet &)
 
 ~HGCalRecHitValidation () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void fillHitsInfo ()
 
void fillHitsInfo (HitsInfo &hits)
 
void fillOccupancyMap (std::map< int, int > &OccupancyMap, int layer)
 
template<class T1 , class T2 >
void recHitValidation (DetId &detId, int layer, const T1 *geom, T2 it)
 

Private Attributes

std::vector< MonitorElement * > energy_
 
std::vector< MonitorElement * > EtaPhi_Minus_
 
std::vector< MonitorElement * > EtaPhi_Plus_
 
int firstLayer_
 
std::vector< MonitorElement * > HitOccupancy_Minus_
 
std::vector< MonitorElement * > HitOccupancy_Plus_
 
bool ifHCAL_
 
unsigned int layers_
 
MonitorElementMeanHitOccupancy_Minus_
 
MonitorElementMeanHitOccupancy_Plus_
 
std::string nameDetector_
 
std::map< int, int > OccupancyMap_minus
 
std::map< int, int > OccupancyMap_plus
 
edm::EDGetToken recHitSource_
 
int verbosity_
 

Detailed Description

Definition at line 41 of file HGCalRecHitValidation.cc.

Constructor & Destructor Documentation

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

Definition at line 93 of file HGCalRecHitValidation.cc.

References Exception, edm::ParameterSet::getParameter(), ifHCAL_, nameDetector_, recHitSource_, and groupFilesInBlocks::temp.

93  :
94  nameDetector_(iConfig.getParameter<std::string>("DetectorName")),
95  ifHCAL_(iConfig.getParameter<bool>("ifHCAL")),
96  verbosity_(iConfig.getUntrackedParameter<int>("Verbosity",0)),
97  firstLayer_(1) {
98 
99  auto temp = iConfig.getParameter<edm::InputTag>("RecHitSource");
100  if (nameDetector_ == "HGCalEESensitive" ||
101  nameDetector_ == "HGCalHESiliconSensitive" ||
102  nameDetector_ == "HGCalHEScintillatorSensitive") {
103  recHitSource_ = consumes<HGCRecHitCollection>(temp);
104  } else if (nameDetector_ == "HCal") {
105  if (ifHCAL_) recHitSource_ = consumes<HBHERecHitCollection>(temp);
106  else recHitSource_ = consumes<HGChebRecHitCollection>(temp);
107  } else {
108  throw cms::Exception("BadHGCRecHitSource")
109  << "HGCal DetectorName given as " << nameDetector_ << " must be: "
110  << "\"HGCalHESiliconSensitive\", \"HGCalHESiliconSensitive\", "
111  << "\"HGCalHEScintillatorSensitive\", or \"HCal\"!";
112  }
113 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
HGCalRecHitValidation::~HGCalRecHitValidation ( )
inlineoverride

Member Function Documentation

void HGCalRecHitValidation::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 125 of file HGCalRecHitValidation.cc.

References HcalDetId::depth(), edm::EventID::event(), fillHitsInfo(), relativeConstraints::geom, motionPolicyChamber::geom0, HGCalTopology::geomMode(), edm::EventSetup::get(), edm::Event::getByToken(), HcalEndcap, HGCalGeometryMode::Hexagon8, HGCalGeometryMode::Hexagon8Full, edm::EventBase::id(), ifHCAL_, edm::ESHandleBase::isValid(), edm::HandleBase::isValid(), HGCalDetId::layer(), HGCScintillatorDetId::layer(), HGCSiliconDetId::layer(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, nameDetector_, OccupancyMap_minus, OccupancyMap_plus, convertSQLiteXML::ok, edm::Handle< T >::product(), edm::ESHandle< T >::product(), recHitSource_, recHitValidation(), edm::SortedCollection< T, SORT >::size(), DetId::subdetId(), HGCalGeometry::topology(), HGCalGeometryMode::Trapezoid, and verbosity_.

Referenced by ~HGCalRecHitValidation().

126  {
127  OccupancyMap_plus.clear();
128  OccupancyMap_minus.clear();
129 
130  bool ok(true);
131  unsigned int ntot(0), nused(0);
132  if (nameDetector_ == "HCal") {
134  iSetup.get<CaloGeometryRecord>().get(geom);
135  if (!geom.isValid()) {
136  edm::LogVerbatim("HGCalValidation") << "Cannot get valid HGCalGeometry "
137  << "Object for " << nameDetector_;
138  } else {
139  const CaloGeometry* geom0 = geom.product();
140  if (ifHCAL_) {
142  iEvent.getByToken(recHitSource_, hbhecoll);
143  if (hbhecoll.isValid()) {
144  if (verbosity_>0)
145  edm::LogVerbatim("HGCalValidation") << nameDetector_ << " with "
146  << hbhecoll->size()
147  << " element(s)";
148  for (const auto & it : *(hbhecoll.product())) {
149  DetId detId = it.id();
150  ntot++;
151  if (detId.subdetId() == HcalEndcap) {
152  nused++;
153  int layer = HcalDetId(detId).depth();
154  recHitValidation(detId, layer, geom0, &it);
155  }
156  }
157  } else {
158  ok = false;
159  edm::LogVerbatim("HGCalValidation") << "HBHERecHitCollection "
160  << "Handle does not exist !!!";
161  }
162  } else {
164  iEvent.getByToken(recHitSource_, hbhecoll);
165  if (hbhecoll.isValid()) {
166  if (verbosity_>0)
167  edm::LogVerbatim("HGCalValidation") << nameDetector_ << " with "
168  << hbhecoll->size()
169  << " element(s)";
170  for (const auto & it : *(hbhecoll.product())) {
171  DetId detId = it.id();
172  ntot++; nused++;
173  int layer = HcalDetId(detId).depth();
174  recHitValidation(detId, layer, geom0, &it);
175  }
176  } else {
177  ok = false;
178  edm::LogVerbatim("HGCalValidation") << "HGChebRecHitCollection "
179  << "Handle does not exist !!!";
180  }
181  }
182  }
183  } else {
185  iSetup.get<IdealGeometryRecord>().get(nameDetector_, geom);
186  if (!geom.isValid()) {
187  edm::LogVerbatim("HGCalValidation") << "Cannot get valid HGCalGeometry "
188  << "Object for " << nameDetector_;
189  } else {
190  const HGCalGeometry* geom0 = geom.product();
192  int geomType = (((mode == HGCalGeometryMode::Hexagon8) ||
193  (mode == HGCalGeometryMode::Hexagon8Full)) ? 1 :
194  ((mode == HGCalGeometryMode::Trapezoid) ? 2 : 0));
195 
196  edm::Handle<HGCRecHitCollection> theRecHitContainers;
197  iEvent.getByToken(recHitSource_, theRecHitContainers);
198  if (theRecHitContainers.isValid()) {
199  if (verbosity_>0)
200  edm::LogVerbatim("HGCalValidation") << nameDetector_ << " with "
201  << theRecHitContainers->size()
202  << " element(s)";
203  for (const auto & it : *(theRecHitContainers.product())) {
204  ntot++; nused++;
205  DetId detId = it.id();
206  int layer = ((geomType == 0) ? HGCalDetId(detId).layer() :
207  ((geomType == 1) ? HGCSiliconDetId(detId).layer() :
208  HGCScintillatorDetId(detId).layer()));
209  recHitValidation(detId, layer, geom0, &it);
210  }
211  } else {
212  ok = false;
213  edm::LogVerbatim("HGCalValidation") << "HGCRecHitCollection Handle "
214  << "does not exist !!!";
215  }
216  }
217  }
218  if (ok) fillHitsInfo();
219  if (verbosity_>0)
220  edm::LogVerbatim("HGCalValidation") << "Event " << iEvent.id().event()
221  << " with " << ntot << " total and "
222  << nused << " used recHits";
223 }
HGCalGeometryMode::GeometryMode geomMode() const
Geometry mode.
Definition: HGCalTopology.h:88
EventNumber_t event() const
Definition: EventID.h:41
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int depth() const
get the tower depth
Definition: HcalDetId.h:166
std::map< int, int > OccupancyMap_minus
int layer() const
get the layer #
const HGCalTopology & topology() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
bool isValid() const
Definition: HandleBase.h:74
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:74
int layer() const
get the layer #
std::map< int, int > OccupancyMap_plus
edm::EventID id() const
Definition: EventBase.h:59
size_type size() const
T get() const
Definition: EventSetup.h:71
bool isValid() const
Definition: ESHandle.h:44
T const * product() const
Definition: ESHandle.h:86
void recHitValidation(DetId &detId, int layer, const T1 *geom, T2 it)
int layer() const
get the layer #
Definition: HGCalDetId.h:48
void HGCalRecHitValidation::bookHistograms ( DQMStore::IBooker iB,
edm::Run const &  ,
edm::EventSetup const &   
)
override

Definition at line 308 of file HGCalRecHitValidation.cc.

References DQMStore::IBooker::book1D(), DQMStore::IBooker::book2D(), DEFINE_FWK_MODULE, energy_, EtaPhi_Minus_, EtaPhi_Plus_, firstLayer_, HitOccupancy_Minus_, HitOccupancy_Plus_, createfilelist::int, layers_, MeanHitOccupancy_Minus_, MeanHitOccupancy_Plus_, nameDetector_, pi, and DQMStore::IBooker::setCurrentFolder().

Referenced by ~HGCalRecHitValidation().

310  {
311 
312  iB.setCurrentFolder("HGCAL/HGCalRecHitsV/"+nameDetector_);
313  std::ostringstream histoname;
314  for (unsigned int il=0; il<layers_; ++il) {
315  int ilayer = firstLayer_ + (int)(il);
316  histoname.str(""); histoname << "HitOccupancy_Plus_layer_" << ilayer;
317  HitOccupancy_Plus_.push_back(iB.book1D( histoname.str().c_str(), "RecHitOccupancy_Plus", 100, 0, 10000));
318  histoname.str(""); histoname << "HitOccupancy_Minus_layer_" << ilayer;
319  HitOccupancy_Minus_.push_back(iB.book1D( histoname.str().c_str(), "RecHitOccupancy_Minus", 100, 0, 10000));
320 
321  histoname.str(""); histoname << "EtaPhi_Plus_" << "layer_" << ilayer;
322  EtaPhi_Plus_.push_back(iB.book2D(histoname.str().c_str(), "Occupancy", 31, 1.45, 3.0, 72, -CLHEP::pi, CLHEP::pi));
323  histoname.str(""); histoname << "EtaPhi_Minus_" << "layer_" << ilayer;
324  EtaPhi_Minus_.push_back(iB.book2D(histoname.str().c_str(), "Occupancy", 31, -3.0, -1.45, 72, -CLHEP::pi, CLHEP::pi));
325 
326  histoname.str(""); histoname << "energy_layer_" << ilayer;
327  energy_.push_back(iB.book1D(histoname.str().c_str(),"energy_",500,0,1));
328  }//loop over layers ends here
329 
330  histoname.str(""); histoname << "SUMOfRecHitOccupancy_Plus";
331  MeanHitOccupancy_Plus_= iB.book1D( histoname.str().c_str(), "SUMOfRecHitOccupancy_Plus", layers_, -0.5, layers_-0.5);
332  histoname.str(""); histoname << "SUMOfRecHitOccupancy_Minus";
333  MeanHitOccupancy_Minus_ = iB.book1D( histoname.str().c_str(), "SUMOfRecHitOccupancy_Minus", layers_, -0.5,layers_-0.5);
334 }
std::vector< MonitorElement * > EtaPhi_Minus_
std::vector< MonitorElement * > EtaPhi_Plus_
std::vector< MonitorElement * > HitOccupancy_Minus_
const Double_t pi
MonitorElement * MeanHitOccupancy_Plus_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * MeanHitOccupancy_Minus_
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
std::vector< MonitorElement * > HitOccupancy_Plus_
std::vector< MonitorElement * > energy_
void HGCalRecHitValidation::dqmBeginRun ( const edm::Run ,
const edm::EventSetup iSetup 
)
override

Definition at line 291 of file HGCalRecHitValidation.cc.

References HGCalDDDConstants::firstLayer(), firstLayer_, edm::EventSetup::get(), HcalDDDRecConstants::getMaxDepth(), HGCalDDDConstants::layers(), layers_, and nameDetector_.

Referenced by ~HGCalRecHitValidation().

292  {
293 
294  if (nameDetector_ == "HCal") {
296  iSetup.get<HcalRecNumberingRecord>().get( pHRNDC );
297  const HcalDDDRecConstants *hcons = &(*pHRNDC);
298  layers_ = hcons->getMaxDepth(1);
299  } else {
301  iSetup.get<IdealGeometryRecord>().get(nameDetector_, pHGDC);
302  const HGCalDDDConstants & hgcons_ = (*pHGDC);
303  layers_ = hgcons_.layers(true);
304  firstLayer_ = hgcons_.firstLayer();
305  }
306 }
unsigned int layers(bool reco) const
int getMaxDepth(const int &type) const
T get() const
Definition: EventSetup.h:71
int firstLayer() const
void HGCalRecHitValidation::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 116 of file HGCalRecHitValidation.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~HGCalRecHitValidation().

116  {
118  desc.add<std::string>("DetectorName","HGCalEESensitive");
119  desc.add<edm::InputTag>("RecHitSource",edm::InputTag("HGCalRecHit","HGCEERecHits"));
120  desc.add<bool>("ifHCAL",false);
121  desc.addUntracked<int>("Verbosity",0);
122  descriptions.add("hgcalRecHitValidationEE",desc);
123 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void HGCalRecHitValidation::fillHitsInfo ( )
private

Definition at line 265 of file HGCalRecHitValidation.cc.

References HitOccupancy_Minus_, HitOccupancy_Plus_, OccupancyMap_minus, and OccupancyMap_plus.

Referenced by analyze(), recHitValidation(), and ~HGCalRecHitValidation().

265  {
266 
267  for (auto const& itr : OccupancyMap_plus) {
268  int layer = itr.first;
269  int occupancy = itr.second;
270  HitOccupancy_Plus_.at(layer)->Fill(occupancy);
271  }
272 
273  for (auto const & itr : OccupancyMap_minus) {
274  int layer = itr.first;
275  int occupancy = itr.second;
276  HitOccupancy_Minus_.at(layer)->Fill(occupancy);
277  }
278 
279 }
std::vector< MonitorElement * > HitOccupancy_Minus_
std::map< int, int > OccupancyMap_minus
std::map< int, int > OccupancyMap_plus
std::vector< MonitorElement * > HitOccupancy_Plus_
void HGCalRecHitValidation::fillHitsInfo ( HitsInfo hits)
private

Definition at line 281 of file HGCalRecHitValidation.cc.

References HGCalRecHitValidation::HitsInfo::energy, energy_, HGCalRecHitValidation::HitsInfo::eta, EtaPhi_Minus_, EtaPhi_Plus_, HGCalRecHitValidation::HitsInfo::layer, and HGCalRecHitValidation::HitsInfo::phi.

281  {
282 
283  unsigned int ilayer = hits.layer;
284  energy_.at(ilayer)->Fill(hits.energy);
285 
286  EtaPhi_Plus_.at(ilayer)->Fill(hits.eta , hits.phi);
287  EtaPhi_Minus_.at(ilayer)->Fill(hits.eta, hits.phi);
288 
289 }
std::vector< MonitorElement * > EtaPhi_Minus_
std::vector< MonitorElement * > EtaPhi_Plus_
std::vector< MonitorElement * > energy_
void HGCalRecHitValidation::fillOccupancyMap ( std::map< int, int > &  OccupancyMap,
int  layer 
)
private

Definition at line 259 of file HGCalRecHitValidation.cc.

Referenced by recHitValidation(), and ~HGCalRecHitValidation().

260  {
261  if (OccupancyMap.find(layer) != OccupancyMap.end()) OccupancyMap[layer]++;
262  else OccupancyMap[layer] = 1;
263 }
template<class T1 , class T2 >
void HGCalRecHitValidation::recHitValidation ( DetId detId,
int  layer,
const T1 *  geom,
T2  it 
)
private

Definition at line 226 of file HGCalRecHitValidation.cc.

References HGCalRecHitValidation::HitsInfo::energy, HGCalRecHitValidation::HitsInfo::eta, PV3DBase< T, PVType, FrameType >::eta(), fillHitsInfo(), fillOccupancyMap(), firstLayer_, HGCalRecHitValidation::HitsInfo::layer, OccupancyMap_minus, OccupancyMap_plus, HGCalRecHitValidation::HitsInfo::phi, PV3DBase< T, PVType, FrameType >::phi(), verbosity_, HGCalRecHitValidation::HitsInfo::x, PV3DBase< T, PVType, FrameType >::x(), HGCalRecHitValidation::HitsInfo::y, PV3DBase< T, PVType, FrameType >::y(), HGCalRecHitValidation::HitsInfo::z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by analyze(), and ~HGCalRecHitValidation().

227  {
228 
229  const GlobalPoint& global = geom->getPosition(detId);
230  double energy = it->energy();
231 
232  float globalx = global.x();
233  float globaly = global.y();
234  float globalz = global.z();
235 
236  HitsInfo hinfo;
237  hinfo.energy = energy;
238  hinfo.x = globalx;
239  hinfo.y = globaly;
240  hinfo.z = globalz;
241  hinfo.layer = layer-firstLayer_;
242  hinfo.phi = global.phi();
243  hinfo.eta = global.eta();
244 
245  if (verbosity_>1)
246  edm::LogVerbatim("HGCalValidation") << "-------------------------- gx = "
247  << globalx << " gy = " << globaly
248  << " gz = " << globalz << " phi = "
249  << hinfo.phi << " eta = " << hinfo.eta
250  << " lay = " << hinfo.layer;
251 
252  fillHitsInfo(hinfo);
253 
254  if (hinfo.eta > 0) fillOccupancyMap(OccupancyMap_plus, hinfo.layer);
255  else fillOccupancyMap(OccupancyMap_minus, hinfo.layer);
256 
257 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
std::map< int, int > OccupancyMap_minus
T z() const
Definition: PV3DBase.h:64
void fillOccupancyMap(std::map< int, int > &OccupancyMap, int layer)
T eta() const
Definition: PV3DBase.h:76
std::map< int, int > OccupancyMap_plus
T x() const
Definition: PV3DBase.h:62

Member Data Documentation

std::vector<MonitorElement*> HGCalRecHitValidation::energy_
private

Definition at line 86 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms(), and fillHitsInfo().

std::vector<MonitorElement*> HGCalRecHitValidation::EtaPhi_Minus_
private

Definition at line 85 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms(), and fillHitsInfo().

std::vector<MonitorElement*> HGCalRecHitValidation::EtaPhi_Plus_
private

Definition at line 84 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms(), and fillHitsInfo().

int HGCalRecHitValidation::firstLayer_
private

Definition at line 80 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms(), dqmBeginRun(), and recHitValidation().

std::vector<MonitorElement*> HGCalRecHitValidation::HitOccupancy_Minus_
private

Definition at line 88 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms(), and fillHitsInfo().

std::vector<MonitorElement*> HGCalRecHitValidation::HitOccupancy_Plus_
private

Definition at line 87 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms(), and fillHitsInfo().

bool HGCalRecHitValidation::ifHCAL_
private

Definition at line 77 of file HGCalRecHitValidation.cc.

Referenced by analyze(), and HGCalRecHitValidation().

unsigned int HGCalRecHitValidation::layers_
private

Definition at line 79 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms(), and dqmBeginRun().

MonitorElement* HGCalRecHitValidation::MeanHitOccupancy_Minus_
private

Definition at line 90 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms().

MonitorElement* HGCalRecHitValidation::MeanHitOccupancy_Plus_
private

Definition at line 89 of file HGCalRecHitValidation.cc.

Referenced by bookHistograms().

std::string HGCalRecHitValidation::nameDetector_
private
std::map<int, int> HGCalRecHitValidation::OccupancyMap_minus
private

Definition at line 82 of file HGCalRecHitValidation.cc.

Referenced by analyze(), fillHitsInfo(), and recHitValidation().

std::map<int, int> HGCalRecHitValidation::OccupancyMap_plus
private

Definition at line 81 of file HGCalRecHitValidation.cc.

Referenced by analyze(), fillHitsInfo(), and recHitValidation().

edm::EDGetToken HGCalRecHitValidation::recHitSource_
private

Definition at line 76 of file HGCalRecHitValidation.cc.

Referenced by analyze(), and HGCalRecHitValidation().

int HGCalRecHitValidation::verbosity_
private

Definition at line 78 of file HGCalRecHitValidation.cc.

Referenced by analyze(), and recHitValidation().