CMS 3D CMS Logo

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

Public Member Functions

 HGCalTestPartialWaferHits (const edm::ParameterSet &ps)
 
 ~HGCalTestPartialWaferHits () 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 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 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<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

const std::string caloHitSource_
 
std::vector< int > dumpDets_
 
const std::string g4Label_
 
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecordgeomToken_
 
const std::string missingFile_
 
const std::string nameSense_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_calo_
 
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 31 of file HGCalTestPartialWaferHits.cc.

Constructor & Destructor Documentation

◆ HGCalTestPartialWaferHits()

HGCalTestPartialWaferHits::HGCalTestPartialWaferHits ( const edm::ParameterSet ps)

Definition at line 50 of file HGCalTestPartialWaferHits.cc.

References nameSense_.

51  : g4Label_(ps.getParameter<std::string>("moduleLabel")),
52  caloHitSource_(ps.getParameter<std::string>("caloHitSource")),
53  nameSense_(ps.getParameter<std::string>("nameSense")),
54  missingFile_(ps.getParameter<std::string>("missingFile")),
55  tok_calo_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, caloHitSource_))),
56  geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_})) {
57  edm::LogVerbatim("HGCalSim") << "Test Hit ID using SimHits for " << nameSense_ << " with module Label: " << g4Label_
58  << " Hits: " << caloHitSource_ << " Missing Wafer file " << missingFile_;
59  if (!missingFile_.empty()) {
60  edm::FileInPath filetmp("SimG4CMS/Calo/data/" + missingFile_);
61  std::string fileName = filetmp.fullPath();
62  std::ifstream fInput(fileName.c_str());
63  if (!fInput.good()) {
64  edm::LogVerbatim("HGCalSim") << "Cannot open file " << fileName;
65  } else {
66  char buffer[80];
67  while (fInput.getline(buffer, 80)) {
68  std::vector<std::string> items = CaloSimUtils::splitString(std::string(buffer));
69  if (items.size() > 2) {
70  int layer = std::atoi(items[0].c_str());
71  int waferU = std::atoi(items[1].c_str());
72  int waferV = std::atoi(items[2].c_str());
73  wafers_.emplace_back(HGCalWaferIndex::waferIndex(layer, waferU, waferV, false));
74  } else if (items.size() == 1) {
75  int dumpdet = std::atoi(items[0].c_str());
76  dumpDets_.emplace_back(dumpdet);
77  edm::LogVerbatim("HGCSim") << nameSense_ << " Dump detector " << dumpdet;
78  }
79  }
80  edm::LogVerbatim("HGCalSim") << "HGCalTestPartialWaferHits::Reads in " << wafers_.size() << ":"
81  << dumpDets_.size() << " wafer|detector information from " << fileName;
82  fInput.close();
83  }
84  }
85 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int32_t waferU(const int32_t index)
constexpr std::array< uint8_t, layerIndexSize > layer
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)
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
int32_t waferV(const int32_t index)
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > geomToken_

◆ ~HGCalTestPartialWaferHits()

HGCalTestPartialWaferHits::~HGCalTestPartialWaferHits ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 96 of file HGCalTestPartialWaferHits.cc.

References python.cmstools::all(), HGCSiliconDetId::cellU(), HGCSiliconDetId::cellV(), dumpDets_, MillePedeFileConverter_cfg::e, spr::find(), relativeConstraints::geom, geomToken_, edm::EventSetup::getData(), good, DetId::HGCalEE, DetId::HGCalHSi, hfClusterShapes_cfi::hits, l1ctLayer2EG_cff::id, hit::id, info(), edm::HandleBase::isValid(), HGCSiliconDetId::layer(), nhits, tok_calo_, HGCalTypes::WaferFull, HGCalWaferIndex::waferIndex(), wafers_, HGCSiliconDetId::waferU(), and HGCSiliconDetId::waferV().

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

◆ beginJob()

void HGCalTestPartialWaferHits::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 39 of file HGCalTestPartialWaferHits.cc.

39 {}

◆ endJob()

void HGCalTestPartialWaferHits::endJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 40 of file HGCalTestPartialWaferHits.cc.

40 {}

◆ fillDescriptions()

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

Definition at line 87 of file HGCalTestPartialWaferHits.cc.

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

87  {
89  desc.add<std::string>("moduleLabel", "g4SimHits");
90  desc.add<std::string>("caloHitSource", "HGCHitsEE");
91  desc.add<std::string>("nameSense", "HGCalEESensitive");
92  desc.add<std::string>("missingFile", "");
93  descriptions.add("hgcalHitPartialEE", desc);
94 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ caloHitSource_

const std::string HGCalTestPartialWaferHits::caloHitSource_
private

Definition at line 43 of file HGCalTestPartialWaferHits.cc.

◆ dumpDets_

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

Definition at line 47 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ g4Label_

const std::string HGCalTestPartialWaferHits::g4Label_
private

Definition at line 43 of file HGCalTestPartialWaferHits.cc.

◆ geomToken_

const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> HGCalTestPartialWaferHits::geomToken_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ missingFile_

const std::string HGCalTestPartialWaferHits::missingFile_
private

Definition at line 43 of file HGCalTestPartialWaferHits.cc.

◆ nameSense_

const std::string HGCalTestPartialWaferHits::nameSense_
private

Definition at line 43 of file HGCalTestPartialWaferHits.cc.

Referenced by HGCalTestPartialWaferHits().

◆ tok_calo_

const edm::EDGetTokenT<edm::PCaloHitContainer> HGCalTestPartialWaferHits::tok_calo_
private

Definition at line 44 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ wafers_

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

Definition at line 46 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().