Index: cards/CMS_PhaseII/CMS_PhaseII_200PU.tcl
===================================================================
--- cards/CMS_PhaseII/CMS_PhaseII_200PU.tcl	(revision e2339af03cbe76802d8e0c030c3ab7ca89f5c5a7)
+++ cards/CMS_PhaseII/CMS_PhaseII_200PU.tcl	(revision 740d4307f5fdc73e925397c349d8b6c2685c0b76)
@@ -1,8 +1,10 @@
+set MaxEvents 10
+
 #
 #  Phase II - Pile-Up
 #
 #  Main authors: Michele Selvaggi (UCL)
-#                                
-#  Released on: 
+#
+#  Released on:
 #
 #  Version: v01
@@ -14,7 +16,6 @@
 
 set ExecutionPath {
- 
-  PileUpMerger 
-  
+
+  PileUpMerger
   ParticlePropagator
 
@@ -28,5 +29,5 @@
 
   TrackMerger
-  
+
   ECal
   HCal
@@ -34,5 +35,5 @@
   ElectronFilter
   TrackPileUpSubtractor
-  
+
   TowerMerger
   NeutralEFlowMerger
@@ -45,15 +46,16 @@
   RunPUPPI
 
+  PhotonFilter
 
   PhotonIsolation
   PhotonEfficiency
-  
+
   ElectronIsolation
   ElectronEfficiency
- 
+
   MuonIsolation
   MuonLooseIdEfficiency
   MuonTightIdEfficiency
- 
+
   NeutrinoFilter
 
@@ -67,5 +69,5 @@
 
   ScalarHT
- 
+
   JetEnergyScale
 
@@ -77,7 +79,7 @@
 
   TauTagging
-  
+
   GenParticleFilter
-  
+
   TreeWriter
 }
@@ -96,9 +98,9 @@
 
   # pre-generated minbias input file
-  set PileUpFile ../eos/cms/store/group/upgrade/delphes/PhaseII/MinBias_100k.pileup 
+  set PileUpFile ../eos/cms/store/group/upgrade/delphes/PhaseII/MinBias_100k.pileup
 
   # average expected pile up
   set MeanPileUp 200
-  
+
   # maximum spread in the beam direction in m
   set ZVertexSpread 0.25
@@ -109,5 +111,5 @@
   # vertex smearing formula f(z,t) (z,t need to be respectively given in m,s)
   set VertexDistributionFormula {exp(-(t^2/160e-12^2/2))*exp(-(z^2/0.053^2/2))}
-  
+
 }
 
@@ -165,5 +167,5 @@
   set OutputArray electrons
   # tracking efficiency formula for electrons
-  set EfficiencyFormula { 
+  set EfficiencyFormula {
       (pt <= 0.2) * (0.00) + \
 	  (abs(eta) <= 1.2) * (pt > 0.2 && pt <= 1.0) * (pt * 0.96) + \
@@ -197,5 +199,5 @@
 	  (abs(eta) > 2.8 && abs(eta) <= 4.0) * (pt > 1.0) * (0.95) + \
 	  (abs(eta) > 4.0) * (0.00)
-	  
+
   }
 }
@@ -210,6 +212,6 @@
   set InputArray  ChargedHadronTrackingEfficiency/chargedHadrons
   set OutputArray chargedHadrons
-  # resolution formula for charged hadrons , 
- 
+  # resolution formula for charged hadrons ,
+
   # from http://mersi.web.cern.ch/mersi/layouts/.private/Baseline_tilted_200_Pixel_1_1_1/index.html
   source trackMomentumResolution.tcl
@@ -227,14 +229,14 @@
 
   # resolution formula for electrons
-  
+
   # taking something flat in energy for now, ECAL will take over at high energy anyway.
   # inferred from hep-ex/1306.2016 and 1502.02701
-  set ResolutionFormula {  
-  
+  set ResolutionFormula {
+
                         (abs(eta) <= 1.5)  * (1+0.64*abs(eta)^2)*(energy*0.028) +
     (abs(eta) > 1.5  && abs(eta) <= 1.75)  * (energy*0.037) +
     (abs(eta) > 1.75  && abs(eta) <= 2.15) * (energy*0.038) +
     (abs(eta) > 2.15  && abs(eta) <= 3.00) * (energy*0.044) +
-    (abs(eta) > 3.00  && abs(eta) <= 4.00) * (energy*0.10)}   
+    (abs(eta) > 3.00  && abs(eta) <= 4.00) * (energy*0.10)}
 
 }
@@ -248,9 +250,9 @@
   set OutputArray muons
   # resolution formula for muons
-  
-  # up to |eta| < 2.8 take measurement from tracking + muon chambers 
-  # for |eta| > 2.8 and pT < 5.0 take measurement from tracking alone taken from 
+
+  # up to |eta| < 2.8 take measurement from tracking + muon chambers
+  # for |eta| > 2.8 and pT < 5.0 take measurement from tracking alone taken from
   # http://mersi.web.cern.ch/mersi/layouts/.private/Baseline_tilted_200_Pixel_1_1_1/index.html
-  source muonMomentumResolution.tcl  
+  source muonMomentumResolution.tcl
 }
 
@@ -282,6 +284,6 @@
   set EFlowTowerOutputArray eflowPhotons
 
-  set IsEcal true 
- 
+  set IsEcal true
+
   set EnergyMin 0.5
   set EnergySignificanceMin 1.0
@@ -296,5 +298,5 @@
 
   # assume 0.02 x 0.02 resolution in eta,phi in the barrel |eta| < 1.5
-  
+
   set PhiBins {}
   for {set i -180} {$i <= 180} {incr i} {
@@ -309,5 +311,5 @@
 
   # assume 0.02 x 0.02 resolution in eta,phi in the endcaps 1.5 < |eta| < 3.0 (HGCAL- ECAL)
-  
+
   set PhiBins {}
   for {set i -180} {$i <= 180} {incr i} {
@@ -326,6 +328,6 @@
   }
 
-  # take present CMS granularity for HF  
- 
+  # take present CMS granularity for HF
+
   # 0.175 x (0.175 - 0.35) resolution in eta,phi in the HF 3.0 < |eta| < 5.0
   set PhiBins {}
@@ -333,5 +335,5 @@
     add PhiBins [expr {$i * $pi/18.0}]
   }
-  
+
   foreach eta {-5 -4.7 -4.525 -4.35 -4.175 -4 -3.825 -3.65 -3.475 -3.3 -3.125 -2.958 3.125 3.3 3.475 3.65 3.825 4 4.175 4.35 4.525 4.7 5} {
     add EtaPhiBins $eta $PhiBins
@@ -359,9 +361,9 @@
 
   # set ResolutionFormula {resolution formula as a function of eta and energy}
-  
+
   # for the ECAL barrel (|eta| < 1.5), see hep-ex/1306.2016 and 1502.02701
   # for the endcaps (1.5 < |eta| < 3.0), we take HGCAL  see LHCC-P-008, Fig. 3.39, p.117
 
-  set ResolutionFormula {  (abs(eta) <= 1.50)                    * (1+0.64*abs(eta)^2)*sqrt(energy^2*0.009^2 + energy*0.12^2 + 0.45^2) + 
+  set ResolutionFormula {  (abs(eta) <= 1.50)                    * (1+0.64*abs(eta)^2)*sqrt(energy^2*0.009^2 + energy*0.12^2 + 0.45^2) +
                            (abs(eta) > 1.50 && abs(eta) <= 1.75) * sqrt(energy^2*0.006^2 + energy*0.20^2) + \
                            (abs(eta) > 1.75 && abs(eta) <= 2.15) * sqrt(energy^2*0.007^2 + energy*0.21^2) + \
@@ -383,6 +385,6 @@
   set EFlowTowerOutputArray eflowNeutralHadrons
 
-  set IsEcal false 
- 
+  set IsEcal false
+
   set EnergyMin 1.0
   set EnergySignificanceMin 1.0
@@ -395,5 +397,5 @@
   # each list starts with the lower edge of the first tower
   # the list ends with the higher edged of the last tower
- 
+
   # assume 0.087 x 0.087 resolution in eta,phi in the barrel |eta| < 1.5
 
@@ -407,5 +409,5 @@
 
   # assume 0.02 x 0.02 resolution in eta,phi in the endcaps 1.5 < |eta| < 3.0 (HGCAL- HCAL)
-  
+
   set PhiBins {}
   for {set i -180} {$i <= 180} {incr i} {
@@ -424,6 +426,6 @@
   }
 
-  # take present CMS granularity for HF  
- 
+  # take present CMS granularity for HF
+
   # 0.175 x (0.175 - 0.35) resolution in eta,phi in the HF 3.0 < |eta| < 5.0
   set PhiBins {}
@@ -431,5 +433,5 @@
     add PhiBins [expr {$i * $pi/18.0}]
   }
-  
+
   foreach eta {-5 -4.7 -4.525 -4.35 -4.175 -4 -3.825 -3.65 -3.475 -3.3 -3.125 -2.958 3.125 3.3 3.475 3.65 3.825 4 4.175 4.35 4.525 4.7 5} {
     add EtaPhiBins $eta $PhiBins
@@ -476,4 +478,5 @@
 }
 
+
 ##########################
 # Track pile-up subtractor
@@ -573,6 +576,6 @@
   set UseExp            false
   set UseNoLep          false
- 
-  ## define puppi algorithm parameters (more than one for the same eta region is possible)                                                                                      
+
+  ## define puppi algorithm parameters (more than one for the same eta region is possible)
   add EtaMinBin           0.0   1.5   4.0
   add EtaMaxBin           1.5   4.0   10.0
@@ -585,5 +588,5 @@
   add ApplyCHS            true  true  true
   add UseCharged          true  true  false
-  add ApplyLowPUCorr      true  true  true 
+  add ApplyLowPUCorr      true  true  true
   add MetricId            5     5     5
   add CombId              0     0     0
@@ -593,5 +596,5 @@
   set OutputArrayTracks   puppiTracks
   set OutputArrayNeutrals puppiNeutrals
-} 
+}
 
 module Merger RunPUPPI {
@@ -620,5 +623,5 @@
 
 ###################
-# Ger PileUp Missing ET 
+# Ger PileUp Missing ET
 ###################
 
@@ -667,5 +670,5 @@
 module FastJetFinder GenJetFinder {
   set InputArray NeutrinoFilter/filteredParticles
- 
+
   set OutputArray jets
 
@@ -720,4 +723,17 @@
 
 
+#################
+# Photon filter
+#################
+
+module PdgCodeFilter PhotonFilter {
+  set InputArray ECal/eflowPhotons
+  set OutputArray photons
+  set Invert true
+  set PTMin 5.0
+  add PdgCode {22}
+}
+
+
 ####################
 # Photon isolation #
@@ -725,22 +741,27 @@
 
 module Isolation PhotonIsolation {
-  
+
   # particle for which calculate the isolation
-  set CandidateInputArray ECal/eflowPhotons
-  
+  set CandidateInputArray PhotonFilter/photons
+
   # isolation collection
-  set IsolationInputArray EFlowMerger/eflow
- 
+  set IsolationInputArray RunPUPPI/PuppiParticles
+
   # output array
   set OutputArray photons
-  
+
+  # veto isolation cand. based on proximity to input cand.
+  set DeltaRMin 0.01
+  set UseMiniCone true
+
   # isolation cone
   set DeltaRMax 0.3
-  
-  # minimum pT  
+
+  # minimum pT
   set PTMin     1.0
-  
+
   # iso ratio to cut
   set PTRatioMax 9999.
+
 }
 
@@ -752,7 +773,7 @@
 
 module Efficiency PhotonEfficiency {
-  
+
   ## input particles
-  set InputArray PhotonIsolation/photons 
+  set InputArray PhotonIsolation/photons
   ## output particles
   set OutputArray photons
@@ -772,12 +793,13 @@
 
 module Isolation ElectronIsolation {
-  
+
   set CandidateInputArray ElectronFilter/electrons
-  
+
   # isolation collection
-  set IsolationInputArray EFlowMerger/eflow
-  
+  set IsolationInputArray RunPUPPI/PuppiParticles
+  #set IsolationInputArray EFlowMerger/eflow
+
   set OutputArray electrons
-  
+
   set DeltaRMax 0.3
   set PTMin 1.0
@@ -793,8 +815,8 @@
 
 module Efficiency ElectronEfficiency {
-  
+
   set InputArray ElectronIsolation/electrons
   set OutputArray electrons
-  
+
   # set EfficiencyFormula {efficiency formula as a function of eta and pt}
   # efficiency formula for electrons
@@ -804,22 +826,22 @@
                          (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 ) * (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.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) >= 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.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) + \
@@ -828,5 +850,5 @@
 					  (abs(eta) > 2.5 && abs(eta) <= 4.0 ) * (pt > 70.0 ) * (0.90) + \
 					  (abs(eta) > 4.0) * (0.00)
- 
+
   }
 }
@@ -838,10 +860,10 @@
 module Isolation MuonIsolation {
   set CandidateInputArray MuonMomentumSmearing/muons
- 
+
   # isolation collection
-  set IsolationInputArray EFlowMerger/eflow
- 
+  set IsolationInputArray RunPUPPI/PuppiParticles
+
   set OutputArray muons
-  
+
   set DeltaRMax 0.3
   set PTMin 1.0
@@ -916,9 +938,8 @@
 
   set BitNumber 1
- 
+
   source btagMedium.tcl
 }
 
-  
 
 #############
@@ -931,9 +952,6 @@
   set BitNumber 2
 
-  source btagTight.tcl 
-}
-
-
-
+  source btagTight.tcl
+}
 
 
@@ -961,5 +979,5 @@
   add EfficiencyFormula {15} { (abs(eta) < 2.3) * 0.97*0.77*( (0.32 + 0.01*pt - 0.000054*pt*pt )*(pt<100)+0.78*(pt>100) ) + \
                                (abs(eta) > 2.3) * (0.000)
-                             } 
+                             }
 }
 
@@ -970,9 +988,9 @@
 
 module StatusPidFilter GenParticleFilter {
-  
+
     set InputArray  Delphes/allParticles
     set OutputArray filteredParticles
     set PTMin 5.0
-    
+
 }
 
@@ -986,5 +1004,5 @@
   add Branch GenParticleFilter/filteredParticles Particle GenParticle
   add Branch PileUpMerger/vertices Vertex Vertex
- 
+
   add Branch GenJetFinder/jets GenJet Jet
   add Branch GenMissingET/momentum GenMissingET MissingET
@@ -993,12 +1011,12 @@
 #  add Branch ECal/eflowPhotons EFlowPhoton Tower
 #  add Branch HCal/eflowNeutralHadrons EFlowNeutralHadron Tower
-  
+
   add Branch PhotonEfficiency/photons Photon Photon
   add Branch ElectronEfficiency/electrons Electron Electron
   add Branch MuonLooseIdEfficiency/muons MuonLoose Muon
   add Branch MuonTightIdEfficiency/muons MuonTight Muon
-   
+
   add Branch JetEnergyScale/jets Jet Jet
-  
+
   add Branch MissingET/momentum MissingET MissingET
   add Branch PuppiMissingET/momentum PuppiMissingET MissingET
