5 from array
import array
6 from copy
import deepcopy
14 for dir
in os.environ[
'CMSSW_SEARCH_PATH'].
split(
":"):
15 if os.path.exists(os.path.join(dir,rfile)):
return os.path.join(dir,rfile)
19 inputFileName =
"DQM.root" 20 outputFileName =
"DQMTree.root" 22 detIDsFileName =
getFileInPath(
'DQM/SiStripMonitorClient/data/detids.dat')
30 currPath = (dir.GetPath().
split(
":/"))[1]
32 for obj
in dir.GetListOfKeys():
33 if not obj.IsFolder():
34 if obj.ReadObjectAny(TClass.GetClass(
"TH2")):
35 th2 = deepcopy(obj.ReadObj())
37 if 6 < th2.GetNbinsX() < 10
and name.find(
"per") != -1
and name.find(
"Lumisection") == -1:
38 print(
''.
join([dir.GetPath(),
'/', name]))
43 if currPath.startswith(i):
47 th2.SetName(prefix + th2.GetName())
48 self.listOfNumHistograms.append(th2)
53 if isXlowerThanZero
and isYlowerThanZero:
55 if isXlowerThanZero
and isYlowerThanZero ==
False:
57 if isXlowerThanZero ==
False and isYlowerThanZero:
59 if isXlowerThanZero ==
False and isYlowerThanZero ==
False:
63 theLadder =
abs(signedLadder)
64 theModule =
abs(signedModule)
104 shortLadder = theLadder - 5 * i
105 for i
in range(0, shortLadder, 2):
110 for i
in range(2, theLadder, 3):
115 sector = (theLadder + 3) // 4
119 thePart = self.
__GetPartStr(signedModule < 0, signedLadder < 0)
121 return "BPix_B" + thePart +
"_SEC" + theSector +
"_LYR" +
str(layer) +
"_LDR" +
str(
abs(signedLadder)) +
"F_MOD" +
str(
abs(signedModule))
124 thePart = self.
__GetPartStr(signedDisk < 0, signedBlade < 0)
125 return "FPix_B" + thePart +
"_D" +
str(
abs(signedDisk)) +
"_BLD" +
str(
abs(signedBlade)) +
"_PNL" +
str(panel) +
"_RNG" +
str(ring)
128 currentGroupName =
"" 134 objName = obj.GetName()
135 objNameSplit = objName.split(
"_")
136 objNameCollected =
''.
join(objNameSplit[0:-1])
137 if objNameCollected != currentGroupName:
138 if len(groupOfHists):
139 self.groupedHistograms.append(groupOfHists)
142 currentGroupName = objNameCollected
143 groupOfHists.append(obj)
144 self.groupedHistograms.append(groupOfHists)
147 str =
"struct MyStruct{" 148 str = str +
"Int_t key;" 151 str = str +
"Float_t " + k +
";" 152 leafStr = leafStr +
":" + k +
"/F" 158 def __init__(self, inputDQMName, outputDQMName, modDicName):
163 index = self.inputFileName.find(
'R000')
166 self.
dirs = [
'DQMData/Run %s/PixelPhase1/Run summary/Phase1_MechanicalView' % (runNumber),
167 'DQMData/Run %s/PixelPhase1/Run summary/Tracks' % (runNumber)]
179 if self.inputFile.IsOpen():
182 for dir
in self.
dirs:
188 with open(self.
detIDsFileName,
"r") as detIDs: # create dictionary online -> rawid 190 items = entry.replace(
"\n",
" ").
split(
" ")
191 self.detDict.update({items[1] :
int(items[0])})
193 self.internalData.update({
int(items[0]) : {}})
201 if self.inputFile.IsOpen():
204 name =
''.
join(group[0].GetName().
split(
"_per_")[0])
205 self.availableNames.append(name)
208 nbinsX = obj.GetNbinsX()
209 nbinsY = obj.GetNbinsY()
215 for x
in range(-maxX, maxX + 1):
218 for y
in range(-maxY, maxY + 1, 1):
228 for x
in range(-maxX, maxX + 1):
231 for y
in range(-maxY, maxY + 1):
234 for panel
in range(1, 3):
238 print(
"Unrecognized plot")
240 print(
"Histograms saved to internal data structure")
254 from ROOT
import MyStruct
259 tree = TTree(
"tree",
"readData")
260 tree.Branch(
"b", ms, leafStr)
262 tree.SetBranchAddress(
"b", tree)
265 setattr(ms,
"key", key)
272 self.outputFile.Close()
274 print(
"Data saved as TTree object")
280 tree = TTree(
"tree",
"readData")
282 key =
array(
"i", [0])
283 tree.Branch(
"detid", key,
"detid/i")
288 dat.update({d :
array(
"f", [0])})
289 tree.Branch(d, dat[d], d +
"/F")
299 self.outputFile.Close()
301 print(
"Data saved as TTree object")
316 if self.inputFile.IsOpen():
317 self.inputFile.Close()
320 for i
in range(1, len(sys.argv), 1):
322 inputFileName = sys.argv[i]
326 outputFileName = sys.argv[i]
330 readerObj.ReadHistograms()
331 readerObj.CreateTree2()
def __CreateDummyStructAsStr(self, dicData)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
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)