Skip to content

Conversation

@angirar
Copy link
Owner

@angirar angirar commented Mar 23, 2018

Phase1 tracking in FastSim

Copy link

@makortel makortel left a comment

Choose a reason for hiding this comment

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

Sorry it took me a bit more than a few days to find good time slot to go though this. I hope you don't mind me going a few steps a head and pointing other points as well than only your immediate question.



"""
trackingPhase1.toModify(TrackerMaterialBlock, TrackerMaterial = dict(

Choose a reason for hiding this comment

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

Even if this is "commented out", the proper era to use is phase1Pixel. The tracking eras should be used to customize only track reconstruction.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I tried to use modifier phase1Pixel. However, I am not getting the desired phase1 geometry while adding the new layers in this fashion to the TrackerMaterial block. Can you point out what could be wrong here?

Copy link

Choose a reason for hiding this comment

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

Technically with Run2_2017[_FastSim] era phase1Pixel should work as well as trackingPhase1.

Taking a closer look now, the BarrelLayer = cms.VPSet( below replaces the BarrelLayer, while you want to add an element at the end. Maybe something along the following would work?

phase1Pixel.toModify(TrackerMaterialBlock,
    TrackerMaterial = dict(
        BarrelLayer = TrackerMaterialBlock.TrackerMaterial.BarrelLayer + [
            cms.PSet(
                limits = ...
                ...
            )
        ]
    )
)

from FastSimulation.Tracking.InitialStep_cff import *
from FastSimulation.Tracking.DetachedQuadStep_cff import *
from FastSimulation.Tracking.HighPtTripletStep_cff import *
from FastSimulation.Tracking.LowPtQuadStep_cff import *

Choose a reason for hiding this comment

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

Given that the FastSimulation.Tracking.* have just dummy imports from RecoTracker.IterativeTracking, you could import from RecoTracker.IterativeTracking directly here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

+JetCoreRegionalStep
+generalTracksBeforeMixing)

iterTracking_Phase1 = cms.Sequence(

Choose a reason for hiding this comment

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

Add leading underscore (i.e. _iterTracking_phase1).

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done. Added a leading underscore to iterTracking_phase1.

const MeasurementTracker * measurementTracker_;
const std::string measurementTrackerLabel_;

SeedingLayerSetsBuilder* seedingLayers_;

Choose a reason for hiding this comment

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

Use unique_ptr.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

const DetLayer * fLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[i]->det()->geographicalId());
const DetLayer * sLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[i+1]->det()->geographicalId());
std::vector<BaseTrackerRecHit const *> fHits(1,static_cast<const BaseTrackerRecHit*>(hits[i]));
std::vector<BaseTrackerRecHit const *> sHits(1,static_cast<const BaseTrackerRecHit*>(hits[i+1]));

Choose a reason for hiding this comment

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

As FastTrackerRecHit inherits from BaseTrackerRecHit, in principle the "up-casting" is unnecessary (or does the compiler complain?).

A more modern way for 'fHits` construction would be

std::vector<BaseTrackerRecHit const *> fHits{hits[i]};

Copy link
Owner Author

Choose a reason for hiding this comment

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

I actually did it exactly similar to how it was being done so far for the doublets check. https://github.com/cms-sw/cmssw/blob/master/FastSimulation/Tracking/src/SeedFinderSelector.cc#L83 and the compiler doesn't complain. But you are right, the modern way works too, so I have replaced them all.

seedCollections = ["pixelPairStepSeedsA", "pixelPairStepSeedsB"],
)
trackingPhase1.toReplaceWith(pixelPairStepSeeds, _pixelPairStepSeedsMerged)
#trackingPhase1.toReplaceWith(pixelPairStepSeeds, _pixelPairStepSeedsMerged)

Choose a reason for hiding this comment

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

(trackingPhase1 & ~fastSim).toReplaceWith(pixelPairStepSeeds, _pixelPairStepSeedsMerged)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done. Thanks. I didn't know if we could use the modifiers this way too!
Right now I am not sure if we have to implement the merged seedcollections in FastSim as well, don't know how much purpose its going to serve.

Copy link

Choose a reason for hiding this comment

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

Yeah, the not (~, and or |) are rather recent additions, to support exactly things like this.

Copy link

Choose a reason for hiding this comment

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

You won't need the merger unless FastSim starts to simulate the pixel inefficiencies and this doublet mitigation strategy.


for(auto& layer: theLayers) {
if(isFastSim)
return ret;

Choose a reason for hiding this comment

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

Rather than adding a new configuration parameter, I'd create a new member function, e.g. makeSeedingLayerSetsHits() to do the construction above that you can call from FastSim code (and from this function to avoid copy-paste).

Copy link
Owner Author

Choose a reason for hiding this comment

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

I can revisit this later.

edm::Event * event_;
};

namespace IHD {

Choose a reason for hiding this comment

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

You should not need any of this stuff as there is only a single construction of impl_. The complexity is needed in HitPairEDProducer because that EDProducer has to support multitude of cases.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Right... thanks. I have removed all of this now.


SeedingLayerSetsHits & layers = *seedingLayer;

for(int i=0; i<(int)hits.size()-1; i++){

Choose a reason for hiding this comment

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

Shouldn't this loop be limited to i < 3?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Correct... But the expression also gives 3 since hits.size() = 4 inside the quad section. But I guess it doesn't have to look so complicated when it is so obvious. So I have changed "(int)hits.size()-1" to 3.

Copy link

Choose a reason for hiding this comment

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

Ok, didn't think of that. In that case keeping the code but adding a comment explaining the situation would have been ok as well.

const RecHitsSortedInPhi secondhm(sHits, trackingRegion_->origin(), sLayer);
HitDoublets res(firsthm,secondhm);
HitPairGeneratorFromLayerPair::doublets(*trackingRegion_,*fLayer,*sLayer,firsthm,secondhm,*eventSetup_,0,res);
impl_->produce(layers, pairCandidate, *trackingRegion_, std::move(res), *event_);

Choose a reason for hiding this comment

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

What you should do here instead is something along

// outside of the for-loop over hits
IntermediateHitDoublets ihd(seedingLayer);
auto filler = ihd.beginRegion(*trackingRegion_);

  // here
  filler.addDoublets(pairCandidate, std::move(res));

// after the loop
std::vector<OrderedHitSeeds> quadrupletResult;
CAHitQuadGenerator_->hitNtuplets(ihd, quadrupletResult, *eventSetup_, *seedingLayer);

Then I'm not sure if the hits would have to be added to the SeedingLayerSetsHits as well. I had imagined "yes", but I don't see now a reason why they would have to, as you pass the hits explicitly to HitPairGeneratorFromLayerPair, and CA operates purely on the doublets.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I did the IHD implementation this way and it seems to work with doublets being added properly to filler. The hitNtuplets() also works, control actually goes inside the function. However, quadrupletResult is always 'false'. I don't know what's going wrong but I think I know where the problem starts. So, inside this loop
https://github.com/cms-sw/cmssw/blob/master/RecoPixelVertexing/PixelTriplets/plugins/CellularAutomaton.cc#L24
with rootVertex=0, it fails to enter this next loop
https://github.com/cms-sw/cmssw/blob/master/RecoPixelVertexing/PixelTriplets/plugins/CellularAutomaton.cc#L29
and then whatever happens, finally numberOfFoundQuadruplets=0 always at line
https://github.com/cms-sw/cmssw/blob/master/RecoPixelVertexing/PixelTriplets/plugins/CAHitQuadrupletGenerator.cc#L229

Copy link
Owner Author

Choose a reason for hiding this comment

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

Also, FastSim RecHits have to be added to SeedingLayerSetsHits as well since it is used by the CA class to create the graph structure here,
https://github.com/cms-sw/cmssw/blob/master/RecoPixelVertexing/PixelTriplets/plugins/CAHitQuadrupletGenerator.cc#L93
I have managed to do it properly this time and it works.

Copy link

Choose a reason for hiding this comment

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

However, quadrupletResult is always 'false'. I don't know what's going wrong but I think I know where the problem starts.

Could you give me a recipe to reproduce? I couldn't come up what could go wrong just by staring the code for a while so I have to try myself. In the meantime I have commented further #3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants