Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:06

0001 #ifndef L1Trigger_TrackFindingTMTT_Histos_h
0002 #define L1Trigger_TrackFindingTMTT_Histos_h
0003 
0004 #include "FWCore/ServiceRegistry/interface/Service.h"
0005 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0006 #include "L1Trigger/TrackFindingTMTT/interface/Settings.h"
0007 #include "L1Trigger/TrackFindingTMTT/interface/L1track3D.h"
0008 #include "L1Trigger/TrackFindingTMTT/interface/TrackerModule.h"
0009 #include "L1Trigger/TrackFindingTMTT/interface/Array2D.h"
0010 
0011 #include <vector>
0012 #include <map>
0013 #include <list>
0014 #include <string>
0015 
0016 class TH1F;
0017 class TH2F;
0018 class TH2Poly;
0019 class TF1;
0020 class TProfile;
0021 class TGraphAsymmErrors;
0022 class TGraph;
0023 class TEfficiency;
0024 
0025 namespace tmtt {
0026 
0027   class InputData;
0028   class TP;
0029   class Sector;
0030   class HTrphi;
0031   class Make3Dtracks;
0032   class L1fittedTrack;
0033   class L1fittedTrk4and5;
0034 
0035   class Histos {
0036   public:
0037     // Store cfg parameters.
0038     Histos(const Settings* settings);
0039 
0040     virtual ~Histos() = default;
0041 
0042     // Book & fill all histograms.
0043     virtual void book();
0044     virtual void fill(const InputData& inputData,
0045                       const Array2D<std::unique_ptr<Sector>>& mSectors,
0046                       const Array2D<std::unique_ptr<HTrphi>>& mHtPhis,
0047                       const Array2D<std::unique_ptr<Make3Dtracks>>& mGet3Dtrks,
0048                       const std::map<std::string, std::list<const L1fittedTrack*>>& mapFinalTracks);
0049 
0050     // Print tracking performance summary & make tracking efficiency histograms.
0051     virtual void endJobAnalysis(const HTrphi::ErrorMonitor* htRphiErrMon = nullptr);
0052 
0053     // Determine "B" parameter, used in GP firmware to allow for tilted modules.
0054     virtual void trackerGeometryAnalysis(const std::list<TrackerModule>& listTrackerModule);
0055 
0056     // Did user request output histograms via the TFileService in their cfg?
0057     virtual bool available() const { return fs_.isAvailable(); }
0058 
0059     // Should histograms be produced?
0060     virtual bool enabled() const { return (settings_->enableHistos() && available()); }
0061 
0062   protected:
0063     // Book histograms for specific topics.
0064     virtual TFileDirectory bookInputData();
0065     virtual TFileDirectory bookEtaPhiSectors();
0066     virtual TFileDirectory bookRphiHT();
0067     virtual TFileDirectory bookRZfilters();
0068     virtual TFileDirectory bookTrackCands(const std::string& tName);
0069     virtual std::map<std::string, TFileDirectory> bookTrackFitting();
0070 
0071     // Fill histograms for specific topics.
0072     virtual void fillInputData(const InputData& inputData);
0073     virtual void fillEtaPhiSectors(const InputData& inputData, const Array2D<std::unique_ptr<Sector>>& mSectors);
0074     virtual void fillRphiHT(const Array2D<std::unique_ptr<HTrphi>>& mHtRphis);
0075     virtual void fillRZfilters(const Array2D<std::unique_ptr<Make3Dtracks>>& mMake3Dtrks);
0076     virtual void fillTrackCands(const InputData& inputData,
0077                                 const Array2D<std::unique_ptr<Make3Dtracks>>& mMake3Dtrks,
0078                                 const std::string& tName);
0079     virtual void fillTrackCands(const InputData& inputData,
0080                                 const std::vector<L1track3D>& tracks,
0081                                 const std::string& tName);
0082     virtual void fillTrackFitting(const InputData& inputData,
0083                                   const std::map<std::string, std::list<const L1fittedTrack*>>& mapFinalTracks);
0084 
0085     // Produce plots of tracking efficiency after HZ or after r-z track filter (run at end of job)
0086     virtual TFileDirectory plotTrackEfficiency(const std::string& tName);
0087     // Produce plots of tracking efficiency after track fit (run at end of job).
0088     virtual TFileDirectory plotTrackEffAfterFit(const std::string& fitName);
0089 
0090     // For Hybrid tracking
0091     // Produce plots of tracklet seed finding efficiency before track reco
0092     virtual void plotTrackletSeedEfficiency() {}
0093     // Produce plots of hybrid duplicate removal efficiency after track reco
0094     virtual void plotHybridDupRemovalEfficiency() {}
0095 
0096     virtual void makeEfficiencyPlot(
0097         TFileDirectory& inputDir, TEfficiency* outputEfficiency, TH1F* pass, TH1F* all, TString name, TString title);
0098 
0099     // Print summary of track-finding performance after track pattern reco.
0100     virtual void printTrackPerformance(const std::string& tName);
0101 
0102     // Print summary of track-finding performance after helix fit for given track fitter.
0103     virtual void printFitTrackPerformance(const std::string& fitName);
0104 
0105     // For Hybrid tracking
0106     // Print summary of seed finding and extrapolation performance during track pattern reco.
0107     virtual void printTrackletSeedFindingPerformance() {}
0108 
0109     // Print summary of duplicate removal performance after track pattern reco.
0110     virtual void printHybridDupRemovalPerformance() {}
0111 
0112   protected:
0113     edm::Service<TFileService> fs_;
0114 
0115     // Configuration parameters.
0116     const Settings* settings_;
0117     unsigned int genMinStubLayers_;
0118     unsigned int numPhiSectors_;
0119     unsigned int numEtaRegions_;
0120     float houghMinPt_;
0121     unsigned int houghNbinsPt_;
0122     unsigned int houghNbinsPhi_;
0123     float chosenRofZ_;
0124     std::vector<std::string> trackFitters_;
0125     std::vector<std::string> useRZfilter_;
0126     bool ranRZfilter_;
0127     bool resPlotOpt_;
0128 
0129     bool oldSumW2opt_;
0130 
0131     // Histograms of input data.
0132     TH1F* hisStubsVsEta_;
0133     TH1F* hisStubsVsR_;
0134 
0135     TH1F* hisNumLayersPerTP_;
0136     TH1F* hisNumPSLayersPerTP_;
0137 
0138     TProfile* hisStubKillFE_;
0139     TProfile* hisStubIneffiVsInvPt_;
0140     TProfile* hisStubIneffiVsEta_;
0141     TH1F* hisBendStub_;
0142     TH1F* hisBendResStub_;
0143 
0144     // Histograms of B parameter for tilted modules.
0145     TGraph* graphBVsZoverR_;
0146 
0147     // Histograms checking that (eta,phi) sector definition is good.
0148     TH1F* hisNumEtaSecsPerStub_;
0149     TH1F* hisNumPhiSecsPerStub_;
0150     TH1F* hisNumStubsPerSec_;
0151 
0152     // Histograms studying 3D track candidates.
0153     std::map<std::string, TProfile*> profNumTrackCands_;
0154     std::map<std::string, TProfile*> profNumTracksVsEta_;
0155     std::map<std::string, TH1F*> hisNumTracksVsQoverPt_;
0156     std::map<std::string, TH1F*> hisNumTrksPerNon_;
0157     std::map<std::string, TProfile*> profStubsOnTracks_;
0158     std::map<std::string, TH1F*> hisStubsOnTracksPerNon_;
0159     std::map<std::string, TH1F*> hisStubsPerTrack_;
0160     std::map<std::string, TH1F*> hisLayersPerTrack_;
0161 
0162     std::map<std::string, TH1F*> hisNumStubsPerLink_;
0163     std::map<std::string, TProfile*> profMeanStubsPerLink_;
0164     std::map<std::string, TH1F*> hisFracMatchStubsOnTracks_;
0165     std::map<std::string, TProfile*> profDupTracksVsEta_;
0166     std::map<std::string, TProfile*> profDupTracksVsInvPt_;
0167 
0168     // Histos of track params after HT.
0169     std::map<std::string, TH1F*> hisQoverPt_;
0170     std::map<std::string, TH1F*> hisPhi0_;
0171     std::map<std::string, TH1F*> hisEta_;
0172     std::map<std::string, TH1F*> hisZ0_;
0173 
0174     // Histograms of track parameter resolution after HT transform.
0175     std::map<std::string, TH1F*> hisQoverPtRes_;
0176     std::map<std::string, TH1F*> hisPhi0Res_;
0177     std::map<std::string, TH1F*> hisEtaRes_;
0178     std::map<std::string, TH1F*> hisZ0Res_;
0179 
0180     // Histos used for denominator of tracking efficiency plots.
0181     TH1F* hisTPinvptForEff_;
0182     TH1F* hisTPetaForEff_;
0183     TH1F* hisTPphiForEff_;
0184     TH1F* hisTPd0ForEff_;
0185     TH1F* hisTPz0ForEff_;
0186     //
0187     TH1F* hisTPinvptForAlgEff_;
0188     TH1F* hisTPetaForAlgEff_;
0189     TH1F* hisTPphiForAlgEff_;
0190     TH1F* hisTPd0ForAlgEff_;
0191     TH1F* hisTPz0ForAlgEff_;
0192 
0193     // Histograms used to make efficiency plots with 3D track candidates prior to fit.
0194     std::map<std::string, TH1F*> hisRecoTPinvptForEff_;
0195     std::map<std::string, TH1F*> hisRecoTPetaForEff_;
0196     std::map<std::string, TH1F*> hisRecoTPphiForEff_;
0197     std::map<std::string, TH1F*> hisRecoTPd0ForEff_;
0198     std::map<std::string, TH1F*> hisRecoTPz0ForEff_;
0199     //
0200     std::map<std::string, TH1F*> hisPerfRecoTPinvptForEff_;
0201     std::map<std::string, TH1F*> hisPerfRecoTPetaForEff_;
0202     //
0203     std::map<std::string, TH1F*> hisRecoTPinvptForAlgEff_;
0204     std::map<std::string, TH1F*> hisRecoTPetaForAlgEff_;
0205     std::map<std::string, TH1F*> hisRecoTPphiForAlgEff_;
0206     std::map<std::string, TH1F*> hisRecoTPd0ForAlgEff_;
0207     std::map<std::string, TH1F*> hisRecoTPz0ForAlgEff_;
0208     //
0209     std::map<std::string, TH1F*> hisPerfRecoTPinvptForAlgEff_;
0210     std::map<std::string, TH1F*> hisPerfRecoTPetaForAlgEff_;
0211 
0212     // Histograms for track fitting evaluation, where std::map index specifies name of track fitting algorithm used.
0213 
0214     std::map<std::string, TProfile*> profNumFitTracks_;
0215     std::map<std::string, TH1F*> hisNumFitTrks_;
0216     std::map<std::string, TH1F*> hisNumFitTrksPerNon_;
0217     std::map<std::string, TH1F*> hisNumFitTrksPerSect_;
0218     std::map<std::string, TH1F*> hisStubsPerFitTrack_;
0219     std::map<std::string, TProfile*> profStubsOnFitTracks_;
0220 
0221     std::map<std::string, TH1F*> hisFitQinvPtMatched_;
0222     std::map<std::string, TH1F*> hisFitPhi0Matched_;
0223     std::map<std::string, TH1F*> hisFitD0Matched_;
0224     std::map<std::string, TH1F*> hisFitZ0Matched_;
0225     std::map<std::string, TH1F*> hisFitEtaMatched_;
0226 
0227     std::map<std::string, TH1F*> hisFitQinvPtUnmatched_;
0228     std::map<std::string, TH1F*> hisFitPhi0Unmatched_;
0229     std::map<std::string, TH1F*> hisFitD0Unmatched_;
0230     std::map<std::string, TH1F*> hisFitZ0Unmatched_;
0231     std::map<std::string, TH1F*> hisFitEtaUnmatched_;
0232 
0233     std::map<std::string, TH1F*> hisKalmanNumUpdateCalls_;
0234     std::map<std::string, TH1F*> hisKalmanChi2DofSkipLay0Matched_;
0235     std::map<std::string, TH1F*> hisKalmanChi2DofSkipLay1Matched_;
0236     std::map<std::string, TH1F*> hisKalmanChi2DofSkipLay2Matched_;
0237     std::map<std::string, TH1F*> hisKalmanChi2DofSkipLay0Unmatched_;
0238     std::map<std::string, TH1F*> hisKalmanChi2DofSkipLay1Unmatched_;
0239     std::map<std::string, TH1F*> hisKalmanChi2DofSkipLay2Unmatched_;
0240 
0241     std::map<std::string, TH1F*> hisFitChi2DofRphiMatched_;
0242     std::map<std::string, TH1F*> hisFitChi2DofRzMatched_;
0243     std::map<std::string, TProfile*> profFitChi2DofRphiVsInvPtMatched_;
0244 
0245     std::map<std::string, TH1F*> hisFitChi2DofRphiUnmatched_;
0246     std::map<std::string, TH1F*> hisFitChi2DofRzUnmatched_;
0247     std::map<std::string, TProfile*> profFitChi2DofRphiVsInvPtUnmatched_;
0248 
0249     std::map<std::string, TProfile*> hisQoverPtResVsTrueEta_;
0250     std::map<std::string, TProfile*> hisPhi0ResVsTrueEta_;
0251     std::map<std::string, TProfile*> hisEtaResVsTrueEta_;
0252     std::map<std::string, TProfile*> hisZ0ResVsTrueEta_;
0253     std::map<std::string, TProfile*> hisD0ResVsTrueEta_;
0254 
0255     std::map<std::string, TProfile*> hisQoverPtResVsTrueInvPt_;
0256     std::map<std::string, TProfile*> hisPhi0ResVsTrueInvPt_;
0257     std::map<std::string, TProfile*> hisEtaResVsTrueInvPt_;
0258     std::map<std::string, TProfile*> hisZ0ResVsTrueInvPt_;
0259     std::map<std::string, TProfile*> hisD0ResVsTrueInvPt_;
0260 
0261     std::map<std::string, TProfile*> profDupFitTrksVsEta_;
0262     std::map<std::string, TProfile*> profDupFitTrksVsInvPt_;
0263 
0264     // Histograms used for efficiency plots made with fitted tracks.
0265     std::map<std::string, TH1F*> hisFitTPinvptForEff_;
0266     std::map<std::string, TH1F*> hisFitTPetaForEff_;
0267     std::map<std::string, TH1F*> hisFitTPphiForEff_;
0268     std::map<std::string, TH1F*> hisFitTPd0ForEff_;
0269     std::map<std::string, TH1F*> hisFitTPz0ForEff_;
0270     std::map<std::string, TH1F*> hisPerfFitTPinvptForEff_;
0271     std::map<std::string, TH1F*> hisPerfFitTPetaForEff_;
0272     std::map<std::string, TH1F*> hisFitTPinvptForAlgEff_;
0273     std::map<std::string, TH1F*> hisFitTPetaForAlgEff_;
0274     std::map<std::string, TH1F*> hisFitTPphiForAlgEff_;
0275     std::map<std::string, TH1F*> hisFitTPd0ForAlgEff_;
0276     std::map<std::string, TH1F*> hisFitTPz0ForAlgEff_;
0277     std::map<std::string, TH1F*> hisPerfFitTPinvptForAlgEff_;
0278     std::map<std::string, TH1F*> hisPerfFitTPetaForAlgEff_;
0279 
0280     // Histograms of tracking efficiency & fake rate after Hough transform or after r-z track filter.
0281     std::map<std::string, TEfficiency*> teffEffVsInvPt_;
0282     std::map<std::string, TEfficiency*> teffEffVsEta_;
0283     std::map<std::string, TEfficiency*> teffEffVsPhi_;
0284     std::map<std::string, TEfficiency*> teffEffVsD0_;
0285     std::map<std::string, TEfficiency*> teffEffVsZ0_;
0286     //
0287     std::map<std::string, TEfficiency*> teffPerfEffVsInvPt_;
0288     std::map<std::string, TEfficiency*> teffPerfEffVsEta_;
0289     std::map<std::string, TEfficiency*> teffAlgEffVsD0_;
0290     std::map<std::string, TEfficiency*> teffAlgEffVsZ0_;
0291     //
0292     std::map<std::string, TEfficiency*> teffAlgEffVsInvPt_;
0293     std::map<std::string, TEfficiency*> teffAlgEffVsEta_;
0294     std::map<std::string, TEfficiency*> teffAlgEffVsPhi_;
0295     //
0296     std::map<std::string, TEfficiency*> teffPerfAlgEffVsInvPt_;
0297     std::map<std::string, TEfficiency*> teffPerfAlgEffVsPt_;
0298     std::map<std::string, TEfficiency*> teffPerfAlgEffVsEta_;
0299 
0300     // Histograms of tracking efficiency & fake rate after Hough transform based on tracks after the track fit.
0301     std::map<std::string, TEfficiency*> teffEffFitVsInvPt_;
0302     std::map<std::string, TEfficiency*> teffEffFitVsEta_;
0303     std::map<std::string, TEfficiency*> teffEffFitVsPhi_;
0304     std::map<std::string, TEfficiency*> teffEffFitVsD0_;
0305     std::map<std::string, TEfficiency*> teffEffFitVsZ0_;
0306     //
0307     std::map<std::string, TEfficiency*> teffPerfEffFitVsInvPt_;
0308     std::map<std::string, TEfficiency*> teffPerfEffFitVsEta_;
0309     //
0310     std::map<std::string, TEfficiency*> teffAlgEffFitVsInvPt_;
0311     std::map<std::string, TEfficiency*> teffAlgEffFitVsEta_;
0312     std::map<std::string, TEfficiency*> teffAlgEffFitVsPhi_;
0313     std::map<std::string, TEfficiency*> teffAlgEffFitVsD0_;
0314     std::map<std::string, TEfficiency*> teffAlgEffFitVsZ0_;
0315     //
0316     std::map<std::string, TEfficiency*> teffPerfAlgEffFitVsInvPt_;
0317     std::map<std::string, TEfficiency*> teffPerfAlgEffFitVsEta_;
0318 
0319     // Number of genuine reconstructed and perfectly reconstructed tracks which were fitted.
0320     std::map<std::string, unsigned int> numFitAlgEff_;
0321     std::map<std::string, unsigned int> numFitPerfAlgEff_;
0322 
0323     // Number of genuine reconstructed and perfectly reconstructed tracks which were fitted post-cut.
0324     std::map<std::string, unsigned int> numFitAlgEffPass_;
0325     std::map<std::string, unsigned int> numFitPerfAlgEffPass_;
0326 
0327     // Range in r of each barrel layer.
0328     std::map<unsigned int, float> mapBarrelLayerMinR_;
0329     std::map<unsigned int, float> mapBarrelLayerMaxR_;
0330     // Range in z of each endcap wheel.
0331     std::map<unsigned int, float> mapEndcapWheelMinZ_;
0332     std::map<unsigned int, float> mapEndcapWheelMaxZ_;
0333 
0334     // Range in (r,z) of each module type.
0335     std::map<unsigned int, float> mapModuleTypeMinR_;
0336     std::map<unsigned int, float> mapModuleTypeMaxR_;
0337     std::map<unsigned int, float> mapModuleTypeMinZ_;
0338     std::map<unsigned int, float> mapModuleTypeMaxZ_;
0339     // Extra std::maps for wierd barrel layers 1-2 & endcap wheels 3-5.
0340     std::map<unsigned int, float> mapExtraAModuleTypeMinR_;
0341     std::map<unsigned int, float> mapExtraAModuleTypeMaxR_;
0342     std::map<unsigned int, float> mapExtraAModuleTypeMinZ_;
0343     std::map<unsigned int, float> mapExtraAModuleTypeMaxZ_;
0344     std::map<unsigned int, float> mapExtraBModuleTypeMinR_;
0345     std::map<unsigned int, float> mapExtraBModuleTypeMaxR_;
0346     std::map<unsigned int, float> mapExtraBModuleTypeMinZ_;
0347     std::map<unsigned int, float> mapExtraBModuleTypeMaxZ_;
0348     std::map<unsigned int, float> mapExtraCModuleTypeMinR_;
0349     std::map<unsigned int, float> mapExtraCModuleTypeMaxR_;
0350     std::map<unsigned int, float> mapExtraCModuleTypeMinZ_;
0351     std::map<unsigned int, float> mapExtraCModuleTypeMaxZ_;
0352     std::map<unsigned int, float> mapExtraDModuleTypeMinR_;
0353     std::map<unsigned int, float> mapExtraDModuleTypeMaxR_;
0354     std::map<unsigned int, float> mapExtraDModuleTypeMinZ_;
0355     std::map<unsigned int, float> mapExtraDModuleTypeMaxZ_;
0356 
0357     bool bApproxMistake_;
0358 
0359     bool printedGeomAnalysis_;
0360   };
0361 
0362 }  // namespace tmtt
0363 #endif