-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33880 from mmusich/introduceAlCaHarvestingUnitTest
Introduce AlCaHarvesting / PCLMetadataWriter unit test
- Loading branch information
Showing
7 changed files
with
236 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from __future__ import print_function | ||
import xml.etree.ElementTree as ET | ||
import sys | ||
|
||
## declare all constants here | ||
TARGET_LIST_OF_TAGS=['SiPixelQualityFromDbRcd_other', 'SiPixelQualityFromDbRcd_prompt', 'SiPixelQualityFromDbRcd_stuckTBM', | ||
'SiStripApvGain_pcl', 'SiStripApvGainAAG_pcl', | ||
'SiStripBadStrip_pcl', 'SiPixelAli_pcl'] | ||
TARGET_DQM_FILES=1 | ||
TARGET_DQM_FILENAME='./DQM_V0001_R000325022__Express__PCLTest__ALCAPROMPT.root' | ||
TARGET_DB_FILES=7 | ||
TARGET_DB_FILENAME='sqlite_file:promptCalibConditions.db' | ||
TOTAL_TARGET_FILES=TARGET_DQM_FILES+TARGET_DB_FILES | ||
|
||
#_____________________________________________________ | ||
def parseXML(xmlfile): | ||
|
||
# create element tree object | ||
tree = ET.parse(xmlfile) | ||
|
||
# get root element | ||
root = tree.getroot() | ||
|
||
totAnaEntries=len(root.findall('AnalysisFile')) | ||
|
||
if(totAnaEntries!=TOTAL_TARGET_FILES): | ||
print("ERROR: found a not expected number (",totAnaEntries,") of AnalysisFile entries in the FrameworkJobReport.xml") | ||
return -1 | ||
|
||
listOfInputTags=[] | ||
|
||
countDBfiles=0 | ||
countDQMfiles=0 | ||
|
||
# iterate news items | ||
for item in root.findall('AnalysisFile'): | ||
# iterate child elements of item | ||
for child in item: | ||
if(child.tag == 'FileName'): | ||
if(child.text==TARGET_DB_FILENAME): | ||
countDBfiles+=1 | ||
elif(child.text==TARGET_DQM_FILENAME): | ||
countDQMfiles+=1 | ||
else: | ||
pass | ||
if(child.tag == 'inputtag'): | ||
listOfInputTags.append(child.attrib['Value']) | ||
|
||
if(countDBfiles!=TARGET_DB_FILES): | ||
print("ERROR! Found a not expected number of DB files",countDBfiles) | ||
return -1 | ||
|
||
if(countDQMfiles!=TARGET_DQM_FILES): | ||
print("ERROR! Found a not expected number of DQM files",countDQMfiles) | ||
return -1 | ||
|
||
## That's strict! | ||
if(listOfInputTags!=TARGET_LIST_OF_TAGS): | ||
print("ERROR! This ",[x for x in listOfTags if x not in listOfInputTags]," is the set of different tags") | ||
return -1 | ||
|
||
return 0 | ||
|
||
#_____________________________________________________ | ||
def main(): | ||
try: | ||
f = open("FrameworkJobReport.xml") | ||
except IOError: | ||
print("File not accessible") | ||
sys.exit(1) | ||
|
||
# parse xml file | ||
result = parseXML('FrameworkJobReport.xml') | ||
if(result==0): | ||
print("All is fine with the world!") | ||
sys.exit(0) | ||
else: | ||
print("Parsing the FwkJobReport results in failure!") | ||
sys.exit(1) | ||
|
||
#_____________________________________________________ | ||
if __name__ == "__main__": | ||
|
||
# calling main function | ||
main() |
14 changes: 14 additions & 0 deletions
14
Calibration/TkAlCaRecoProducers/test/testAlCaHarvesting.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#! /bin/bash | ||
|
||
function die { echo $1: status $2 ; exit $2; } | ||
function cleanTheHouse { | ||
rm -fr millepede.* | ||
rm -fr pede* | ||
rm -fr treeFile.root | ||
} | ||
|
||
echo "TESTING Calibration/TkAlCaRecoProducers ..." | ||
cmsRun -e ${LOCAL_TEST_DIR}/testPCLAlCaHarvesting.py || die "Failure running testPCLAlCaHarvesting.py" $? | ||
cleanTheHouse | ||
echo "PARSING Framework Job Report ..." | ||
python ${LOCAL_TEST_DIR}/parseFwkJobReport.py |
3 changes: 3 additions & 0 deletions
3
Calibration/TkAlCaRecoProducers/test/testCalibrationTkAlCaRecoProducers.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "FWCore/Utilities/interface/TestHelper.h" | ||
|
||
RUNTEST() |
123 changes: 123 additions & 0 deletions
123
Calibration/TkAlCaRecoProducers/test/testPCLAlCaHarvesting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
from __future__ import print_function | ||
import calendar | ||
import CondCore.Utilities.conddblib as conddb | ||
|
||
#___________________________________________________________________ | ||
def findRunStopTime(run_number): | ||
con = conddb.connect(url = conddb.make_url("pro")) | ||
session = con.session() | ||
RunInfo = session.get_dbtype(conddb.RunInfo) | ||
bestRun = session.query(RunInfo.run_number,RunInfo.start_time, RunInfo.end_time).filter(RunInfo.run_number >= run_number).first() | ||
if bestRun is None: | ||
raise Exception("Run %s can't be matched with an existing run in the database." % run_number) | ||
|
||
start= bestRun[1] | ||
stop = bestRun[2] | ||
|
||
bestRunStartTime = calendar.timegm( bestRun[1].utctimetuple() ) << 32 | ||
bestRunStopTime = calendar.timegm( bestRun[2].utctimetuple() ) << 32 | ||
|
||
print("run start time:",start,"(",bestRunStartTime,")") | ||
print("run stop time: ",stop,"(",bestRunStopTime,")") | ||
|
||
return bestRunStopTime | ||
|
||
import optparse | ||
parser = optparse.OptionParser(usage = 'Usage: %prog [options] <file> [<file> ...]\n') | ||
parser.add_option('-G', '--inputGT', | ||
dest = 'inputGT', | ||
default = 'auto:run2_data', | ||
help = 'Global Tag to get conditions') | ||
|
||
parser.add_option('-r', '--inputRun', | ||
dest = 'inputRun', | ||
default = 325022, | ||
help = 'run to be used') | ||
|
||
parser.add_option('-t', '--inputTime', | ||
dest = 'inputTime', | ||
default = 6614916085915320320, | ||
help = 'time to be used') | ||
|
||
parser.add_option('-e', '--enableJobReport', | ||
dest = 'empty', | ||
default = None, | ||
help = 'unused') | ||
|
||
(options, arguments) = parser.parse_args() | ||
|
||
import FWCore.ParameterSet.Config as cms | ||
process = cms.Process('ALCAHARVEST') | ||
|
||
# import of standard configurations | ||
process.load('Configuration.StandardSequences.Services_cff') | ||
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') | ||
process.load('FWCore.MessageService.MessageLogger_cfi') | ||
process.load('Configuration.EventContent.EventContent_cff') | ||
process.load('Configuration.StandardSequences.GeometryRecoDB_cff') | ||
process.load('Configuration.StandardSequences.MagneticField_cff') | ||
process.load('Configuration.StandardSequences.AlCaHarvesting_cff') | ||
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') | ||
|
||
## | ||
## configure the source with an random run | ||
## | ||
process.source = cms.Source("EmptySource", | ||
firstRun = cms.untracked.uint32(options.inputRun), | ||
numberEventsInRun = cms.untracked.uint32(1), | ||
numberEventsInLuminosityBlock = cms.untracked.uint32(1), | ||
firstTime = cms.untracked.uint64(options.inputTime), | ||
timeBetweenEvents = cms.untracked.uint64(1) | ||
) | ||
|
||
process.maxEvents = cms.untracked.PSet( | ||
input = cms.untracked.int32(1) | ||
) | ||
|
||
process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiStripQuality_dbOutput) | ||
process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiStripGains_dbOutput) | ||
process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiStripGainsAAG_dbOutput ) | ||
process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiPixelAli_dbOutput) | ||
process.PoolDBOutputService.toPut.extend(process.ALCAHARVESTSiPixelQuality_dbOutput) | ||
|
||
process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiStripQuality_metadata) | ||
process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiStripGains_metadata ) | ||
process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiStripGainsAAG_metadata) | ||
process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiPixelAli_metadata) | ||
process.pclMetadataWriter.recordsToMap.extend(process.ALCAHARVESTSiPixelQuality_metadata) | ||
|
||
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') | ||
from Configuration.AlCa.GlobalTag import GlobalTag | ||
process.GlobalTag = GlobalTag(process.GlobalTag, options.inputGT, '') | ||
|
||
process.SiStripQuality = cms.Path(process.ALCAHARVESTSiStripQuality) | ||
process.alcaSiStripQualityHarvester.CalibrationThreshold = cms.untracked.uint32(0) | ||
|
||
process.SiStripGains = cms.Path(process.ALCAHARVESTSiStripGains) | ||
#process.alcaSiStripGainsHarvester. | ||
|
||
process.SiStripGainsAAG = cms.Path(process.ALCAHARVESTSiStripGainsAAG) | ||
#process.alcaSiStripGainsAAGHarvester. | ||
|
||
process.SiPixelAli = cms.Path(process.ALCAHARVESTSiPixelAli) | ||
|
||
process.SiPixelQuality = cms.Path(process.ALCAHARVESTSiPixelQuality) | ||
|
||
process.ALCAHARVESTDQMSaveAndMetadataWriter = cms.Path(process.dqmSaver+process.pclMetadataWriter) | ||
|
||
process.schedule = cms.Schedule(process.SiStripQuality, | ||
process.SiStripGains, | ||
process.SiStripGainsAAG, | ||
process.SiPixelAli, | ||
process.SiPixelQuality, | ||
process.ALCAHARVESTDQMSaveAndMetadataWriter) | ||
|
||
from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask | ||
associatePatAlgosToolsTask(process) | ||
|
||
# Customisation from command line | ||
|
||
# Add early deletion of temporary data products to reduce peak memory need | ||
from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete | ||
process = customiseEarlyDelete(process) | ||
# End adding early deletion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters