52 #include "TEnumConstant.h"
54 template <
typename MyEnum>
55 MyEnum strToEnum(
std::string const& enumConstName) {
56 TEnum* en = TEnum::GetEnum(
typeid(MyEnum));
58 if (TEnumConstant
const* enc = en->GetConstant(enumConstName.c_str())) {
59 return static_cast<MyEnum>(enc->GetValue());
61 throw cms::Exception(
"Configuration") << enumConstName <<
" is not a valid member of " <<
typeid(MyEnum).
name();
64 throw cms::Exception(
"LogicError") <<
typeid(MyEnum).
name() <<
" not recognised by ROOT";
69 if (enumConstName ==
"kNever")
70 return MyEnum::kNever;
71 else if (enumConstName ==
"kForSiStrips")
72 return MyEnum::kForSiStrips;
73 else if (enumConstName ==
"kAlways")
74 return MyEnum::kAlways;
77 << enumConstName <<
" is not a valid member of " <<
typeid(MyEnum).
name()
78 <<
" (or strToEnum needs updating, this is a manual translation found at " << __FILE__ <<
" line " << __LINE__
103 const double deltaZVertex,
140 template <
typename T>
150 : magFieldToken_{iC.esConsumes()} {
154 originRadius_ = regionPSet.
getParameter<
double>(
"originRadius");
155 originHalfLength_ = regionPSet.
getParameter<
double>(
"originHalfLength");
156 deltaPhiRegion_ = regionPSet.
getParameter<
double>(
"deltaPhiRegion");
157 deltaEtaRegion_ = regionPSet.
getParameter<
double>(
"deltaEtaRegion");
158 useZInVertex_ = regionPSet.
getParameter<
bool>(
"useZInVertex");
159 useZInBeamspot_ = regionPSet.
getParameter<
bool>(
"useZInBeamspot");
160 nrSigmaForBSDeltaZ_ = regionPSet.
getParameter<
double>(
"nrSigmaForBSDeltaZ");
161 defaultZ_ = regionPSet.
getParameter<
double>(
"defaultZ");
162 minBSDeltaZ_ = regionPSet.
getParameter<
double>(
"minBSDeltaZ");
164 whereToUseMeasTracker_ = strToEnum<RectangularEtaPhiTrackingRegion::UseMeasurementTracker>(
167 validateConfigSettings();
171 auto superClustersTags = regionPSet.
getParameter<std::vector<edm::InputTag>>(
"superClusters");
175 verticesToken_ = iC.consumes(verticesTag);
180 measTrackerEventToken_ = iC.consumes(measTrackerEventTag);
182 for (
const auto&
tag : superClustersTags) {
183 superClustersTokens_.emplace_back(iC.consumes(
tag));
190 desc.add<
double>(
"ptMin", 1.5);
191 desc.add<
double>(
"originRadius", 0.2);
192 desc.add<
double>(
"originHalfLength", 15.0)
193 ->setComment(
"z range is +/- this value except when using the beamspot (useZInBeamspot=true)");
194 desc.add<
double>(
"deltaPhiRegion", 0.4);
195 desc.add<
double>(
"deltaEtaRegion", 0.1);
196 desc.add<
bool>(
"useZInVertex",
false)
197 ->setComment(
"use the leading vertex position +/-orginHalfLength, mutually exclusive with useZInBeamspot");
198 desc.add<
bool>(
"useZInBeamspot",
true)
200 "use the beamspot position +/- nrSigmaForBSDeltaZ* sigmaZ_{bs}, mutually exclusive with useZInVertex");
201 desc.add<
double>(
"nrSigmaForBSDeltaZ", 3.0)
202 ->setComment(
"# of sigma to extend the z region when using the beamspot, only active if useZInBeamspot=true");
203 desc.add<
double>(
"minBSDeltaZ", 0.0)
204 ->setComment(
"a minimum value of the beamspot sigma z to use, only active if useZInBeamspot=true");
205 desc.add<
double>(
"defaultZ", 0.)
206 ->setComment(
"the default z position, only used if useZInVertex and useZInBeamspot are both false");
207 desc.add<
bool>(
"precise",
true);
210 ->setComment(
"only used if useZInBeamspot is true");
212 desc.add<std::vector<edm::InputTag>>(
"superClusters",
213 std::vector<edm::InputTag>{
edm::InputTag{
"hltEgammaSuperClustersToPixelMatch"}});
219 descriptions.
add(
"trackingRegionsFromSuperClusters", descRegion);
226 double deltaZVertex = 0;
236 auto superClustersHandle = getHandle(
iEvent, superClustersToken);
237 for (
auto& superClusterRef : *superClustersHandle) {
253 if (!verticesHandle->empty()) {
255 const auto&
pv = verticesHandle->front();
267 const double bsSigmaZ =
std::sqrt(beamSpotHandle->sigmaZ() * beamSpotHandle->sigmaZ() +
268 beamSpotHandle->sigmaZ0Error() * beamSpotHandle->sigmaZ0Error());
283 const double deltaZVertex,
291 return std::make_unique<RectangularEtaPhiTrackingRegion>(fts.momentum(),
306 <<
" when constructing TrackingRegionsFromSuperClustersProducer both useZInVertex (" <<
useZInVertex_
307 <<
") and useZInBeamspot (" <<
useZInBeamspot_ <<
") can not be true as they are mutually exclusive options"
318 "TrackingRegionsFromSuperClustersProducer");