def addKinematicSelection(self,process,dumperTemplate=None,
                           dumpTrees=True,dumpWorkspace=False,dumpHistos=True,splitByIso=True):
     """
     Add basic kinematic selection to the process    
     """
     if not dumperTemplate:
         dumperTemplate = self.dumperTemplate
     
     template = simpleTemplate.clone(src=cms.InputTag("flashggDiPhotons"),
                                     cut = cms.string(
             "mass > %(massCut)f"
             " && leadingPhoton.pt > %(ptLead)f %(scalingFunc)s && subLeadingPhoton.pt > %(ptSublead)f %(scalingFunc)s"
             " && abs(leadingPhoton.superCluster.eta)<2.5 && abs(subLeadingPhoton.superCluster.eta)<2.5 "
             " && ( abs(leadingPhoton.superCluster.eta)<1.4442 || abs(leadingPhoton.superCluster.eta)>1.566)"
             " && ( abs(subLeadingPhoton.superCluster.eta)<1.4442 || abs(subLeadingPhoton.superCluster.eta)>1.566)" 
             " && ( abs(leadingPhoton.superCluster.eta) < 1.5 || abs(subLeadingPhoton.superCluster.eta) < 1.5 )"
             % { "massCut" : self.massCut, 
                 "ptLead"  : self.ptLead,
                 "ptSublead" : self.ptSublead,
                 "scalingFunc" : self.scalingFunc
                 }
             )
                                     )
     
     if self.computeMVA:
         setattr(process,"tmpKinDiphotons",template)
         template = diphotonsWithMVA.clone(src=cms.InputTag("tmpKinDiphotons"))
     
     self.analysisSelections += self.addDiphoSelection(process,"kin",template,dumperTemplate,
                                                       dumpTrees=dumpTrees,dumpWorkspace=dumpWorkspace,dumpHistos=dumpHistos,splitByIso=splitByIso,selectN=False)
def mkCategoryHistos(process,name,sel):
    setattr(process,name,flashggPreselectedDiPhotons.clone(cut = cms.string(sel)))
    photons = getattr(process,name)
        
    num = mkHistogrammer(process,"num%s" % name, name)
    den = mkHistogrammer(process,"den%s" % name, name)

    return (photons,num,den)
Exemple #3
0
def mkCategoryHistos(process, name, sel):
    setattr(process, name,
            flashggPreselectedDiPhotons.clone(cut=cms.string(sel)))
    photons = getattr(process, name)

    num = mkHistogrammer(process, "num%s" % name, name)
    den = mkHistogrammer(process, "den%s" % name, name)

    return (photons, num, den)
                            fileNames=cms.untracked.vstring(
        )
)
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32( 1000 )

process.TFileService = cms.Service("TFileService",
                                   fileName = cms.string("test.root")
)

from flashgg.MicroAOD.flashggPreselectedDiPhotons_cfi import flashggPreselectedDiPhotons
process.kinPreselDiPhotons = flashggPreselectedDiPhotons.clone(
cut=cms.string(
        "mass > 100"
        " && leadingPhoton.pt > 30 && subLeadingPhoton.pt > 30"
        " && abs(leadingPhoton.superCluster.eta)<2.5 && abs(subLeadingPhoton.superCluster.eta)<2.5 "
        " && ( abs(leadingPhoton.superCluster.eta)<1.4442 || abs(leadingPhoton.superCluster.eta)>1.566)"
        " && ( abs(subLeadingPhoton.superCluster.eta)<1.4442 || abs(subLeadingPhoton.superCluster.eta)>1.566)"
        ## " && leadingPhoton.genMatchType != subLeadingPhoton.genMatchType " ## selects only prompt-fake pairs
        )
                                                              )


process.flashggSinglePhotonViews = cms.EDProducer("FlashggSinglePhotonViewProducer",
                                          DiPhotonTag=cms.untracked.InputTag('kinPreselDiPhotons'),
                                          maxCandidates = cms.int32(1)
                                          )

process.load("flashgg.Taggers.photonViewDumper_cfi") ##  import diphotonDumper 
import flashgg.Taggers.dumperConfigTools as cfgTools

process.photonViewDumper.src = "flashggSinglePhotonViews"
process.source = cms.Source("PoolSource",
                            fileNames=cms.untracked.vstring(
        )
)
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32( 1000 )

process.TFileService = cms.Service("TFileService",
                                   fileName = cms.string("test.root")
)

from flashgg.MicroAOD.flashggPreselectedDiPhotons_cfi import flashggPreselectedDiPhotons
process.kinPreselDiPhotons = flashggPreselectedDiPhotons.clone(
cut=cms.string(
        "leadingPhoton.pt > 40 && subLeadingPhoton.pt > 30"
        " && abs(leadingPhoton.superCluster.eta)<2.5 && abs(subLeadingPhoton.superCluster.eta)<2.5 "
        " && ( abs(leadingPhoton.superCluster.eta)<1.4442 || abs(leadingPhoton.superCluster.eta)>1.566)"
        " && ( abs(subLeadingPhoton.superCluster.eta)<1.4442 || abs(subLeadingPhoton.superCluster.eta)>1.566)"
        )
                                                              )

process.load("flashgg.Taggers.diphotonDumper_cfi") ##  import diphotonDumper 
import flashgg.Taggers.dumperConfigTools as cfgTools

process.diphotonDumper.src = "kinPreselDiPhotons"

process.diphotonDumper.dumpTrees = True
process.diphotonDumper.dumpWorkspace = False
process.diphotonDumper.quietRooFit = True


# split tree, histogram and datasets by process
Exemple #6
0
process = cms.Process("Analysis")

process.load("FWCore.MessageService.MessageLogger_cfi")
process.source = cms.Source(
    "PoolSource",
    fileNames=cms.untracked.vstring("file:myMicroAODOutputFile.root"))
process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))
process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000)

process.TFileService = cms.Service("TFileService",
                                   fileName=cms.string("test.root"))

from flashgg.MicroAOD.flashggPreselectedDiPhotons_cfi import flashggPreselectedDiPhotons
process.kinPreselDiPhotons = flashggPreselectedDiPhotons.clone(cut=cms.string(
    "leadingPhoton.pt > 40 && subLeadingPhoton.pt > 30"
    " && abs(leadingPhoton.superCluster.eta)<2.5 && abs(subLeadingPhoton.superCluster.eta)<2.5 "
    " && ( abs(leadingPhoton.superCluster.eta)<1.4442 || abs(leadingPhoton.superCluster.eta)>1.566)"
    " && ( abs(subLeadingPhoton.superCluster.eta)<1.4442 || abs(subLeadingPhoton.superCluster.eta)>1.566)"
))

process.load("flashgg.Taggers.diphotonDumper_cfi")  ##  import diphotonDumper
import flashgg.Taggers.dumperConfigTools as cfgTools

process.diphotonDumper.src = "kinPreselDiPhotons"

process.diphotonDumper.dumpTrees = True
process.diphotonDumper.dumpWorkspace = False
process.diphotonDumper.quietRooFit = True

# split tree, histogram and datasets by process
process.diphotonDumper.nameTemplate = "$PROCESS_$SQRTS_$LABEL_$SUBCAT"
## do not split by process
    def addDiphoSelection(self,process,label,selectorTemplate,dumperTemplate=None,dumpTrees=False,dumpWorkspace=False,dumpHistos=True,splitByIso=False,
                          selectN=False):
        """
        Add diphoton producer and dumper to the process
        """
        
        modules = []
        
        if not dumperTemplate:
            dumperTemplate = self.dumperTemplate

        diphoColl  = "%sDiPhotons" % label
        dumperName = label
        
        ## register diphoton selector and associated dumper
        setattr(process,"all"+diphoColl,selectorTemplate.clone())
        if selectN:
            setattr(process,diphoColl,self.sortTemplate.clone(src=cms.InputTag("all"+diphoColl),
                                                              maxNumber=cms.uint32(selectN),
                                                              ))
        else:
            setattr(process,diphoColl,self.sortTemplate.clone(src=cms.InputTag("all"+diphoColl)))            
        setattr(process,dumperName,dumperTemplate.clone(src=cms.InputTag(diphoColl), 
                                                        dumpTrees=cms.untracked.bool(dumpTrees),
                                                        dumpWorkspace=cms.untracked.bool(dumpWorkspace),
                                                        dumpHistos=cms.untracked.bool(dumpHistos),
                                                        )
                )
        
        dumper = getattr(process,dumperName)
        modules.append( (diphoColl,dumperName) )
        
        ## split into isolated and non isolated parts
        if splitByIso:
            self.splitByIso.append(dumperName)
            setattr(process,diphoColl+"GenIso",simpleTemplate.clone(src=cms.InputTag(diphoColl),
                                                                 cut=cms.string("leadingPhoton.genMatchType == 1 && subLeadingPhoton.genMatchType == 1 "
                                                                                " && leadingPhoton.%(genIsoVar)s < %(genIsoCut)f"
                                                                                " && subLeadingPhoton.%(genIsoVar)s < %(genIsoCut)f" 
                                                                                % self.isoCut
                                                                                )
                                                                 )
                    )
            setattr(process,dumperName+"GenIso",dumperTemplate.clone(src=cms.InputTag(diphoColl+"GenIso"), 
                                                                  dumpTrees=cms.untracked.bool(dumpTrees),
                                                                  dumpWorkspace=cms.untracked.bool(dumpWorkspace),
                                                                  dumpHistos=cms.untracked.bool(dumpHistos),
                                                                  )
                    )
            
            setattr(process,diphoColl+"NonGenIso",simpleTemplate.clone(src=cms.InputTag(diphoColl),
                                                                    cut=cms.string("leadingPhoton.genMatchType != 1 || subLeadingPhoton.genMatchType != 1 "
                                                                                   " || leadingPhoton.%(genIsoVar)s >= %(genIsoCut)f"
                                                                                   " || subLeadingPhoton.%(genIsoVar)s >= %(genIsoCut)f"
                                                                                   % self.isoCut
                                                                                   )
                                                                    )
                    )
            setattr(process,dumperName+"NonGenIso",dumperTemplate.clone(src=cms.InputTag(diphoColl+"NonGenIso"), 
                                                                     dumpTrees=cms.untracked.bool(dumpTrees),
                                                                     dumpWorkspace=cms.untracked.bool(dumpWorkspace),
                                                                     dumpHistos=cms.untracked.bool(dumpHistos),
                                                                     )
                    )
            
            modules.append( (diphoColl+"GenIso",dumperName+"GenIso"))
            modules.append( (diphoColl+"NonGenIso",dumperName+"NonGenIso"))
            self.splitDumpers.extend( [dumperName+"GenIso",dumperName+"NonGenIso"] )
            
        return modules