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 for (
unsigned int i = 0;
i < layers.
size();
i++)
106 for (
unsigned int j = 0; j < 4; ++j)
110 layers[
i][j].name());
141 for (
auto &
v : g.
theLayers[
i].isOuterHitOfCell)
v.clear();
145 template <
typename T_HitDoublets,
typename T_GeneratorOrPairsFunction>
147 T_GeneratorOrPairsFunction generatorOrPairsFunction) {
148 for (
unsigned int i = 0;
i < layers.
size();
i++)
150 for (
unsigned int j = 0; j < 4; ++j)
154 layers[
i][j].name());
177 const bool nonEmpty = generatorOrPairsFunction(layers[
i][j-1], layers[
i][j], hitDoublets);
182 innerVertex->theOuterLayers.push_back(
vertexIndex);
185 innerVertex->theOuterLayerPairs.push_back(
207 <<
"CAHitQuadrupletsGenerator expects SeedingLayerSetsHits::numberOfLayersInSet() to be 4, got " 212 std::vector<HitDoublets> hitDoublets;
217 createGraphStructure(layers, g);
218 fillGraph(layers, g, hitDoublets,
221 std::vector<HitDoublets>& hitDoublets) {
222 hitDoublets.emplace_back(thePairGenerator.
doublets(region, ev, es, inner, outer));
229 std::vector<const HitDoublets *> hitDoubletsPtr;
230 hitDoubletsPtr.reserve(hitDoublets.size());
231 for(
const auto&
e: hitDoublets)
232 hitDoubletsPtr.emplace_back(&
e);
239 std::vector<OrderedHitSeeds>&
result,
244 std::vector<const HitDoublets *> hitDoublets;
255 const int numberOfHitsInNtuplet = 4;
256 std::vector<CACell::CAntuplet> foundQuadruplets;
261 for(
const auto& regionLayerPairs: regionDoublets) {
265 foundQuadruplets.clear();
267 createGraphStructure(layers, g);
270 clearGraphStructure(layers, g);
273 fillGraph(layers, g, hitDoublets,
276 std::vector<const HitDoublets *>& hitDoublets) {
278 auto found = std::find_if(regionLayerPairs.begin(), regionLayerPairs.end(),
279 std::bind(layerPairEqual, _1, inner.
index(), outer.
index()));
280 if(
found != regionLayerPairs.end()) {
281 hitDoublets.emplace_back(&(
found->doublets()));
289 ca.createAndConnectCells(hitDoublets, region,
caThetaCut,
292 ca.evolve(numberOfHitsInNtuplet);
294 ca.findNtuplets(foundQuadruplets, numberOfHitsInNtuplet);
296 auto & allCells = ca.getAllCells();
301 std::array<float, 4> bc_r;
302 std::array<float, 4> bc_z;
303 std::array<float, 4> bc_errZ2;
304 std::array<GlobalPoint, 4> gps;
305 std::array<GlobalError, 4> ges;
306 std::array<bool, 4> barrels;
307 bool hasAlreadyPushedACandidate =
false;
309 unsigned int previousfourthLayerId = 0;
310 std::array<unsigned int, 2> previousCellIds ={{0,0}};
311 unsigned int previousSideId = 0;
312 int previousSubDetId = 0;
314 unsigned int numberOfFoundQuadruplets = foundQuadruplets.size();
317 for (
unsigned int quadId = 0; quadId < numberOfFoundQuadruplets; ++quadId)
324 for(
unsigned int i = 0;
i< 3; ++
i)
326 auto const& ahit = allCells[foundQuadruplets[quadId][
i]].getInnerHit();
327 gps[
i] = ahit->globalPosition();
328 ges[
i] = ahit->globalPositionError();
329 barrels[
i] =
isBarrel(ahit->geographicalId().subdetId());
332 auto const& ahit = allCells[foundQuadruplets[quadId][2]].getOuterHit();
333 gps[3] = ahit->globalPosition();
334 ges[3] = ahit->globalPositionError();
335 barrels[3] =
isBarrel(ahit->geographicalId().subdetId());
338 const auto fourthLayerId = tTopo->
layer(ahit->geographicalId());
339 const auto sideId = tTopo->
side(ahit->geographicalId());
340 const auto subDetId = ahit->geographicalId().subdetId();
341 const auto isTheSameTriplet = (quadId != 0) && (foundQuadruplets[quadId][0] == previousCellIds[0]) && (foundQuadruplets[quadId][1] == previousCellIds[1]);
342 const auto isTheSameFourthLayer = (quadId != 0) && (fourthLayerId == previousfourthLayerId) && (
subDetId == previousSubDetId) && (sideId == previousSideId);
344 previousCellIds = {{foundQuadruplets[quadId][0], foundQuadruplets[quadId][1]}};
345 previousfourthLayerId = fourthLayerId;
348 if(!(isTheSameTriplet && isTheSameFourthLayer ))
351 hasAlreadyPushedACandidate =
false;
363 const float abscurv =
std::abs(curvature);
364 const float thisMaxChi2 = maxChi2Eval.
value(abscurv);
367 SeedingHitSet tmpTriplet(allCells[foundQuadruplets[quadId][0]].getInnerHit(),
368 allCells[foundQuadruplets[quadId][2]].getInnerHit(),
369 allCells[foundQuadruplets[quadId][2]].getOuterHit());
378 float chi2 = std::numeric_limits<float>::quiet_NaN();
383 const float simpleCot = ( gps.back().z() - gps.front().z() ) / (gps.back().perp() - gps.front().perp() );
385 for (
int i=0;
i < 4; ++
i)
391 bc_z[
i] = point.
z() - region.
origin().
z();
392 bc_errZ2[
i] = (barrels[
i]) ? error.
czz() : error.
rerr(point)*
sqr(simpleCot);
395 chi2 = rzLine.
chi2();
399 RZLine rzLine(gps, ges, barrels);
400 chi2 = rzLine.
chi2();
417 if (chi2 < selectedChi2)
420 if(hasAlreadyPushedACandidate)
422 result[
index].pop_back();
424 result[
index].emplace_back(allCells[foundQuadruplets[quadId][0]].getInnerHit(),
425 allCells[foundQuadruplets[quadId][1]].getInnerHit(),
426 allCells[foundQuadruplets[quadId][2]].getInnerHit(),
427 allCells[foundQuadruplets[quadId][2]].getOuterHit());
428 hasAlreadyPushedACandidate =
true;
433 result[
index].emplace_back(allCells[foundQuadruplets[quadId][0]].getInnerHit(),
434 allCells[foundQuadruplets[quadId][1]].getInnerHit(),
435 allCells[foundQuadruplets[quadId][2]].getInnerHit(),
436 allCells[foundQuadruplets[quadId][2]].getOuterHit());
446 std::vector<const HitDoublets *>& hitDoublets,
CAGraph&
g,
453 const int numberOfHitsInNtuplet = 4;
454 std::vector<CACell::CAntuplet> foundQuadruplets;
461 ca.
evolve(numberOfHitsInNtuplet);
463 ca.
findNtuplets(foundQuadruplets, numberOfHitsInNtuplet);
470 std::array<float, 4> bc_r;
471 std::array<float, 4> bc_z;
472 std::array<float, 4> bc_errZ2;
473 std::array<GlobalPoint, 4> gps;
474 std::array<GlobalError, 4> ges;
475 std::array<bool, 4> barrels;
476 bool hasAlreadyPushedACandidate =
false;
478 unsigned int previousfourthLayerId = 0;
479 std::array<unsigned int, 2> previousCellIds ={{0,0}};
480 unsigned int previousSideId = 0;
481 int previousSubDetId = 0;
483 unsigned int numberOfFoundQuadruplets = foundQuadruplets.size();
486 for (
unsigned int quadId = 0; quadId < numberOfFoundQuadruplets; ++quadId)
493 for(
unsigned int i = 0;
i< 3; ++
i)
495 auto const& ahit = allCells[foundQuadruplets[quadId][
i]].getInnerHit();
496 gps[
i] = ahit->globalPosition();
497 ges[
i] = ahit->globalPositionError();
498 barrels[
i] =
isBarrel(ahit->geographicalId().subdetId());
501 auto const& ahit = allCells[foundQuadruplets[quadId][2]].getOuterHit();
502 gps[3] = ahit->globalPosition();
503 ges[3] = ahit->globalPositionError();
504 barrels[3] =
isBarrel(ahit->geographicalId().subdetId());
508 const auto fourthLayerId = tTopo->
layer(ahit->geographicalId());
509 const auto sideId = tTopo->
side(ahit->geographicalId());
510 const auto subDetId = ahit->geographicalId().subdetId();
511 const auto isTheSameTriplet = (quadId != 0) && (foundQuadruplets[quadId][0] == previousCellIds[0]) && (foundQuadruplets[quadId][1] == previousCellIds[1]);
512 const auto isTheSameFourthLayer = (quadId != 0) && (fourthLayerId == previousfourthLayerId) && (
subDetId == previousSubDetId) && (sideId == previousSideId);
514 previousCellIds = {{foundQuadruplets[quadId][0], foundQuadruplets[quadId][1]}};
515 previousfourthLayerId = fourthLayerId;
518 if(!(isTheSameTriplet && isTheSameFourthLayer ))
521 hasAlreadyPushedACandidate =
false;
535 const float abscurv =
std::abs(curvature);
536 const float thisMaxChi2 = maxChi2Eval.
value(abscurv);
540 SeedingHitSet tmpTriplet(allCells[foundQuadruplets[quadId][0]].getInnerHit(),
541 allCells[foundQuadruplets[quadId][2]].getInnerHit(),
542 allCells[foundQuadruplets[quadId][2]].getOuterHit());
551 float chi2 = std::numeric_limits<float>::quiet_NaN();
556 const float simpleCot = ( gps.back().z() - gps.front().z() ) / (gps.back().perp() - gps.front().perp() );
558 for (
int i=0;
i < 4; ++
i)
564 bc_z[
i] = point.
z() - region.
origin().
z();
565 bc_errZ2[
i] = (barrels[
i]) ? error.
czz() : error.
rerr(point)*
sqr(simpleCot);
568 chi2 = rzLine.
chi2();
572 RZLine rzLine(gps, ges, barrels);
573 chi2 = rzLine.
chi2();
594 if (chi2 < selectedChi2)
598 if(hasAlreadyPushedACandidate)
604 result.emplace_back(allCells[foundQuadruplets[quadId][0]].getInnerHit(),
605 allCells[foundQuadruplets[quadId][1]].getInnerHit(),
606 allCells[foundQuadruplets[quadId][2]].getInnerHit(),
607 allCells[foundQuadruplets[quadId][2]].getOuterHit());
608 hasAlreadyPushedACandidate =
true;
614 result.emplace_back(allCells[foundQuadruplets[quadId][0]].getInnerHit(),
615 allCells[foundQuadruplets[quadId][1]].getInnerHit(),
616 allCells[foundQuadruplets[quadId][2]].getInnerHit(),
617 allCells[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 createAndConnectCells(const std::vector< const HitDoublets * > &, const TrackingRegion &, const float, const float, const float)
GlobalPoint const & origin() const
def create(alignables, pedeDump, additionalData, outputFile, config)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
LayerCacheType theLayerCache
CAHitQuadrupletGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC, bool needSeedingLayerSetsHits=true)
unsigned int side(const DetId &id) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< CACell > & getAllCells()
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
unsigned int subDetId[21]
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
unsigned short LayerIndex
const QuantityDependsPt maxChi2
T rerr(const GlobalPoint &aPoint) const
unsigned int layer(const DetId &id) const
Square< F >::type sqr(const F &f)
std::vector< int > theRootLayers
const bool caOnlyOneLastHitPerLayerFilter
void hitNtuplets(const IntermediateHitDoublets ®ionDoublets, std::vector< OrderedHitSeeds > &result, const edm::EventSetup &es, const SeedingLayerSetsHits &layers)
static void fillDescriptions(edm::ParameterSetDescription &desc)
QuantityDependsPtEval evaluator(const edm::EventSetup &es) const
virtual ~CAHitQuadrupletGenerator()
unsigned short size() const
Get the number of SeedingLayerSets.
T const * product() const
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)