Index: cards/CMS_PhaseII/CMS_PhaseII_Substructure_PIX4022_0PU.tcl
===================================================================
--- cards/CMS_PhaseII/CMS_PhaseII_Substructure_PIX4022_0PU.tcl	(revision 8f4a9538ea18d1d2710e2ccc49d1ab17aca13fa0)
+++ cards/CMS_PhaseII/CMS_PhaseII_Substructure_PIX4022_0PU.tcl	(revision 8cbe720773d9c1587889da379439b9d4d32aad96)
@@ -1,2 +1,4 @@
+set MaxEvents 100
+
 #
 #  Phase II - No Pile-Up
@@ -33,10 +35,14 @@
   PhotonEnergySmearing
   ElectronFilter
+
   TrackPileUpSubtractor
+  RecoPuFilter
 
   TowerMerger
   NeutralEFlowMerger
-  EFlowMergerAllTracks
+
   EFlowMerger
+  EFlowMergerCHS
+  Rho
 
   LeptonFilterNoLep
@@ -48,12 +54,22 @@
 
   PhotonIsolation
+  PhotonIsolationCHS
   PhotonEfficiency
+  PhotonEfficiencyCHS
 
   ElectronIsolation
+  ElectronIsolationCHS
+
   ElectronEfficiency
+  ElectronEfficiencyCHS
 
   MuonIsolation
+  MuonIsolationCHS
+
   MuonLooseIdEfficiency
   MuonTightIdEfficiency
+
+  MuonLooseIdEfficiencyCHS
+  MuonTightIdEfficiencyCHS
 
   NeutrinoFilter
@@ -68,4 +84,6 @@
   FastJetFinder
   FastJetFinderAK8
+  JetPileUpSubtractor
+  JetPileUpSubtractorAK8
   FastJetFinderPUPPI
   FastJetFinderPUPPIAK8
@@ -121,11 +139,11 @@
 
   # maximum spread in the beam direction in m
-  set ZVertexSpread 0
+  set ZVertexSpread 0.25
 
   # maximum spread in time in s
-  set TVertexSpread 0
+  set TVertexSpread 800E-12
 
   # vertex smearing formula f(z,t) (z,t need to be respectively given in m,s) - {exp(-(t^2/160e-12^2/2))*exp(-(z^2/0.053^2/2))}
-  set VertexDistributionFormula 1
+  set VertexDistributionFormula {exp(-(t^2/160e-12^2/2))*exp(-(z^2/0.053^2/2))}
 
 }
@@ -273,7 +291,4 @@
   source muonMomentumResolution.tcl
 }
-
-
-
 
 ##############
@@ -527,4 +542,12 @@
 }
 
+########################
+# Reco PU filter
+########################
+
+module RecoPuFilter RecoPuFilter {
+  set InputArray HCal/eflowTracks
+  set OutputArray eflowTracks
+}
 
 ###################################################
@@ -539,5 +562,4 @@
 }
 
-
 ####################
 # Neutral eflow erger
@@ -551,8 +573,7 @@
 }
 
-
-####################
+#####################
 # Energy flow merger
-####################
+#####################
 
 module Merger EFlowMerger {
@@ -564,11 +585,11 @@
 }
 
-##################################
-# Energy flow merger (all tracks)
-##################################
-
-module Merger EFlowMergerAllTracks {
+############################
+# Energy flow merger no PU
+############################
+
+module Merger EFlowMergerCHS {
 # add InputArray InputArray
-  add InputArray TrackMerger/tracks
+  add InputArray RecoPuFilter/eflowTracks
   add InputArray PhotonEnergySmearing/eflowPhotons
   add InputArray HCal/eflowNeutralHadrons
@@ -695,5 +716,4 @@
 }
 
-
 #####################
 # MC truth jet finder
@@ -735,13 +755,45 @@
 }
 
-############
+
+#############
+# Rho pile-up
+#############
+
+module FastJetFinder Rho {
+#  set InputArray Calorimeter/towers
+  set InputArray EFlowMergerCHS/eflow
+
+  set ComputeRho true
+  set RhoOutputArray rho
+
+  # area algorithm: 0 Do not compute area, 1 Active area explicit ghosts, 2 One ghost passive area, 3 Passive area, 4 Voronoi, 5 Active area
+  set AreaAlgorithm 5
+
+  # jet algorithm: 1 CDFJetClu, 2 MidPoint, 3 SIScone, 4 kt, 5 Cambridge/Aachen, 6 antikt
+  set JetAlgorithm 4
+  set ParameterR 0.4
+  set GhostEtaMax 5.0
+
+  add RhoEtaRange -5.0 -4.0
+  add RhoEtaRange -4.0 -1.5
+  add RhoEtaRange -1.5 1.5
+  add RhoEtaRange 1.5 4.0
+  add RhoEtaRange 4.0 5.0
+
+  set JetPTMin 0.0
+}
+
+
+##############
 # Jet finder
-############
+##############
 
 module FastJetFinder FastJetFinder {
 #  set InputArray TowerMerger/towers
-  set InputArray EFlowMerger/eflow
+  set InputArray EFlowMergerCHS/eflow
 
   set OutputArray jets
+
+  set AreaAlgorithm 5
 
   # algorithm: 1 CDFJetClu, 2 MidPoint, 3 SIScone, 4 kt, 5 Cambridge/Aachen, 6 antikt
@@ -755,7 +807,9 @@
 module FastJetFinder FastJetFinderAK8 {
 #  set InputArray TowerMerger/towers
-  set InputArray EFlowMerger/eflow
+  set InputArray EFlowMergerCHS/eflow
 
   set OutputArray jets
+
+  set AreaAlgorithm 5
 
   # algorithm: 1 CDFJetClu, 2 MidPoint, 3 SIScone, 4 kt, 5 Cambridge/Aachen, 6 antikt
@@ -784,4 +838,30 @@
 }
 
+###########################
+# Jet Pile-Up Subtraction
+###########################
+
+module JetPileUpSubtractor JetPileUpSubtractor {
+  set JetInputArray FastJetFinder/jets
+  set RhoInputArray Rho/rho
+
+  set OutputArray jets
+
+  set JetPTMin 15.0
+}
+
+##############################
+# Jet Pile-Up Subtraction AK8
+##############################
+
+module JetPileUpSubtractor JetPileUpSubtractorAK8 {
+  set JetInputArray FastJetFinderAK8/jets
+  set RhoInputArray Rho/rho
+
+  set OutputArray jets
+
+  set JetPTMin 15.0
+}
+
 module FastJetFinder FastJetFinderPUPPI {
 #  set InputArray TowerMerger/towers
@@ -833,5 +913,5 @@
 
 module EnergyScale JetEnergyScale {
-  set InputArray FastJetFinder/jets
+  set InputArray JetPileUpSubtractor/jets
   set OutputArray jets
 
@@ -841,5 +921,5 @@
 
 module EnergyScale JetEnergyScaleAK8 {
-  set InputArray FastJetFinderAK8/jets
+  set InputArray JetPileUpSubtractorAK8/jets
   set OutputArray jets
 
@@ -907,4 +987,30 @@
 }
 
+
+########################
+# Photon isolation CHS #
+########################
+
+module Isolation PhotonIsolationCHS {
+
+  # particle for which calculate the isolation
+  set CandidateInputArray PhotonFilter/photons
+
+  # isolation collection
+  set IsolationInputArray EFlowMerger/eflow
+
+  # output array
+  set OutputArray photons
+
+  # isolation cone
+  set DeltaRMax 0.3
+
+  # minimum pT
+  set PTMin     1.0
+
+  # iso ratio to cut
+  set PTRatioMax 9999.
+
+}
 
 
@@ -929,4 +1035,23 @@
 
 
+#####################
+# Photon efficiency #
+#####################
+
+module Efficiency PhotonEfficiencyCHS {
+
+  ## input particles
+  set InputArray PhotonIsolationCHS/photons
+  ## output particles
+  set OutputArray photons
+  # set EfficiencyFormula {efficiency formula as a function of eta and pt}
+  # efficiency formula for photons
+  set EfficiencyFormula {                      (pt <= 10.0) * (0.00) + \
+	                   (abs(eta) <= 1.5) * (pt > 10.0)  * (0.9635) + \
+	 (abs(eta) > 1.5 && abs(eta) <= 4.0) * (pt > 10.0)  * (0.9624) + \
+	 (abs(eta) > 4.0)                                   * (0.00)}
+
+}
+
 ######################
 # Electron isolation #
@@ -949,4 +1074,23 @@
 }
 
+
+##########################
+# Electron isolation CHS #
+##########################
+
+module Isolation ElectronIsolationCHS {
+
+  set CandidateInputArray ElectronFilter/electrons
+
+  # isolation collection
+  set IsolationInputArray EFlowMerger/eflow
+
+  set OutputArray electrons
+
+  set DeltaRMax 0.3
+  set PTMin 1.0
+  set PTRatioMax 9999.
+
+}
 
 
@@ -995,4 +1139,49 @@
 }
 
+###########################
+# Electron efficiency CHS #
+###########################
+
+module Efficiency ElectronEfficiencyCHS {
+
+  set InputArray ElectronIsolationCHS/electrons
+  set OutputArray electrons
+
+  # set EfficiencyFormula {efficiency formula as a function of eta and pt}
+  # efficiency formula for electrons
+  set EfficiencyFormula {
+                                      (pt <= 4.0)  * (0.00) + \
+                         (abs(eta) <= 1.45 ) * (pt >  4.0 && pt <= 6.0)   * (0.50) + \
+                         (abs(eta) <= 1.45 ) * (pt >  6.0 && pt <= 8.0)   * (0.70) + \
+                         (abs(eta) <= 1.45 ) * (pt >  8.0 && pt <= 10.0)  * (0.85) + \
+                         (abs(eta) <= 1.45 ) * (pt > 10.0 && pt <= 30.0)  * (0.94) + \
+                         (abs(eta) <= 1.45 ) * (pt > 30.0 && pt <= 50.0)  * (0.97) + \
+                         (abs(eta) <= 1.45 ) * (pt > 50.0 && pt <= 70.0)  * (0.98) + \
+                         (abs(eta) <= 1.45 ) * (pt > 70.0 )  * (1.0) + \
+                         (abs(eta) > 1.45  && abs(eta) <= 1.55) * (pt >  4.0 && pt <= 10.0)   * (0.35) + \
+                         (abs(eta) > 1.45  && abs(eta) <= 1.55) * (pt > 10.0 && pt <= 30.0)   * (0.40) + \
+                         (abs(eta) > 1.45  && abs(eta) <= 1.55) * (pt > 30.0 && pt <= 70.0)   * (0.45) + \
+                         (abs(eta) > 1.45  && abs(eta) <= 1.55) * (pt > 70.0 )  * (0.55) + \
+                         (abs(eta) >= 1.55 && abs(eta) <= 2.0 ) * (pt >  4.0 && pt <= 10.0)  * (0.75) + \
+                         (abs(eta) >= 1.55 && abs(eta) <= 2.0 ) * (pt > 10.0 && pt <= 30.0)  * (0.85) + \
+                         (abs(eta) >= 1.55 && abs(eta) <= 2.0 ) * (pt > 30.0 && pt <= 50.0)  * (0.95) + \
+                         (abs(eta) >= 1.55 && abs(eta) <= 2.0 ) * (pt > 50.0 && pt <= 70.0)  * (0.95) + \
+                         (abs(eta) >= 1.55 && abs(eta) <= 2.0 ) * (pt > 70.0 )  * (1.0) + \
+                         (abs(eta) >= 2.0 && abs(eta) <= 2.5 ) * (pt >  4.0 && pt <= 10.0)  * (0.65) + \
+                         (abs(eta) >= 2.0 && abs(eta) <= 2.5 ) * (pt > 10.0 && pt <= 30.0)  * (0.75) + \
+                         (abs(eta) >= 2.0 && abs(eta) <= 2.5 ) * (pt > 30.0 && pt <= 50.0)  * (0.90) + \
+                         (abs(eta) >= 2.0 && abs(eta) <= 2.5 ) * (pt > 50.0 && pt <= 70.0)  * (0.90) + \
+                         (abs(eta) >= 2.0 && abs(eta) <= 2.5 ) * (pt > 70.0 )  * (0.90) + \
+                         (abs(eta) > 2.5 && abs(eta) <= 4.0 ) * (pt > 4.0 && pt <= 10.0) * (0.65) + \
+					  (abs(eta) > 2.5 && abs(eta) <= 4.0 ) * (pt > 10.0 && pt <= 30.0) * (0.75) + \
+					  (abs(eta) > 2.5 && abs(eta) <= 4.0 ) * (pt > 30.0 && pt <= 50.0) * (0.90) + \
+					  (abs(eta) > 2.5 && abs(eta) <= 4.0 ) * (pt > 50.0 && pt <= 70.0) * (0.90) + \
+					  (abs(eta) > 2.5 && abs(eta) <= 4.0 ) * (pt > 70.0 ) * (0.90) + \
+					  (abs(eta) > 4.0) * (0.00)
+
+  }
+}
+
+
 ##################
 # Muon isolation #
@@ -1013,8 +1202,26 @@
 }
 
-
-##################
-# Muon Loose Id  #
-##################
+######################
+# Muon isolation CHS #
+######################
+
+module Isolation MuonIsolationCHS {
+  set CandidateInputArray MuonMomentumSmearing/muons
+
+  # isolation collection
+  set IsolationInputArray EFlowMerger/eflow
+
+  set OutputArray muons
+
+  set DeltaRMax 0.3
+  set PTMin 1.0
+  set PTRatioMax 9999.
+
+}
+
+
+#####################
+# Muon Loose Id     #
+#####################
 
 module Efficiency MuonLooseIdEfficiency {
@@ -1038,4 +1245,28 @@
 }
 
+
+#####################
+# Muon Loose Id CHS #
+#####################
+
+module Efficiency MuonLooseIdEfficiencyCHS {
+    set InputArray MuonIsolationCHS/muons
+    set OutputArray muons
+    # tracking + LooseID efficiency formula for muons
+    source muonLooseId.tcl
+
+}
+
+
+######################
+# Muon Tight Id  CHS #
+######################
+
+module Efficiency MuonTightIdEfficiencyCHS {
+    set InputArray MuonIsolationCHS/muons
+    set OutputArray muons
+    # tracking + TightID efficiency formula for muons
+    source muonTightId.tcl
+}
 
 
@@ -1250,5 +1481,5 @@
 module StatusPidFilter GenParticleFilter {
 
-    set InputArray  Delphes/allParticles
+    set InputArray Delphes/allParticles
     set OutputArray filteredParticles
     set PTMin 5.0
@@ -1278,4 +1509,9 @@
   add Branch MuonLooseIdEfficiency/muons MuonLoose Muon
   add Branch MuonTightIdEfficiency/muons MuonTight Muon
+
+  add Branch PhotonEfficiencyCHS/photons PhotonCHS Photon
+  add Branch ElectronEfficiencyCHS/electrons ElectronCHS Electron
+  add Branch MuonLooseIdEfficiencyCHS/muons MuonLooseCHS Muon
+  add Branch MuonTightIdEfficiencyCHS/muons MuonTightCHS Muon
 
   add Branch JetEnergyScale/jets Jet Jet
@@ -1289,3 +1525,4 @@
   add Branch GenPileUpMissingET/momentum GenPileUpMissingET MissingET
   add Branch ScalarHT/energy ScalarHT ScalarHT
-}
+
+}
