3 from __future__
import print_function
6 from array
import array
7 from copy
import deepcopy
15 for dir
in os.environ[
'CMSSW_SEARCH_PATH'].
split(
":"):
16 if os.path.exists(os.path.join(dir,rfile)):
return os.path.join(dir,rfile)
20 inputFileName =
"DQM.root" 21 outputFileName =
"DQMTree.root" 23 detIDsFileName =
getFileInPath(
'DQM/SiStripMonitorClient/data/detids.dat')
31 currPath = (dir.GetPath().
split(
":/"))[1]
33 for obj
in dir.GetListOfKeys():
34 if not obj.IsFolder():
35 if obj.ReadObjectAny(TClass.GetClass(
"TH2")):
36 th2 = deepcopy(obj.ReadObj())
38 if 6 < th2.GetNbinsX() < 10
and name.find(
"per") != -1
and name.find(
"Lumisection") == -1:
39 print(
''.
join([dir.GetPath(),
'/', name]))
44 if currPath.startswith(i):
48 th2.SetName(prefix + th2.GetName())
49 self.listOfNumHistograms.append(th2)
54 if isXlowerThanZero
and isYlowerThanZero:
56 if isXlowerThanZero
and isYlowerThanZero ==
False:
58 if isXlowerThanZero ==
False and isYlowerThanZero:
60 if isXlowerThanZero ==
False and isYlowerThanZero ==
False:
64 theLadder =
abs(signedLadder)
65 theModule =
abs(signedModule)
105 shortLadder = theLadder - 5 * i
106 for i
in range(0, shortLadder, 2):
111 for i
in range(2, theLadder, 3):
116 sector = (theLadder + 3) // 4
120 thePart = self.
__GetPartStr(signedModule < 0, signedLadder < 0)
122 return "BPix_B" + thePart +
"_SEC" + theSector +
"_LYR" +
str(layer) +
"_LDR" +
str(
abs(signedLadder)) +
"F_MOD" +
str(
abs(signedModule))
125 thePart = self.
__GetPartStr(signedDisk < 0, signedBlade < 0)
126 return "FPix_B" + thePart +
"_D" +
str(
abs(signedDisk)) +
"_BLD" +
str(
abs(signedBlade)) +
"_PNL" +
str(panel) +
"_RNG" +
str(ring)
129 currentGroupName =
"" 135 objName = obj.GetName()
136 objNameSplit = objName.split(
"_")
137 objNameCollected =
''.
join(objNameSplit[0:-1])
138 if objNameCollected != currentGroupName:
139 if len(groupOfHists):
140 self.groupedHistograms.append(groupOfHists)
143 currentGroupName = objNameCollected
144 groupOfHists.append(obj)
145 self.groupedHistograms.append(groupOfHists)
148 str =
"struct MyStruct{" 149 str = str +
"Int_t key;" 152 str = str +
"Float_t " + k +
";" 153 leafStr = leafStr +
":" + k +
"/F" 159 def __init__(self, inputDQMName, outputDQMName, modDicName):
164 index = self.inputFileName.find(
'R000')
167 self.
dirs = [
'DQMData/Run %s/PixelPhase1/Run summary/Phase1_MechanicalView' % (runNumber),
168 'DQMData/Run %s/PixelPhase1/Run summary/Tracks' % (runNumber)]
180 if self.inputFile.IsOpen():
183 for dir
in self.
dirs:
189 with open(self.
detIDsFileName,
"r") as detIDs: # create dictionary online -> rawid 191 items = entry.replace(
"\n",
" ").
split(
" ")
192 self.detDict.update({items[1] :
int(items[0])})
194 self.internalData.update({
int(items[0]) : {}})
202 if self.inputFile.IsOpen():
205 name =
''.
join(group[0].GetName().
split(
"_per_")[0])
206 self.availableNames.append(name)
209 nbinsX = obj.GetNbinsX()
210 nbinsY = obj.GetNbinsY()
216 for x
in range(-maxX, maxX + 1):
219 for y
in range(-maxY, maxY + 1, 1):
229 for x
in range(-maxX, maxX + 1):
232 for y
in range(-maxY, maxY + 1):
235 for panel
in range(1, 3):
239 print(
"Unrecognized plot")
241 print(
"Histograms saved to internal data structure")
255 from ROOT
import MyStruct
260 tree = TTree(
"tree",
"readData")
261 tree.Branch(
"b", ms, leafStr)
263 tree.SetBranchAddress(
"b", tree)
266 setattr(ms,
"key", key)
273 self.outputFile.Close()
275 print(
"Data saved as TTree object")
281 tree = TTree(
"tree",
"readData")
283 key =
array(
"i", [0])
284 tree.Branch(
"detid", key,
"detid/i")
289 dat.update({d :
array(
"f", [0])})
290 tree.Branch(d, dat[d], d +
"/F")
300 self.outputFile.Close()
302 print(
"Data saved as TTree object")
310 print((d, module[d]))
317 if self.inputFile.IsOpen():
318 self.inputFile.Close()
321 for i
in range(1, len(sys.argv), 1):
323 inputFileName = sys.argv[i]
327 outputFileName = sys.argv[i]
331 readerObj.ReadHistograms()
332 readerObj.CreateTree2()
def __CreateDummyStructAsStr(self, dicData)
S & print(S &os, JobReport::InputFile const &f)
def __init__(self, inputDQMName, outputDQMName, modDicName)
Abs< T >::type abs(const T &t)
def __GetBarrelSector(self, layer, signedLadder, signedModule)
def __TraverseDirTree(self, dir)
static std::string join(char **cmd)
def __GetPartStr(self, isXlowerThanZero, isYlowerThanZero)
def __GroupHistograms(self)
def __BuildOnlineDiskName(self, signedDisk, signedBlade, panel, ring)
def __BuildOnlineBarrelName(self, signedModule, signedLadder, layer)