def WriteParticle2(file, part, rank, status): # Skipping if already defined if InstanceName.Find(part.name + rank + status): return # Getting new name newname = InstanceName.Get(part.name + rank + status) # Do mother before if part.mumType != "": WriteParticle2(file, part.mumPart, rank, 'allstate') # Identifier function file.write(' bool isP_'+newname+\ '(const MCParticleFormat* part) const {\n') # Null pointer file.write(' if ( part==0 ) return false;\n') # FinalSate if status == "finalstate": file.write( " if ( !PHYSICS->Id->IsFinalState(part) ) return false;\n") elif status == "initialstate": file.write( " if ( !PHYSICS->Id->IsInitialState(part) ) return false;\n") elif status == "interstate": file.write( " if ( !PHYSICS->Id->IsInterState(part) ) return false;\n") # Id file.write(' if ( ') variables = [] for item in part.particle.ids: variables.append('(part->pdgid()!=' + str(item) + ')') file.write('&&'.join(variables)) file.write(' ) return false;\n') # Mother if part.mumType != "": mumname = InstanceName.Get(part.mumPart.name + rank + 'allstate') if part.mumType == "<": file.write(' if ( !isP_' + mumname +\ '(part->mother1()) ) return false;\n') elif part.mumType == "<<": file.write(' const MCParticleFormat* cand = part;\n') file.write(' bool success=false;\n') file.write(' while(cand->mother1()!=0)\n') file.write(' {\n') file.write(' if ( isP_' + mumname +\ '(cand->mother1()) ) {success=true;break;}\n') file.write(' cand = cand->mother1();\n') file.write(' }\n') file.write(' if (!success) return false;\n') # PT rank # return file.write(' return true; }\n')
def WriteFillWithMuonContainer(part, file, rank, status): # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Put negative muon if part.particle.Find(13): file.write(' if (event.rec()->muons()[i].charge()<0) '+\ container+'.push_back(&(event.rec()->muons()[i]));\n') # Put positive muon if part.particle.Find(-13): file.write(' if (event.rec()->muons()[i].charge()>0) '+\ container+'.push_back(&(event.rec()->muons()[i]));\n') # Put isolated negative muon if part.particle.Find(130): file.write(' if ( (event.rec()->muons()[i].charge()<0) &&'+\ ' PHYSICS->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\ container+'.push_back(&(event.rec()->muons()[i]));\n') # Put isolated positive muon if part.particle.Find(-130): file.write(' if ( (event.rec()->muons()[i].charge()>0) &&'+\ ' PHYSICS->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\ container+'.push_back(&(event.rec()->muons()[i]));\n')
def WriteParticle(file, part, rank, status, regions, level): # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status + '_REG_' + '_'.join(regions)): return # Getting new name newname = InstanceName.Get('P_' + part.name + rank + status + '_REG_' + '_'.join(regions)) if level in [MA5RunningType.PARTON, MA5RunningType.HADRON]: # Creating new container file.write(" std::vector<const MCParticleFormat*> " +\ newname + ";\n") # Creating function for filling container if part.PTrank == 0: WriteParticle2(file, part, rank, status) else: # Creating new container file.write(" std::vector<const RecParticleFormat*> " +\ newname + ";\n")
def WriteFillWithJetContainer(part, file, rank, status): # If PTrank, no fill if part.PTrank != 0: return # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Put jet if part.particle.Find(21): file.write(' '+container+\ '.push_back(&(event.rec()->jets()[i]));\n') return # Put b jet if part.particle.Find(5): file.write(' if (event.rec()->jets()[i].btag()) '+\ container+'.push_back(&(event.rec()->jets()[i]));\n') # Put nb jet if part.particle.Find(1): file.write(' if (!event.rec()->jets()[i].btag()) '+\ container+'.push_back(&(event.rec()->jets()[i]));\n')
def WriteCleanContainer(part, file, rank, status): # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Getting id name id = 'isP_' + InstanceName.Get(part.name + rank + status) file.write(' ' + container + '.clear();\n')
def WriteFillContainer(part, file, rank, status): # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Getting id name id = 'isP_' + InstanceName.Get(part.name + rank + status) file.write(' if ('+id+'((&(event.mc()->particles()[i])))) ' +\ container + '.push_back(&(event.mc()->particles()[i]));\n')
def WriteJobRank(part, file, rank, status): if part.PTrank == 0: return # Skipping if already defined if InstanceName.Find("PTRANK_" + part.name + rank + status): return container = InstanceName.Get('P_' + part.name + rank + status) file.write(' // Sorting particle collection according to ' + rank + '\n') file.write(' // for getting ' + str(part.PTrank) + 'th particle\n') file.write(' PHYSICS->rankFilter(' + container + ',' + str(part.PTrank) + ',' + rank + ');\n\n')
def WriteFillWithMHTContainerMC(part, file, rank, status): # If PTrank, no fill if part.PTrank != 0: return # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Put MHT if part.particle.Find(99): file.write(' '+container+\ '.push_back(&(event.mc()->MHT()));\n')
def WriteFillWithPhotonContainer(part, file, rank, status): # If PTrank, no fill if part.PTrank != 0: return # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Put photon if part.particle.Find(22): file.write(' ' + container + '.push_back(&(event.rec()->photons()[i]));\n')
def WriteFillWithTauContainer(part, file, rank, status): # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Put negative tau if part.particle.Find(15): file.write(' if (event.rec()->taus()[i].charge()<0) '+\ container+'.push_back(&(event.rec()->taus()[i]));\n') # Put positive tau if part.particle.Find(-15): file.write(' if (event.rec()->taus()[i].charge()>0) '+\ container+'.push_back(&(event.rec()->taus()[i]));\n')
def WriteJobRank(part, file, rank, status, regions): if part.PTrank == 0: return # Skipping if already defined if InstanceName.Find("PTRANK_" + part.name + rank + status): return container = InstanceName.Get('P_' + part.name + rank + status + '_REG_' + '_'.join(regions)) refpart = copy.copy(part) refpart.PTrank = 0 newcontainer = InstanceName.Get('P_' + refpart.name + 'PTordering' + status + '_REG_' + '_'.join(regions)) file.write(' // Sorting particle collection according to ' + rank + '\n') file.write(' // for getting ' + str(part.PTrank) + 'th particle\n') file.write(' '+container+'=SORTER->rankFilter('+\ newcontainer+','+str(part.PTrank)+','+rank+');\n\n')
def WriteFillContainer(part, file, rank, status, regions): # If PTrank, no fill if part.PTrank != 0: return # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status + '_REG_' + '_'.join(regions)): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status + '_REG_' + '_'.join(regions)) # Getting id name id = 'isP_' + InstanceName.Get(part.name + rank + status) file.write(' if ('+id+'((&(event.mc()->particles()[i])))) ' +\ container + '.push_back(&(event.mc()->particles()[i]));\n')
def WriteParticle(file, part, rank, status, level): # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting new name newname = InstanceName.Get('P_' + part.name + rank + status) if level in [MA5RunningType.PARTON, MA5RunningType.HADRON]: # Creating new container file.write(" std::vector<const MCParticleFormat*> " +\ newname + ";\n") WriteParticle2(file, part, rank, status) else: # Creating new container file.write(" std::vector<const RecParticleFormat*> " +\ newname + ";\n")
def WriteFillWithElectronContainer(part, file, rank, status): # If PTrank, no fill if part.PTrank != 0: return # Skipping if already defined if InstanceName.Find('P_' + part.name + rank + status): return # Getting container name container = InstanceName.Get('P_' + part.name + rank + status) # Put negative electron if part.particle.Find(11): file.write(' if (event.rec()->electrons()[i].charge()<0) '+\ container+'.push_back(&(event.rec()->electrons()[i]));\n') # Put positive electron if part.particle.Find(-11): file.write(' if (event.rec()->electrons()[i].charge()>0) '+\ container+'.push_back(&(event.rec()->electrons()[i]));\n')