From 5d50d53ad4a18e6c9fd8178fb71d5cdd2abc611f Mon Sep 17 00:00:00 2001
From: Laurent Forthomme <laurent.forthomme@cern.ch>
Date: Mon, 26 Jun 2017 09:32:12 +0200
Subject: [PATCH 1/4] Specifying the input tag for the lite local tracks leaves

---
 TopAnalysis/python/miniAnalyzer_cfi.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/TopAnalysis/python/miniAnalyzer_cfi.py b/TopAnalysis/python/miniAnalyzer_cfi.py
index 01895bbf..f2c9fc21 100644
--- a/TopAnalysis/python/miniAnalyzer_cfi.py
+++ b/TopAnalysis/python/miniAnalyzer_cfi.py
@@ -43,7 +43,8 @@ analysis = cms.EDAnalyzer("MiniAnalyzer",
                           badPFMuonFilter        = cms.InputTag('BadPFMuonFilter'),
                           mets                   = cms.InputTag('slimmedMETs'),                          
                           puppimets              = cms.InputTag('slimmedMETsPuppi'),
-                          pfCands                = cms.InputTag('packedPFCandidates'),                          
+                          pfCands                = cms.InputTag('packedPFCandidates'),
+                          ctppsLocalTracks       = cms.InputTag('ctppsLocalTrackLiteProducer'),
                           eleMvaIdMap            = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"),
                           eleVetoIdMap           = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
                           eleLooseIdMap          = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
-- 
GitLab


From 062d35e89ff89bbcf7ecdf7c3826e92742d7de95 Mon Sep 17 00:00:00 2001
From: Laurent Forthomme <laurent.forthomme@cern.ch>
Date: Mon, 26 Jun 2017 10:32:15 +0200
Subject: [PATCH 2/4] Only retrieve the forward tracks if dealing with data

---
 TopAnalysis/plugins/MiniAnalyzer.cc | 34 +++++++++++++++--------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/TopAnalysis/plugins/MiniAnalyzer.cc b/TopAnalysis/plugins/MiniAnalyzer.cc
index ad654d6f..bb895ee1 100644
--- a/TopAnalysis/plugins/MiniAnalyzer.cc
+++ b/TopAnalysis/plugins/MiniAnalyzer.cc
@@ -499,22 +499,24 @@ int MiniAnalyzer::recAnalysis(const edm::Event& iEvent, const edm::EventSetup& i
   edm::Handle<pat::PackedCandidateCollection> pfcands;
   iEvent.getByToken(pfToken_,pfcands);
 
-  //CTPPS local tracks
-  ev_.nfwdtrk=0;
-  edm::Handle<std::vector<CTPPSLocalTrackLite> > ctppslocaltracks;
-  iEvent.getByToken(ctppsToken_, ctppslocaltracks);
-  for (const CTPPSLocalTrackLite& lt : *ctppslocaltracks) {
-    const CTPPSDetId detid(lt.getRPId());
-    if (detid.station()!=0) continue; // only keep the 210m horizontal stations
-
-    ev_.fwdtrk_arm[ev_.nfwdtrk] = detid.arm(); // 0 = sector 4-5 ; 1 = sector 5-6
-    ev_.fwdtrk_pot[ev_.nfwdtrk] = detid.rp(); // 2 = near pot ; 3 = far pot
-    ev_.fwdtrk_x[ev_.nfwdtrk] = lt.getX()*1.e-3; // store in m
-    ev_.fwdtrk_x_unc[ev_.nfwdtrk] = lt.getXUnc()*1.e-3;
-    ev_.fwdtrk_y[ev_.nfwdtrk] = lt.getY()*1.e-3;
-    ev_.fwdtrk_y_unc[ev_.nfwdtrk] = lt.getYUnc()*1.e-3;
-
-    ev_.nfwdtrk++;
+  if(iEvent.isRealData()) {
+    //CTPPS local tracks (only present in data)
+    ev_.nfwdtrk=0;
+    edm::Handle<std::vector<CTPPSLocalTrackLite> > ctppslocaltracks;
+    iEvent.getByToken(ctppsToken_, ctppslocaltracks);
+    for (const CTPPSLocalTrackLite& lt : *ctppslocaltracks) {
+      const CTPPSDetId detid(lt.getRPId());
+      if (detid.station()!=0) continue; // only keep the 210m horizontal stations
+
+      ev_.fwdtrk_arm[ev_.nfwdtrk] = detid.arm(); // 0 = sector 4-5 ; 1 = sector 5-6
+      ev_.fwdtrk_pot[ev_.nfwdtrk] = detid.rp(); // 2 = near pot ; 3 = far pot
+      ev_.fwdtrk_x[ev_.nfwdtrk] = lt.getX()*1.e-3; // store in m
+      ev_.fwdtrk_x_unc[ev_.nfwdtrk] = lt.getXUnc()*1.e-3;
+      ev_.fwdtrk_y[ev_.nfwdtrk] = lt.getY()*1.e-3;
+      ev_.fwdtrk_y_unc[ev_.nfwdtrk] = lt.getYUnc()*1.e-3;
+
+      ev_.nfwdtrk++;
+    }
   }
 
 
-- 
GitLab


From be9689de40c39d062009f2754441872f9ab2f482 Mon Sep 17 00:00:00 2001
From: Laurent Forthomme <laurent.forthomme@cern.ch>
Date: Mon, 26 Jun 2017 13:06:12 +0200
Subject: [PATCH 3/4] Now storing the forward tracks branches onto the mini
 event

---
 TopAnalysis/src/MiniEvent.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/TopAnalysis/src/MiniEvent.cc b/TopAnalysis/src/MiniEvent.cc
index b41eac55..8ad4dc9a 100644
--- a/TopAnalysis/src/MiniEvent.cc
+++ b/TopAnalysis/src/MiniEvent.cc
@@ -124,6 +124,15 @@ void createMiniEventTree(TTree *t,MiniEvent_t &ev)
   t->Branch("met_phi",     ev.met_phi,    "met_phi[nmet]/F");
   t->Branch("met_sig",     ev.met_sig,    "met_sig[nmet]/F");
   t->Branch("met_filterBits", &ev.met_filterBits, "met_filterBits/I");
+
+  //CTPPS local tracks
+  t->Branch("nfwdtrk",    &ev.nfwdtrk,       "nfwdtrk/I");
+  t->Branch("fwdtrk_arm",  ev.fwdtrk_arm,    "fwdtrk_arm[nfwdtrk]/F");
+  t->Branch("fwdtrk_pot",  ev.fwdtrk_pot,    "fwdtrk_pot[nfwdtrk]/F");
+  t->Branch("fwdtrk_x",    ev.fwdtrk_x,      "fwdtrk_x[nfwdtrk]/F");
+  t->Branch("fwdtrk_x_unc",ev.fwdtrk_x_unc,  "fwdtrk_x_unc[nfwdtrk]/F");
+  t->Branch("fwdtrk_y",    ev.fwdtrk_y,      "fwdtrk_y[nfwdtrk]/F");
+  t->Branch("fwdtrk_y_unc",ev.fwdtrk_y_unc,  "fwdtrk_y_unc[nfwdtrk]/F");
 }
 
 //
-- 
GitLab


From de5124bc4a89fbb73e53c2966d598829560bf566 Mon Sep 17 00:00:00 2001
From: Laurent Forthomme <laurent.forthomme@cern.ch>
Date: Mon, 26 Jun 2017 13:12:47 +0200
Subject: [PATCH 4/4] Retrieving the forward tracks branches from the mini
 event

---
 TopAnalysis/src/MiniEvent.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/TopAnalysis/src/MiniEvent.cc b/TopAnalysis/src/MiniEvent.cc
index 8ad4dc9a..e3fee4d4 100644
--- a/TopAnalysis/src/MiniEvent.cc
+++ b/TopAnalysis/src/MiniEvent.cc
@@ -264,4 +264,13 @@ void attachToMiniEventTree(TTree *t,MiniEvent_t &ev,bool full)
   t->SetBranchAddress("met_phi",   ev.met_phi);
   t->SetBranchAddress("met_sig",   ev.met_sig);
   t->SetBranchAddress("met_filterBits", &ev.met_filterBits);
+
+  //CTPPS local tracks
+  t->SetBranchAddress("nfwdtrk",    &ev.nfwdtrk);
+  t->SetBranchAddress("fwdtrk_arm",  ev.fwdtrk_arm);
+  t->SetBranchAddress("fwdtrk_pot",  ev.fwdtrk_pot);
+  t->SetBranchAddress("fwdtrk_x",    ev.fwdtrk_x);
+  t->SetBranchAddress("fwdtrk_x_unc",ev.fwdtrk_x_unc);
+  t->SetBranchAddress("fwdtrk_y",    ev.fwdtrk_y);
+  t->SetBranchAddress("fwdtrk_y_unc",ev.fwdtrk_y_unc);
 }
-- 
GitLab