Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:32

0001 #!/usr/bin/env python3
0002 """
0003 _cosmics_
0004 
0005 Test for Cosmics Scenario implementation
0006 
0007 """
0008 
0009 
0010 import unittest
0011 import FWCore.ParameterSet.Config as cms
0012 from Configuration.DataProcessing.GetScenario import getScenario
0013 
0014 
0015 
0016 def writePSetFile(name, process):
0017     """
0018     _writePSetFile_
0019 
0020     Util to dump the process to a file
0021 
0022     """
0023     handle = open(name, 'w')
0024     handle.write(process.dumpPython())
0025     handle.close()
0026 
0027 
0028 class cosmicsScenarioTest(unittest.TestCase):
0029     """
0030     unittest for cosmics scenario
0031 
0032     """
0033 
0034     def testA(self):
0035         """get the scenario"""
0036         try:
0037             scenario = getScenario("cosmics")
0038         except Exception as ex:
0039             msg = "Failed to get cosmics scenario\n"
0040             msg += str(ex)
0041             self.fail(msg)
0042 
0043 
0044     def testPromptReco(self):
0045         """test promptReco method"""
0046         scenario = getScenario("cosmics")
0047         try:
0048             process = scenario.promptReco("GLOBALTAG::ALL")
0049             writePSetFile("testPromptReco.py", process)
0050         except Exception as ex:
0051             msg = "Failed to create Prompt Reco configuration\n"
0052             msg += "for cosmics Scenario\n"
0053             msg += str(ex)
0054             self.fail(msg)
0055 
0056 
0057     def testExpressProcessing(self):
0058         """ test expressProcessing method"""
0059         scenario = getScenario("cosmics")
0060         try:
0061             process = scenario.expressProcessing("GLOBALTAG::ALL")
0062             writePSetFile("testExpressProcessing.py", process)
0063         except Exception as ex:
0064             msg = "Failed to create Express Processing configuration\n"
0065             msg += "for cosmics Scenario\n"
0066             msg += str(ex)
0067             self.fail(msg)
0068 
0069 
0070     def testAlcaSkim(self):
0071         """ test alcaSkim method"""
0072         scenario = getScenario("cosmics")
0073         try:
0074             process = scenario.alcaSkim(["MuAlCalIsolatedMu"])
0075             writePSetFile("testAlcaReco.py", process)
0076         except Exception as ex:
0077            msg = "Failed to create Alca Skimming configuration\n"
0078            msg += "for cosmics Scenario\n"
0079            msg += str(ex)
0080            self.fail(msg)
0081 
0082 
0083     def testDQMHarvesting(self):
0084         """test dqmHarvesting  method"""
0085         scenario = getScenario("cosmics")
0086         try:
0087             process = scenario.dqmHarvesting("dataset", 123456,
0088                                              "GLOBALTAG::ALL")
0089             writePSetFile("testDQMHarvesting.py", process)
0090         except Exception as ex:
0091             msg = "Failed to create DQM Harvesting configuration "
0092             msg += "for cosmics scenario:\n"
0093             msg += str(ex)
0094             self.fail(msg)
0095 
0096 
0097 if __name__ == '__main__':
0098     unittest.main()