Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-13 23:21:01

0001 #ifndef TESTTRACKHITS_H
0002 #define TESTTRACKHITS_H
0003 // -*- C++ -*-
0004 //
0005 // Package:    TestTrackHits
0006 // Class:      TestTrackHits
0007 //
0008 /**\class TestTrackHits TestTrackHits.cc RecoTracker/TestTrackHits/src/TestTrackHits.cc
0009 
0010  Description: <one line class summary>
0011 
0012  Implementation:
0013      <Notes on implementation>
0014 */
0015 //
0016 // Original Author:  Giuseppe Cerati
0017 //         Created:  Tue Feb 13 17:29:10 CET 2007
0018 //
0019 //
0020 
0021 #include <memory>
0022 #include <vector>
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028 #include "FWCore/Utilities/interface/InputTag.h"
0029 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0030 #include "MagneticField/Engine/interface/MagneticField.h"
0031 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
0032 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
0033 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
0034 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0035 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
0036 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0037 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0038 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0039 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
0040 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
0041 #include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
0042 #include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h"
0043 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0044 #include "Geometry/CommonDetUnit/interface/GluedGeomDet.h"
0045 #include <TFile.h>
0046 #include <TH1F.h>
0047 #include <TH2F.h>
0048 #include "DataFormats/TrackReco/interface/Track.h"
0049 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0050 #include "TrackingTools/PatternTools/interface/MeasurementExtractor.h"
0051 //#include "PhysicsTools/RecoAlgos/interface/RecoTrackSelector.h"
0052 #include <sstream>
0053 
0054 class TestTrackHits : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0055 public:
0056   explicit TestTrackHits(const edm::ParameterSet &);
0057   ~TestTrackHits() override;
0058 
0059 private:
0060   void beginRun(edm::Run const &run, const edm::EventSetup &) override;
0061   void analyze(const edm::Event &, const edm::EventSetup &) override;
0062   void endRun(edm::Run const &run, const edm::EventSetup &) override {}
0063   void endJob() override;
0064 
0065   std::pair<LocalPoint, LocalVector> projectHit(const PSimHit &, const StripGeomDetUnit *, const BoundPlane &);
0066 
0067   template <unsigned int D>
0068   double computeChi2Increment(MeasurementExtractor, TransientTrackingRecHit::ConstRecHitPointer);
0069   double computeChi2Increment(MeasurementExtractor me, TransientTrackingRecHit::ConstRecHitPointer hit) {
0070     switch (hit->dimension()) {
0071       case 1:
0072         return computeChi2Increment<1>(me, hit);
0073       case 2:
0074         return computeChi2Increment<2>(me, hit);
0075       case 3:
0076         return computeChi2Increment<3>(me, hit);
0077       case 4:
0078         return computeChi2Increment<4>(me, hit);
0079       case 5:
0080         return computeChi2Increment<5>(me, hit);
0081     }
0082     throw cms::Exception("CkfDebugger error: rechit of dimension not 1,2,3,4,5");
0083   }
0084 
0085   TrackerHitAssociator::Config trackerHitAssociatorConfig_;
0086 
0087   std::string propagatorName;
0088   std::string builderName;
0089   std::string srcName;
0090   std::string tpName;
0091   std::string updatorName;
0092   std::string out;
0093   edm::ESHandle<TrackerGeometry> theG;
0094   edm::ESHandle<MagneticField> theMF;
0095   edm::ESHandle<Propagator> thePropagator;
0096   edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder;
0097   edm::ESHandle<TrajectoryStateUpdator> theUpdator;
0098   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> theGToken;
0099   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theMFToken;
0100   edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorToken;
0101   edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theBuilderToken;
0102   edm::ESGetToken<TrajectoryStateUpdator, TrackingComponentsRecord> theUpdatorToken;
0103   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTopoToken;
0104   edm::Handle<reco::TrackToTrackingParticleAssociator> trackAssociator;
0105   edm::Handle<std::vector<Trajectory> > trajCollectionHandle;
0106   edm::Handle<edm::View<reco::Track> > trackCollectionHandle;
0107   edm::Handle<TrajTrackAssociationCollection> trajTrackAssociationCollectionHandle;
0108   edm::Handle<TrackingParticleCollection> trackingParticleCollectionHandle;
0109   //RecoTrackSelector selectRecoTracks;
0110 
0111   TFile *file;
0112   std::stringstream title;
0113   std::map<std::string, TH1F *> hPullGP_X_ts;
0114   std::map<std::string, TH1F *> hPullGP_Y_ts;
0115   std::map<std::string, TH1F *> hPullGP_Z_ts;
0116   std::map<std::string, TH1F *> hPullGM_X_ts;
0117   std::map<std::string, TH1F *> hPullGM_Y_ts;
0118   std::map<std::string, TH1F *> hPullGM_Z_ts;
0119   std::map<std::string, TH1F *> hPullGP_X_rs;
0120   std::map<std::string, TH1F *> hPullGP_Y_rs;
0121   std::map<std::string, TH1F *> hPullGP_Z_rs;
0122   std::map<std::string, TH1F *> hPullGP_X_tr;
0123   std::map<std::string, TH1F *> hPullGP_Y_tr;
0124   std::map<std::string, TH1F *> hPullGP_Z_tr;
0125   std::map<std::string, TH1F *> hChi2Increment;
0126   std::map<std::string, TH1F *> hChi2Increment_mono;
0127   std::map<std::string, TH1F *> hChi2Increment_stereo;
0128   std::map<std::string, TH2F *> hChi2IncrementVsEta;
0129   std::map<std::string, TH1F *> hChi2GoodHit;
0130   std::map<std::string, TH1F *> hChi2BadHit;
0131   std::map<std::string, TH1F *> hChi2DeltaHit;
0132   std::map<std::string, TH1F *> hChi2NSharedHit;
0133   std::map<std::string, TH1F *> hChi2SharedHit;
0134   TH1F *hTotChi2Increment, *hTotChi2GoodHit, *hTotChi2BadHit, *hTotChi2DeltaHit, *hTotChi2NSharedHit,
0135       *hTotChi2SharedHit;
0136   TH2F *hProcess_vs_Chi2, *hClsize_vs_Chi2, *hGoodHit_vs_Chi2;
0137   TH2F *hPixClsize_vs_Chi2, *hPrjClsize_vs_Chi2, *hSt1Clsize_vs_Chi2, *hSt2Clsize_vs_Chi2;
0138   TH1F *hClusterSize, *hPixClusterSize, *hPrjClusterSize, *hSt1ClusterSize, *hSt2ClusterSize;
0139   TH1F *hSimHitVecSize, *hPixSimHitVecSize, *hPrjSimHitVecSize, *hSt1SimHitVecSize, *hSt2SimHitVecSize;
0140   TH1F *goodbadmerged, *energyLossRatio, *mergedPull;
0141   TH1F *probXgood, *probXbad, *probXdelta, *probXshared, *probXnoshare;
0142   TH1F *probYgood, *probYbad, *probYdelta, *probYshared, *probYnoshare;
0143 
0144   std::map<std::string, TH1F *> hPullGP_X_ts_mono;
0145   std::map<std::string, TH1F *> hPullGP_Y_ts_mono;
0146   std::map<std::string, TH1F *> hPullGP_Z_ts_mono;
0147   std::map<std::string, TH1F *> hPullGM_X_ts_mono;
0148   std::map<std::string, TH1F *> hPullGM_Y_ts_mono;
0149   std::map<std::string, TH1F *> hPullGM_Z_ts_mono;
0150   std::map<std::string, TH1F *> hPullGP_X_rs_mono;
0151   std::map<std::string, TH1F *> hPullGP_Y_rs_mono;
0152   std::map<std::string, TH1F *> hPullGP_Z_rs_mono;
0153   std::map<std::string, TH1F *> hPullGP_X_tr_mono;
0154   std::map<std::string, TH1F *> hPullGP_Y_tr_mono;
0155   std::map<std::string, TH1F *> hPullGP_Z_tr_mono;
0156 
0157   std::map<std::string, TH1F *> hPullGP_X_ts_stereo;
0158   std::map<std::string, TH1F *> hPullGP_Y_ts_stereo;
0159   std::map<std::string, TH1F *> hPullGP_Z_ts_stereo;
0160   std::map<std::string, TH1F *> hPullGM_X_ts_stereo;
0161   std::map<std::string, TH1F *> hPullGM_Y_ts_stereo;
0162   std::map<std::string, TH1F *> hPullGM_Z_ts_stereo;
0163   std::map<std::string, TH1F *> hPullGP_X_rs_stereo;
0164   std::map<std::string, TH1F *> hPullGP_Y_rs_stereo;
0165   std::map<std::string, TH1F *> hPullGP_Z_rs_stereo;
0166   std::map<std::string, TH1F *> hPullGP_X_tr_stereo;
0167   std::map<std::string, TH1F *> hPullGP_Y_tr_stereo;
0168   std::map<std::string, TH1F *> hPullGP_Z_tr_stereo;
0169 };
0170 
0171 #endif