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 33 of file HGCalTestPartialWaferHits.cc.

Constructor & Destructor Documentation

◆ HGCalTestPartialWaferHits()

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

Definition at line 52 of file HGCalTestPartialWaferHits.cc.

References nameSense_.

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

References python.cmstools::all(), TauDecayModes::dec, change_name::diff, dumpDets_, PVValHelper::dx, PVValHelper::dy, MillePedeFileConverter_cfg::e, spr::find(), relativeConstraints::geom, geomToken_, edm::EventSetup::getData(), caHitNtupletGeneratorKernels::good, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, hfClusterShapes_cfi::hits, l1ctLayer2EG_cff::id, hit::id, info(), edm::HandleBase::isValid(), nameSense_, nhits, mathSSE::sqrt(), tok_calo_, validateGeometry_cfg::valid, HGCalTypes::WaferFull, HGCalWaferIndex::waferIndex(), wafers_, geometryCSVtoXML::xx, and geometryCSVtoXML::xy.

98  {
99  // get HGCalGeometry
100  const HGCalGeometry* geom = &iS.getData(geomToken_);
101  const HGCalDDDConstants& hgc = geom->topology().dddConstants();
102  int firstLayer = hgc.getLayerOffset();
103  // get the hit collection
104  const edm::Handle<edm::PCaloHitContainer>& hitsCalo = e.getHandle(tok_calo_);
105  bool getHits = (hitsCalo.isValid());
106  uint32_t nhits = (getHits) ? hitsCalo->size() : 0;
107  uint32_t good(0), allSi(0), all(0), allSc(0), bad(0);
108  constexpr double tol = 2.0;
109  edm::LogVerbatim("HGCalSim") << "HGCalTestPartialWaferHits: Input flags Hits " << getHits << " with " << nhits
110  << " hits: Layer Offset " << firstLayer;
111 
112  if (getHits) {
113  std::vector<PCaloHit> hits;
114  hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end());
115  if (!hits.empty()) {
116  // Loop over all hits
117  for (auto hit : hits) {
118  ++all;
119  DetId id(hit.id());
120  bool valid = (geom->topology()).valid(id);
121  std::ostringstream st1;
122  if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
123  ++allSi;
124  HGCSiliconDetId hid(id);
125  st1 << hid;
126  if (((id.det() == DetId::HGCalEE) && (nameSense_ == "HGCalEESensitive")) ||
127  ((id.det() == DetId::HGCalHSi) && (nameSense_ == "HGCalHESiliconSensitive"))) {
128  std::string_view pid =
129  ((hgc.cassetteShiftSilicon(hid.layer(), hid.waferU(), hid.waferV())) ? "HGCSim" : "HGCalSim");
130  const auto& info = hgc.waferInfo(hid.layer(), hid.waferU(), hid.waferV());
131  if (!valid)
132  st1 << " Wafer Type:Part:Orient:Cassette " << info.type << ":" << info.part << ":" << info.orient << ":"
133  << info.cassette;
134  bool toCheck(false);
135  if (!wafers_.empty()) {
136  int indx = HGCalWaferIndex::waferIndex(firstLayer + hid.layer(), hid.waferU(), hid.waferV(), false);
137  if (std::find(wafers_.begin(), wafers_.end(), indx) != wafers_.end())
138  toCheck = true;
139  } else if (!dumpDets_.empty()) {
140  if ((std::find(dumpDets_.begin(), dumpDets_.end(), static_cast<int>(id.det())) != dumpDets_.end()) &&
141  (info.part != HGCalTypes::WaferFull))
142  toCheck = true;
143  } else {
144  // Only partial wafers
145  toCheck = (info.part != HGCalTypes::WaferFull);
146  }
147  if (toCheck) {
148  ++good;
149  GlobalPoint pos = geom->getPosition(id);
150  bool valid1 = geom->topology().valid(id);
151  bool valid2 = hgc.isValidHex8(hid.layer(), hid.waferU(), hid.waferV(), hid.cellU(), hid.cellV(), false);
152  auto xy = hgc.locateCell(hid, false);
153  double xx = (hid.zside() > 0) ? xy.first : -xy.first;
154  double dx = xx - pos.x();
155  double dy = xy.second - pos.y();
156  double diff = std::sqrt(dx * dx + dy * dy);
157  if ((diff > tol) || (!valid1) || (!valid2))
158  pid = "HGCalError";
159  edm::LogVerbatim(pid) << "Hit[" << all << ":" << allSi << ":" << good << "]" << hid
160  << " Wafer Type:Part:Orient:Cassette " << info.type << ":" << info.part << ":"
161  << info.orient << ":" << info.cassette << " at (" << pos.x() << ":" << xx << ":"
162  << dx << ", " << pos.y() << ":" << xy.second << ":" << dy << ", " << pos.z()
163  << ") Valid " << valid1 << ":" << valid2 << " Distance " << diff;
164  }
165  }
166  } else if (id.det() == DetId::HGCalHSc) {
167  ++allSc;
168  HGCScintillatorDetId hid(id);
169  st1 << hid;
170  if ((id.det() == DetId::HGCalHSc) && (nameSense_ == "HGCalHEScintillatorSensitive")) {
171  std::string_view pid = ((hgc.cassetteShiftScintillator(hid.layer(), hid.iphi())) ? "HGCSim" : "HGCalSim");
172  GlobalPoint pos = geom->getPosition(id);
173  bool valid1 = geom->topology().valid(id);
174  bool valid2 = hgc.isValidTrap(hid.zside(), hid.layer(), hid.ring(), hid.iphi());
175  if ((!valid1) || (!valid2))
176  pid = "HGCalError";
177  int cassette = hgc.cassetteTile(hid.iphi());
178  edm::LogVerbatim(pid) << "Hit[" << all << ":" << allSc << "] " << hid << " Cassette " << cassette << " at ("
179  << pos.x() << ", " << pos.y() << ", " << pos.z() << ") Valid " << valid1 << ":"
180  << valid2;
181  }
182  } else {
183  st1 << std::hex << id.rawId() << std::dec;
184  }
185  if (!valid) {
186  edm::LogVerbatim("HGCalError") << "Invalid ID " << st1.str();
187  ++bad;
188  }
189  }
190  }
191  }
192  edm::LogVerbatim("HGCalSim") << "Total hits = " << all << ":" << nhits << " Good Silicon DetIds = " << allSi << ":"
193  << good << " Scintitllator = " << allSc << " Invalid = " << bad;
194 }
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
T sqrt(T t)
Definition: SSEVec.h:19
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_
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 41 of file HGCalTestPartialWaferHits.cc.

41 {}

◆ endJob()

void HGCalTestPartialWaferHits::endJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 42 of file HGCalTestPartialWaferHits.cc.

42 {}

◆ fillDescriptions()

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

Definition at line 89 of file HGCalTestPartialWaferHits.cc.

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

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

Member Data Documentation

◆ caloHitSource_

const std::string HGCalTestPartialWaferHits::caloHitSource_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

◆ dumpDets_

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

Definition at line 49 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ g4Label_

const std::string HGCalTestPartialWaferHits::g4Label_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

◆ geomToken_

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

Definition at line 47 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ missingFile_

const std::string HGCalTestPartialWaferHits::missingFile_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

◆ nameSense_

const std::string HGCalTestPartialWaferHits::nameSense_
private

Definition at line 45 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze(), and HGCalTestPartialWaferHits().

◆ tok_calo_

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

Definition at line 46 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().

◆ wafers_

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

Definition at line 48 of file HGCalTestPartialWaferHits.cc.

Referenced by analyze().