|
1 | 1 | def expandNanoMapping(seqList, mapping, key): |
2 | | - maxLevel=30 |
3 | | - level=0 |
4 | | - while '@' in repr(seqList) and level<maxLevel: |
5 | | - level+=1 |
| 2 | + maxLevel = 30 |
| 3 | + level = 0 |
| 4 | + while '@' in repr(seqList) and level < maxLevel: |
| 5 | + level += 1 |
6 | 6 | for specifiedCommand in seqList: |
7 | 7 | if specifiedCommand.startswith('@'): |
8 | | - location=specifiedCommand[1:] |
| 8 | + location = specifiedCommand[1:] |
9 | 9 | if not location in mapping: |
10 | | - raise Exception("Impossible to map "+location+" from "+repr(mapping)) |
11 | | - mappedTo=mapping[location] |
| 10 | + raise Exception("Impossible to map " + location + " from " + repr(mapping)) |
| 11 | + mappedTo = mapping[location] |
12 | 12 | # no mapping for specified key |
13 | 13 | # NOTE: mising key of key=None is interpreted differently than empty string: |
14 | 14 | # - An empty string recalls the default for the given key |
15 | 15 | # - None is interpreted as "ignore this" |
16 | | - insertAt=seqList.index(specifiedCommand) |
| 16 | + insertAt = seqList.index(specifiedCommand) |
17 | 17 | seqList.remove(specifiedCommand) |
18 | 18 | if key in mappedTo and mappedTo[key] is not None: |
19 | | - allToInsert=mappedTo[key].split('+') |
20 | | - for offset,toInsert in enumerate(allToInsert): |
21 | | - seqList.insert(insertAt+offset,toInsert) |
22 | | - break; |
23 | | - if level==maxLevel: |
24 | | - raise Exception("Could not fully expand "+repr(seqList)+" from "+repr(mapping)) |
| 19 | + allToInsert = mappedTo[key].split('+') |
| 20 | + for offset, toInsert in enumerate(allToInsert): |
| 21 | + seqList.insert(insertAt + offset, toInsert) |
| 22 | + break |
| 23 | + if level == maxLevel: |
| 24 | + raise Exception("Could not fully expand " + repr(seqList) + " from " + repr(mapping)) |
25 | 25 |
|
26 | 26 |
|
27 | 27 | autoNANO = { |
28 | 28 | # PHYS is a mapping to the default NANO config, i.e. empty strings |
29 | 29 | 'PHYS': {'sequence': '', |
30 | 30 | 'customize': ''}, |
31 | 31 | # L1 flavours: add tables through customize, supposed to be combined with PHYS |
32 | | - 'L1' : {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomize'}, |
33 | | - 'L1FULL' : {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull'}, |
34 | | - #scouting nano |
35 | | - 'Scout' : {'sequence': 'PhysicsTools/NanoAOD/custom_run3scouting_cff'}, |
36 | | - 'JME' : { 'sequence': '@PHYS', |
37 | | - 'customize': '@PHYS+PhysicsTools/NanoAOD/custom_jme_cff.PrepJMECustomNanoAOD'}, |
38 | | - 'JMErePuppi' : { 'sequence': '@PHYS', |
39 | | - 'customize': '@PHYS+@JME+PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET'}, |
| 32 | + 'L1': {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomize'}, |
| 33 | + 'L1FULL': {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull'}, |
| 34 | + # scouting nano |
| 35 | + 'Scout': {'sequence': 'PhysicsTools/NanoAOD/custom_run3scouting_cff'}, |
| 36 | + # JME nano |
| 37 | + 'JME': {'sequence': '@PHYS', |
| 38 | + 'customize': '@PHYS+PhysicsTools/NanoAOD/custom_jme_cff.PrepJMECustomNanoAOD'}, |
| 39 | + 'JMErePuppi': {'sequence': '@PHYS', |
| 40 | + 'customize': '@PHYS+@JME+PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET'}, |
40 | 41 | # L1 DPG (standalone with full calo TP info, L1T reemulation customization) |
41 | 42 | 'L1DPG' : {'sequence': 'DPGAnalysis/L1TNanoAOD/l1tNano_cff.l1tNanoSequence', |
42 | | - 'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull,DPGAnalysis/L1TNanoAOD/l1tNano_cff.addCaloFull,L1Trigger/Configuration/customiseReEmul.L1TReEmulFromRAW'}, |
| 43 | + 'customize': ','.join(['PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull', |
| 44 | + 'DPGAnalysis/L1TNanoAOD/l1tNano_cff.addCaloFull', |
| 45 | + 'L1Trigger/Configuration/customiseReEmul.L1TReEmulFromRAW'])}, |
43 | 46 | # Muon POG flavours : add tables through customize, supposed to be combined with PHYS |
44 | | - 'MUPOG' : {'sequence': '@PHYS', |
45 | | - 'customize' : '@PHYS+PhysicsTools/NanoAOD/custom_muon_cff.PrepMuonCustomNanoAOD'}, |
| 47 | + 'MUPOG': {'sequence': '@PHYS', |
| 48 | + 'customize': '@PHYS+PhysicsTools/NanoAOD/custom_muon_cff.PrepMuonCustomNanoAOD'}, |
46 | 49 | # MUDPG flavours: use their own sequence |
47 | | - 'MUDPG' : {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoProducer', |
48 | | - 'customize': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoCustomize'}, |
49 | | - 'MUDPGBKG' : {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoProducerBkg', |
50 | | - 'customize': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoBkgCustomize'}, |
51 | | - # HCAL favlours: |
52 | | - 'HCAL' : {'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask'}, |
53 | | - 'HCALCalib' : { 'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask', |
54 | | - 'customize': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.customiseHcalCalib'}, |
55 | | - #EGM flavours: add variables through customize |
56 | | - 'EGM' : {'sequence': '@PHYS', |
57 | | - 'customize' : '@PHYS+PhysicsTools/NanoAOD/egamma_custom_cff.addExtraEGammaVarsCustomize'}, |
| 50 | + 'MUDPG': {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoProducer', |
| 51 | + 'customize': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoCustomize'}, |
| 52 | + 'MUDPGBKG': {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoProducerBkg', |
| 53 | + 'customize': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoBkgCustomize'}, |
| 54 | + # HCAL flavors: |
| 55 | + 'HCAL': {'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask'}, |
| 56 | + 'HCALCalib': {'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask', |
| 57 | + 'customize': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.customiseHcalCalib'}, |
| 58 | + # EGM flavours: add variables through customize |
| 59 | + 'EGM': {'sequence': '@PHYS', |
| 60 | + 'customize': '@PHYS+PhysicsTools/NanoAOD/egamma_custom_cff.addExtraEGammaVarsCustomize'}, |
58 | 61 | # PromptReco config: PHYS+L1 |
59 | | - 'Prompt' : {'sequence': '@PHYS', |
60 | | - 'customize': '@PHYS+@L1'}, |
| 62 | + 'Prompt': {'sequence': '@PHYS', |
| 63 | + 'customize': '@PHYS+@L1'}, |
61 | 64 | # Add lepton track parameters through customize combined with PHYS |
62 | 65 | 'LepTrackInfo' : {'sequence': '@PHYS', |
63 | 66 | 'customize': '@PHYS+PhysicsTools/NanoAOD/leptonTimeLifeInfo_common_cff.addTrackVarsToTimeLifeInfo'}, |
64 | 67 | # Custom BTV Nano for SF measurements or tagger training |
65 | | - 'BTV' : {'sequence': '@PHYS', |
66 | | - 'customize':'@PHYS+PhysicsTools/NanoAOD/custom_btv_cff.BTVCustomNanoAOD'} |
| 68 | + 'BTV': {'sequence': '@PHYS', |
| 69 | + 'customize': '@PHYS+PhysicsTools/NanoAOD/custom_btv_cff.BTVCustomNanoAOD'}, |
| 70 | + # NANOGEN (from LHE/GEN/AOD) |
| 71 | + 'GEN': {'sequence': 'PhysicsTools/NanoAOD/nanogen_cff.nanogenSequence', |
| 72 | + 'customize': 'PhysicsTools/NanoAOD/nanogen_cff.customizeNanoGEN'}, |
| 73 | + # NANOGEN (from MiniAOD) |
| 74 | + 'GENFromMini': {'sequence': 'PhysicsTools/NanoAOD/nanogen_cff.nanogenSequence', |
| 75 | + 'customize': 'PhysicsTools/NanoAOD/nanogen_cff.customizeNanoGENFromMini'}, |
67 | 76 | } |
0 commit comments