cms-jet / JetToolbox

Python framework for configuration of jet tools via the jet toolbox.
https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetToolbox
7 stars 36 forks source link

Add option for custom output collection name #45

Closed nstrobbe closed 7 years ago

nstrobbe commented 7 years ago

I want to run the toolbox (ak8+puppi+Softdrop) twice, each with a different pfCandidates collection as input. As far as I can tell, this is not currently going to work, since both collections would end up having the same name. Could you add an option to customize the name of the output collections? I.e. perhaps using a postfix?

Thanks!

alefisico commented 7 years ago

Hi @nstrobbe just to understand more your requirement, can you show your current configuration? What exactly are you running and what exactly do you want to get.

nstrobbe commented 7 years ago

So, the first collection I'm making is this one:

jetToolbox( process, 'ak8', 'ak8JetSubs', 'out',
  runOnMC = options.mcInfo,
  PUMethod='Puppi',
  addSoftDropSubjets = True,
  addSoftDrop = True,
  addNsub = True,
  bTagDiscriminators = ['pfCombinedInclusiveSecondaryVertexV2BJetTags'],
  addCMSTopTagger = False)

Then I want the same jet collections (ak8Puppi and the subjets collection), but starting from a list of PF candidates without leptons in it. For that I do something like:

process.pfCandidatesNoMu =  cms.EDProducer("CandPtrProjector",
                                          src = cms.InputTag("packedPFCandidates"),
                                          veto = cms.InputTag("prodMuons", "mu2Clean"))
process.pfCandidatesNoEle = cms.EDProducer("CandPtrProjector",
                                          src = cms.InputTag("pfCandidatesNoMu"),
                                          veto = cms.InputTag("prodElectrons", "ele2Clean"))

jetToolbox( process, 'ak8', 'ak8JetSubsNoLep', 'out',
 runOnMC = options.mcInfo,
 PUMethod='Puppi',
 newPFCollection=True,
 nameNewPFCollection='pfCandidatesNoEle',
 addSoftDropSubjets = True,
 addSoftDrop = True,
 addNsub = True,
 bTagDiscriminators = ['pfCombinedInclusiveSecondaryVertexV2BJetTags'],
 addCMSTopTagger = False)

In the end I want to access the ak8 jets, their associated softdrop mass and nsubjettiness variables, and I want to access the softdrop subjets with their btag discriminant. Let me know if you need more information about my configuration.

alefisico commented 7 years ago

Hi @nstrobbe, I add a "postFix="" option in the newest working branch: jetToolbox_80X I tested it already but just in case, could you please test it and let me know if it is what you need or if you found a bug.

alefisico commented 7 years ago

ok, I'll assume that, after my tests, this feature is working. I'll close this issue.

nstrobbe commented 7 years ago

Hi @alefisico Sorry for the long radio silence. Travel and holidays got in the way of me actually testing this feature. Now that I'm back, I tried implementing my original plan in our analysis code base, and I'm still running into some issues.

I added the following lines into our cmssw config. This should create two jet collections using different input pf candidates.

from JMEAnalysis.JetToolbox.jetToolbox_cff import jetToolbox

# Normal collection
jetToolbox( process, 'ak8', 'ak8JetSubs', 'out',
  runOnMC = options.mcInfo,
  PUMethod='Puppi',
  addSoftDropSubjets = True,
  addSoftDrop = True,
  addNsub = True,
  bTagDiscriminators = ['pfCombinedInclusiveSecondaryVertexV2BJetTags'],
  addCMSTopTagger = False)

# To get the lepton cleaned collection                                                                                                                                               
process.pfCandidatesNoMu =  cms.EDProducer("CandPtrProjector",
                                          src = cms.InputTag("packedPFCandidates"),
                                          veto = cms.InputTag("prodMuons", "mu2Clean"))
process.pfCandidatesNoEle = cms.EDProducer("CandPtrProjector",
                                          src = cms.InputTag("pfCandidatesNoMu"),
                                          veto = cms.InputTag("prodElectrons", "ele2Clean"))
jetToolbox( process, 'ak8', 'ak8JetSubsNoLep', 'out',
            runOnMC = options.mcInfo,
            PUMethod='Puppi',
            newPFCollection=True,
            nameNewPFCollection='pfCandidatesNoEle',
            addSoftDropSubjets = True,
            addSoftDrop = True,
            addNsub = True,
            bTagDiscriminators = ['pfCombinedInclusiveSecondaryVertexV2BJetTags'],
            addCMSTopTagger = False,
            postFix="NoLep")

However, the two output collections I get, are identical. On top of that, when I swap the order of the two toolbox calls, I still get two identical collections, but different from before the swap. Do you have any idea what could be going on? Is there anything I can provide that would help? I could send you the edmConfigDump of our config, although that gets to be very long.

nstrobbe commented 7 years ago

Some more information that I extracted from the edmConfigDump for both cases (cleaned collection first, or last). cleaned_first.txt cleaned_last.txt

It seems that there is always only one process.puppi object. When the cleaned version is put last, it has candName = cms.InputTag("pfCandidatesNoEle"), when it is put first, it has candName = cms.InputTag("packedPFCandidates"). This is then propagated to process.ak8PFJetsPuppi, of which there is also only one version (rather than two, where one has "NoLep" in the name as I had expected)

process.ak8PFJetsPuppi = cms.EDProducer("FastjetJetProducer",  
     .....
     src = cms.InputTag("puppi"), 
)

Hope this helps.

alefisico commented 7 years ago

Hi @nstrobbe sorry for the extremely late reply. I think the problem with your example is that at the moment the nameNewPFCollection is case sensitive. So, you will need to add the word puppi in the nameNewPFCollection as described in the twiki: https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetToolbox#New_PF_Collection

However, it has been pointed out that maybe we should include an extra option to avoid this confusion. So in the next version of the jetToolbox I will include a flag for this.

Please let me know if you have any other comment/question.