56 #include "TEnumConstant.h" 58 template <
typename MyEnum>
59 MyEnum strToEnum(
std::string const& enumConstName) {
60 TEnum* en = TEnum::GetEnum(
typeid(MyEnum));
62 if (TEnumConstant
const* enc = en->GetConstant(enumConstName.c_str())) {
63 return static_cast<MyEnum
>(enc->GetValue());
65 throw cms::Exception(
"Configuration") << enumConstName <<
" is not a valid member of " <<
typeid(MyEnum).
name();
68 throw cms::Exception(
"LogicError") <<
typeid(MyEnum).
name() <<
" not recognised by ROOT";
73 if (enumConstName ==
"kNever")
74 return MyEnum::kNever;
75 else if (enumConstName ==
"kForSiStrips")
76 return MyEnum::kForSiStrips;
77 else if (enumConstName ==
"kAlways")
78 return MyEnum::kAlways;
81 << enumConstName <<
" is not a valid member of " <<
typeid(MyEnum).
name()
82 <<
" (or strToEnum needs updating, this is a manual translation found at " << __FILE__ <<
" line " << __LINE__
107 const double deltaZVertex,
146 template <
typename T>
156 : magFieldToken_{iC.esConsumes()} {
160 originRadius_ = regionPSet.
getParameter<
double>(
"originRadius");
161 originHalfLength_ = regionPSet.
getParameter<
double>(
"originHalfLength");
162 deltaPhiRegion_ = regionPSet.
getParameter<
double>(
"deltaPhiRegion");
163 deltaEtaRegion_ = regionPSet.
getParameter<
double>(
"deltaEtaRegion");
164 useZInVertex_ = regionPSet.
getParameter<
bool>(
"useZInVertex");
165 useZInBeamspot_ = regionPSet.
getParameter<
bool>(
"useZInBeamspot");
166 nrSigmaForBSDeltaZ_ = regionPSet.
getParameter<
double>(
"nrSigmaForBSDeltaZ");
167 defaultZ_ = regionPSet.
getParameter<
double>(
"defaultZ");
168 minBSDeltaZ_ = regionPSet.
getParameter<
double>(
"minBSDeltaZ");
170 whereToUseMeasTracker_ = strToEnum<RectangularEtaPhiTrackingRegion::UseMeasurementTracker>(
173 validateConfigSettings();
175 auto verticesTag = regionPSet.getParameter<
edm::InputTag>(
"vertices");
177 auto superClustersTags = regionPSet.getParameter<std::vector<edm::InputTag>>(
"superClusters");
178 auto measTrackerEventTag = regionPSet.getParameter<
edm::InputTag>(
"measurementTrackerEvent");
181 verticesToken_ = iC.consumes(verticesTag);
186 measTrackerEventToken_ = iC.consumes(measTrackerEventTag);
188 for (
const auto&
tag : superClustersTags) {
189 superClustersTokens_.emplace_back(iC.consumes(
tag));
192 msmakerToken_ = iC.esConsumes();
199 desc.add<
double>(
"ptMin", 1.5);
200 desc.add<
double>(
"originRadius", 0.2);
201 desc.add<
double>(
"originHalfLength", 15.0)
202 ->setComment(
"z range is +/- this value except when using the beamspot (useZInBeamspot=true)");
203 desc.add<
double>(
"deltaPhiRegion", 0.4);
204 desc.add<
double>(
"deltaEtaRegion", 0.1);
205 desc.add<
bool>(
"useZInVertex",
false)
206 ->setComment(
"use the leading vertex position +/-orginHalfLength, mutually exclusive with useZInBeamspot");
207 desc.add<
bool>(
"useZInBeamspot",
true)
209 "use the beamspot position +/- nrSigmaForBSDeltaZ* sigmaZ_{bs}, mutually exclusive with useZInVertex");
210 desc.add<
double>(
"nrSigmaForBSDeltaZ", 3.0)
211 ->setComment(
"# of sigma to extend the z region when using the beamspot, only active if useZInBeamspot=true");
212 desc.add<
double>(
"minBSDeltaZ", 0.0)
213 ->setComment(
"a minimum value of the beamspot sigma z to use, only active if useZInBeamspot=true");
214 desc.add<
double>(
"defaultZ", 0.)
215 ->setComment(
"the default z position, only used if useZInVertex and useZInBeamspot are both false");
216 desc.add<
bool>(
"precise",
true);
219 ->setComment(
"only used if useZInBeamspot is true");
221 desc.add<std::vector<edm::InputTag>>(
"superClusters",
222 std::vector<edm::InputTag>{
edm::InputTag{
"hltEgammaSuperClustersToPixelMatch"}});
228 descriptions.
add(
"trackingRegionsFromSuperClusters", descRegion);
235 double deltaZVertex = 0;
249 auto superClustersHandle = getHandle(
iEvent, superClustersToken);
250 for (
auto& superClusterRef : *superClustersHandle) {
253 *superClusterRef, vtxPos, deltaZVertex,
Charge::POS, measTrackerEvent, magField, msmaker));
255 *superClusterRef, vtxPos, deltaZVertex,
Charge::NEG, measTrackerEvent, magField, msmaker));
266 if (!verticesHandle->empty()) {
268 const auto&
pv = verticesHandle->front();
280 const double bsSigmaZ =
std::sqrt(beamSpotHandle->sigmaZ() * beamSpotHandle->sigmaZ() +
281 beamSpotHandle->sigmaZ0Error() * beamSpotHandle->sigmaZ0Error());
296 const double deltaZVertex,
305 return std::make_unique<RectangularEtaPhiTrackingRegion>(fts.momentum(),
322 <<
" when constructing TrackingRegionsFromSuperClustersProducer both useZInVertex (" <<
useZInVertex_ 323 <<
") and useZInBeamspot (" <<
useZInBeamspot_ <<
") can not be true as they are mutually exclusive options" 334 "TrackingRegionsFromSuperClustersProducer");
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const math::XYZPoint & position() const
cluster centroid position
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
T getParameter(std::string const &) const
RectangularEtaPhiTrackingRegion::UseMeasurementTracker whereToUseMeasTracker_
#define DEFINE_FWK_MODULE(type)
constexpr bool isUninitialized() const noexcept
Global3DPoint GlobalPoint
double nrSigmaForBSDeltaZ_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
math::XYZPoint Point
point in the space
TrackingRegionsFromSuperClustersProducer(const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc)
GlobalPoint getVtxPos(const edm::Event &iEvent, double &deltaZVertex) const
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
std::vector< edm::EDGetTokenT< std::vector< reco::SuperClusterRef > > > superClustersTokens_
bool getData(T &iHolder) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double energy() const
cluster energy
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~TrackingRegionsFromSuperClustersProducer() override
void validateConfigSettings() const
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
std::unique_ptr< TrackingRegion > createTrackingRegion(const reco::SuperCluster &superCluster, const GlobalPoint &vtxPos, const double deltaZVertex, const Charge charge, const MeasurementTrackerEvent *measTrackerEvent, const MagneticField &magField, const MultipleScatteringParametrisationMaker *msmaker) const
edm::EDGetTokenT< MeasurementTrackerEvent > measTrackerEventToken_
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > msmakerToken_
#define DEFINE_EDM_PLUGIN(factory, type, name)