CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Alignment/OfflineValidation/plugins/ResidualRefitting.h

Go to the documentation of this file.
00001 #ifndef _ResidualRefitting_h__
00002 #define __ResidualRefitting_h_ (1)
00003 
00004 
00005 #include <vector>
00006 #include <string>
00007 
00008 #include "TFile.h"
00009 #include "TBranch.h"
00010 #include "TTree.h"
00011 
00012 #include "DataFormats/Common/interface/Handle.h"
00013 #include "DataFormats/MuonReco/interface/Muon.h"
00014 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00015 #include "DataFormats/TrackReco/interface/Track.h"
00016 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00017 
00018 #include "FWCore/Framework/interface/EDAnalyzer.h"
00019 #include "FWCore/Utilities/interface/InputTag.h"
00020 
00021 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00022 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00023 
00024 #include "MagneticField/Engine/interface/MagneticField.h"
00025 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00026 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00027 //#include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00028 //#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
00029 
00030 //#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00031 
00032 //#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
00033 
00034 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00035 //#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00036 //#include "TrackingTools/TrackRefitter/interface/TrackTransformer.h"
00037 
00038 class ResidualRefitting : public edm::EDAnalyzer{
00039 
00040         static const int N_MAX_STORED = 10;
00041         static const int N_MAX_STORED_HIT = 1000;
00042 
00043         static const int PXB = 1;
00044         static const int PXF = 2;
00045         static const int TIB = 3;
00046         static const int TID = 4;
00047         static const int TOB = 5;
00048         static const int TEC = 6;
00049         
00050 
00051  public:
00052 
00053 //      typedef std::pair<const Trajectory*, const reco::Track*> ConstTrajTrackPair;
00054 //      typedef std::vector< ConstTrajTrackPair >  ConstTrajTrackPairCollection;
00055 
00056         typedef struct {
00057                 int evtNum_;
00058                 int runNum_;
00059         } storage_event;
00060 
00061         ResidualRefitting::storage_event eventInfo_;
00062 
00063  
00064         typedef struct {
00065 
00066                 int n_;
00067     
00068                 int     charge_                 [N_MAX_STORED];
00069                 float   pt_                     [N_MAX_STORED];
00070                 float   eta_                    [N_MAX_STORED];
00071                 float   p_                      [N_MAX_STORED];
00072                 float   phi_                    [N_MAX_STORED];
00073                 int     numRecHits_     [N_MAX_STORED];
00074                 float   chiSq_                  [N_MAX_STORED];
00075                 float   ndf_                    [N_MAX_STORED];
00076                 float   chiSqOvrNdf_    [N_MAX_STORED];
00077         
00078         } storage_muon; // Storage for standard muon information
00079 
00080         typedef struct {
00081         
00082                 int n_;
00083                 int muonLink_[N_MAX_STORED_HIT];
00084                 
00085                 int system_             [N_MAX_STORED_HIT];
00086                 int endcap_             [N_MAX_STORED_HIT];
00087                 int station_    [N_MAX_STORED_HIT];
00088                 int ring_               [N_MAX_STORED_HIT];
00089                 int chamber_    [N_MAX_STORED_HIT];
00090                 int layer_              [N_MAX_STORED_HIT];
00091                 int superLayer_ [N_MAX_STORED_HIT];
00092                 int wheel_              [N_MAX_STORED_HIT];
00093                 int sector_             [N_MAX_STORED_HIT];
00094                 
00095                 float   gpX_            [N_MAX_STORED_HIT];
00096                 float   gpY_            [N_MAX_STORED_HIT];
00097                 float   gpZ_            [N_MAX_STORED_HIT];
00098                 float   gpEta_          [N_MAX_STORED_HIT];
00099                 float   gpPhi_          [N_MAX_STORED_HIT];
00100                 float   lpX_            [N_MAX_STORED_HIT];
00101                 float   lpY_            [N_MAX_STORED_HIT];
00102                 float   lpZ_            [N_MAX_STORED_HIT];
00103                 
00104 
00105         } storage_hit;
00106 
00107         typedef struct {
00108         
00109                 int n_;
00110                 
00111                 int muonLink_           [N_MAX_STORED_HIT];
00112                 int recLink_            [N_MAX_STORED_HIT];
00113                 float gpX_                      [N_MAX_STORED_HIT];
00114                 float gpY_                      [N_MAX_STORED_HIT];
00115                 float gpZ_                      [N_MAX_STORED_HIT];
00116                 float gpEta_            [N_MAX_STORED_HIT];
00117                 float gpPhi_            [N_MAX_STORED_HIT];
00118                 float lpX_                      [N_MAX_STORED_HIT];
00119                 float lpY_                      [N_MAX_STORED_HIT];
00120                 float lpZ_                      [N_MAX_STORED_HIT];
00121                 float resX_                     [N_MAX_STORED_HIT];
00122                 float resY_                     [N_MAX_STORED_HIT];
00123                 float resZ_                     [N_MAX_STORED_HIT];
00124         } storage_trackExtrap;
00125                 
00126         typedef struct {
00127         
00128                 int n_;
00129                 
00130                 int muonLink_   [N_MAX_STORED_HIT];
00131                 int detector_   [N_MAX_STORED_HIT];
00132                 int subdetector_[N_MAX_STORED_HIT];
00133                 int blade_              [N_MAX_STORED_HIT];
00134                 int disk_               [N_MAX_STORED_HIT];
00135                 int ladder_             [N_MAX_STORED_HIT];
00136                 int layer_              [N_MAX_STORED_HIT];
00137                 int module_             [N_MAX_STORED_HIT];
00138                 int panel_              [N_MAX_STORED_HIT];
00139                 int ring_               [N_MAX_STORED_HIT];
00140                 int side_               [N_MAX_STORED_HIT];
00141                 int wheel_              [N_MAX_STORED_HIT];
00142                                 
00143                 float gpX_              [N_MAX_STORED_HIT];
00144                 float gpY_              [N_MAX_STORED_HIT];
00145                 float gpZ_              [N_MAX_STORED_HIT];
00146                 float gpEta_    [N_MAX_STORED_HIT];
00147                 float gpPhi_    [N_MAX_STORED_HIT];
00148                 float lpX_              [N_MAX_STORED_HIT];
00149                 float lpY_              [N_MAX_STORED_HIT];
00150                 float lpZ_              [N_MAX_STORED_HIT];
00151                                 
00152         } storage_trackHit;
00153                 
00154 //Standard Muon info storage
00155         ResidualRefitting::storage_muon
00156          storageGmrOld_  ,      
00157          storageGmrNew_  , storageSamNew_       , storageTrkNew_,
00158          storageGmrNoSt1_, storageSamNoSt1_     ,
00159          storageGmrNoSt2_, storageSamNoSt2_     ,
00160          storageGmrNoSt3_, storageSamNoSt3_     ,
00161          storageGmrNoSt4_, storageSamNoSt4_     ,
00162          
00163          storageGmrNoPXBLayer1, storageGmrNoPXBLayer2, storageGmrNoPXBLayer3, 
00164          storageTrkNoPXBLayer1, storageTrkNoPXBLayer2, storageTrkNoPXBLayer3,           
00165 
00166          storageGmrNoPXF, storageTrkNoPXF,
00167 
00168          storageGmrNoTIBLayer1, storageGmrNoTIBLayer2, storageGmrNoTIBLayer3, storageGmrNoTIBLayer4, 
00169          storageTrkNoTIBLayer1, storageTrkNoTIBLayer2, storageTrkNoTIBLayer3, storageTrkNoTIBLayer4, 
00170          storageGmrNoTID, storageTrkNoTID,
00171          storageGmrNoTOBLayer1, storageGmrNoTOBLayer2, storageGmrNoTOBLayer3, storageGmrNoTOBLayer4, storageGmrNoTOBLayer5, storageGmrNoTOBLayer6,
00172          storageTrkNoTOBLayer1, storageTrkNoTOBLayer2, storageTrkNoTOBLayer3, storageTrkNoTOBLayer4, storageTrkNoTOBLayer5, storageTrkNoTOBLayer6,
00173          storageGmrNoTEC, storageTrkNoTEC;      
00174          
00175          
00176          
00177 //Rec hit storage        
00178         ResidualRefitting::storage_hit                  storageRecMuon_;
00179         ResidualRefitting::storage_trackHit     storageTrackHit_;
00180 
00181 //Track Extrapolation to Muon System
00182         ResidualRefitting::storage_trackExtrap          storageTrackExtrapRec_, storageTrackExtrapRecNoSt1_,
00183                                                                                         storageTrackExtrapRecNoSt2_, storageTrackExtrapRecNoSt3_, storageTrackExtrapRecNoSt4_;
00184 
00185 //Track Extrapolation with Cylinder
00186     ResidualRefitting::storage_trackExtrap              trackExtrap120_, samExtrap120_;
00187    
00188 //Track Extrapolation to Tracker system
00189         ResidualRefitting::storage_trackExtrap          storageTrackExtrapTracker_,
00190                         storageTrackNoPXBLayer1, storageTrackNoPXBLayer2, storageTrackNoPXBLayer3,
00191                         storageTrackNoPXF,
00192                         storageTrackNoTIBLayer1, storageTrackNoTIBLayer2, storageTrackNoTIBLayer3,storageTrackNoTIBLayer4,
00193                         storageTrackNoTID,
00194                         storageTrackNoTOBLayer1, storageTrackNoTOBLayer2, storageTrackNoTOBLayer3,
00195                         storageTrackNoTOBLayer4, storageTrackNoTOBLayer5, storageTrackNoTOBLayer6,
00196                         storageTrackNoTEC;
00197   
00198 //
00199 // Start of the method declarations
00200 //
00201  
00202         explicit ResidualRefitting( const edm::ParameterSet & );
00203         ~ResidualRefitting();
00204         
00205         virtual void analyze(const edm::Event&, const edm::EventSetup&);
00206         virtual void beginJob() ;
00207         virtual void endJob() ;
00208 //Zero Storage
00209         void zero_storage();
00210         void zero_muon(ResidualRefitting::storage_muon* str);
00211         void zero_trackExtrap(ResidualRefitting::storage_trackExtrap* str);
00212         void branchMuon(ResidualRefitting::storage_muon& storageTmp, std::string branchName);
00213         void branchTrackExtrap(ResidualRefitting::storage_trackExtrap& storageTmp, std::string branchName);
00214         
00215         
00216 
00217 //      void collectTrackRecExtrap(reco::MuonCollection::const_iterator muon, ResidualRefitting::storage_trackExtrap& storeTemp);
00218         void muonInfo(ResidualRefitting::storage_muon& storeMuon, reco::TrackRef muon, int val);
00219         
00220         void CollectTrackHits(edm::Handle<reco::TrackCollection> trackColl, ResidualRefitting::storage_trackExtrap& trackExtrap);
00221         void StoreTrackerRecHits(DetId detid, int iTrack, int iRec);
00222         void NewTrackMeasurements(edm::Handle<reco::TrackCollection> trackCollOrig, edm::Handle<reco::TrackCollection> trackColl,
00223           ResidualRefitting::storage_trackExtrap& trackExtrap);
00224         int MatchTrackWithRecHits(reco::TrackCollection::const_iterator trackIt, edm::Handle<reco::TrackCollection> ref);
00225         
00226         bool IsSameHit(trackingRecHit_iterator hit1, trackingRecHit_iterator hit2);
00227 
00228 
00229         void trkExtrap(DetId detid, int iTrkLink, int iTrk, int iRec,
00230                                         FreeTrajectoryState freeTrajState,
00231                                         LocalPoint recPoint,
00232                                         storage_trackExtrap& storeTemp);
00233 
00234         void cylExtrapTrkSam(int recNum, reco::TrackRef track, ResidualRefitting::storage_trackExtrap& storage, double rho);
00235 
00236 //Simplifiying functions
00237         FreeTrajectoryState freeTrajStateMuon(reco::TrackRef muon);//Returns a Free Trajectory State
00238 //Debug Data Dumps
00239 //      void dumpRecoMuonColl(reco::MuonCollection::const_iterator muon); //
00240 //      void dumpRecoTrack(reco::TrackCollection::const_iterator muon);
00241         void dumpTrackRef(reco::TrackRef muon, std::string str); 
00242         void dumpTrackExtrap(ResidualRefitting::storage_trackExtrap track);
00243         void dumpTrackHits(ResidualRefitting::storage_trackHit hit);
00244         void dumpMuonRecHits(ResidualRefitting::storage_hit hit);
00245 
00246         int ReturnSector(DetId detid);
00247         int ReturnStation(DetId detid);
00248 
00249         
00250 // Deprecated Functions
00251         void omitStation(edm::Handle<reco::MuonCollection> funcMuons, edm::Handle<reco::TrackCollection>,
00252                 ResidualRefitting::storage_muon& storeGmr, ResidualRefitting::storage_muon& storeSam,
00253                 ResidualRefitting::storage_trackExtrap& storeExtrap, int omitStation);
00254         void omitTrackerSystem(edm::Handle<reco::MuonCollection> trkMuons, ResidualRefitting::storage_muon& storeGmr,
00255                 ResidualRefitting::storage_muon& storeTrk,
00256                 ResidualRefitting::storage_trackExtrap& storeExtrap, int omitSystem);
00257       
00258         // output histogram file name
00259         std::string outputFileName_;
00260         //edm::InputTag PropagatorSource_;              
00261         std::string PropagatorSource_;          
00262 
00263         // names of product labels
00264         edm::InputTag tracks_,
00265          muons_, muonsRemake_,
00266          muonsNoStation1_, muonsNoStation2_, muonsNoStation3_,muonsNoStation4_,//Global Muon Collections
00267          muonsNoPXBLayer1_, muonsNoPXBLayer2_, muonsNoPXBLayer3_,
00268          muonsNoPXF_,
00269          muonsNoTIBLayer1_, muonsNoTIBLayer2_, muonsNoTIBLayer3_, muonsNoTIBLayer4_,
00270          muonsNoTID_,
00271          muonsNoTOBLayer1_, muonsNoTOBLayer2_, muonsNoTOBLayer3_, muonsNoTOBLayer4_, muonsNoTOBLayer5_, muonsNoTOBLayer6_,
00272          muonsNoTEC_;
00273 //         tjTag; 
00274 
00275 
00276         bool debug_;
00277 
00278         // output ROOT file
00279         TFile * outputFile_ ;
00280 
00281         TTree   *outputTree_;
00282         TBranch *outputBranch_;
00283 
00284 //      unsigned int nBins_;
00285   
00286         const MagneticField* theField;
00287         const edm::ESHandle<GlobalTrackingGeometry> trackingGeometry;
00288         MuonServiceProxy* theService;
00289         edm::ESHandle<Propagator> thePropagator;
00290   
00291 };
00292 
00293 #endif