def ParseOneLine(line): if line.find("vector >") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print ("mapVarsVectorVectorFloat[\"%s\"] = %s;" %(strippedName,strippedName)) elif line.find("vector >") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print ("mapVarsVectorVectorDouble[\"%s\"] = %s;" %(strippedName,strippedName)) elif line.find("vector >") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorVectorInt[\"%s\"] = %s;"%(strippedName,strippedName)) elif line.find("vector > ") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorVectorUnsignedInt[\"%s\"] = %s;"%(strippedName,strippedName)) elif line.find("vector") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print ("mapVarsVectorFloat[\"%s\"] = %s;" %(strippedName,strippedName)) elif line.find("vector") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorInt[\"%s\"] = %s;"%(strippedName,strippedName)) elif line.find("vector") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorShort[\"%s\"] = %s;"%(strippedName,strippedName)) elif line.find("vector ") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorUnsignedShort[\"%s\"] = %s;"%(strippedName,strippedName)) elif line.find("vector ") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorUnsignedInt[\"%s\"] = %s;"%(strippedName,strippedName)) elif line.find("vector ") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorString[\"%s\"] = %s;"%(strippedName,strippedName)) elif line.find("Int_t jet") != -1: pos1 = line.find("j") pos2 = line.find(";") strippedName = line[pos1:pos2] print("mapVarsInt[\"%s\"] = %s;" %(strippedName,strippedName)) elif line.find("Float_t MET") != -1: pos1 = line.find("M") pos2 = line.find(";") strippedName = line[pos1:pos2] print("mapVarsFloat[\"%s\"] = %s;" %(strippedName,strippedName)) elif line.find("vector") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print ("mapVarsVectorDouble[\"%s\"] = %s;" %(strippedName,strippedName)) elif line.find("Bool_t ") != -1: pos1 = line.find("_") pos2 = line.find(";") strippedName = line[pos1+12:pos2] print ("mapVarsBool[\"%s\"] = &%s;" %(strippedName,strippedName)) elif line.find("vector >") != -1: pos1 = line.find("*") pos2 = line.find(";") strippedName = line[pos1+1:pos2] print("mapVarsVectorVectorString[\"%s\"] = %s;"%(strippedName,strippedName)) else: return def PrintHeader(): print("#include \"Background.h\"") print("\nvoid Background::LoadVarsMap(){") def PrintTail(): print("}\n") ################################## startReading=False PrintHeader() for line in open("Background.h"): if startReading and line.find("//--") != -1: startReading=False elif not startReading and line.find("//--") != -1: startReading=True if startReading: if not "//" in line: ParseOneLine(line) PrintTail()