Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-27 04:04:12

0001 #ifndef CalibTracker_SiPixelerrorEstimation_SiPixelErrorEstimation_h
0002 #define CalibTracker_SiPixelerrorEstimation_SiPixelErrorEstimation_h
0003 
0004 #include <memory>
0005 
0006 // user include files
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 #include "DataFormats/Common/interface/Handle.h"
0018 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0019 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0020 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0021 
0022 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
0023 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
0024 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
0025 #include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h"
0026 #include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h"
0027 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
0028 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0029 
0030 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
0031 
0032 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0033 
0034 //--- for SimHit association
0035 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0036 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
0037 
0038 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0039 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0040 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
0041 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0042 #include "Geometry/CommonDetUnit/interface/GluedGeomDet.h"
0043 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0044 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0045 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
0046 #include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
0047 
0048 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
0049 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0050 
0051 #include <string>
0052 
0053 #include <TROOT.h>
0054 #include <TTree.h>
0055 #include <TFile.h>
0056 #include <TH1F.h>
0057 #include <TProfile.h>
0058 
0059 class TTree;
0060 class TFile;
0061 
0062 class SiPixelErrorEstimation : public edm::one::EDAnalyzer<> {
0063 public:
0064   explicit SiPixelErrorEstimation(const edm::ParameterSet&);
0065   ~SiPixelErrorEstimation() override;
0066 
0067   void beginJob() override;
0068   void analyze(const edm::Event&, const edm::EventSetup&) override;
0069   void endJob() override;
0070 
0071   void computeAnglesFromDetPosition(const SiPixelCluster& cl, const GeomDetUnit& det, float& alpha, float& beta);
0072 
0073 private:
0074   edm::ParameterSet conf_;
0075   edm::EDGetTokenT<std::vector<Trajectory>> tTrajectory;
0076   edm::EDGetTokenT<SiPixelRecHitCollection> tPixRecHitCollection;
0077   edm::EDGetTokenT<edm::SimTrackContainer> tSimTrackContainer;
0078   edm::EDGetTokenT<reco::TrackCollection> tTrackCollection;
0079   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopoToken_;
0080   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeomToken_;
0081   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldToken_;
0082   std::string outputFile_;
0083   std::string src_;
0084   bool checkType_;         // do we check that the simHit associated with recHit is of the expected particle type ?
0085   int genType_;            // the type of particle that the simHit associated with recHits should be
0086   bool include_trk_hits_;  // if set to false, take only hits directly from detector modules (don't ntuplize hits from tracks)
0087 
0088   // variables that go in the output ttree_track_hits_
0089   float rechitx;      // x position of hit
0090   float rechity;      // y position of hit
0091   float rechitz;      // z position of hit
0092   float rechiterrx;   // x position error of hit (error not squared)
0093   float rechiterry;   // y position error of hit (error not squared)
0094   float rechitresx;   // difference between reconstructed hit x position and 'true' x position
0095   float rechitresy;   // difference between reconstructed hit y position and 'true' y position
0096   float rechitpullx;  // x residual divideded by error
0097   float rechitpully;  // y residual divideded by error
0098 
0099   float strip_rechitx;     // x position of hit
0100   float strip_rechity;     // y position of hit
0101   float strip_rechitz;     // z position of hit
0102   float strip_rechiterrx;  // x position error of hit (error not squared)
0103   float strip_rechiterry;  // y position error of hit (error not squared)
0104   float strip_rechitresx;  // difference between reconstructed hit x position and 'true' x position
0105 
0106   float strip_rechitresx2;
0107 
0108   float strip_rechitresy;   // difference between reconstructed hit y position and 'true' y position
0109   float strip_rechitpullx;  // x residual divideded by error
0110   float strip_rechitpully;  // y residual divideded by error
0111   int strip_is_stereo;
0112   int strip_hit_type;  // matched=0, 1D=1 or 2D=2
0113   int detector_type;   //IB1=1, IB2=2, OB1=3, OB2=4
0114 
0115   float strip_trk_pt;
0116   float strip_cotalpha;
0117   float strip_cotbeta;
0118   float strip_locbx;
0119   float strip_locby;
0120   float strip_locbz;
0121   float strip_charge;
0122   int strip_size;
0123   int strip_edge;
0124   int strip_nsimhit;  // number of simhits associated with a rechit
0125   int strip_pidhit;   // PID of the particle that produced the simHit associated with the recHit
0126   int strip_simproc;  // procces type
0127 
0128   int strip_subdet_id;  // enum SubDetector { UNKNOWN=0, TIB=3, TID=4, TOB=5, TEC=6 };
0129 
0130   int strip_tib_layer;
0131   int strip_tib_module;
0132   int strip_tib_order;
0133   int strip_tib_side;
0134   int strip_tib_is_double_side;
0135   int strip_tib_is_z_plus_side;
0136   int strip_tib_is_z_minus_side;
0137   int strip_tib_layer_number;
0138   int strip_tib_string_number;
0139   int strip_tib_module_number;
0140   int strip_tib_is_internal_string;
0141   int strip_tib_is_external_string;
0142   int strip_tib_is_rphi;
0143   int strip_tib_is_stereo;
0144 
0145   int strip_tob_layer;
0146   int strip_tob_module;
0147   //int strip_tob_order             ;
0148   int strip_tob_side;
0149   int strip_tob_is_double_side;
0150   int strip_tob_is_z_plus_side;
0151   int strip_tob_is_z_minus_side;
0152   int strip_tob_layer_number;
0153   int strip_tob_rod_number;
0154   int strip_tob_module_number;
0155 
0156   int strip_tob_is_rphi;
0157   int strip_tob_is_stereo;
0158 
0159   float strip_prob;
0160   int strip_qbin;
0161 
0162   int strip_nprm;
0163 
0164   int strip_pidhit1;
0165   int strip_simproc1;
0166 
0167   int strip_pidhit2;
0168   int strip_simproc2;
0169 
0170   int strip_pidhit3;
0171   int strip_simproc3;
0172 
0173   int strip_pidhit4;
0174   int strip_simproc4;
0175 
0176   int strip_pidhit5;
0177   int strip_simproc5;
0178 
0179   int strip_split;
0180   float strip_clst_err_x;
0181   float strip_clst_err_y;
0182 
0183   int npix;      // number of pixel in the cluster
0184   int nxpix;     // size of cluster (number of pixels) along x direction
0185   int nypix;     // size of cluster (number of pixels) along y direction
0186   float charge;  // total charge in cluster
0187 
0188   int edgex;  // edgex = 1 if the cluster is at the x edge of the module
0189   int edgey;  // edgey = 1 if the cluster is at the y edge of the module
0190 
0191   int bigx;  // bigx = 1 if the cluster contains at least one big pixel in x
0192   int bigy;  // bigy = 1 if the cluster contains at least one big pixel in y
0193 
0194   float alpha;  // track angle in the xz plane of the module local coordinate system
0195   float beta;   // track angle in the yz plane of the module local coordinate system
0196 
0197   float trk_alpha;  // reconstructed track angle in the xz plane of the module local coordinate system
0198   float trk_beta;   // reconstructed track angle in the yz plane of the module local coordinate system
0199 
0200   float phi;  // polar track angle
0201   float eta;  // pseudo-rapidity (function of theta, the azimuthal angle)
0202 
0203   int subdetId;
0204   int layer;
0205   int ladder;
0206   int mod;
0207   int side;
0208   int disk;
0209   int blade;
0210   int panel;
0211   int plaq;
0212 
0213   int half;     // half = 1 if the barrel module is half size and 0 if it is full size (only defined for barrel)
0214   int flipped;  // flipped = 1 if the module is flipped and 0 if non-flipped (only defined for barrel)
0215 
0216   int nsimhit;  // number of simhits associated with a rechit
0217   int pidhit;   // PID of the particle that produced the simHit associated with the recHit
0218   int simproc;  // procces tye
0219 
0220   float simhitx;  // true x position of hit
0221   float simhity;  // true y position of hit
0222 
0223   int evt;
0224   int run;
0225 
0226   float hit_probx;
0227   float hit_proby;
0228   float hit_cprob0;
0229   float hit_cprob1;
0230   float hit_cprob2;
0231 
0232   int pixel_split;
0233 
0234   float pixel_clst_err_x;
0235   float pixel_clst_err_y;
0236 
0237   // variables that go in the output ttree_sll_hits_
0238 
0239   int all_subdetid;
0240 
0241   int all_layer;
0242   int all_ladder;
0243   int all_mod;
0244 
0245   int all_side;
0246   int all_disk;
0247   int all_blade;
0248   int all_panel;
0249   int all_plaq;
0250 
0251   int all_half;
0252   int all_flipped;
0253 
0254   int all_cols;
0255   int all_rows;
0256 
0257   float all_rechitx;
0258   float all_rechity;
0259   float all_rechitz;
0260 
0261   float all_simhitx;
0262   float all_simhity;
0263 
0264   float all_rechiterrx;
0265   float all_rechiterry;
0266 
0267   float all_rechitresx;
0268   float all_rechitresy;
0269 
0270   float all_rechitpullx;
0271   float all_rechitpully;
0272 
0273   int all_npix;
0274   int all_nxpix;
0275   int all_nypix;
0276 
0277   int all_edgex;
0278   int all_edgey;
0279 
0280   int all_bigx;
0281   int all_bigy;
0282 
0283   float all_alpha;
0284   float all_beta;
0285 
0286   float all_simphi;
0287   float all_simtheta;
0288 
0289   int all_nsimhit;
0290   int all_pidhit;
0291   int all_simproc;
0292 
0293   float all_vtxr;
0294   float all_vtxz;
0295 
0296   float all_simpx;
0297   float all_simpy;
0298   float all_simpz;
0299 
0300   float all_eloss;
0301 
0302   int all_trkid;
0303 
0304   float all_x1;
0305   float all_x2;
0306   float all_y1;
0307   float all_y2;
0308   float all_z1;
0309   float all_z2;
0310 
0311   float all_row1;
0312   float all_row2;
0313   float all_col1;
0314   float all_col2;
0315 
0316   float all_gx1;
0317   float all_gx2;
0318   float all_gy1;
0319   float all_gy2;
0320   float all_gz1;
0321   float all_gz2;
0322 
0323   float all_simtrketa;
0324   float all_simtrkphi;
0325 
0326   float all_clust_row;
0327   float all_clust_col;
0328 
0329   float all_clust_x;
0330   float all_clust_y;
0331 
0332   float all_clust_q;
0333 
0334   int all_clust_maxpixcol;
0335   int all_clust_maxpixrow;
0336   int all_clust_minpixcol;
0337   int all_clust_minpixrow;
0338 
0339   int all_clust_geoid;
0340 
0341   float all_clust_alpha;
0342   float all_clust_beta;
0343 
0344   static const int maxpix = 10000;
0345   float all_pixrow[maxpix];
0346   float all_pixcol[maxpix];
0347   float all_pixadc[maxpix];
0348   // Just added
0349   float all_pixx[maxpix];
0350   float all_pixy[maxpix];
0351   float all_pixgx[maxpix];
0352   float all_pixgy[maxpix];
0353   float all_pixgz[maxpix];
0354 
0355   float all_hit_probx;
0356   float all_hit_proby;
0357   float all_hit_cprob0;
0358   float all_hit_cprob1;
0359   float all_hit_cprob2;
0360 
0361   int all_pixel_split;
0362   float all_pixel_clst_err_x;
0363   float all_pixel_clst_err_y;
0364 
0365   // ----------------------------------
0366 
0367   TFile* tfile_;
0368   TTree* ttree_all_hits_;
0369   TTree* ttree_track_hits_;
0370 
0371   TTree* ttree_track_hits_strip_;
0372 
0373   TrackerHitAssociator::Config trackerHitAssociatorConfig_;
0374 };
0375 
0376 #endif