def readCmdLine(self, parsed): # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear( parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(parsed.maxRecordNumber) self._marlin.setInputFiles( self._extractFileList(parsed.lcioMuonFile, "slcio")) self._marlin.setProcessorParameter(self._pfoAnalysisProcessor, "RootFile", self._pfoOutputFile) self._muonEnergy = parsed.muonEnergy
def readCmdLine(self, parsed): # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear(parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(parsed.maxRecordNumber) self._marlin.setInputFiles(self._extractFileList(parsed.lcioPhotonFile, "slcio")) self._maxNIterations = int(parsed.maxNIterations) self._energyScaleAccuracy = float(parsed.ecalCalibrationAccuracy) self._inputMinCosThetaBarrel, self._inputMaxCosThetaBarrel = self._getGeometry().getEcalBarrelCosThetaRange() self._inputMinCosThetaEndcap, self._inputMaxCosThetaEndcap = self._getGeometry().getEcalEndcapCosThetaRange() self._photonEnergy = parsed.photonEnergy
def readCmdLine(self, parsed) : # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear(parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(parsed.maxRecordNumber) self._marlin.setInputFiles(self._extractFileList(parsed.lcioPhotonFile, "slcio")) self._maxNIterations = int(parsed.maxNIterations) self._energyScaleAccuracy = float(parsed.ecalCalibrationAccuracy) self._photonEnergy = parsed.photonEnergy # setup pandora settings pandora = PandoraXML(parsed.pandoraSettings) pandora.setRemoveEnergyCorrections(True) newPandoraSettings = pandora.generateNewXmlFile() self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "PandoraSettingsXmlFile", newPandoraSettings)
def readCmdLine(self, parsed) : # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear(parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(int(parsed.maxRecordNumber)) self._marlin.setInputFiles(self._extractFileList(parsed.lcioKaon0LFile, "slcio")) self._maxNIterations = int(parsed.maxNIterations) self._energyScaleAccuracy = float(parsed.hcalCalibrationAccuracy) if self._runRingCalibration: self._inputHcalRingGeometryFactor = self._getGeometry().getHcalGeometryFactor() self._inputMinCosThetaBarrel, self._inputMaxCosThetaBarrel = self._getGeometry().getHcalBarrelCosThetaRange() self._inputMinCosThetaEndcap, self._inputMaxCosThetaEndcap = self._getGeometry().getHcalEndcapCosThetaRange() self._kaon0LEnergy = parsed.kaon0LEnergy
class HcalEnergyStep(CalibrationStep): def __init__(self): CalibrationStep.__init__(self, "HcalEnergy") self._marlin = None self._maxNIterations = 5 self._energyScaleAccuracy = 0.01 self._kaon0LEnergy = 0 self._inputHcalRingGeometryFactor = None self._inputMinCosThetaBarrel = None self._inputMaxCosThetaBarrel = None self._inputMinCosThetaEndcap = None self._inputMaxCosThetaEndcap = None # step output self._outputHcalBarrelFactors = None self._outputHcalEndcapFactors = None self._outputHcalRingFactors = None self._runRingCalibration = True # command line requirement self._requireSteeringFile() self._requireCompactFile() self._requireIterations() self._requireKaon0LFile() self._requireHCalAccuracy() """ Whether to run the hcal ring calibration """ def setRunHcalRingCalibration(self, runRingCalib): self._runRingCalibration = runRingCalib """ Should return the current list of hcal barrel energy factors from marlin xml file """ def hcalBarrelEnergyFactors(self): return [] """ Should return the current list of hcal barrel energy factors from marlin xml file """ def hcalEndcapEnergyFactors(self): return [] """ Get the hcal endcap mip """ def hcalEndcapMip(self): pass """ Get the hcal ring mip """ def hcalRingMip(self): pass """ Should set the current list of hcal barrel/endcap energy factors into marlin xml file """ def setEnergyFactors(self, barrelFactors, endcapFactors): pass def description(self): return "Calculate the constants related to the energy deposit in a hcal cell (unit GeV). Outputs the hcalBarrelFactor, hcalEndcapFactor and hcalRingFactor values" def readCmdLine(self, parsed): # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear( parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(int(parsed.maxRecordNumber)) self._marlin.setInputFiles( self._extractFileList(parsed.lcioKaon0LFile, "slcio")) self._maxNIterations = int(parsed.maxNIterations) self._energyScaleAccuracy = float(parsed.hcalCalibrationAccuracy) if self._runRingCalibration: self._inputHcalRingGeometryFactor = self._getGeometry( ).getHcalGeometryFactor() self._inputMinCosThetaBarrel, self._inputMaxCosThetaBarrel = self._getGeometry( ).getHcalBarrelCosThetaRange() self._inputMinCosThetaEndcap, self._inputMaxCosThetaEndcap = self._getGeometry( ).getHcalEndcapCosThetaRange() self._kaon0LEnergy = parsed.kaon0LEnergy def init(self, config): self._cleanupElement(config) self._marlin.loadInputParameters(config) self._loadStepOutputs(config) if len(self._runProcessors): self._marlin.turnOffProcessorsExcept(self._runProcessors) def run(self, config): # loop variables barrelCurrentPrecision = 0. endcapCurrentPrecision = 0. barrelRescaleFactor = 1. endcapRescaleFactor = 1. barrelRescaleFactorCumul = 1. endcapRescaleFactorCumul = 1. barrelAccuracyReached = False endcapAccuracyReached = False hcalBarrelFactors = self.hcalBarrelEnergyFactors() hcalEndcapFactors = self.hcalEndcapEnergyFactors() pfoAnalysisFile = "" hcalEnergyCalibrator = HcalCalibrator() hcalEnergyCalibrator.setKaon0LEnergy(self._kaon0LEnergy) for iteration in range(self._maxNIterations): # readjust iteration parameters if not barrelAccuracyReached: for index in range(len(hcalBarrelFactors)): hcalBarrelFactors[ index] = hcalBarrelFactors[index] * barrelRescaleFactor if not endcapAccuracyReached: for index in range(len(hcalEndcapFactors)): hcalEndcapFactors[ index] = hcalEndcapFactors[index] * endcapRescaleFactor pfoAnalysisFile = "./PfoAnalysis_{0}_iter{1}.root".format( self._name, iteration) # run marlin ... self.setEnergyFactors(hcalBarrelFactors, hcalEndcapFactors) self._marlin.setProcessorParameter(self._pfoAnalysisProcessor, "RootFile", pfoAnalysisFile) self._marlin.setProcessorParameter("MyPfoAnalysis", "RootFile", pfoAnalysisFile) self._marlin.run() # run calibration for barrel if not barrelAccuracyReached: hcalEnergyCalibrator.setRootFile(pfoAnalysisFile) hcalEnergyCalibrator.setDetectorRegion("Barrel") hcalEnergyCalibrator.setCosThetaRange( self._inputMinCosThetaBarrel, self._inputMaxCosThetaBarrel) hcalEnergyCalibrator.run() newBarrelKaon0LEnergy = hcalEnergyCalibrator.getHcalDigiMean() barrelRescaleFactor = float( self._kaon0LEnergy) / newBarrelKaon0LEnergy barrelRescaleFactorCumul = barrelRescaleFactorCumul * barrelRescaleFactor barrelCurrentPrecision = abs(1 - 1. / barrelRescaleFactor) # run calibration for endcap if not endcapAccuracyReached: hcalEnergyCalibrator.setRootFile(pfoAnalysisFile) hcalEnergyCalibrator.setDetectorRegion("EndCap") hcalEnergyCalibrator.setCosThetaRange( self._inputMinCosThetaEndcap, self._inputMaxCosThetaEndcap) hcalEnergyCalibrator.run() newEndcapKaon0LEnergy = hcalEnergyCalibrator.getHcalDigiMean() endcapRescaleFactor = float( self._kaon0LEnergy) / newEndcapKaon0LEnergy endcapRescaleFactorCumul = endcapRescaleFactorCumul * endcapRescaleFactor endcapCurrentPrecision = abs(1 - 1. / endcapRescaleFactor) self._logger.info("=============================================") self._logger.info( "======= Barrel output for iteration {0} =======".format( iteration)) self._logger.info(" => calibrationFactors : {0}".format(", ".join( map(str, hcalBarrelFactors)))) self._logger.info(" => calibrationRescaleFactor : " + str(barrelRescaleFactor)) self._logger.info(" => calibrationRescaleFactorCumul : " + str(barrelRescaleFactorCumul)) self._logger.info(" => currentPrecision : " + str(barrelCurrentPrecision)) self._logger.info(" => newKaon0LEnergy : " + str(newBarrelKaon0LEnergy)) self._logger.info("=============================================") self._logger.info("") self._logger.info("=============================================") self._logger.info( "======= Endcap output for iteration {0} =======".format( iteration)) self._logger.info(" => calibrationFactors : {0}".format(", ".join( map(str, hcalEndcapFactors)))) self._logger.info(" => calibrationRescaleFactor : " + str(endcapRescaleFactor)) self._logger.info(" => calibrationRescaleFactorCumul : " + str(endcapRescaleFactorCumul)) self._logger.info(" => currentPrecision : " + str(endcapCurrentPrecision)) self._logger.info(" => newKaon0LEnergy : " + str(newEndcapKaon0LEnergy)) self._logger.info("=============================================") # write down iteration results self._writeIterationOutput( config, iteration, { "barrelPrecision": barrelCurrentPrecision, "barrelRescale": barrelRescaleFactor, "barrelRescale": barrelRescaleFactor, "newBarrelKaon0LEnergy": newBarrelKaon0LEnergy, "endcapPrecision": endcapCurrentPrecision, "endcapRescale": endcapRescaleFactor, "newEndcapKaon0LEnergy": newEndcapKaon0LEnergy }) # are we accurate enough ?? if barrelCurrentPrecision < self._energyScaleAccuracy and not barrelAccuracyReached: barrelAccuracyReached = True self._outputHcalBarrelFactors = hcalBarrelFactors # are we accurate enough ?? if endcapCurrentPrecision < self._energyScaleAccuracy and not endcapAccuracyReached: endcapAccuracyReached = True self._outputHcalEndcapFactors = hcalEndcapFactors if barrelAccuracyReached and endcapAccuracyReached: break if not barrelAccuracyReached or not endcapAccuracyReached: raise RuntimeError( "{0}: Couldn't reach the user accuracy ({1})".format( self._name, self._energyScaleAccuracy)) if self._runRingCalibration: hcalRingCalibrator = HcalRingCalibrator() hcalRingCalibrator.setRootFile(pfoAnalysisFile) hcalRingCalibrator.setKaon0LEnergy(self._kaon0LEnergy) hcalRingCalibrator.run() directionCorrectionEndcap = hcalRingCalibrator.getEndcapMeanDirectionCorrection( ) directionCorrectionRing = hcalRingCalibrator.getRingMeanDirectionCorrection( ) directionCorrectionRatio = directionCorrectionEndcap / directionCorrectionRing # compute hcal ring factor mipRatio = self.hcalEndcapMip() / self.hcalRingMip() self._outputHcalRingFactors = [ directionCorrectionRatio * mipRatio * factor * self._inputHcalRingGeometryFactor for factor in self._outputHcalEndcapFactors ] self._logger.info( "===============================================") self._logger.info( "==== Hcal ring output after all iterations ====") self._logger.info(" => ring calib factor : {0}".format(", ".join( map(str, self._outputHcalRingFactors)))) self._logger.info( "===============================================") """ Write output (must be reimplemented) """ def writeOutput(self, config): raise RuntimeError( "HcalEnergyStep.writeOutput: method not implemented !")
class PandoraEMScaleStep(CalibrationStep): def __init__(self): CalibrationStep.__init__(self, "PandoraEMScale") self._marlin = None self._maxNIterations = 5 self._energyScaleAccuracy = 0.01 self._photonEnergy = 0 # step input self._inputEcalToEMGeV = None self._inputHcalToEMGeV = None # step output self._outputEcalToEMGeV = None self._outputHcalToEMGeV = None # command line requirement self._requireSteeringFile() self._requireCompactFile() self._requireIterations() self._requirePhotonFile() self._requireECalAccuracy() def description(self): return "Calibrate the electromagnetic scale of the ecal and the hcal. Outputs the constants ECalToEMGeVCalibration and HCalToEMGeVCalibration" def readCmdLine(self, parsed): # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear( parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(parsed.maxRecordNumber) self._marlin.setInputFiles( self._extractFileList(parsed.lcioPhotonFile, "slcio")) self._maxNIterations = int(parsed.maxNIterations) self._energyScaleAccuracy = float(parsed.ecalCalibrationAccuracy) self._photonEnergy = parsed.photonEnergy # setup pandora settings pandoraSettings = self._marlin.getProcessorParameter( self._marlinPandoraProcessor, "PandoraSettingsXmlFile") pandora = PandoraXML(pandoraSettings) pandora.setRemoveEnergyCorrections(True) newPandoraSettings = pandora.generateNewXmlFile() self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "PandoraSettingsXmlFile", newPandoraSettings) def init(self, config): self._cleanupElement(config) self._marlin.loadInputParameters(config) self._loadStepOutputs(config) if len(self._runProcessors): self._marlin.turnOffProcessorsExcept(self._runProcessors) self._inputEcalToEMGeV = float( self._marlin.getProcessorParameter(self._marlinPandoraProcessor, "ECalToEMGeVCalibration")) self._inputHcalToEMGeV = float( self._marlin.getProcessorParameter(self._marlinPandoraProcessor, "HCalToEMGeVCalibration")) def run(self, config): # loop variables currentPrecision = 0. calibrationRescaleFactor = 1. calibrationRescaleFactorCumul = 1. accuracyReached = False ecalToEMGeV = self._inputEcalToEMGeV hcalToEMGeV = self._inputHcalToEMGeV emScaleCalibrator = PandoraEMScaleCalibrator() emScaleCalibrator.setPhotonEnergy(self._photonEnergy) for iteration in range(self._maxNIterations): # readjust iteration parameters ecalToEMGeV = ecalToEMGeV * calibrationRescaleFactor hcalToEMGeV = hcalToEMGeV * calibrationRescaleFactor pfoAnalysisFile = "./PfoAnalysis_{0}_iter{1}.root".format( self._name, iteration) # run marlin ... self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "ECalToEMGeVCalibration", str(ecalToEMGeV)) self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "HCalToEMGeVCalibration", str(hcalToEMGeV)) self._marlin.setProcessorParameter(self._pfoAnalysisProcessor, "RootFile", pfoAnalysisFile) self._marlin.run() # ... and calibration script emScaleCalibrator.setRootFile(pfoAnalysisFile) emScaleCalibrator.setPhotonEnergy(self._photonEnergy) emScaleCalibrator.run() newPhotonEnergy = emScaleCalibrator.getEcalToEMMean() calibrationRescaleFactor = float( self._photonEnergy) / newPhotonEnergy calibrationRescaleFactorCumul = calibrationRescaleFactorCumul * calibrationRescaleFactor currentPrecision = abs(1 - 1. / calibrationRescaleFactor) # write down iteration results self._writeIterationOutput( config, iteration, { "precision": currentPrecision, "rescale": calibrationRescaleFactor, "newPhotonEnergy": newPhotonEnergy }) # are we accurate enough ?? if currentPrecision < self._energyScaleAccuracy: print "{0}: ecal energy accuracy reached !".format(self._name) accuracyReached = True self._outputEcalToEMGeV = ecalToEMGeV self._outputHcalToEMGeV = hcalToEMGeV break if not accuracyReached: raise RuntimeError( "{0}: Couldn't reach the user accuracy ({1})".format( self._name, self._energyScaleAccuracy)) def writeOutput(self, config): output = self._getXMLStepOutput(config, create=True) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "ECalToEMGeVCalibration", self._outputEcalToEMGeV) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "HCalToEMGeVCalibration", self._outputHcalToEMGeV)
class PandoraHadScaleStep(CalibrationStep) : def __init__(self) : CalibrationStep.__init__(self, "PandoraHadScale") self._marlin = None self._hadScaleCalibrator = None self._maxNIterations = 5 self._ecalEnergyScaleAccuracy = 0.01 self._hcalEnergyScaleAccuracy = 0.01 self._kaon0LEnergy = 0 # step input self._inputEcalToHadGeVBarrel = None self._inputEcalToHadGeVEndcap = None self._inputHcalToHadGeV = None # step output self._outputEcalToHadGeVBarrel = None self._outputEcalToHadGeVEndcap = None self._outputHcalToHadGeV = None # command line requirement self._requireSteeringFile() self._requireCompactFile() self._requireIterations() self._requireKaon0LFile() self._requireHCalAccuracy() self._requireECalAccuracy() def description(self): return "Calibrate the hadronic scale of the ecal and the hcal. Outputs the constants ECalToHadGeVCalibrationBarrel, ECalToHadGeVCalibrationEndCap and HCalToHadGeVCalibration" def readCmdLine(self, parsed) : # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear(parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(parsed.maxRecordNumber) self._marlin.setInputFiles(self._extractFileList(parsed.lcioKaon0LFile, "slcio")) self._maxNIterations = int(parsed.maxNIterations) self._ecalEnergyScaleAccuracy = float(parsed.ecalCalibrationAccuracy) self._hcalEnergyScaleAccuracy = float(parsed.hcalCalibrationAccuracy) self._kaon0LEnergy = parsed.kaon0LEnergy # setup pandora settings pandoraSettings = self._marlin.getProcessorParameter(self._marlinPandoraProcessor, "PandoraSettingsXmlFile") pandora = PandoraXML(pandoraSettings) pandora.setRemoveEnergyCorrections(True) newPandoraSettings = pandora.generateNewXmlFile() self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "PandoraSettingsXmlFile", newPandoraSettings) def init(self, config) : self._cleanupElement(config) self._marlin.loadInputParameters(config) self._loadStepOutputs(config) if len(self._runProcessors): self._marlin.turnOffProcessorsExcept(self._runProcessors) def run(self, config) : # loop variables currentEcalPrecision = 0. currentHcalPrecision = 0. ecalRescaleFactor = 1. hcalRescaleFactor = 1. ecalRescaleFactorCumul = 1. hcalRescaleFactorCumul = 1. ecalAccuracyReached = False hcalAccuracyReached = False ecalToHadGeVBarrel = float(self._marlin.getProcessorParameter(self._marlinPandoraProcessor, "ECalToHadGeVCalibrationBarrel")) ecalToHadGeVEndcap = float(self._marlin.getProcessorParameter(self._marlinPandoraProcessor, "ECalToHadGeVCalibrationEndCap")) hcalToHadGeV = float(self._marlin.getProcessorParameter(self._marlinPandoraProcessor, "HCalToHadGeVCalibration")) hadScaleCalibrator = PandoraHadScaleCalibrator() hadScaleCalibrator.setKaon0LEnergy(self._kaon0LEnergy) for iteration in range(self._maxNIterations) : # readjust iteration parameters if not ecalAccuracyReached: ecalToHadGeVBarrel = ecalToHadGeVBarrel*ecalRescaleFactor ecalToHadGeVEndcap = ecalToHadGeVEndcap*ecalRescaleFactor if not hcalAccuracyReached: hcalToHadGeV = hcalToHadGeV*hcalRescaleFactor pfoAnalysisFile = "./PfoAnalysis_{0}_iter{1}.root".format(self._name, iteration) # run marlin ... self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "ECalToHadGeVCalibrationBarrel", str(ecalToHadGeVBarrel)) self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "ECalToHadGeVCalibrationEndCap", str(ecalToHadGeVEndcap)) self._marlin.setProcessorParameter(self._marlinPandoraProcessor, "HCalToHadGeVCalibration", str(hcalToHadGeV)) self._marlin.setProcessorParameter(self._pfoAnalysisProcessor , "RootFile", pfoAnalysisFile) self._marlin.run() # ... and calibration script hadScaleCalibrator.setRootFile(pfoAnalysisFile) hadScaleCalibrator.run() if not ecalAccuracyReached : newEcalKaon0LEnergy = hadScaleCalibrator.getEcalToHad() ecalRescaleFactor = float(self._kaon0LEnergy) / newEcalKaon0LEnergy ecalRescaleFactorCumul = ecalRescaleFactorCumul*ecalRescaleFactor currentEcalPrecision = abs(1 - 1. / ecalRescaleFactor) if not hcalAccuracyReached : newHcalKaon0LEnergy = hadScaleCalibrator.getHcalToHad() hcalRescaleFactor = float(self._kaon0LEnergy) / newHcalKaon0LEnergy hcalRescaleFactorCumul = hcalRescaleFactorCumul*hcalRescaleFactor currentHcalPrecision = abs(1 - 1. / hcalRescaleFactor) # write down iteration results self._writeIterationOutput(config, iteration, {"ecalPrecision" : currentEcalPrecision, "ecalRescale" : ecalRescaleFactor, "newEcalKaon0LEnergy" : newEcalKaon0LEnergy, "hcalPrecision" : currentHcalPrecision, "hcalRescale" : hcalRescaleFactor, "newHcalKaon0LEnergy" : newHcalKaon0LEnergy}) # are we accurate enough ?? if currentEcalPrecision < self._ecalEnergyScaleAccuracy : ecalAccuracyReached = True self._outputEcalToHadGeVBarrel = ecalToHadGeVBarrel self._outputEcalToHadGeVEndcap = ecalToHadGeVEndcap # are we accurate enough ?? if currentHcalPrecision < self._hcalEnergyScaleAccuracy : hcalAccuracyReached = True self._outputHcalToHadGeV = hcalToHadGeV if ecalAccuracyReached and hcalAccuracyReached : break if not ecalAccuracyReached or not hcalAccuracyReached : raise RuntimeError("{0}: Couldn't reach the user accuracy".format(self._name)) def writeOutput(self, config) : output = self._getXMLStepOutput(config, create=True) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "ECalToHadGeVCalibrationBarrel", self._outputEcalToHadGeVBarrel) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "ECalToHadGeVCalibrationEndCap", self._outputEcalToHadGeVEndcap) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "HCalToHadGeVCalibration", self._outputHcalToHadGeV)
class PandoraMipScaleStep(CalibrationStep): def __init__(self): CalibrationStep.__init__(self, "PandoraMipScale") self._marlin = None self._muonEnergy = 0 self._pfoOutputFile = "./PfoAnalysis_" + self._name + ".root" # step output self._outputEcalToGeVMip = None self._outputHcalToGeVMip = None self._outputMuonToGeVMip = None # command line requirement self._requireSteeringFile() self._requireCompactFile() self._requireMuonFile() def description(self): return "Calculate the EcalToGeVMip, HcalToGeVMip and MuonToGeVMip that correspond to the mean reconstructed energy of mip calorimeter hit in the respective detectors" def readCmdLine(self, parsed): # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear( parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(parsed.maxRecordNumber) self._marlin.setInputFiles( self._extractFileList(parsed.lcioMuonFile, "slcio")) self._marlin.setProcessorParameter(self._pfoAnalysisProcessor, "RootFile", self._pfoOutputFile) self._muonEnergy = parsed.muonEnergy def init(self, config): self._cleanupElement(config) self._marlin.loadInputParameters(config) self._loadStepOutputs(config) if len(self._runProcessors): self._marlin.turnOffProcessorsExcept(self._runProcessors) def run(self, config): self._marlin.run() mipScaleCalibrator = PandoraMipScaleCalibrator() mipScaleCalibrator.setMuonEnergy(self._muonEnergy) mipScaleCalibrator.setRootFile(self._pfoOutputFile) mipScaleCalibrator.run() self._outputEcalToGeVMip = mipScaleCalibrator.getEcalToGeVMip() self._outputHcalToGeVMip = mipScaleCalibrator.getHcalToGeVMip() self._outputMuonToGeVMip = mipScaleCalibrator.getMuonToGeVMip() def writeOutput(self, config): output = self._getXMLStepOutput(config, create=True) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "ECalToMipCalibration", self._outputEcalToGeVMip) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "HCalToMipCalibration", self._outputHcalToGeVMip) self._writeProcessorParameter(output, self._marlinPandoraProcessor, "MuonToMipCalibration", self._outputMuonToGeVMip)
class MipScaleStep(CalibrationStep): def __init__(self): CalibrationStep.__init__(self, "MipScale") self._marlin = None self._pfoOutputFile = "./PfoAnalysis_" + self._name + ".root" self._hcalBarrelMip = 0. self._hcalEndcapMip = 0. self._hcalRingMip = 0. self._ecalMip = 0. self._muonEnergy = 0 # set requirements self._requireMuonFile() self._requireCompactFile() self._requireSteeringFile() """ Get the step description """ def description(self): return "Calculate the mip values from SimCalorimeter collections in the muon lcio file. Outputs ecal mip, hcal barrel mip, hcal endcap mip and hcal ring mip values" """ Read command line parsing """ def readCmdLine(self, parsed): # setup marlin self._marlin = Marlin(parsed.steeringFile) gearFile = self._manager.getGearConverter().convertToGear( parsed.compactFile) self._marlin.setGearFile(gearFile) self._marlin.setCompactFile(parsed.compactFile) self._marlin.setMaxRecordNumber(parsed.maxRecordNumber) self._marlin.setInputFiles( self._extractFileList(parsed.lcioMuonFile, "slcio")) self._marlin.setProcessorParameter(self._pfoAnalysisProcessor, "RootFile", self._pfoOutputFile) self._muonEnergy = parsed.muonEnergy """ Initialize the step """ def init(self, config): self._cleanupElement(config) self._marlin.loadInputParameters(config) self._loadStepOutputs(config) """ Run the calibration step """ def run(self, config): self._marlin.loadInputParameters(config) self._loadStepOutputs(config) if len(self._runProcessors): self._marlin.turnOffProcessorsExcept(self._runProcessors) if len(self._turnoffProcessors): self._marlin.turnOffProcessors(self._turnoffProcessors) self._marlin.run() mipCalibrator = MipCalibrator() mipCalibrator.setRootFile(self._pfoOutputFile) mipCalibrator.setMuonEnergy(self._muonEnergy) mipCalibrator.run() self._hcalBarrelMip = mipCalibrator.getHcalBarrelMip() self._hcalEndcapMip = mipCalibrator.getHcalEndcapMip() self._hcalRingMip = mipCalibrator.getHcalRingMip() self._ecalMip = mipCalibrator.getEcalMip() """ Write step output (must be overriden in daughter classes) """ def writeOutput(self, config): raise RuntimeError( "MipScaleStep.writeOutput: method not implemented !")