CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/Calibration/IsolatedParticles/plugins/IsolatedTracksNxN.h

Go to the documentation of this file.
00001 #ifndef CalibrationIsolatedParticlesIsolatedTracksNxN_h
00002 #define CalibrationIsolatedParticlesIsolatedTracksNxN_h
00003 
00004 // system include files
00005 #include <memory>
00006 #include <cmath>
00007 #include <string>
00008 #include <map>
00009 #include <vector>
00010 
00011 // user include files
00012 #include <Math/GenVector/VectorUtil.h>
00013 
00014 #include "FWCore/Framework/interface/Frameworkfwd.h"
00015 #include "FWCore/Framework/interface/EDAnalyzer.h"
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "FWCore/Framework/interface/ESHandle.h"
00018 #include "FWCore/Framework/interface/EventSetup.h"
00019 #include "FWCore/Framework/interface/MakerMacros.h"
00020 
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022 
00023 // TFile Service
00024 #include "FWCore/ServiceRegistry/interface/Service.h"
00025 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00026 
00027 #include "DataFormats/Common/interface/Ref.h"
00028 #include "DataFormats/Common/interface/Handle.h"
00029 #include "DataFormats/Math/interface/Point3D.h"
00030 #include "DataFormats/Candidate/interface/Candidate.h"
00031 
00032 // muons and tracks
00033 #include "DataFormats/TrackReco/interface/Track.h"
00034 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00035 #include "DataFormats/TrackReco/interface/HitPattern.h"
00036 // Vertices
00037 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00038 #include "DataFormats/VertexReco/interface/Vertex.h"
00039 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00040 // Calorimeters
00041 #include "DataFormats/DetId/interface/DetId.h"
00042 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00043 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00044 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00045 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00046 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00047 
00048 //L1 objects
00049 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00050 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
00051 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00052 #include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
00053 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
00054 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
00055 
00056 // Jets in the event
00057 #include "DataFormats/JetReco/interface/CaloJet.h"
00058 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00059 #include "DataFormats/JetReco/interface/JetExtendedAssociation.h"
00060 
00061 // SimHit
00062 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00063 //simtrack
00064 #include "SimDataFormats/Track/interface/SimTrack.h"
00065 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00066 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00067 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00068 
00069 // track associator
00070 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00071 #include "TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"
00072 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00073 // ecal / hcal
00074 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00075 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00076 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00077 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
00078 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00079 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00080 
00081 #include "RecoCaloTools/Navigation/interface/CaloNavigator.h"
00082 
00083 //L1 trigger Menus etc
00084 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00085 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
00086 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00087 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00088 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00089 
00090 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00091 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00092 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00093 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
00094 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapFwd.h"
00095 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
00096 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
00097 
00098 #include "Calibration/IsolatedParticles/interface/FindCaloHit.h"
00099 #include "Calibration/IsolatedParticles/interface/eECALMatrix.h"
00100 #include "Calibration/IsolatedParticles/interface/eHCALMatrix.h"
00101 #include "Calibration/IsolatedParticles/interface/MatchingSimTrack.h"
00102 #include "Calibration/IsolatedParticles/interface/CaloSimInfo.h"
00103 
00104 // root objects
00105 #include "TROOT.h"
00106 #include "TSystem.h"
00107 #include "TFile.h"
00108 #include "TH1F.h"
00109 #include "TH2F.h"
00110 #include "TProfile.h"
00111 #include "TDirectory.h"
00112 #include "TTree.h"
00113 
00114 class IsolatedTracksNxN : public edm::EDAnalyzer {
00115 
00116 public:
00117   explicit IsolatedTracksNxN(const edm::ParameterSet&);
00118   ~IsolatedTracksNxN();
00119   
00120 private:
00121   //void   beginJob(const edm::EventSetup&) ;
00122   void   beginJob() ;
00123   void   analyze(const edm::Event&, const edm::EventSetup&);
00124   void   endJob() ;
00125 
00126   void   printTrack(const reco::Track* pTrack);
00127 
00128   void   BookHistograms();
00129 
00130   double DeltaPhi(double v1, double v2);
00131   double DeltaR(double eta1, double phi1, double eta2, double phi2);
00132 
00133 
00134   void clearTreeVectors();  
00135   
00136 private:
00137 
00138   L1GtUtils m_l1GtUtils;
00139 
00140   bool initL1, doMC, writeAllTracks;
00141   static const size_t nL1BitsMax=128;
00142 
00143   // map of trig bit, algo name and num events passed
00144   std::map< std::pair<unsigned int,std::string>, int> l1AlgoMap;
00146   unsigned int m_numberDaqPartitions;
00148   const L1GtTriggerMask* m_l1GtTmAlgo;
00149   std::vector<unsigned int> m_triggerMaskAlgoTrig;
00150 
00151   double pvTracksPtMin_;
00152   bool   debugL1Info_, L1TriggerAlgoInfo_;
00153   int    debugTrks_;
00154   bool   printTrkHitPattern_;
00155   int    myverbose_;
00156   edm::InputTag L1extraTauJetSource_,  L1extraCenJetSource_,    L1extraFwdJetSource_;
00157   edm::InputTag L1extraMuonSource_,    L1extraIsoEmSource_,     L1extraNonIsoEmSource_;
00158   edm::InputTag L1GTReadoutRcdSource_, L1GTObjectMapRcdSource_;
00159   edm::InputTag JetExtender_, JetSrc_;
00160   edm::InputTag HBHERecHitSource_;
00161 
00162   double minTrackP_, maxTrackEta_;
00163   double tMinE_, tMaxE_, tMinH_, tMaxH_;
00164   int    nEventProc;
00165 
00166   const MagneticField *bField;
00167 
00168   double genPartPBins[16], genPartEtaBins[4];
00169 
00170   static const size_t NPBins   = 15;
00171   static const size_t NEtaBins = 3;
00172   
00173   TH1F *h_maxNearP15x15[NPBins][NEtaBins],
00174        *h_maxNearP21x21[NPBins][NEtaBins],
00175        *h_maxNearP25x25[NPBins][NEtaBins],
00176        *h_maxNearP31x31[NPBins][NEtaBins];
00177 
00178   TH1I *h_L1AlgoNames;
00179   TH1F *h_PVTracksWt;
00180 
00181   TH1F *h_nTracks;
00182 
00183   TH1F *h_recPt_0,    *h_recP_0,    *h_recEta_0, *h_recPhi_0;
00184   TH2F *h_recEtaPt_0, *h_recEtaP_0;
00185 
00186   TH1F *h_recPt_1,    *h_recP_1,    *h_recEta_1, *h_recPhi_1;
00187   TH2F *h_recEtaPt_1, *h_recEtaP_1;
00188 
00189   TH1F *h_recPt_2,    *h_recP_2,    *h_recEta_2, *h_recPhi_2;
00190   TH2F *h_recEtaPt_2, *h_recEtaP_2;
00191 
00192   
00193  
00194   TTree* tree;
00195 
00196   int    t_nTracks;
00197 
00198   int t_RunNo, t_EvtNo, t_Lumi, t_Bunch;
00199   std::vector<std::string> *t_L1AlgoNames;
00200   std::vector<int>         *t_L1PreScale;
00201   int                      t_L1Decision[128];
00202 
00203   std::vector<double> *t_PVx, *t_PVy, *t_PVz, *t_PVTracksSumPt;
00204   std::vector<double> *t_PVTracksSumPtWt, *t_PVTracksSumPtHP, *t_PVTracksSumPtHPWt;
00205   std::vector<int>    *t_PVisValid, *t_PVNTracks, *t_PVNTracksWt, *t_PVndof;
00206   std::vector<int>    *t_PVNTracksHP, *t_PVNTracksHPWt;
00207 
00208   std::vector<double> *t_L1CenJetPt,    *t_L1CenJetEta,    *t_L1CenJetPhi;
00209   std::vector<double> *t_L1FwdJetPt,    *t_L1FwdJetEta,    *t_L1FwdJetPhi;
00210   std::vector<double> *t_L1TauJetPt,    *t_L1TauJetEta,    *t_L1TauJetPhi;
00211   std::vector<double> *t_L1MuonPt,      *t_L1MuonEta,      *t_L1MuonPhi;
00212   std::vector<double> *t_L1IsoEMPt,     *t_L1IsoEMEta,     *t_L1IsoEMPhi;
00213   std::vector<double> *t_L1NonIsoEMPt,  *t_L1NonIsoEMEta,  *t_L1NonIsoEMPhi;
00214   std::vector<double> *t_L1METPt,       *t_L1METEta,       *t_L1METPhi;
00215 
00216   std::vector<double> *t_jetPt,         *t_jetEta,         *t_jetPhi;
00217   std::vector<double> *t_nTrksJetCalo,  *t_nTrksJetVtx;
00218 
00219   std::vector<double> *t_trackPAll,     *t_trackEtaAll,    *t_trackPhiAll,  *t_trackPdgIdAll;
00220   std::vector<double> *t_trackPtAll;
00221   std::vector<double> *t_trackDxyAll,   *t_trackDzAll,     *t_trackDxyPVAll,*t_trackDzPVAll, *t_trackChiSqAll;
00222 
00223   std::vector<double> *t_trackP,        *t_trackPt,        *t_trackEta,      *t_trackPhi;
00224   std::vector<double> *t_trackEcalEta,  *t_trackEcalPhi,   *t_trackHcalEta,  *t_trackHcalPhi;   
00225   std::vector<double> *t_trackDxy,      *t_trackDxyBS,     *t_trackDz,       *t_trackDzBS;  
00226   std::vector<double> *t_trackDxyPV,    *t_trackDzPV;
00227   std::vector<double> *t_trackChiSq;
00228   std::vector<int>    *t_trackPVIdx;
00229 
00230   std::vector<int>    *t_NLayersCrossed,    *t_trackNOuterHits;
00231   std::vector<int>    *t_trackHitsTOB,      *t_trackHitsTEC;
00232   std::vector<int>    *t_trackHitInMissTOB, *t_trackHitInMissTEC,  *t_trackHitInMissTIB,  *t_trackHitInMissTID,  *t_trackHitInMissTIBTID;
00233   std::vector<int>    *t_trackHitOutMissTOB,*t_trackHitOutMissTEC, *t_trackHitOutMissTIB, *t_trackHitOutMissTID, *t_trackHitOutMissTOBTEC;
00234   std::vector<int>    *t_trackHitInMeasTOB, *t_trackHitInMeasTEC,  *t_trackHitInMeasTIB,  *t_trackHitInMeasTID;
00235   std::vector<int>    *t_trackHitOutMeasTOB,*t_trackHitOutMeasTEC, *t_trackHitOutMeasTIB, *t_trackHitOutMeasTID;
00236   std::vector<double> *t_trackOutPosOutHitDr, *t_trackL;
00237 
00238   std::vector<double> *t_maxNearP31x31;
00239   std::vector<double> *t_maxNearP25x25;
00240   std::vector<double> *t_maxNearP21x21;
00241   std::vector<double> *t_maxNearP15x15;
00242 
00243   std::vector<int>    *t_ecalSpike11x11;
00244   std::vector<double> *t_e7x7,       *t_e9x9,       *t_e11x11,       *t_e15x15;
00245   std::vector<double> *t_e7x7_10Sig, *t_e9x9_10Sig, *t_e11x11_10Sig, *t_e15x15_10Sig;
00246   std::vector<double> *t_e7x7_15Sig, *t_e9x9_15Sig, *t_e11x11_15Sig, *t_e15x15_15Sig;
00247   std::vector<double> *t_e7x7_20Sig, *t_e9x9_20Sig, *t_e11x11_20Sig, *t_e15x15_20Sig;
00248   std::vector<double> *t_e7x7_25Sig, *t_e9x9_25Sig, *t_e11x11_25Sig, *t_e15x15_25Sig;
00249   std::vector<double> *t_e7x7_30Sig, *t_e9x9_30Sig, *t_e11x11_30Sig, *t_e15x15_30Sig;
00250 
00251   std::vector<double> *t_esimPdgId,         *t_simTrackP;
00252 
00253   std::vector<double> *t_trkEcalEne;
00254 
00255   std::vector<double> *t_esim7x7,       *t_esim9x9,         *t_esim11x11,        *t_esim15x15;
00256   std::vector<double> *t_esim7x7Matched, *t_esim9x9Matched, *t_esim11x11Matched, *t_esim15x15Matched;
00257   std::vector<double> *t_esim7x7Rest,    *t_esim9x9Rest,    *t_esim11x11Rest,    *t_esim15x15Rest;
00258   std::vector<double> *t_esim7x7Photon,  *t_esim9x9Photon,  *t_esim11x11Photon,  *t_esim15x15Photon;
00259   std::vector<double> *t_esim7x7NeutHad, *t_esim9x9NeutHad, *t_esim11x11NeutHad, *t_esim15x15NeutHad;
00260   std::vector<double> *t_esim7x7CharHad, *t_esim9x9CharHad, *t_esim11x11CharHad, *t_esim15x15CharHad;
00261 
00262   std::vector<double> *t_maxNearHcalP3x3,   *t_maxNearHcalP5x5,   *t_maxNearHcalP7x7;
00263   std::vector<double> *t_h3x3,              *t_h5x5,              *t_h7x7;
00264   std::vector<double> *t_h3x3Sig,           *t_h5x5Sig,           *t_h7x7Sig;
00265   std::vector<int>    *t_infoHcal;
00266 
00267   std::vector<double> *t_trkHcalEne;
00268   std::vector<double> *t_hsim3x3,           *t_hsim5x5,           *t_hsim7x7;
00269   std::vector<double> *t_hsim3x3Matched,    *t_hsim5x5Matched,    *t_hsim7x7Matched;
00270   std::vector<double> *t_hsim3x3Rest,       *t_hsim5x5Rest,       *t_hsim7x7Rest;
00271   std::vector<double> *t_hsim3x3Photon,     *t_hsim5x5Photon,     *t_hsim7x7Photon;
00272   std::vector<double> *t_hsim3x3NeutHad,    *t_hsim5x5NeutHad,    *t_hsim7x7NeutHad;
00273   std::vector<double> *t_hsim3x3CharHad,    *t_hsim5x5CharHad,    *t_hsim7x7CharHad;
00274 
00275   edm::Service<TFileService> fs;
00276   int                 nbad;
00277 };
00278 
00279 #endif