Skip to content

Commit

Permalink
Merge pull request #19498 from VinInn/MSGalore93
Browse files Browse the repository at this point in the history
MultipleScattering parameterization
  • Loading branch information
cmsbuild authored Jul 4, 2017
2 parents 2af1298 + e5d5e24 commit 63024c6
Show file tree
Hide file tree
Showing 16 changed files with 848 additions and 93 deletions.
1 change: 1 addition & 0 deletions RecoTracker/MeasurementDet/plugins/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.h"


#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Utilities/interface/typelookup.h"
Expand Down
1 change: 1 addition & 0 deletions RecoTracker/MeasurementDet/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<use name="FWCore/MessageLogger"/>
<use name="RecoTracker/MeasurementDet"/>
<use name="RecoTracker/Record"/>
<use name="TrackingTools/KalmanUpdators"/>
<library file="*.cc" name="RecoTrackerMeasurementDetTest">
<flags EDM_PLUGIN="1"/>
</library>
Expand Down
187 changes: 187 additions & 0 deletions RecoTracker/MeasurementDet/test/MeasurementTrackerTest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include <FWCore/MessageLogger/interface/MessageLogger.h>

#include <RecoTracker/MeasurementDet/interface/MeasurementTracker.h>
#include <RecoTracker/Record/interface/CkfComponentsRecord.h>
#include "TrackingTools/DetLayers/interface/NavigationSchool.h"
#include "RecoTracker/Record/interface/NavigationSchoolRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
#include "MagneticField/VolumeGeometry/interface/MagVolumeOutsideValidity.h"
#include "DataFormats/GeometrySurface/interface/PlaneBuilder.h"


#include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
#include "TrackPropagation/RungeKutta/interface/defaultRKPropagator.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"

#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
#include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"

#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"

namespace {

Surface::RotationType rotation( const GlobalVector& zDir)
{
GlobalVector zAxis = zDir.unit();
GlobalVector yAxis( zAxis.y(), -zAxis.x(), 0);
GlobalVector xAxis = yAxis.cross( zAxis);
return Surface::RotationType( xAxis, yAxis, zAxis);
}


}

class MeasurementTrackerTest : public edm::EDAnalyzer {
public:
explicit MeasurementTrackerTest(const edm::ParameterSet&);
~MeasurementTrackerTest();


private:
virtual void analyze(const edm::Event&, const edm::EventSetup&) override;

std::string theMeasurementTrackerName;
std::string theNavigationSchoolName;
};


MeasurementTrackerTest::MeasurementTrackerTest(const edm::ParameterSet& iConfig):
theMeasurementTrackerName(iConfig.getParameter<std::string>("measurementTracker"))
,theNavigationSchoolName(iConfig.getParameter<std::string>("navigationSchool")){}

MeasurementTrackerTest::~MeasurementTrackerTest() {}

void MeasurementTrackerTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;

//get the measurementtracker
edm::ESHandle<MeasurementTracker> measurementTracker;
edm::ESHandle<NavigationSchool> navSchool;

iSetup.get<CkfComponentsRecord>().get(theMeasurementTrackerName, measurementTracker);
iSetup.get<NavigationSchoolRecord>().get(theNavigationSchoolName, navSchool);

auto const & geom = *(TrackerGeometry const *)(*measurementTracker).geomTracker();
auto const & searchGeom = *(*measurementTracker).geometricSearchTracker();
auto const & dus = geom.detUnits();

auto firstBarrel = geom.offsetDU(GeomDetEnumerators::tkDetEnum[1]);
auto firstForward = geom.offsetDU(GeomDetEnumerators::tkDetEnum[2]);

std::cout << "number of dets " << dus.size() << std::endl;
std::cout << "Bl/Fw loc " << firstBarrel<< '/' << firstForward << std::endl;

edm::ESHandle<MagneticField> magfield;
iSetup.get<IdealMagneticFieldRecord>().get(magfield);

edm::ESHandle<Propagator> propagatorHandle;
iSetup.get<TrackingComponentsRecord>().get("PropagatorWithMaterial", propagatorHandle);
auto const & ANprop = *propagatorHandle;

// error (very very small)
ROOT::Math::SMatrixIdentity id;
AlgebraicSymMatrix55 C(id);
C *= 1.e-16;

CurvilinearTrajectoryError err(C);

//use negative sigma=-3.0 in order to use a more conservative definition of isInside() for Bounds classes.
Chi2MeasurementEstimator estimator(30.,-3.0,0.5,2.0,0.5,1.e12); // same as defauts....

KFUpdator kfu;
LocalError he(0.01*0.01,0,0.02*0.02);

for (float tl = 0.1f; tl<3.0f; tl+=0.5f) {

float p = 1.0f;
float phi = 0.1415f;
float tanlmd = tl; // 0.1f;
auto sinth2 = 1.f/(1.f+tanlmd*tanlmd);
auto sinth = std::sqrt(sinth2);
auto costh = tanlmd*sinth;

std::cout << tanlmd << ' ' << sinth << ' ' << costh << std::endl;

GlobalVector startingMomentum(p*std::sin(phi)*sinth,p*std::cos(phi)*sinth,p*costh);
float z = 0.1f;
GlobalPoint startingPosition(0,0,z);

// make TSOS happy
//Define starting plane
PlaneBuilder pb;
auto rot = rotation(startingMomentum);
auto startingPlane = pb.plane( startingPosition, rot);

GlobalVector moms[3] = { 0.5f*startingMomentum,startingMomentum,10.f*startingMomentum};

for (auto mom : moms) {

TrajectoryStateOnSurface startingStateP( GlobalTrajectoryParameters(startingPosition,
mom, 1, magfield.product()),
err, *startingPlane);
auto tsos = startingStateP;

// auto layer = searchGeom.idToLayer(dus[firstBarrel]->geographicalId());
const DetLayer* layer = searchGeom.pixelBarrelLayers().front();
{
auto it = layer;
std::cout << "first layer " << (it->isBarrel() ? " Barrel" : " Forward") << " layer " << it->seqNum() << " SubDet " << it->subDetector()<< std::endl;
}
auto const & detWithState = layer->compatibleDets(tsos,ANprop,estimator);
if(!detWithState.size()) { std::cout << "no det on first layer" << std::endl; continue;}
auto did = detWithState.front().first->geographicalId();
std::cout << "arrived at " << int(did) << std::endl;
tsos = detWithState.front().second;
std::cout << tsos.globalPosition() << ' ' << tsos.localError().positionError() << std::endl;

SiPixelRecHit::ClusterRef pref;
SiPixelRecHit hitpx(tsos.localPosition(),he,1.,*detWithState.front().first,pref);
tsos = kfu.update(tsos, hitpx);
std::cout << tsos.globalPosition() << ' ' << tsos.localError().positionError() << std::endl;


for (auto il=1; il<4; ++il) {
if (!layer) break;
auto const & compLayers = (*navSchool).nextLayers(*layer,*tsos.freeState(),alongMomentum);
layer = nullptr;
for(auto it : compLayers){
if (it->basicComponents().empty()) {
//this should never happen. but better protect for it
std::cout <<"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate." << std::endl;
continue;
}
std::cout << il << (it->isBarrel() ? " Barrel" : " Forward") << " layer " << it->seqNum() << " SubDet " << it->subDetector()<< std::endl;
auto const & detWithState = it->compatibleDets(tsos,ANprop,estimator);
if(!detWithState.size()) { std::cout << "no det on this layer" << std::endl; continue;}
layer = it;
auto did = detWithState.front().first->geographicalId();
std::cout << "arrived at " << int(did) << std::endl;
tsos = detWithState.front().second;
std::cout << tsos.globalPosition() << ' ' << tsos.localError().positionError() << std::endl;
}
} // layer loop
} // loop on moms
} // loop on tanLa
}

//define this as a plug-in
DEFINE_FWK_MODULE(MeasurementTrackerTest);
77 changes: 0 additions & 77 deletions RecoTracker/MeasurementDet/test/MeasurementTrackerUpdator.cc

This file was deleted.

45 changes: 45 additions & 0 deletions RecoTracker/MeasurementDet/test/measTkTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#

import FWCore.ParameterSet.Config as cms

process = cms.Process("MAGNETICFIELDTEST")

process.source = cms.Source("EmptySource")
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(1)
)

# Example configuration for the magnetic field

# Uncomment ONE of the following:

### Uniform field
#process.load("Configuration.StandardSequences.MagneticField_0T_cff")
#process.localUniform.ZFieldInTesla = 3.8


### Full field map, static configuration for each field value
#process.load("Configuration.StandardSequences.MagneticField_20T_cff")
#process.load("Configuration.StandardSequences.MagneticField_30T_cff")
#process.load("Configuration.StandardSequences.MagneticField_35T_cff")
#process.load("Configuration.StandardSequences.MagneticField_38T_cff")
#process.load("Configuration.StandardSequences.MagneticField_40T_cff")

### Configuration to select map based on recorded current in the DB
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
process.GlobalTag = GlobalTag(process.GlobalTag,'auto:phase1_2017_realistic', '')
#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '')
process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
process.load('Configuration.StandardSequences.Reconstruction_cff')
process.load("MagneticField.Engine.autoMagneticFieldProducer_cfi")
process.AutoMagneticFieldESProducer.valueOverride = 18000


process.myTest = cms.EDAnalyzer("MeasurementTrackerTest",
measurementTracker = cms.string(''),
navigationSchool = cms.string('SimpleNavigationSchool')
)
process.p1 = cms.Path(process.myTest)

19 changes: 19 additions & 0 deletions RecoTracker/Record/interface/TkMSParameterizationRecord.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef RecoTracker_Record_TkMSParameterizationRecord_h
#define RecoTracker_Record_TkMSParameterizationRecord_h

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"
#include "FWCore/Framework/interface/DependentRecordImplementation.h"

#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoTracker/Record/interface/NavigationSchoolRecord.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"


#include "boost/mpl/vector.hpp"


class TkMSParameterizationRecord : public edm::eventsetup::DependentRecordImplementation<TkMSParameterizationRecord,
boost::mpl::vector<TrackingComponentsRecord,NavigationSchoolRecord> > {};

#endif

6 changes: 6 additions & 0 deletions RecoTracker/Record/src/TkMSParameterizationRecord.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "RecoTracker/Record/interface/TkMSParameterizationRecord.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
#include "FWCore/Utilities/interface/typelookup.h"
#include "RecoTracker/TkNavigation/interface/TkMSParameterization.h"
TYPELOOKUP_DATA_REG(TkMSParameterization);
EVENTSETUP_RECORD_REG(TkMSParameterizationRecord);
Loading

0 comments on commit 63024c6

Please sign in to comment.