Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triplet check in FastSim #14083

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
efe662a
Merged refs/pull/13437/head from repository cms-sw
Feb 23, 2016
15c3a6b
remove no-longer used files
Feb 23, 2016
cf4a641
merge
Jan 20, 2016
f6f122a
fix
Feb 23, 2016
b3d576b
Merged fastsim-hittriplets-feb23 from repository lveldere
a-kapoor Feb 23, 2016
ac73698
Primary Implementation of triplet Check
a-kapoor Feb 26, 2016
82028f3
Merged hitTriplet from repository ANSH0712
Feb 26, 2016
f923243
fix some compilation issues
Feb 26, 2016
537018b
refactor seedfinder selector
Feb 26, 2016
a5e8222
Merged fastsim-4anshul from repository lveldere
a-kapoor Feb 26, 2016
302d786
Removed a typo in a config
a-kapoor Feb 26, 2016
78eca14
Implemented Full-Triplet-Check
a-kapoor Feb 29, 2016
15d753f
Merged FastSim-Triplet from repository ANSH0712
a-kapoor Mar 1, 2016
d331ada
Test
a-kapoor Mar 1, 2016
2fd7bb2
Merged Triplet-Check from repository ANSH0712
a-kapoor Mar 10, 2016
d864570
Split the triplet function in PixelTripletLargeTipGenerator so that i…
a-kapoor Mar 10, 2016
a4333fd
Implemedted triplet check for lowPtStep in FastSim Tracking and corre…
a-kapoor Mar 14, 2016
0c0c6df
Merged Triplet-Check-In-FastSim from repository ANSH0712
a-kapoor Mar 15, 2016
88a35c7
Did some technical Changes in MultiHitGeneratorFromChi2 plugin in Ful…
a-kapoor Mar 15, 2016
c6785cb
Added Triplet Check for seeds in TobTecStep and PixelLessStep in Fast…
a-kapoor Mar 16, 2016
eb886c4
Merged Triplet-Check-In-FastSim_15Mar from repository ANSH0712
Apr 5, 2016
fa87e30
do per event initialisation of MultiHitGeneratorFromChi2
Apr 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions FastSimulation/Tracking/plugins/BuildFile.xml
Expand Up @@ -18,13 +18,15 @@
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="RecoPixelVertexing/PixelTrackFitting"/>
<use name="RecoTracker/TkTrackingRegions"/>
<use name="RecoTracker/TkSeedGenerator"/>
<use name="SimDataFormats/Track"/>
<use name="SimDataFormats/Vertex"/>
<use name="TrackingTools/PatternTools"/>
<use name="TrackingTools/TrajectoryParametrization"/>
<use name="TrackingTools/TrajectoryState"/>
<use name="TrackingTools/MaterialEffects"/>
<use name="SimGeneral/MixingModule"/>
<use name="RecoPixelVertexing/PixelTriplets"/>
<library name="FastSimulationTrackingPlugins" file="*.cc">
<flags EDM_PLUGIN="1"/>
</library>
96 changes: 63 additions & 33 deletions FastSimulation/Tracking/plugins/TrajectorySeedProducer.cc
Expand Up @@ -49,7 +49,10 @@
#include "RecoTracker/Record/interface/CkfComponentsRecord.h"
#include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"
#include "RecoTracker/TkHitPairs/interface/RecHitsSortedInPhi.h"

#include "RecoPixelVertexing/PixelTriplets/interface/HitTripletGeneratorFromPairAndLayers.h"
#include "RecoPixelVertexing/PixelTriplets/interface/HitTripletGeneratorFromPairAndLayersFactory.h"
#include "RecoTracker/TkSeedGenerator/interface/MultiHitGeneratorFromPairAndLayers.h"
#include "RecoTracker/TkSeedGenerator/interface/MultiHitGeneratorFromPairAndLayersFactory.h"
// geometry
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

Expand Down Expand Up @@ -80,21 +83,33 @@ class TrajectorySeedProducer

bool skipSeedFinderSelector;

std::unique_ptr<HitTripletGeneratorFromPairAndLayers> pixelTripletGenerator;
std::unique_ptr<MultiHitGeneratorFromPairAndLayers> MultiHitGenerator;
public:

TrajectorySeedProducer(const edm::ParameterSet& conf);

virtual void produce(edm::Event& e, const edm::EventSetup& es);

};


template class SeedingTree<TrackingLayer>;
template class SeedingNode<TrackingLayer>;

TrajectorySeedProducer::TrajectorySeedProducer(const edm::ParameterSet& conf)
{

// produces
if(conf.exists("pixelTripletGeneratorFactory"))
{
const edm::ParameterSet & tripletConfig = conf.getParameter<edm::ParameterSet>("pixelTripletGeneratorFactory");
auto iC = consumesCollector();
pixelTripletGenerator.reset(HitTripletGeneratorFromPairAndLayersFactory::get()->create(tripletConfig.getParameter<std::string>("ComponentName"),tripletConfig,iC));
}
if(conf.exists("MultiHitGeneratorFactory"))
{
const edm::ParameterSet & tripletConfig = conf.getParameter<edm::ParameterSet>("MultiHitGeneratorFactory");
//auto iC = consumesCollector();
MultiHitGenerator.reset(MultiHitGeneratorFromPairAndLayersFactory::get()->create(tripletConfig.getParameter<std::string>("ComponentName"),tripletConfig));
}
produces<TrajectorySeedCollection>();

// consumes
Expand Down Expand Up @@ -173,51 +188,66 @@ void TrajectorySeedProducer::produce(edm::Event& e, const edm::EventSetup& es)
return;
}

// pointer to selected region
// pointers for selector function
TrackingRegion * selectedTrackingRegion = 0;
auto pixelTripletGeneratorPtr = pixelTripletGenerator.get();
auto MultiHitGeneratorPtr = MultiHitGenerator.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for this *Ptr objects.
Just use the .get() function on the unique_ptr whenever needed.

if(MultiHitGenerator)
{
MultiHitGenerator->initES(es);
}
std::unique_ptr<HitDoublets> hitDoublets;

// define a lambda function
// to select hit pairs, triplets, ... compatible with the region
SeedFinder::Selector selectorFunction = [&es,&measurementTracker,&selectedTrackingRegion](const std::vector<const FastTrackerRecHit*>& hits) -> bool
SeedFinder::Selector selectorFunction = [&es,&measurementTracker,&selectedTrackingRegion,&pixelTripletGeneratorPtr,&MultiHitGeneratorPtr,&hitDoublets](const std::vector<const FastTrackerRecHit*>& hits) mutable -> bool
{
// criteria for hit pairs
// based on HitPairGeneratorFromLayerPair::doublets( const TrackingRegion& region, const edm::Event & iEvent, const edm::EventSetup& iSetup, Layers layers)
if (hits.size()==2)
if(hits.size()==2)
{
const FastTrackerRecHit * innerHit = hits[0];
const FastTrackerRecHit * outerHit = hits[1];
const FastTrackerRecHit * firstHit = hits[0];
const FastTrackerRecHit * secondHit = hits[1];

const DetLayer * innerLayer = measurementTracker->geometricSearchTracker()->detLayer(innerHit->det()->geographicalId());
const DetLayer * outerLayer = measurementTracker->geometricSearchTracker()->detLayer(outerHit->det()->geographicalId());
const DetLayer * firstLayer = measurementTracker->geometricSearchTracker()->detLayer(firstHit->det()->geographicalId());
const DetLayer * secondLayer = measurementTracker->geometricSearchTracker()->detLayer(secondHit->det()->geographicalId());

std::vector<BaseTrackerRecHit const *> innerHits(1,(const BaseTrackerRecHit*) innerHit->hit());
std::vector<BaseTrackerRecHit const *> outerHits(1,(const BaseTrackerRecHit*) outerHit->hit());

const RecHitsSortedInPhi* ihm=new RecHitsSortedInPhi (innerHits, selectedTrackingRegion->origin(), innerLayer);
const RecHitsSortedInPhi* ohm=new RecHitsSortedInPhi (outerHits, selectedTrackingRegion->origin(), outerLayer);

HitDoublets result(*ihm,*ohm);
HitPairGeneratorFromLayerPair::doublets(*selectedTrackingRegion,*innerLayer,*outerLayer,*ihm,*ohm,es,0,result);

if(result.size()!=0)
{
return true;
}
else
{
return false;
}
std::vector<BaseTrackerRecHit const *> firstHits(1,(const BaseTrackerRecHit*) firstHit->hit());
std::vector<BaseTrackerRecHit const *> secondHits(1,(const BaseTrackerRecHit*) secondHit->hit());

const RecHitsSortedInPhi* fhm=new RecHitsSortedInPhi (firstHits, selectedTrackingRegion->origin(), firstLayer);
const RecHitsSortedInPhi* shm=new RecHitsSortedInPhi (secondHits, selectedTrackingRegion->origin(), secondLayer);
hitDoublets.reset(new HitDoublets(*fhm,*shm));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you store data in a pointer outside the lambda. This may cause problems because it depends on the hits when this method is called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, this looks like almost certain memory leak. Where are fhm and shm deleted (i.e. who owns them)?

Copy link
Contributor

@lveldere lveldere Apr 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's indeed a memory leak.
Perhaps you need to declare fhm and shm outside the lambda functions as regular objects, not pointers and pass to the lambda function via the square brackets.
Getting a bit ugly...

HitPairGeneratorFromLayerPair::doublets(*selectedTrackingRegion,*firstLayer,*secondLayer,*fhm,*shm,es,0,*hitDoublets);
return hitDoublets->size()!=0;
}
else
{

// no criteria for hit combinations that are not pairs
else if((pixelTripletGeneratorPtr||MultiHitGeneratorPtr)&& hits.size()==3 && hitDoublets->size()!=0)
{

const FastTrackerRecHit * thirdHit = hits[2];
const DetLayer * thirdLayer = measurementTracker->geometricSearchTracker()->detLayer(thirdHit->det()->geographicalId());
std::vector<const DetLayer *> thirdLayerDetLayer(1,thirdLayer);
std::vector<BaseTrackerRecHit const *> thirdHits(1,(const BaseTrackerRecHit*) thirdHit->hit());
const RecHitsSortedInPhi* thm=new RecHitsSortedInPhi (thirdHits, selectedTrackingRegion->origin(), thirdLayer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a memory leak indeed.
We are making some changes to the seedfinder class to allow for a cleaner selector that doesn't require new statements, is easier to read and a bit more robust.

if(pixelTripletGeneratorPtr){
OrderedHitTriplets Tripletresult;
pixelTripletGeneratorPtr->hitTriplets(*selectedTrackingRegion,Tripletresult,es,*hitDoublets,&thm,thirdLayerDetLayer,1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you use the hitDoublets again to retrieve the information. You assume that together with the third hit these form a triplet that satisfies the seeding layers. I think there can be cases where this is not true, e.g. if you have two hits for the first layer, then you get two doublets where the first one is overridden by the next one and hence the two hits in the doublets are not identical to the hits with which this method is called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are making assumptions on how the loop over the seeding tree happens.
It's definitely error prone...
We need to discuss this.

return Tripletresult.size()!=0;
}
if(MultiHitGeneratorPtr){
OrderedMultiHits Tripletresult;
MultiHitGeneratorPtr->hitTriplets(*selectedTrackingRegion,Tripletresult,es,*hitDoublets,&thm,thirdLayerDetLayer,1);
return Tripletresult.size()!=0;
}
return true;
}

return true;
};

if(skipSeedFinderSelector)
{
{
selectedTrackingRegion = regions[0].get();
selectorFunction = [](const std::vector<const FastTrackerRecHit*>& hits) -> bool
{
Expand Down
6 changes: 4 additions & 2 deletions FastSimulation/Tracking/python/DetachedTripletStep_cff.py
Expand Up @@ -13,15 +13,17 @@
minLayersCrossed = 3,
layerList = _detachedTripletStep.detachedTripletStepSeedLayers.layerList.value(),
RegionFactoryPSet = _detachedTripletStep.detachedTripletStepSeeds.RegionFactoryPSet,
hitMasks = cms.InputTag("detachedTripletStepMasks"),
pixelTripletGeneratorFactory = _detachedTripletStep.detachedTripletStepSeeds.OrderedHitsFactoryPSet.GeneratorPSet,
hitMasks = cms.InputTag("detachedTripletStepMasks")
)

#del detachedTripletStepSeeds.pixelTripletGeneratorFactory.SeedComparitorPSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of comment

# track candidates
import FastSimulation.Tracking.TrackCandidateProducer_cfi
detachedTripletStepTrackCandidates = FastSimulation.Tracking.TrackCandidateProducer_cfi.trackCandidateProducer.clone(
src = cms.InputTag("detachedTripletStepSeeds"),
MinNumberOfCrossedLayers = 3,
hitMasks = cms.InputTag("detachedTripletStepMasks"),
hitMasks = cms.InputTag("detachedTripletStepMasks")
)

# tracks
Expand Down
5 changes: 3 additions & 2 deletions FastSimulation/Tracking/python/InitialStep_cff.py
Expand Up @@ -9,9 +9,10 @@
minLayersCrossed = 3,
layerList = RecoTracker.IterativeTracking.InitialStep_cff.initialStepSeedLayers.layerList.value(),
RegionFactoryPSet = RecoTracker.IterativeTracking.InitialStep_cff.initialStepSeeds.RegionFactoryPSet,
MeasurementTrackerEvent = cms.InputTag("MeasurementTrackerEvent")
MeasurementTrackerEvent = cms.InputTag("MeasurementTrackerEvent"),
pixelTripletGeneratorFactory = RecoTracker.IterativeTracking.InitialStep_cff.initialStepSeeds.OrderedHitsFactoryPSet.GeneratorPSet,
)

initialStepSeeds.pixelTripletGeneratorFactory.SeedComparitorPSet=cms.PSet( ComponentName = cms.string( "none" ) )
# track candidates
import FastSimulation.Tracking.TrackCandidateProducer_cfi
initialStepTrackCandidates = FastSimulation.Tracking.TrackCandidateProducer_cfi.trackCandidateProducer.clone(
Expand Down
7 changes: 4 additions & 3 deletions FastSimulation/Tracking/python/LowPtTripletStep_cff.py
Expand Up @@ -12,11 +12,12 @@
import FastSimulation.Tracking.TrajectorySeedProducer_cfi
lowPtTripletStepSeeds = FastSimulation.Tracking.TrajectorySeedProducer_cfi.trajectorySeedProducer.clone(
minLayersCrossed = 3,
layerList = RecoTracker.IterativeTracking.InitialStep_cff.initialStepSeedLayers.layerList.value(),
RegionFactoryPSet = RecoTracker.IterativeTracking.InitialStep_cff.initialStepSeeds.RegionFactoryPSet,
layerList = RecoTracker.IterativeTracking.LowPtTripletStep_cff.lowPtTripletStepSeedLayers.layerList.value(),
RegionFactoryPSet = RecoTracker.IterativeTracking.LowPtTripletStep_cff.lowPtTripletStepSeeds.RegionFactoryPSet,
hitMasks = cms.InputTag("lowPtTripletStepMasks"),
pixelTripletGeneratorFactory = RecoTracker.IterativeTracking.LowPtTripletStep_cff.lowPtTripletStepSeeds.OrderedHitsFactoryPSet.GeneratorPSet
)

lowPtTripletStepSeeds.pixelTripletGeneratorFactory.SeedComparitorPSet=cms.PSet( ComponentName = cms.string( "none" ) )
# track candidates
import FastSimulation.Tracking.TrackCandidateProducer_cfi
lowPtTripletStepTrackCandidates = FastSimulation.Tracking.TrackCandidateProducer_cfi.trackCandidateProducer.clone(
Expand Down
10 changes: 6 additions & 4 deletions FastSimulation/Tracking/python/MixedTripletStep_cff.py
Expand Up @@ -14,18 +14,20 @@
minLayersCrossed = 3,
layerList = RecoTracker.IterativeTracking.MixedTripletStep_cff.mixedTripletStepSeedLayersA.layerList.value(),
RegionFactoryPSet = RecoTracker.IterativeTracking.MixedTripletStep_cff.mixedTripletStepSeedsA.RegionFactoryPSet,
hitMasks = cms.InputTag("mixedTripletStepMasks"),
pixelTripletGeneratorFactory = RecoTracker.IterativeTracking.MixedTripletStep_cff.mixedTripletStepSeedsA.OrderedHitsFactoryPSet.GeneratorPSet,
hitMasks = cms.InputTag("mixedTripletStepMasks")
)

#del mixedTripletStepSeedsA.pixelTripletGeneratorFactory.SeedComparitorPSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of comment

###
import FastSimulation.Tracking.TrajectorySeedProducer_cfi
mixedTripletStepSeedsB = FastSimulation.Tracking.TrajectorySeedProducer_cfi.trajectorySeedProducer.clone(
minLayersCrossed = 3,
layerList = RecoTracker.IterativeTracking.MixedTripletStep_cff.mixedTripletStepSeedLayersB.layerList.value(),
RegionFactoryPSet = RecoTracker.IterativeTracking.MixedTripletStep_cff.mixedTripletStepSeedsB.RegionFactoryPSet,
hitMasks = cms.InputTag("mixedTripletStepMasks"),
pixelTripletGeneratorFactory = RecoTracker.IterativeTracking.MixedTripletStep_cff.mixedTripletStepSeedsB.OrderedHitsFactoryPSet.GeneratorPSet,
hitMasks = cms.InputTag("mixedTripletStepMasks")
)

#del mixedTripletStepSeedsB.pixelTripletGeneratorFactory.SeedComparitorPSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of comment

mixedTripletStepSeeds = RecoTracker.IterativeTracking.MixedTripletStep_cff.mixedTripletStepSeeds.clone()

#track candidates
Expand Down
4 changes: 3 additions & 1 deletion FastSimulation/Tracking/python/PixelLessStep_cff.py
Expand Up @@ -14,8 +14,10 @@
layerList = RecoTracker.IterativeTracking.PixelLessStep_cff.pixelLessStepSeedLayers.layerList.value(),
RegionFactoryPSet = RecoTracker.IterativeTracking.PixelLessStep_cff.pixelLessStepSeeds.RegionFactoryPSet,
hitMasks = cms.InputTag("pixelLessStepMasks"),
MultiHitGeneratorFactory = RecoTracker.IterativeTracking.PixelLessStep_cff.pixelLessStepSeeds.OrderedHitsFactoryPSet.GeneratorPSet
)

pixelLessStepSeeds.MultiHitGeneratorFactory.SeedComparitorPSet=cms.PSet( ComponentName = cms.string( "none" ) )
pixelLessStepSeeds.MultiHitGeneratorFactory.refitHits = False
# track candidates
import FastSimulation.Tracking.TrackCandidateProducer_cfi
pixelLessStepTrackCandidates = FastSimulation.Tracking.TrackCandidateProducer_cfi.trackCandidateProducer.clone(
Expand Down
4 changes: 3 additions & 1 deletion FastSimulation/Tracking/python/TobTecStep_cff.py
Expand Up @@ -14,8 +14,10 @@
layerList = RecoTracker.IterativeTracking.TobTecStep_cff.tobTecStepSeedLayersTripl.layerList.value(),
RegionFactoryPSet = RecoTracker.IterativeTracking.TobTecStep_cff.tobTecStepSeedsTripl.RegionFactoryPSet,
hitMasks = cms.InputTag("tobTecStepMasks"),
MultiHitGeneratorFactory = RecoTracker.IterativeTracking.TobTecStep_cff.tobTecStepSeedsTripl.OrderedHitsFactoryPSet.GeneratorPSet
)

tobTecStepSeedsTripl.MultiHitGeneratorFactory.SeedComparitorPSet=cms.PSet( ComponentName = cms.string( "none" ) )
tobTecStepSeedsTripl.MultiHitGeneratorFactory.refitHits = False
#pair seeds
import FastSimulation.Tracking.TrajectorySeedProducer_cfi
tobTecStepSeedsPair = FastSimulation.Tracking.TrajectorySeedProducer_cfi.trajectorySeedProducer.clone(
Expand Down
Expand Up @@ -33,6 +33,17 @@ class HitTripletGeneratorFromPairAndLayers {
const edm::Event & ev, const edm::EventSetup& es,
const SeedingLayerSetsHits::SeedingLayerSet& pairLayers,
const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers) = 0;

virtual void hitTriplets(
const TrackingRegion& region,
OrderedHitTriplets & result,
const edm::EventSetup & es,
const HitDoublets & doublets,
const RecHitsSortedInPhi ** thirdHitMap,
const std::vector<const DetLayer *> & thirdLayerDetLayer,
const int nThirdLayers)
{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you don't want this to be pure virtual (=0)? OK, it would mean that you would have to implement this in a couple of other triplet generators too, but then we would notice already at compile-time if some triplet generator would not implement it (as opposed to wondering unexpected results).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, better pure virtual

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.
Then we'll put dummy implementations with an edm::LogWarning in
PixelTripletLowPtGenerator and PixelTripletNoTipGenerator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not throwing an exception?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it again, I agree that an exception is the best option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why exception, runtime error, instead of compile time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anshul and I agree to make the new function
HitTripletGeneratorFromPairAndLayers::hitTriplets purely virtual
=> there will be an error on compile time if there is no
implementation in one of the leaf classes

For the leaf classes that are currently not used by FastSim we'll
implement the hitTriplets function to throw an error.
In this way someone who configures FastSim to use one of those leaf
classes will become aware that there is no implementation ready.

On Mon, Apr 18, 2016 at 10:56 AM, Slava Krutelyov
notifications@github.com wrote:

In
RecoPixelVertexing/PixelTriplets/interface/HitTripletGeneratorFromPairAndLayers.h:

@@ -33,6 +33,17 @@ class HitTripletGeneratorFromPairAndLayers {
const edm::Event & ev, const edm::EventSetup&
es,
const SeedingLayerSetsHits::SeedingLayerSet&
pairLayers,
const
std::vectorSeedingLayerSetsHits::SeedingLayer& thirdLayers) = 0;
+

  • virtual void hitTriplets(
  • const TrackingRegion& region,
  • OrderedHitTriplets & result,
  • const edm::EventSetup & es,
  • const HitDoublets & doublets,
  • const RecHitsSortedInPhi ** thirdHitMap,
  • const std::vector<const DetLayer *> & thirdLayerDetLayer,
  • const int nThirdLayers)
  • {};

why exception, runtime error, instead of compile time?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood all comments. Implementing suggestions !


protected:
std::unique_ptr<HitPairGeneratorFromLayerPair> thePairGenerator;
LayerCacheType *theLayerCache;
Expand Down
Expand Up @@ -60,51 +60,62 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region,
const SeedingLayerSetsHits::SeedingLayerSet& pairLayers,
const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers)
{
if (theComparitor) theComparitor->init(ev, es);

auto const & doublets = thePairGenerator->doublets(region,ev,es, pairLayers);

if (doublets.empty()) return;

int size = thirdLayers.size();
const RecHitsSortedInPhi * thirdHitMap[size];
vector<const DetLayer *> thirdLayerDetLayer(size,0);
for (int il=0; il<size; ++il)
{
thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region, ev, es);
thirdLayerDetLayer[il] = thirdLayers[il].detLayer();
}
hitTriplets(region,result,es,doublets,thirdHitMap,thirdLayerDetLayer,size);
}

if (theComparitor) theComparitor->init(ev, es);

auto const & doublets = thePairGenerator->doublets(region,ev,es, pairLayers);

if (doublets.empty()) return;

auto outSeq = doublets.detLayer(HitDoublets::outer)->seqNum();

void PixelTripletHLTGenerator::hitTriplets(
const TrackingRegion& region,
OrderedHitTriplets & result,
const edm::EventSetup & es,
const HitDoublets & doublets,
const RecHitsSortedInPhi ** thirdHitMap,
const std::vector<const DetLayer *> & thirdLayerDetLayer,
const int nThirdLayers)
{
auto outSeq = doublets.detLayer(HitDoublets::outer)->seqNum();

// std::cout << "pairs " << doublets.size() << std::endl;

float regOffset = region.origin().perp(); //try to take account of non-centrality (?)
int size = thirdLayers.size();

declareDynArray(ThirdHitRZPrediction<PixelRecoLineRZ>, size, preds);
declareDynArray(ThirdHitCorrection, size, corrections);
float regOffset = region.origin().perp(); //try to take account of non-centrality (?)

declareDynArray(ThirdHitRZPrediction<PixelRecoLineRZ>, nThirdLayers, preds);
declareDynArray(ThirdHitCorrection, nThirdLayers, corrections);

const RecHitsSortedInPhi * thirdHitMap[size];
typedef RecHitsSortedInPhi::Hit Hit;
typedef RecHitsSortedInPhi::Hit Hit;

using NodeInfo = KDTreeNodeInfo<unsigned int>;
std::vector<NodeInfo > layerTree; // re-used throughout
std::vector<unsigned int> foundNodes; // re-used thoughout
foundNodes.reserve(100);

declareDynArray(KDTreeLinkerAlgo<unsigned int>,size, hitTree);
float rzError[size]; //save maximum errors

declareDynArray(KDTreeLinkerAlgo<unsigned int>,nThirdLayers, hitTree);
float rzError[nThirdLayers]; //save maximum errors

const float maxDelphi = region.ptMin() < 0.3f ? float(M_PI)/4.f : float(M_PI)/8.f; // FIXME move to config??
const float maxphi = M_PI+maxDelphi, minphi = -maxphi; // increase to cater for any range
const float safePhi = M_PI-maxDelphi; // sideband


// fill the prediction vector
for (int il=0; il<size; ++il) {
thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region, ev, es);
for (int il=0; il<nThirdLayers; ++il) {
auto const & hits = *thirdHitMap[il];
ThirdHitRZPrediction<PixelRecoLineRZ> & pred = preds[il];
pred.initLayer(thirdLayers[il].detLayer());
pred.initLayer(thirdLayerDetLayer[il]);
pred.initTolerance(extraHitRZtolerance);

corrections[il].init(es, region.ptMin(), *doublets.detLayer(HitDoublets::inner), *doublets.detLayer(HitDoublets::outer),
*thirdLayers[il].detLayer(), useMScat, useBend);
*thirdLayerDetLayer[il], useMScat, useBend);

layerTree.clear();
float minv=999999.0f, maxv= -minv; // Initialise to extreme values in case no hits
Expand All @@ -125,7 +136,7 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region,
//add fudge factors in case only one hit and also for floating-point inaccuracy
hitTree[il].build(layerTree, phiZ); // make KDtree
rzError[il] = maxErr; //save error
// std::cout << "layer " << thirdLayers[il].detLayer()->seqNum() << " " << layerTree.size() << std::endl;
// std::cout << "layer " << thirdLayerDetLayer[il]->seqNum() << " " << layerTree.size() << std::endl;
}

float imppar = region.originRBound();
Expand Down Expand Up @@ -158,8 +169,8 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region,
// std::cout << ip << ": " << point1.r() << ","<< point1.z() << " "
// << point2.r() << ","<< point2.z() <<std::endl;

for (int il=0; il!=size; ++il) {
const DetLayer * layer = thirdLayers[il].detLayer();
for (int il=0; il!=nThirdLayers; ++il) {
const DetLayer * layer = thirdLayerDetLayer[il];
auto barrelLayer = layer->isBarrel();

if ( (!barrelLayer) & (toPos != std::signbit(layer->position().z())) ) continue;
Expand Down Expand Up @@ -258,7 +269,7 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region,
hitTree[il].search(phiZ, foundNodes);
}

// std::cout << ip << ": " << thirdLayers[il].detLayer()->seqNum() << " " << foundNodes.size() << " " << prmin << " " << prmax << std::endl;
// std::cout << ip << ": " << thirdLayerDetLayer[il]->seqNum() << " " << foundNodes.size() << " " << prmin << " " << prmax << std::endl;


// int kk=0;
Expand Down