diff --git a/.gitignore b/.gitignore index 37cb604..c60e909 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,15 @@ *.root **/.root -*/**/*.root \ No newline at end of file +*/**/*.root +*.png +**/.png +*/**/*.png +*.pdf +**/.pdf +*/**/*.pdf +*.eps +**/.eps +*/**/*.eps +*.pyc +**/.pyc +*/**/*.pyc diff --git a/tools.py b/tools.py index 367e9f2..80c66b6 100755 --- a/tools.py +++ b/tools.py @@ -264,18 +264,69 @@ y = point.Y() return inEllipse(x,y,a,b) +listOfHitLSSegments = None +numberOfHitLSSegments = None +zstarts = [] +zends = [] +lsNames = [] +nZ, Nphi, nBins = None, None, None +Nphi = 16 +dphi = 2.*math.pi/Nphi +phistart = dphi/2. +nin, zout = None, None +zstepsize = None +# To hold the energy loss listOfSegments = [] +abig = 250. +b = 500. +asmall = 250. -def makeLSsegments(nodes): - zi = -2478 - zo = 3678 - zstepsize = 100 - Nz = int(math.ceil((zi-zo)/zstepsize)) - Nphi = 16 - dphi = 2*math.pi/N - phistart = dphi/2; +def makeLSsegments(nodes, tree): + global zstarts, zends, lsNames, Nz, Nphi, nBins, zin, zout, zstepsize + for node in nodes.keys(): + if 'LiSc' in node: + zstarts.append(nodes[node]['z']['pos']-nodes[node]['z']['dim']) + zends.append(nodes[node]['z']['pos']+nodes[node]['z']['dim']) + lsNames.append(node) + # ATTENTION! there is some superposition in z + # To keep it clean & easy, we will do the segmentation + # as Martin first suggested, i.e. by hands!!! + # It cannot be so bad... + zstarts.sort() + zends.sort() + Nz = len(zstarts) + zin = min(zstarts) + zout = max(zends) + zstepsize = 100. + #Nz = int(math.ceil((zi-zo)/zstepsize)) nBins = Nphi*Nz - SegmentIsHit = [0] * nBins + global listOfHitSegments, numberOfHitLSSegments, listOfSegments + for i in xrange(nBins): + listOfSegments.append(0.) + tree, listOfHitLSSegments = AddVect(tree, 'listOfHitLSSegments', 'int') + tree, numberOfHitLSSegments = AddVar(tree, 'numberOfHitLSSegments', 'int') -def fillSegments(): - pass \ No newline at end of file +def hitSegments(event, nodes): + global listOfHitSegments, numberOfHitLSSegments, listOfSegments + global abig, asmall, b, phistart, dphi, Nphi, nBins + endsmall = nodes['T1Endplate_1']['z']['pos']+nodes['T1Endplate_1']['z']['dim'] + for hit in event.vetoPoint: + z = hit.GetZ() + x = hit.GetX() + y = hit.GetY() + a = abig + if z < endsmall: + a = asmall + phi = ROOT.TMath.ATan2(a*y,b*x)+2*math.pi + zbin = int(math.floor( (z-zin)/zstepsize )) + phibin = int((math.floor( (phi+phistart)/dphi ))%Nphi) + iBin = zbin*Nphi+phibin + listOfSegments[iBin] += hit.GetEnergyLoss() + nHit = 0 + for iBin in xrange(nBins): + if listOfSegments[iBin] > 0.045: + nHit +=1 + Push(listOfHitSegments, iBin) + Push(numberOfHitLSSegments, nHit) + +