CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
HeterogeneousHGCalRecHitsValidator Class Reference

#include <HeterogeneousHGCalRecHitsValidator.h>

Inheritance diagram for HeterogeneousHGCalRecHitsValidator:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 
 HeterogeneousHGCalRecHitsValidator (const edm::ParameterSet &)
 
 ~HeterogeneousHGCalRecHitsValidator () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< 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 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)
 

Private Member Functions

void set_geometry_ (const edm::EventSetup &, const unsigned &)
 

Private Attributes

std::array< ValidHitCollection, nsubdetectorscpuValidRecHits
 
std::array< ValidHitCollection, nsubdetectorsdiffsValidRecHits
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordestokenGeom_
 
std::array< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, nsubdetectorsestokens_
 
std::array< ValidHitCollection, nsubdetectorsgpuValidRecHits
 
std::array< std::string, nsubdetectorshandles_str_
 
hgcal::RecHitTools recHitTools_
 
std::array< std::array< edm::EDGetTokenT< HGChefRecHitCollection >, ncomputingdevices >, nsubdetectorstokens_
 
std::array< std::string, nsubdetectorstreenames_
 
std::array< TTree *, nsubdetectorstrees_
 

Static Private Attributes

static const unsigned ncomputingdevices = 2
 
static const unsigned nsubdetectors = 3
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 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)
 

Detailed Description

Definition at line 34 of file HeterogeneousHGCalRecHitsValidator.h.

Constructor & Destructor Documentation

◆ HeterogeneousHGCalRecHitsValidator()

HeterogeneousHGCalRecHitsValidator::HeterogeneousHGCalRecHitsValidator ( const edm::ParameterSet ps)
explicit

Definition at line 3 of file HeterogeneousHGCalRecHitsValidator.cc.

References edm::ParameterSet::getParameter().

4  : tokens_({{{{consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("cpuRecHitsEEToken")),
5  consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("gpuRecHitsEEToken"))}},
6  {{consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("cpuRecHitsHSiToken")),
7  consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("gpuRecHitsHSiToken"))}},
8  {{consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("cpuRecHitsHSciToken")),
9  consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("gpuRecHitsHSciToken"))}}}}),
10  treenames_({{"CEE", "CHSi", "CHSci"}}) {
11  usesResource(TFileService::kSharedResource);
12  estokenGeom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
14  for (unsigned i(0); i < nsubdetectors; ++i) {
15  estokens_[i] = esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", handles_str_[i]});
16  trees_[i] = fs->make<TTree>(treenames_[i].c_str(), treenames_[i].c_str());
17  trees_[i]->Branch("cpu", "ValidHitCollection", &cpuValidRecHits[i]);
18  trees_[i]->Branch("gpu", "ValidHitCollection", &gpuValidRecHits[i]);
19  trees_[i]->Branch("diffs", "ValidHitCollection", &diffsValidRecHits[i]);
20  }
21 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::array< std::string, nsubdetectors > handles_str_
std::array< ValidHitCollection, nsubdetectors > cpuValidRecHits
std::array< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, nsubdetectors > estokens_
std::array< std::array< edm::EDGetTokenT< HGChefRecHitCollection >, ncomputingdevices >, nsubdetectors > tokens_
std::array< TTree *, nsubdetectors > trees_
std::array< std::string, nsubdetectors > treenames_
std::array< ValidHitCollection, nsubdetectors > gpuValidRecHits
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > estokenGeom_
std::array< ValidHitCollection, nsubdetectors > diffsValidRecHits

◆ ~HeterogeneousHGCalRecHitsValidator()

HeterogeneousHGCalRecHitsValidator::~HeterogeneousHGCalRecHitsValidator ( )
override

Definition at line 23 of file HeterogeneousHGCalRecHitsValidator.cc.

23 {}

Member Function Documentation

◆ analyze()

void HeterogeneousHGCalRecHitsValidator::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 31 of file HeterogeneousHGCalRecHitsValidator.cc.

References cms::cuda::assert(), gather_cfg::cout, cpuValidRecHits, CaloRecHit::detid(), diffsValidRecHits, CaloRecHit::energy(), estokenGeom_, HGCRecHit::flagBits(), gpuValidRecHits, mps_fire::i, nhits, nsubdetectors, recHitTools_, set_geometry_(), hgcal::RecHitTools::setGeometry(), singleTopDQM_cfi::setup, HGCRecHit::signalOverSigmaNoise(), CaloRecHit::time(), HGCRecHit::timeError(), tokens_, and trees_.

31  {
33 
34  //future subdetector loop
35  for (size_t idet = 0; idet < nsubdetectors; ++idet) {
36  set_geometry_(setup, idet);
37 
38  //get hits produced with the CPU
39  const auto &cpuhits = event.get(tokens_[idet][0]);
40 
41  //get hits produced with the GPU
42  const auto &gpuhits = event.get(tokens_[idet][1]);
43 
44  size_t nhits = cpuhits.size();
45  std::cout << nhits << ", " << gpuhits.size() << std::endl;
46  assert(nhits == gpuhits.size());
47  //float sum_cpu = 0.f, sum_gpu = 0.f, sum_son_cpu = 0.f, sum_son_gpu = 0.f;
48  for (unsigned i(0); i < nhits; i++) {
49  const HGCRecHit &cpuHit = cpuhits[i];
50  const HGCRecHit &gpuHit = gpuhits[i];
51 
52  const float cpuEn = cpuHit.energy();
53  const float gpuEn = gpuHit.energy();
54  //sum_cpu += cpuEn; sum_gpu += gpuEn;
55 
56  const float cpuTime = cpuHit.time();
57  const float gpuTime = gpuHit.time();
58  const float cpuTimeErr = cpuHit.timeError();
59  const float gpuTimeErr = gpuHit.timeError();
60  const DetId cpuDetId = cpuHit.detid();
61  const DetId gpuDetId = gpuHit.detid();
62  const float cpuFB = cpuHit.flagBits();
63  const float gpuFB = gpuHit.flagBits();
64  const float cpuSoN = cpuHit.signalOverSigmaNoise();
65  const float gpuSoN = gpuHit.signalOverSigmaNoise();
66  //sum_son_cpu += cpuSoN; sum_son_gpu += gpuSoN;
67 
68  ValidHit vCPU(cpuEn, cpuTime, cpuTimeErr, cpuDetId, cpuFB, cpuSoN);
69  ValidHit vGPU(gpuEn, gpuTime, gpuTimeErr, gpuDetId, gpuFB, gpuSoN);
70  ValidHit vDiffs(cpuEn - gpuEn,
71  cpuTime - gpuTime,
72  cpuTimeErr - gpuTimeErr,
73  cpuDetId - gpuDetId,
74  cpuFB - gpuFB,
75  cpuSoN - gpuSoN);
76 
77  cpuValidRecHits[idet].push_back(vCPU);
78  gpuValidRecHits[idet].push_back(vGPU);
79  diffsValidRecHits[idet].push_back(vDiffs);
80  }
81  trees_[idet]->Fill();
82  }
83 }
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
float signalOverSigmaNoise() const
Definition: HGCRecHit.cc:72
std::array< ValidHitCollection, nsubdetectors > cpuValidRecHits
assert(be >=bs)
constexpr float energy() const
Definition: CaloRecHit.h:29
std::array< std::array< edm::EDGetTokenT< HGChefRecHitCollection >, ncomputingdevices >, nsubdetectors > tokens_
std::array< TTree *, nsubdetectors > trees_
void set_geometry_(const edm::EventSetup &, const unsigned &)
Definition: DetId.h:17
std::array< ValidHitCollection, nsubdetectors > gpuValidRecHits
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > estokenGeom_
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
constexpr float time() const
Definition: CaloRecHit.h:31
float timeError() const
Definition: HGCRecHit.cc:79
uint32_t flagBits() const
Definition: HGCRecHit.h:111
std::array< ValidHitCollection, nsubdetectors > diffsValidRecHits

◆ endJob()

void HeterogeneousHGCalRecHitsValidator::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 25 of file HeterogeneousHGCalRecHitsValidator.cc.

25 {}

◆ set_geometry_()

void HeterogeneousHGCalRecHitsValidator::set_geometry_ ( const edm::EventSetup setup,
const unsigned &  detidx 
)
private

Definition at line 27 of file HeterogeneousHGCalRecHitsValidator.cc.

References estokens_, patZpeak::handle, and singleTopDQM_cfi::setup.

Referenced by analyze().

27  {
29 }
std::array< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, nsubdetectors > estokens_

Member Data Documentation

◆ cpuValidRecHits

std::array<ValidHitCollection, nsubdetectors> HeterogeneousHGCalRecHitsValidator::cpuValidRecHits
private

Definition at line 55 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().

◆ diffsValidRecHits

std::array<ValidHitCollection, nsubdetectors> HeterogeneousHGCalRecHitsValidator::diffsValidRecHits
private

Definition at line 55 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().

◆ estokenGeom_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> HeterogeneousHGCalRecHitsValidator::estokenGeom_
private

Definition at line 47 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().

◆ estokens_

std::array<edm::ESGetToken<HGCalGeometry, IdealGeometryRecord>, nsubdetectors> HeterogeneousHGCalRecHitsValidator::estokens_
private

Definition at line 46 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by set_geometry_().

◆ gpuValidRecHits

std::array<ValidHitCollection, nsubdetectors> HeterogeneousHGCalRecHitsValidator::gpuValidRecHits
private

Definition at line 55 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().

◆ handles_str_

std::array<std::string, nsubdetectors> HeterogeneousHGCalRecHitsValidator::handles_str_
private
Initial value:
= {
{"HGCalEESensitive", "HGCalHESiliconSensitive", "HGCalHEScintillatorSensitive"}}

Definition at line 49 of file HeterogeneousHGCalRecHitsValidator.h.

◆ ncomputingdevices

const unsigned HeterogeneousHGCalRecHitsValidator::ncomputingdevices = 2
staticprivate

Definition at line 43 of file HeterogeneousHGCalRecHitsValidator.h.

◆ nsubdetectors

const unsigned HeterogeneousHGCalRecHitsValidator::nsubdetectors = 3
staticprivate

Definition at line 42 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().

◆ recHitTools_

hgcal::RecHitTools HeterogeneousHGCalRecHitsValidator::recHitTools_
private

Definition at line 51 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().

◆ tokens_

std::array<std::array<edm::EDGetTokenT<HGChefRecHitCollection>, ncomputingdevices>, nsubdetectors> HeterogeneousHGCalRecHitsValidator::tokens_
private

Definition at line 45 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().

◆ treenames_

std::array<std::string, nsubdetectors> HeterogeneousHGCalRecHitsValidator::treenames_
private

Definition at line 54 of file HeterogeneousHGCalRecHitsValidator.h.

◆ trees_

std::array<TTree*, nsubdetectors> HeterogeneousHGCalRecHitsValidator::trees_
private

Definition at line 53 of file HeterogeneousHGCalRecHitsValidator.h.

Referenced by analyze().