CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
HGCalTestPartialWaferRecHits Class Reference
Inheritance diagram for HGCalTestPartialWaferRecHits:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 HGCalTestPartialWaferRecHits (const edm::ParameterSet &ps)
 
 ~HGCalTestPartialWaferRecHits () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 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)
 

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 endJob () 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 Attributes

std::vector< int > dumpDets_
 
const std::string missingFile_
 
const std::string nameDetector_
 
const edm::EDGetTokenT< HGCRecHitCollectionrecHitSource_
 
const edm::InputTag source_
 
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecordtok_hgcGeom_
 
std::vector< int > wafers_
 

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 30 of file HGCalTestPartialWaferRecHits.cc.

Constructor & Destructor Documentation

◆ HGCalTestPartialWaferRecHits()

HGCalTestPartialWaferRecHits::HGCalTestPartialWaferRecHits ( const edm::ParameterSet ps)

Definition at line 50 of file HGCalTestPartialWaferRecHits.cc.

References nameDetector_.

51  : nameDetector_(ps.getParameter<std::string>("detectorName")),
52  missingFile_(ps.getParameter<std::string>("missingFile")),
53  source_(ps.getParameter<edm::InputTag>("source")),
54  recHitSource_(consumes<HGCRecHitCollection>(source_)),
55  tok_hgcGeom_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", nameDetector_})) {
56  edm::LogVerbatim("HGCalSim") << "Test Hit ID using RecHits for " << nameDetector_ << " with module Label: " << source_
57  << " Missing Wafer file " << missingFile_;
58  if (!missingFile_.empty()) {
59  edm::FileInPath filetmp("SimG4CMS/Calo/data/" + missingFile_);
60  std::string fileName = filetmp.fullPath();
61  std::ifstream fInput(fileName.c_str());
62  if (!fInput.good()) {
63  edm::LogVerbatim("HGCalSim") << "Cannot open file " << fileName;
64  } else {
65  char buffer[80];
66  while (fInput.getline(buffer, 80)) {
67  std::vector<std::string> items = CaloSimUtils::splitString(std::string(buffer));
68  if (items.size() > 2) {
69  int layer = std::atoi(items[0].c_str());
70  int waferU = std::atoi(items[1].c_str());
71  int waferV = std::atoi(items[2].c_str());
72  wafers_.emplace_back(HGCalWaferIndex::waferIndex(layer, waferU, waferV, false));
73  } else if (items.size() == 1) {
74  int dumpdet = std::atoi(items[0].c_str());
75  dumpDets_.emplace_back(dumpdet);
76  edm::LogVerbatim("HGCalSim") << nameDetector_ << " Dump detector " << dumpdet;
77  }
78  }
79  edm::LogVerbatim("HGCalSim") << "HGCalTestPartialWaferRecHits::Reads in " << wafers_.size() << ":"
80  << dumpDets_.size() << " wafer|detector information from " << fileName;
81  fInput.close();
82  }
83  }
84 }
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< HGCRecHitCollection > recHitSource_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
int32_t waferU(const int32_t index)
std::vector< std::string > splitString(const std::string &)
Definition: CaloSimUtils.cc:3
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
int32_t waferV(const int32_t index)
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > tok_hgcGeom_

◆ ~HGCalTestPartialWaferRecHits()

HGCalTestPartialWaferRecHits::~HGCalTestPartialWaferRecHits ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 94 of file HGCalTestPartialWaferRecHits.cc.

References python.cmstools::all(), HGCSiliconDetId::cellU(), HGCSiliconDetId::cellV(), dumpDets_, MillePedeFileConverter_cfg::e, spr::find(), relativeConstraints::geom, edm::EventSetup::getData(), caHitNtupletGeneratorKernels::good, DetId::HGCalEE, DetId::HGCalHSi, l1ctLayer2EG_cff::id, info(), edm::HandleBase::isValid(), HGCSiliconDetId::layer(), nhits, edm::Handle< T >::product(), recHitSource_, edm::SortedCollection< T, SORT >::size(), tok_hgcGeom_, HGCalTypes::WaferFull, HGCalWaferIndex::waferIndex(), wafers_, HGCSiliconDetId::waferU(), and HGCSiliconDetId::waferV().

94  {
95  // get hgcalGeometry
96  const HGCalGeometry* geom = &iS.getData(tok_hgcGeom_);
97  const HGCalDDDConstants& hgc = geom->topology().dddConstants();
98  int firstLayer = hgc.getLayerOffset();
99  // get the hit collection
100  const edm::Handle<HGCRecHitCollection>& theRecHitContainers = e.getHandle(recHitSource_);
101  bool getHits = (theRecHitContainers.isValid());
102  uint32_t nhits = (getHits) ? theRecHitContainers->size() : 0;
103  uint32_t good(0), allSi(0), all(0);
104  edm::LogVerbatim("HGCalSim") << "HGCalTestPartialWaferRecHits: Input flags Hits " << getHits << " with " << nhits
105  << " hits: Layer Offset " << firstLayer;
106 
107  if (getHits) {
108  // Loop over all hits
109  for (const auto& it : *(theRecHitContainers.product())) {
110  ++all;
111  DetId id(it.id());
112  if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
113  ++allSi;
114  HGCSiliconDetId hid(id);
115  const auto& info = hgc.waferInfo(hid.layer(), hid.waferU(), hid.waferV());
116  bool toCheck(false);
117  if (!wafers_.empty()) {
118  int indx = HGCalWaferIndex::waferIndex(firstLayer + hid.layer(), hid.waferU(), hid.waferV(), false);
119  if (std::find(wafers_.begin(), wafers_.end(), indx) != wafers_.end())
120  toCheck = true;
121  } else if (!dumpDets_.empty()) {
122  if ((std::find(dumpDets_.begin(), dumpDets_.end(), static_cast<int>(id.det())) != dumpDets_.end()) &&
123  (info.part != HGCalTypes::WaferFull))
124  toCheck = true;
125  } else {
126  // Only partial wafers
127  toCheck = (info.part != HGCalTypes::WaferFull);
128  }
129  if (toCheck) {
130  ++good;
131  GlobalPoint pos = geom->getPosition(id);
132  bool valid1 = geom->topology().valid(id);
133  bool valid2 = hgc.isValidHex8(hid.layer(), hid.waferU(), hid.waferV(), hid.cellU(), hid.cellV(), false);
134  edm::LogVerbatim("HGCalSim") << "Hit[" << all << ":" << allSi << ":" << good << "]" << hid
135  << " Wafer Type:Part:Orient:Cassette " << info.type << ":" << info.part << ":"
136  << info.orient << ":" << info.cassette << " at (" << pos.x() << ", " << pos.y()
137  << ", " << pos.z() << ") Validity " << valid1 << ":" << valid2;
138  }
139  }
140  }
141  }
142  edm::LogVerbatim("HGCalSim") << "Total hits = " << all << ":" << nhits << " Good DetIds = " << allSi << ":" << good;
143 }
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< HGCRecHitCollection > recHitSource_
static const TGPicture * info(bool iBackgroundIsBlack)
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
size_type size() const
T const * product() const
Definition: Handle.h:70
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static constexpr int32_t WaferFull
Definition: HGCalTypes.h:35
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
Definition: DetId.h:17
bool isValid() const
Definition: HandleBase.h:70
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > tok_hgcGeom_

◆ beginJob()

void HGCalTestPartialWaferRecHits::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 38 of file HGCalTestPartialWaferRecHits.cc.

38 {}

◆ endJob()

void HGCalTestPartialWaferRecHits::endJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 39 of file HGCalTestPartialWaferRecHits.cc.

39 {}

◆ fillDescriptions()

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

Definition at line 86 of file HGCalTestPartialWaferRecHits.cc.

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

86  {
88  desc.add<std::string>("detectorName", "HGCalEESensitive");
89  desc.add<std::string>("missingFile", "");
90  desc.add<edm::InputTag>("source", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
91  descriptions.add("hgcalRecHitPartialEE", desc);
92 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ dumpDets_

std::vector<int> HGCalTestPartialWaferRecHits::dumpDets_
private

Definition at line 47 of file HGCalTestPartialWaferRecHits.cc.

Referenced by analyze().

◆ missingFile_

const std::string HGCalTestPartialWaferRecHits::missingFile_
private

Definition at line 42 of file HGCalTestPartialWaferRecHits.cc.

◆ nameDetector_

const std::string HGCalTestPartialWaferRecHits::nameDetector_
private

Definition at line 42 of file HGCalTestPartialWaferRecHits.cc.

Referenced by HGCalTestPartialWaferRecHits().

◆ recHitSource_

const edm::EDGetTokenT<HGCRecHitCollection> HGCalTestPartialWaferRecHits::recHitSource_
private

Definition at line 44 of file HGCalTestPartialWaferRecHits.cc.

Referenced by analyze().

◆ source_

const edm::InputTag HGCalTestPartialWaferRecHits::source_
private

◆ tok_hgcGeom_

const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> HGCalTestPartialWaferRecHits::tok_hgcGeom_
private

Definition at line 45 of file HGCalTestPartialWaferRecHits.cc.

Referenced by analyze().

◆ wafers_

std::vector<int> HGCalTestPartialWaferRecHits::wafers_
private

Definition at line 46 of file HGCalTestPartialWaferRecHits.cc.

Referenced by analyze().