CMS 3D CMS Logo

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

Public Member Functions

 HcalSimHitAnalysis (const edm::ParameterSet &ps)
 
 ~HcalSimHitAnalysis () override
 
- 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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Private Attributes

std::string g4Label_
 
std::string hcalHits_
 
TH2F * poszn_ [ndets_]
 
TH2F * poszp_ [ndets_]
 
bool testNumber_
 
edm::EDGetTokenT< edm::PCaloHitContainertok_calo_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordtok_geom_
 
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecordtok_HRNDC_
 
bool verbose_
 

Static Private Attributes

static const int ndets_ = 4
 

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 HcalSimHitAnalysis.cc.

Constructor & Destructor Documentation

◆ HcalSimHitAnalysis()

HcalSimHitAnalysis::HcalSimHitAnalysis ( const edm::ParameterSet ps)

Definition at line 62 of file HcalSimHitAnalysis.cc.

62  {
63  usesResource(TFileService::kSharedResource);
64 
65  g4Label_ = ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits");
66  hcalHits_ = ps.getUntrackedParameter<std::string>("HitCollection", "HcalHits");
67  verbose_ = ps.getUntrackedParameter<bool>("Verbose", false);
68  testNumber_ = ps.getUntrackedParameter<bool>("TestNumber", true);
69 
70  tok_calo_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hcalHits_));
71  tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
72  tok_HRNDC_ = esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord>();
73 
74  edm::LogVerbatim("HitStudy") << "Module Label: " << g4Label_ << " Hits: " << hcalHits_ << " testNumber "
75  << testNumber_;
76 }

References g4Label_, edm::ParameterSet::getUntrackedParameter(), hcalHits_, TFileService::kSharedResource, AlCaHLTBitMon_QueryRunRegistry::string, testNumber_, tok_calo_, tok_geom_, tok_HRNDC_, and verbose_.

◆ ~HcalSimHitAnalysis()

HcalSimHitAnalysis::~HcalSimHitAnalysis ( )
inlineoverride

Definition at line 43 of file HcalSimHitAnalysis.cc.

43 {}

Member Function Documentation

◆ analyze()

void HcalSimHitAnalysis::analyze ( edm::Event const &  e,
edm::EventSetup const &  iS 
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 120 of file HcalSimHitAnalysis.cc.

120  {
121  if (verbose_)
122  edm::LogVerbatim("HitStudy") << "Run = " << e.id().run() << " Event = " << e.id().event();
123 
124  // get hcalGeometry
125  const CaloGeometry* geo = &iS.getData(tok_geom_);
126  const HcalGeometry* hgeom = static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
127  const auto& pHRNDC = iS.getData(tok_HRNDC_);
128  const HcalDDDRecConstants* hcons = &pHRNDC;
129 
131  e.getByToken(tok_calo_, hitsCalo);
132  bool getHits = (hitsCalo.isValid());
133  uint32_t nhits = (getHits) ? hitsCalo->size() : 0;
134  if (verbose_)
135  edm::LogVerbatim("HitStudy") << "HcalSimHitAnalysis: Input flags Hits " << getHits << " with " << nhits << " hits";
136  if (getHits) {
137  std::vector<PCaloHit> hits;
138  hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end());
139  if (!hits.empty()) {
140  std::map<HcalDetId, double> hitMap;
141  for (auto hit : hits) {
142  double edep = hit.energy();
143  uint32_t id = hit.id();
144  HcalDetId hid = (testNumber_) ? HcalHitRelabeller::relabel(id, hcons) : HcalDetId(id);
145  auto it = hitMap.find(hid);
146  if (it == hitMap.end()) {
147  hitMap[hid] = edep;
148  } else {
149  (it->second) += edep;
150  }
151  }
152 
153  for (auto it : hitMap) {
154  HcalDetId id(it.first);
155  GlobalPoint gpos = hgeom->getPosition(id);
156  HcalSubdetector subdet = (id).subdet();
157  int indx =
158  ((subdet == HcalBarrel)
159  ? 0
160  : ((subdet == HcalEndcap) ? 1 : ((subdet == HcalOuter) ? 2 : ((subdet == HcalForward) ? 3 : -1))));
161  if (verbose_)
162  edm::LogVerbatim("HitStudy") << "HcalSimHitAnalysis: " << id << ":" << it.second << " at " << gpos
163  << " subdet " << subdet << ":" << indx;
164  if (indx >= 0) {
165  double x = ((indx == 0) || (indx == 2)) ? std::abs(gpos.z()) : gpos.x();
166  double y = ((indx == 0) || (indx == 2)) ? (gpos.perp()) : gpos.y();
167  if (id.zside() >= 0)
168  poszp_[indx]->Fill(x, y);
169  else
170  poszn_[indx]->Fill(x, y);
171  }
172  }
173  }
174  }
175 }

References funct::abs(), MillePedeFileConverter_cfg::e, edm::EventSetup::getData(), HcalGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, hfClusterShapes_cfi::hits, triggerObjects_cff::id, hit::id, edm::HandleBase::isValid(), nhits, PV3DBase< T, PVType, FrameType >::perp(), poszn_, poszp_, HcalHitRelabeller::relabel(), testNumber_, tok_calo_, tok_geom_, tok_HRNDC_, verbose_, x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and ecaldqm::zside().

◆ beginJob()

void HcalSimHitAnalysis::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 87 of file HcalSimHitAnalysis.cc.

87  {
89  if (!tfile.isAvailable())
90  throw cms::Exception("BadConfig") << "TFileService unavailable: "
91  << "please add it to config file";
92  char name[20], title[120];
93  std::string dets[ndets_] = {"HB", "HE", "HO", "HF"};
94  int nx[ndets_] = {100, 100, 350, 160};
95  double xlo[ndets_] = {0, -300, 0, -160};
96  double xhi[ndets_] = {500, 300, 3500, 160};
97  int ny[ndets_] = {100, 100, 50, 160};
98  double ylo[ndets_] = {170, -300, 375, -160};
99  double yhi[ndets_] = {370, 300, 425, 160};
100  std::string xttl[ndets_] = {"|z| (cm)", "x (cm)", "|z| (cm)", "x (cm)"};
101  std::string yttl[ndets_] = {"#rho (cm)", "y (cm)", "#rho (cm)", "y (cm)"};
102  for (int i = 0; i < ndets_; i++) {
103  sprintf(name, "poszp%d", i);
104  sprintf(title, "%s+", dets[i].c_str());
105  poszp_[i] = tfile->make<TH2F>(name, title, nx[i], xlo[i], xhi[i], ny[i], ylo[i], yhi[i]);
106  poszp_[i]->GetXaxis()->SetTitle(xttl[i].c_str());
107  poszp_[i]->GetYaxis()->SetTitle(yttl[i].c_str());
108  sprintf(title, "%s-", dets[i].c_str());
109  poszp_[i]->GetYaxis()->SetTitleOffset(1.2);
110  poszp_[i]->Sumw2();
111  sprintf(name, "poszn%d", i);
112  poszn_[i] = tfile->make<TH2F>(name, title, nx[i], xlo[i], xhi[i], ny[i], ylo[i], yhi[i]);
113  poszn_[i]->GetXaxis()->SetTitle(xttl[i].c_str());
114  poszn_[i]->GetYaxis()->SetTitle(yttl[i].c_str());
115  poszn_[i]->GetYaxis()->SetTitleOffset(1.2);
116  poszn_[i]->Sumw2();
117  }
118 }

References mps_fire::i, Skims_PA_cff::name, ndets_, poszn_, poszp_, AlCaHLTBitMon_QueryRunRegistry::string, compare::tfile, and runGCPTkAlMap::title.

◆ beginRun()

void HcalSimHitAnalysis::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprotected

Definition at line 49 of file HcalSimHitAnalysis.cc.

49 {}

◆ endRun()

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

Definition at line 50 of file HcalSimHitAnalysis.cc.

50 {}

◆ fillDescriptions()

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

Definition at line 78 of file HcalSimHitAnalysis.cc.

78  {
80  desc.addUntracked<std::string>("ModuleLabel", "g4SimHits");
81  desc.addUntracked<std::string>("HitCollection", "HcalHits");
82  desc.addUntracked<bool>("Verbose", false);
83  desc.addUntracked<bool>("TestNumber", true);
84  descriptions.add("hcalSimHitAnalysis", desc);
85 }

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

Member Data Documentation

◆ g4Label_

std::string HcalSimHitAnalysis::g4Label_
private

Definition at line 54 of file HcalSimHitAnalysis.cc.

Referenced by HcalSimHitAnalysis().

◆ hcalHits_

std::string HcalSimHitAnalysis::hcalHits_
private

Definition at line 54 of file HcalSimHitAnalysis.cc.

Referenced by HcalSimHitAnalysis().

◆ ndets_

const int HcalSimHitAnalysis::ndets_ = 4
staticprivate

Definition at line 53 of file HcalSimHitAnalysis.cc.

Referenced by beginJob().

◆ poszn_

TH2F * HcalSimHitAnalysis::poszn_[ndets_]
private

Definition at line 59 of file HcalSimHitAnalysis.cc.

Referenced by analyze(), and beginJob().

◆ poszp_

TH2F* HcalSimHitAnalysis::poszp_[ndets_]
private

Definition at line 59 of file HcalSimHitAnalysis.cc.

Referenced by analyze(), and beginJob().

◆ testNumber_

bool HcalSimHitAnalysis::testNumber_
private

Definition at line 55 of file HcalSimHitAnalysis.cc.

Referenced by analyze(), and HcalSimHitAnalysis().

◆ tok_calo_

edm::EDGetTokenT<edm::PCaloHitContainer> HcalSimHitAnalysis::tok_calo_
private

Definition at line 56 of file HcalSimHitAnalysis.cc.

Referenced by analyze(), and HcalSimHitAnalysis().

◆ tok_geom_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> HcalSimHitAnalysis::tok_geom_
private

Definition at line 57 of file HcalSimHitAnalysis.cc.

Referenced by analyze(), and HcalSimHitAnalysis().

◆ tok_HRNDC_

edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> HcalSimHitAnalysis::tok_HRNDC_
private

Definition at line 58 of file HcalSimHitAnalysis.cc.

Referenced by analyze(), and HcalSimHitAnalysis().

◆ verbose_

bool HcalSimHitAnalysis::verbose_
private

Definition at line 55 of file HcalSimHitAnalysis.cc.

Referenced by analyze(), and HcalSimHitAnalysis().

HcalSimHitAnalysis::verbose_
bool verbose_
Definition: HcalSimHitAnalysis.cc:55
DDAxes::y
HcalSimHitAnalysis::ndets_
static const int ndets_
Definition: HcalSimHitAnalysis.cc:53
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
DetId::Hcal
Definition: DetId.h:28
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DDAxes::x
HcalBarrel
Definition: HcalAssistant.h:33
edm::Handle
Definition: AssociativeIterator.h:50
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
HcalSimHitAnalysis::poszn_
TH2F * poszn_[ndets_]
Definition: HcalSimHitAnalysis.cc:59
CaloGeometry
Definition: CaloGeometry.h:21
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HcalSimHitAnalysis::tok_geom_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
Definition: HcalSimHitAnalysis.cc:57
HcalSimHitAnalysis::testNumber_
bool testNumber_
Definition: HcalSimHitAnalysis.cc:55
tfile
Definition: tfile.py:1
HcalOuter
Definition: HcalAssistant.h:35
Point3DBase< float, GlobalTag >
nhits
Definition: HIMultiTrackSelector.h:42
HcalSimHitAnalysis::tok_HRNDC_
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_HRNDC_
Definition: HcalSimHitAnalysis.cc:58
HcalGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Definition: HcalGeometry.cc:179
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HcalDetId
Definition: HcalDetId.h:12
edm::Service< TFileService >
HcalSimHitAnalysis::tok_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
Definition: HcalSimHitAnalysis.cc:56
HcalSimHitAnalysis::hcalHits_
std::string hcalHits_
Definition: HcalSimHitAnalysis.cc:54
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
compare.tfile
tfile
Definition: compare.py:324
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
HcalHitRelabeller::relabel
DetId relabel(const uint32_t testId) const
Definition: HcalHitRelabeller.cc:49
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
HcalEndcap
Definition: HcalAssistant.h:34
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
HcalSimHitAnalysis::g4Label_
std::string g4Label_
Definition: HcalSimHitAnalysis.cc:54
HcalSimHitAnalysis::poszp_
TH2F * poszp_[ndets_]
Definition: HcalSimHitAnalysis.cc:59
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HcalDDDRecConstants
Definition: HcalDDDRecConstants.h:23
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HcalGeometry
Definition: HcalGeometry.h:17
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37