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
Triplet check in FastSim #14083
Changes from all commits
efe662a
15c3a6b
cf4a641
f6f122a
b3d576b
ac73698
82028f3
f923243
537018b
a5e8222
302d786
78eca14
15d753f
d331ada
2fd7bb2
d864570
a4333fd
0c0c6df
88a35c7
c6785cb
eb886c4
fa87e30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
||
|
@@ -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 | ||
|
@@ -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(); | ||
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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition, this looks like almost certain memory leak. Where are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's indeed a memory leak. |
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where do these get deleted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a memory leak indeed. |
||
if(pixelTripletGeneratorPtr){ | ||
OrderedHitTriplets Tripletresult; | ||
pixelTripletGeneratorPtr->hitTriplets(*selectedTrackingRegion,Tripletresult,es,*hitDoublets,&thm,thirdLayerDetLayer,1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
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 | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
{}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure you don't want this to be pure virtual ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed, better pure virtual There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not throwing an exception? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why exception, runtime error, instead of compile time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anshul and I agree to make the new function For the leaf classes that are currently not used by FastSim we'll On Mon, Apr 18, 2016 at 10:56 AM, Slava Krutelyov
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
There was a problem hiding this comment.
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.