12 Functions that work on photon lists. 
   16 from basf2 
import create_path
 
   19 import modularAnalysis 
as ma
 
   22 def getRandomId(size=6, chars=string.ascii_uppercase + string.digits):
 
   23     return ''.join(random.choice(chars) 
for _ 
in range(size))
 
   26 def writeClosestParticleExtraClusterInfo(
 
   28     particleSelection='True',
 
   34     Add various variables to the first particle that are related to their angular separation and kinematics. 
   36     @param particleList Particle list with particle candidates that will have the extra information in the end 
   37     @param particleSelection Selection for the other particle 
   38     @param roe_path a path for the rest of event to be executed 
   39     @param deadend_path a path for skipping irrelevant RestOfEvent objects that may exist (if this was called twice, for instance) 
   40     @param path modules are added to this path 
   43     particleType = particleList.split(
":")[0]
 
   46         roe_path = create_path()
 
   49         deadend_path = create_path()
 
   52     ma.buildRestOfEvent(particleList, path=path)
 
   55     pListPair = 
'vpho:writeClosestParticleExtraClusterInfo' + getRandomId()
 
   56     pList0 = particleType + 
':writeClosestParticleExtraClusterInfo' + getRandomId()
 
   57     pList1 = particleType + 
':writeClosestParticleExtraClusterInfo' + getRandomId()
 
   59     ma.signalSideParticleFilter(particleList, 
'', roe_path, deadend_path)
 
   61     ma.fillSignalSideParticleList(pList0, 
'^' + particleList, path=roe_path)
 
   63     ma.fillParticleList(pList1, 
'isInRestOfEvent == 1 and ' + particleSelection, path=roe_path)
 
   65     ma.reconstructDecay(pListPair + 
' -> ' + pList0 + 
' ' + pList1, 
'', path=roe_path)
 
   68     ma.rankByLowest(pListPair, 
'daughterClusterAngleInBetween(0, 1)', 1, path=roe_path)
 
   73     ma.variableToSignalSideExtraInfo(pListPair, {
'useLabFrame(daughterClusterAngleInBetween(0, 1))': 
'openingAngle'}, path=roe_path)
 
   74     ma.variableToSignalSideExtraInfo(pListPair, {
'useLabFrame(daughterDiffOf(0, 1, clusterTheta))': 
'deltaTheta'}, path=roe_path)
 
   75     ma.variableToSignalSideExtraInfo(pListPair, {
'useLabFrame(daughterDiffOfClusterPhi(0, 1))': 
'deltaPhi'}, path=roe_path)
 
   77     path.for_each(
'RestOfEvent', 
'RestOfEvents', roe_path)