ATLAS Offline Software
TileFolders.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2 
3 """Define TileFolders class to keep and return Tile folders"""
4 
6  """Keep Tile folders taking into account whether it is online/offline and MC/Data"""
7 
8  def __init__(self, isMC, isOnline):
9  """Initialize taking into account whether it is online/offline and MC/Data"""
10  self._folders = []
11  self._isMC = isMC
12  self._isOnlineAndNotMC = isOnline and not isMC
13 
14  def add(self, folder, db):
15  """Add and return Tile folder using given db Tile schema"""
16  self._folders.append((folder + '<key>' + folder + '</key>', db, 'CondAttrListCollection'))
17  return folder
18 
19  def addSplitMC(self, folder, folderMC):
20  """Add and return Tile folder, using folder (online) for real data, folderMC (offline) for MC"""
21  actualFolder, db = (folderMC, 'TILE_OFL') if self._isMC else (folder, 'TILE')
22  return self.add(actualFolder, db)
23 
24  def addSplitOnline(self, onlineFolder, oflineFolder):
25  """Add and return Tile folder, using onlineFolder online, oflineFolder offline"""
26  actualFolder, db = (onlineFolder, 'TILE') if self._isOnlineAndNotMC else (oflineFolder, 'TILE_OFL')
27  return self.add(actualFolder, db)
28 
29  def get(self):
30  """Return Tile folders as list of (folder, DB, 'CondAttrListCollection')"""
31  return self._folders
32 
33 
34 
35 import unittest
36 class TestTileFolders( unittest.TestCase ):
37  def test_OfflineData(self):
38  folders = TileFolders(isMC = False, isOnline = False)
39  self.assertEqual(folders.get(), [], 'Initial folders are not empty')
40 
41  self.assertEqual(folders.add('TEST', 'DB'), 'TEST', 'Wrong folder is added')
42  self.assertTrue(('TEST<key>TEST</key>', 'DB', 'CondAttrListCollection') in folders.get(), 'No correct folder')
43 
44  self.assertEqual(folders.addSplitOnline('ONL', 'OFL'), 'OFL', 'Wrong folder is added')
45  self.assertTrue(('OFL<key>OFL</key>', 'TILE_OFL', 'CondAttrListCollection') in folders.get(), 'No correct folder')
46 
47  self.assertEqual(folders.addSplitMC('DATA', 'MC'), 'DATA', 'Wrong folder is added')
48  self.assertTrue(('DATA<key>DATA</key>', 'TILE', 'CondAttrListCollection') in folders.get(), 'No correct folder')
49 
50  self.assertEqual(len(folders.get()), 3, 'Number of added folders is wrong')
51 
52 
53  def test_OfflineMC(self):
54  folders = TileFolders(isMC = True, isOnline = False)
55  self.assertEqual(folders.get(), [], 'Initial folders are not empty')
56 
57  self.assertEqual(folders.add('TEST', 'DB'), 'TEST', 'Wrong folder is added')
58  self.assertTrue(('TEST<key>TEST</key>', 'DB', 'CondAttrListCollection') in folders.get(), 'No correct folder')
59 
60  self.assertEqual(folders.addSplitOnline('ONL', 'OFL'), 'OFL', 'Wrong folder is added')
61  self.assertTrue(('OFL<key>OFL</key>', 'TILE_OFL', 'CondAttrListCollection') in folders.get(), 'No correct folder')
62 
63  self.assertEqual(folders.addSplitMC('DATA', 'MC'), 'MC', 'Wrong folder is added')
64  self.assertTrue(('MC<key>MC</key>', 'TILE_OFL', 'CondAttrListCollection') in folders.get(), 'No correct folder')
65 
66  self.assertEqual(len(folders.get()), 3, 'Number of added folders is wrong')
67 
68 
69  def test_OnlineData(self):
70  folders = TileFolders(isMC = False, isOnline = True)
71  self.assertEqual(folders.get(), [], 'Initial folders are not empty')
72 
73  self.assertEqual(folders.add('TEST', 'DB'), 'TEST', 'Wrong folder is added')
74  self.assertTrue(('TEST<key>TEST</key>', 'DB', 'CondAttrListCollection') in folders.get(), 'No correct folder')
75 
76  self.assertEqual(folders.addSplitOnline('ONL', 'OFL'), 'ONL', 'Wrong folder is added')
77  self.assertTrue(('ONL<key>ONL</key>', 'TILE', 'CondAttrListCollection') in folders.get(), 'No correct folder')
78 
79  self.assertEqual(folders.addSplitMC('DATA', 'MC'), 'DATA', 'Wrong folder is added')
80  self.assertTrue(('DATA<key>DATA</key>', 'TILE', 'CondAttrListCollection') in folders.get(), 'No correct folder')
81 
82  self.assertEqual(len(folders.get()), 3, 'Number of added folders is wrong')
83 
84 
85  def test_OnlineMC(self):
86  folders = TileFolders(isMC = True, isOnline = True)
87  self.assertEqual(folders.get(), [], 'Initial folders are not empty')
88 
89  self.assertEqual(folders.add('TEST', 'DB'), 'TEST', 'Wrong folder is added')
90  self.assertTrue(('TEST<key>TEST</key>', 'DB', 'CondAttrListCollection') in folders.get(), 'No correct folder')
91 
92  self.assertEqual(folders.addSplitOnline('ONL', 'OFL'), 'OFL', 'Wrong folder is added')
93  self.assertTrue(('OFL<key>OFL</key>', 'TILE_OFL', 'CondAttrListCollection') in folders.get(), 'No correct folder')
94 
95  self.assertEqual(folders.addSplitMC('DATA', 'MC'), 'MC', 'Wrong folder is added')
96  self.assertTrue(('MC<key>MC</key>', 'TILE_OFL', 'CondAttrListCollection') in folders.get(), 'No correct folder')
97 
98  self.assertEqual(len(folders.get()), 3, 'Number of added folders is wrong')
99 
100 
101 
102 if __name__ == "__main__":
103  unittest.main()
python.TileFolders.TestTileFolders
Definition: TileFolders.py:36
python.TileFolders.TileFolders.__init__
def __init__(self, isMC, isOnline)
Definition: TileFolders.py:8
python.TileFolders.TileFolders.get
def get(self)
Definition: TileFolders.py:29
python.TileFolders.TestTileFolders.test_OfflineMC
def test_OfflineMC(self)
Definition: TileFolders.py:53
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.TileFolders.TestTileFolders.test_OnlineMC
def test_OnlineMC(self)
Definition: TileFolders.py:85
python.TileFolders.TileFolders.addSplitOnline
def addSplitOnline(self, onlineFolder, oflineFolder)
Definition: TileFolders.py:24
python.TileFolders.TileFolders._isOnlineAndNotMC
_isOnlineAndNotMC
Definition: TileFolders.py:12
python.TileFolders.TestTileFolders.test_OfflineData
def test_OfflineData(self)
Definition: TileFolders.py:37
python.TileFolders.TestTileFolders.test_OnlineData
def test_OnlineData(self)
Definition: TileFolders.py:69
python.TileFolders.TileFolders._isMC
_isMC
Definition: TileFolders.py:11
python.TileFolders.TileFolders
Definition: TileFolders.py:5
pickleTool.object
object
Definition: pickleTool.py:30
python.TileFolders.TileFolders._folders
_folders
Definition: TileFolders.py:10
python.TileFolders.TileFolders.addSplitMC
def addSplitMC(self, folder, folderMC)
Definition: TileFolders.py:19
python.TileFolders.TileFolders.add
def add(self, folder, db)
Definition: TileFolders.py:14