42 using namespace ctfseeding;
52 caThetaCut(cfg.getParameter<double>(
"CAThetaCut")),
53 caPhiCut(cfg.getParameter<double>(
"CAPhiCut")),
54 caHardPtCut(cfg.getParameter<double>(
"CAHardPtCut")),
55 caOnlyOneLastHitPerLayerFilter(cfg.getParameter<bool>(
"CAOnlyOneLastHitPerLayerFilter"))
57 if(needSeedingLayerSetsHits)
60 if (cfg.
exists(
"SeedComparitorPSet"))
65 if (comparitorName !=
"none")
77 desc.
add<
double>(
"extraHitRPhitolerance", 0.1);
78 desc.
add<
bool>(
"fitFastCircle",
false);
79 desc.
add<
bool>(
"fitFastCircleChi2Cut",
false);
80 desc.
add<
bool>(
"useBendingCorrection",
false);
81 desc.
add<
double>(
"CAThetaCut", 0.00125);
82 desc.
add<
double>(
"CAPhiCut", 10);
83 desc.
add<
double>(
"CAHardPtCut", 0);
84 desc.
add<
bool>(
"CAOnlyOneLastHitPerLayerFilter",
false);
86 descMaxChi2.
add<
double>(
"pt1", 0.2);
87 descMaxChi2.add<
double>(
"pt2", 1.5);
88 descMaxChi2.add<
double>(
"value1", 500);
89 descMaxChi2.add<
double>(
"value2", 50);
90 descMaxChi2.add<
bool>(
"enabled",
true);
95 descComparitor.setAllowAnything();
104 template <
typename T_HitDoublets,
typename T_GeneratorOrPairsFunction>
106 T_GeneratorOrPairsFunction generatorOrPairsFunction) {
107 for (
unsigned int i = 0;
i < layers.
size();
i++)
109 for (
unsigned int j = 0;
j < 4; ++
j)
111 auto vertexIndex = 0;
113 layers[
i][
j].name());
121 vertexIndex = foundVertex - g.
theLayers.begin();
146 const bool nonEmpty = generatorOrPairsFunction(layers[
i][
j-1], layers[
i][
j], hitDoublets);
149 g.
theLayers[vertexIndex].theInnerLayers.push_back(
151 innerVertex->theOuterLayers.push_back(vertexIndex);
152 g.
theLayers[vertexIndex].theInnerLayerPairs.push_back(
154 innerVertex->theOuterLayerPairs.push_back(
176 <<
"CAHitQuadrupletsGenerator expects SeedingLayerSetsHits::numberOfLayersInSet() to be 4, got "
182 std::vector<HitDoublets> hitDoublets;
186 fillGraph(layers, g, hitDoublets,
189 std::vector<HitDoublets>& hitDoublets) {
190 hitDoublets.emplace_back(thePairGenerator.
doublets(region, ev, es, inner, outer));
197 std::vector<const HitDoublets *> hitDoubletsPtr;
198 hitDoubletsPtr.reserve(hitDoublets.size());
199 for(
const auto&
e: hitDoublets)
200 hitDoubletsPtr.emplace_back(&
e);
212 std::vector<const HitDoublets *> hitDoublets;
219 fillGraph(layers, g, hitDoublets,
222 std::vector<const HitDoublets *>& hitDoublets) {
223 using namespace std::placeholders;
224 auto found = std::find_if(regionLayerPairs.
begin(), regionLayerPairs.
end(),
225 std::bind(layerPairEqual, _1, inner.
index(), outer.
index()));
226 if(
found != regionLayerPairs.
end()) {
227 hitDoublets.emplace_back(&(
found->doublets()));
238 std::vector<const HitDoublets *>& hitDoublets,
const CAGraph& g,
245 const int numberOfHitsInNtuplet = 4;
246 std::vector<CACell::CAntuplet> foundQuadruplets;
253 ca.
evolve(numberOfHitsInNtuplet);
255 ca.
findNtuplets(foundQuadruplets, numberOfHitsInNtuplet);
261 std::array<float, 4> bc_r;
262 std::array<float, 4> bc_z;
263 std::array<float, 4> bc_errZ2;
264 std::array<GlobalPoint, 4> gps;
265 std::array<GlobalError, 4> ges;
266 std::array<bool, 4> barrels;
267 unsigned int fourthLayerId = 0;
268 unsigned int previousfourthLayerId = 0;
270 int previousSubDetId = 0;
271 unsigned int sideId = 0;
272 unsigned int previousSideId = 0;
273 std::array<unsigned int, 2> previousCellIds ={{0,0}};
274 bool isTheSameTriplet =
false;
275 bool isTheSameFourthLayer =
false;
276 bool hasAlreadyPushedACandidate =
false;
280 unsigned int numberOfFoundQuadruplets = foundQuadruplets.size();
283 for (
unsigned int quadId = 0; quadId < numberOfFoundQuadruplets; ++quadId)
286 auto isBarrel = [](
const unsigned id) ->
bool
290 for(
unsigned int i = 0;
i< 3; ++
i)
292 auto const& ahit = foundQuadruplets[quadId][
i]->getInnerHit();
293 gps[
i] = ahit->globalPosition();
294 ges[
i] = ahit->globalPositionError();
295 barrels[
i] =
isBarrel(ahit->geographicalId().subdetId());
298 auto const& ahit = foundQuadruplets[quadId][2]->getOuterHit();
299 gps[3] = ahit->globalPosition();
300 ges[3] = ahit->globalPositionError();
301 barrels[3] =
isBarrel(ahit->geographicalId().subdetId());
305 fourthLayerId = tTopo->
layer(ahit->geographicalId());
306 sideId = tTopo->
side(ahit->geographicalId());
307 subDetId = ahit->geographicalId().subdetId();
308 isTheSameTriplet = (quadId != 0) && (foundQuadruplets[quadId][0]->getCellId() == previousCellIds[0]) && (foundQuadruplets[quadId][1]->getCellId() == previousCellIds[1]);
309 isTheSameFourthLayer = (quadId != 0) && (fourthLayerId == previousfourthLayerId) && (subDetId == previousSubDetId) && (sideId == previousSideId);
311 previousCellIds = {{foundQuadruplets[quadId][0]->getCellId(), foundQuadruplets[quadId][1]->getCellId()}};
312 previousfourthLayerId = fourthLayerId;
315 if(!(isTheSameTriplet && isTheSameFourthLayer ))
318 hasAlreadyPushedACandidate =
false;
332 const float abscurv =
std::abs(curvature);
333 const float thisMaxChi2 = maxChi2Eval.
value(abscurv);
337 SeedingHitSet tmpTriplet(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
346 float chi2 = std::numeric_limits<float>::quiet_NaN();
351 const float simpleCot = ( gps.back().z() - gps.front().z() ) / (gps.back().perp() - gps.front().perp() );
353 for (
int i=0;
i < 4; ++
i)
359 bc_z[
i] = point.
z() - region.
origin().
z();
360 bc_errZ2[
i] = (barrels[
i]) ? error.
czz() : error.
rerr(point)*
sqr(simpleCot);
363 chi2 = rzLine.
chi2();
367 RZLine rzLine(gps, ges, barrels);
368 chi2 = rzLine.
chi2();
389 if (chi2 < selectedChi2)
393 if(hasAlreadyPushedACandidate)
398 result.emplace_back(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][1]->getInnerHit(),
399 foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
400 hasAlreadyPushedACandidate =
true;
407 result.emplace_back(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][1]->getInnerHit(), foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
void findNtuplets(std::vector< CACell::CAntuplet > &, const unsigned int)
float value(float curvature) const
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
const bool useBendingCorrection
void hitNtuplets(const IntermediateHitDoublets::RegionLayerSets ®ionLayerPairs, OrderedHitSeeds &result, const edm::EventSetup &es, const SeedingLayerSetsHits &layers)
const_iterator begin() const
void createAndConnectCells(const std::vector< const HitDoublets * > &, const TrackingRegion &, const float, const float, const float)
GlobalPoint const & origin() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
LayerCacheType theLayerCache
bool isBarrel(GeomDetEnumerators::SubDetector m)
CAHitQuadrupletGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC, bool needSeedingLayerSetsHits=true)
const_iterator end() const
unsigned int side(const DetId &id) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::unique_ptr< SeedComparitor > theComparitor
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Range curvature(double transverseIP) const
virtual void hitQuadruplets(const TrackingRegion ®, OrderedHitSeeds &quadruplets, const edm::Event &ev, const edm::EventSetup &es)
from base class
T inversePt(T curvature, const edm::EventSetup &iSetup)
T x() const
Cartesian x coordinate.
static unsigned int minLayers
T curvature(T InversePt, const edm::EventSetup &iSetup)
std::vector< CALayer > theLayers
void initEvent(const edm::Event &ev, const edm::EventSetup &es)
Abs< T >::type abs(const T &t)
const float extraHitRPhitolerance
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< CALayerPair > theLayerPairs
HitDoublets doublets(const TrackingRegion ®, const edm::Event &ev, const edm::EventSetup &es, Layers layers)
const bool fitFastCircleChi2Cut
const TrackingRegion & region() const
unsigned short LayerIndex
const QuantityDependsPt maxChi2
T rerr(const GlobalPoint &aPoint) const
T const * product() const
unsigned int layer(const DetId &id) const
Square< F >::type sqr(const F &f)
std::vector< int > theRootLayers
const bool caOnlyOneLastHitPerLayerFilter
static void fillDescriptions(edm::ParameterSetDescription &desc)
QuantityDependsPtEval evaluator(const edm::EventSetup &es) const
unsigned int subDetId[20]
virtual ~CAHitQuadrupletGenerator()
unsigned short size() const
Get the number of SeedingLayerSets.
tuple size
Write out results.
edm::EDGetTokenT< SeedingLayerSetsHits > theSeedingLayerToken
T get(const Candidate &c)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
void evolve(const unsigned int)