Skip to content

Commit

Permalink
modernize CalibTracker/SiStripHitResolution package
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Feb 15, 2023
1 parent e2626d0 commit a618cf3
Show file tree
Hide file tree
Showing 17 changed files with 3,068 additions and 2,181 deletions.
66 changes: 34 additions & 32 deletions CalibTracker/SiStripHitResolution/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
<use name="RecoLocalTracker/SiStripClusterizer"/>
<use name="CommonTools/UtilAlgos"/>
<use name="DataFormats/DetId"/>
<use name="DataFormats/SiStripDetId"/>
<use name="DataFormats/TrackingRecHit"/>
<use name="DataFormats/CSCRecHit"/>
<use name="DataFormats/DTRecHit"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/Common"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="Geometry/CommonDetUnit"/>
<use name="Geometry/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<use name="RecoTracker/Record"/>
<use name="RecoTracker/MeasurementDet"/>
<use name="RecoTracker/TkSeedGenerator"/>
<use name="SimDataFormats/TrackingAnalysis"/>
<use name="SimTracker/TrackerHitAssociation"/>
<use name="TrackingTools/PatternTools"/>
<use name="TrackingTools/TrackFitters"/>
<use name="TrackingTools/MeasurementDet"/>
<use name="RecoTracker/TransientTrackingRecHit"/>
<use name="CommonTools/Statistics"/>
<use name="DataFormats/TrackerRecHit2D"/>
<use name="TrackingTools/AnalyticalJacobians"/>
<use name="TrackingTools/KalmanUpdators"/>
<flags EDM_PLUGIN="1"/>
<use name="CommonTools/Statistics"/>
<use name="CommonTools/UtilAlgos"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/DetId"/>
<use name="DataFormats/SiStripDetId"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/TrackerRecHit2D"/>
<use name="DataFormats/TrackingRecHit"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="Geometry/CommonDetUnit"/>
<use name="Geometry/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<use name="RecoLocalTracker/SiStripClusterizer"/>
<use name="RecoTracker/MeasurementDet"/>
<use name="RecoTracker/Record"/>
<use name="RecoTracker/TkSeedGenerator"/>
<use name="RecoTracker/TransientTrackingRecHit"/>
<use name="SimDataFormats/TrackingAnalysis"/>
<use name="SimTracker/TrackerHitAssociation"/>
<use name="TrackingTools/AnalyticalJacobians"/>
<use name="TrackingTools/KalmanUpdators"/>
<use name="TrackingTools/MeasurementDet"/>
<use name="TrackingTools/PatternTools"/>
<use name="TrackingTools/TrackFitters"/>
<use name="TrackingTools/TrajectoryState"/>
<use name="root"/>
<export>
<lib name="1"/>
</export>
240 changes: 139 additions & 101 deletions CalibTracker/SiStripHitResolution/interface/HitResol.h
Original file line number Diff line number Diff line change
@@ -1,144 +1,182 @@
#include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
#include "CalibTracker/Records/interface/SiStripQualityRcd.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/DetId/interface/DetIdCollection.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementError.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementVector.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/Scalers/interface/LumiScalers.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
#include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
#include "RecoTracker/Record/interface/CkfComponentsRecord.h"
#include "RecoTracker/SingleTrackPattern/interface/CosmicTrajectoryBuilder.h"
#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
#include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
#include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h"
#include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h"
#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "RecoTracker/SingleTrackPattern/interface/CosmicTrajectoryBuilder.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementError.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementVector.h"
#include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
#include "DataFormats/DetId/interface/DetIdCollection.h"

#include "DataFormats/Scalers/interface/LumiScalers.h"
#include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"

#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"

#include "TRandom2.h"
#include "TTree.h"
#include "TROOT.h"
#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"

#include <vector>
#include "TTree.h"
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include "Riostream.h"
#include "TRandom2.h"

class TrackerTopology;

class HitResol : public edm::EDAnalyzer {
public:
class HitResol : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit HitResol(const edm::ParameterSet& conf);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
double checkConsistency(const StripClusterParameterEstimator::LocalValues& parameters, double xx, double xerr);
bool isDoubleSided(unsigned int iidd, const TrackerTopology* tTopo) const;
bool check2DPartner(unsigned int iidd, const std::vector<TrajectoryMeasurement>& traj);
~HitResol() override;
~HitResol() override = default;
unsigned int checkLayer(unsigned int iidd, const TrackerTopology* tTopo);
// float getSimHitRes(const GeomDetUnit * det, const LocalVector& trackdirection, const TrackingRecHit& recHit, float & trackWidth, float* pitch, LocalVector& drift);
void getSimHitRes(const GeomDetUnit * det, const LocalVector& trackdirection, const TrackingRecHit& recHit, float & trackWidth, float* pitch, LocalVector& drift);
void getSimHitRes(const GeomDetUnit* det,
const LocalVector& trackdirection,
const TrackingRecHit& recHit,
float& trackWidth,
float* pitch,
LocalVector& drift);
double getSimpleRes(const TrajectoryMeasurement* traj1);
bool getPairParameters(const MagneticField* magField_, AnalyticalPropagator& propagator,const TrajectoryMeasurement* traj1, const TrajectoryMeasurement* traj2, float & pairPath, float & hitDX, float & trackDX, float & trackDXE, float & trackParamX, float &trackParamY , float & trackParamDXDZ, float &trackParamDYDZ , float & trackParamXE, float &trackParamYE, float & trackParamDXDZE, float &trackParamDYDZE);
bool getPairParameters(const MagneticField* magField_,
AnalyticalPropagator& propagator,
const TrajectoryMeasurement* traj1,
const TrajectoryMeasurement* traj2,
float& pairPath,
float& hitDX,
float& trackDX,
float& trackDXE,
float& trackParamX,
float& trackParamY,
float& trackParamDXDZ,
float& trackParamDYDZ,
float& trackParamXE,
float& trackParamYE,
float& trackParamDXDZE,
float& trackParamDYDZE);
typedef std::vector<Trajectory> TrajectoryCollection;

private:
private:
void beginJob() override;
void endJob() override;
void endJob() override;
void analyze(const edm::Event& e, const edm::EventSetup& c) override;

// ----------member data ---------------------------
// ----------member data ---------------------------

// ED tokens
const edm::EDGetTokenT<LumiScalersCollection> scalerToken_;
const edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > commonModeToken_;

bool addLumi_;
bool addCommonMode_;
bool cutOnTracks_;
unsigned int trackMultiplicityCut_;
bool useFirstMeas_;
bool useLastMeas_;
bool useAllHitsFromTracksWithMissingHits_;
double MomentumCut_;
unsigned int UsePairsOnly_;

const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_;
const edm::EDGetTokenT< std::vector<Trajectory> > trajectories_token_;
const edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAsso_token_;
const edm::EDGetTokenT< std::vector<Trajectory> > tjToken_;
const edm::EDGetTokenT<reco::TrackCollection> combinatorialTracks_token_;
const edm::EDGetTokenT<std::vector<Trajectory> > tjToken_;
const edm::EDGetTokenT<reco::TrackCollection> tkToken_;
const edm::EDGetTokenT< edmNew::DetSetVector<SiStripCluster> > clusters_token_;
const edm::EDGetTokenT<DetIdCollection> digis_token_;
const edm::EDGetTokenT<MeasurementTrackerEvent> trackerEvent_token_;

edm::ParameterSet conf_;

// ES tokens
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
const edm::ESGetToken<StripClusterParameterEstimator, TkStripCPERecord> cpeToken_;
const edm::ESGetToken<SiStripQuality, SiStripQualityRcd> siStripQualityToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;

// configuration parameters
const bool addLumi_;
const bool DEBUG_;
const bool cutOnTracks_;
const double momentumCut_;
const int compSettings_;
const unsigned int usePairsOnly_;
const unsigned int layers_;
const unsigned int trackMultiplicityCut_;

// output file
TTree* reso;
TTree* treso;
std::map<TString, TH2F*> histos2d_;

int events,EventTrackCKF;

int compSettings;
unsigned int layers;
bool DEBUG;
unsigned int whatlayer;

double MomentumCut;


// Tree declarations
//Hit Resolution Ntuple Content
float mymom ;
int numHits ;
float ProbTrackChi2 ;
unsigned int iidd1 ;
float mypitch1 ;
unsigned int clusterWidth ;
float expWidth ;
float atEdge ;
float simpleRes ;
unsigned int iidd2 ;
unsigned int clusterWidth_2 ;
float expWidth_2 ;
float atEdge_2 ;

float pairPath ;
float hitDX ;
float trackDX ;
float trackDXE ;
float trackParamX ;
float trackParamY ;
float trackParamDXDZ ;
float trackParamDYDZ ;
float trackParamXE ;
float trackParamYE ;
float trackParamDXDZE ;
float trackParamDYDZE ;
unsigned int pairsOnly ;
float track_momentum ;
float track_eta ;
float track_trackChi2 ;
// conversion
static constexpr float cmToUm = 10000.f;

};
// counters
int events, EventTrackCKF;

// Tree declarations
// Hit Resolution Ntuple Content
float mymom;
int numHits;
int NumberOf_tracks;
float ProbTrackChi2;
float StripCPE1_smp_pos_error;
float StripCPE2_smp_pos_error;
float StripErrorSquared1;
float StripErrorSquared2;
float uerr2;
float uerr2_2;
unsigned int clusterWidth;
unsigned int clusterWidth_2;
unsigned int clusterCharge;
unsigned int clusterCharge_2;
unsigned int iidd1;
unsigned int iidd2;
unsigned int pairsOnly;
float pairPath;
float mypitch1;
float mypitch2;
float expWidth;
float expWidth_2;
float driftAlpha;
float driftAlpha_2;
float thickness;
float thickness_2;
float trackWidth;
float trackWidth_2;
float atEdge;
float atEdge_2;
float simpleRes;
float hitDX;
float trackDX;
float trackDXE;
float trackParamX;
float trackParamY;
float trackParamXE;
float trackParamYE;
float trackParamDXDZ;
float trackParamDYDZ;
float trackParamDXDZE;
float trackParamDYDZE;
float track_momentum;
float track_pt;
float track_eta;
float track_width;
float track_phi;
float track_trackChi2;
float N1;
float N2;
float N1uProj;
float N2uProj;
int Nstrips;
int Nstrips_2;
};

//#endif
Loading

0 comments on commit a618cf3

Please sign in to comment.