-
Notifications
You must be signed in to change notification settings - Fork 6
5-Nov-2015 revisión #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,67 +1,154 @@ | ||
| import ROOT as ROOT | ||
| from ROOT import * | ||
| import sys | ||
| import getopt | ||
| from DataFormats.FWLite import Events, Handle | ||
| from Muon import Muon | ||
| from readTTree import readTTree | ||
|
|
||
|
|
||
| def main (): | ||
| class Selection(object): | ||
|
|
||
| # Max and min variables | ||
| def __init__(self,pt_min,eta_max,distance,dB_max,isolation,mass_min,normChi2_max,numValidHits ): | ||
| #Otros posibles constructores eleigiendo el numero de cortes y en cuales variables."Seian Muchos" | ||
| self.pt_min = pt_min | ||
| self.eta_max = eta_max | ||
| self.distance = distance | ||
| self.dB_max = dB_max | ||
| self.normChi2_max = normChi2_max | ||
| self.isolation = isolation | ||
| #dimensionless. (sumPt+emEnergy+hadEnergy)/muon.pt = maxima energia antes de considerarlo como un jet de particulas. | ||
| self.mass_min = mass_min | ||
| self.numValidHits = numValidHits | ||
|
|
||
| pt_min = 12 | ||
| eta_max = 2.4 | ||
| distance = 0.2 | ||
| dB_max = 0.02 # cm. dB=impact parameter | ||
| #normChi2_max = 10 | ||
| isolation = 0.15 | ||
| #dimensionless. (sumPt+emEnergy+hadEnergy)/muon.pt = maxima energia antes de considerarlo como un jet de particulas. | ||
| mass_min = 60 | ||
| chi2 = 10 | ||
| numValidHits = 10 | ||
| self.good_muons = [] | ||
| self.mass=[] | ||
| self.pt_1=[] | ||
| self.pt_2=[] | ||
|
|
||
| # Good muons list | ||
| good_muons = [] | ||
|
|
||
| #####self read y self muons???????########Tambien puedo llamar a esta clase y su metodo desde el script principal(donde este el main, no??? | ||
| read=readTTree() | ||
| muons=read.process() | ||
|
|
||
| bin=[] | ||
|
|
||
| self.bin=[0]*10 | ||
| self.bin[0]=len(muons) | ||
|
|
||
| # Histograms for good muons variables | ||
| h_pt = ROOT.TH1F('g_pt', 'good_pt', 50, -2, 300) | ||
|
|
||
| self.G_pt = ROOT.TH1F('g_pt', 'Transverse Momentum good Muons', 50, -2, 300) | ||
| self.G_eta=ROOT.TH1F( 'g_eta', 'Angle Transverse good Muons', 50, -50 , 50 ) | ||
|
|
||
|
|
||
| for iMuon in range(0, len(muons)): | ||
| #muons[iMuon].printMuon() | ||
| # Good muons list | ||
| if selector(muons[iMuon], pt_min): | ||
| #muons[iMuon].printMuon() | ||
| good_muons.append(muons[iMuon]) | ||
| h_pt.Fill(muons[iMuon].getPt()) | ||
| # Print elements of good_muons | ||
| # The selector function evaluates if the inner muon is GlobalMuon and TrackerMuon returning a boolean type before starting the selection for the different variables cuts. | ||
| if selector(muons[iMuon],self.pt_min,self.eta_max,self.distance,self.dB_max,self.isolation,self.normChi2_max,self.numValidHits ): | ||
| #append this muon to the good muons list. | ||
| self.good_muons.append(muons[iMuon]) | ||
|
|
||
| self.G_pt.Fill(muons[iMuon].getPt()) | ||
| self.G_eta.Fill(muons[iMuon].getEta()) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lo raro es que no te de un error de indexación en esta y la siguiente línea |
||
|
|
||
| self.Ghistos = ROOT.TFile("Ghistos.root", "RECREATE") | ||
| self.G_pt.Write() | ||
| self.G_eta.Write() | ||
| self.Ghistos.Close() | ||
|
|
||
| ######??????????meter los histogramas en el bucle de good muos y comentar. | ||
|
|
||
| for i in range (0,len(self.good_muons)): | ||
| j=i | ||
| self.good_muons[i].getEvent() | ||
| while self.good_muons[j+1].getEvent()== self.good_muons[j].getEvent(): | ||
| if (self.good_muons[j].getCharge()*self.good_muons[j+1].getCharge())<0: | ||
| #get its Lorentz vector through a ROOT function | ||
|
|
||
| tlv1=ROOT.TLorentzVector() | ||
| tlv1.SetPxPyPzE(self.good_muons[j].getPx(), self.good_muons[j].getPy(), self.good_muons[j].getPz(), self.good_muons[j].getEnergy()) | ||
| tlv2=ROOT.TLorentzVector() | ||
| tlv2.SetPxPyPzE(self.good_muons[j+1].getPx(), self.good_muons[j+1].getPy(), self.good_muons[j+1].getPz(), self.good_muons[j+1].getEnergy()) | ||
|
|
||
| #self.pt_1.append(self.good_muons[i].getPt()) | ||
| #self.pt_2.append(self.good_muons[i+1].getPt()) | ||
| mass=(tlv1+tlv2).M() | ||
| if self.mass_min<mass<120: | ||
| self.mass.append(mass) | ||
| j=j+1 | ||
|
|
||
|
|
||
| # Print elements of good_muons | ||
| #for jMuon in range (0, len(good_muons)): | ||
| # good_muons[jMuon].printMuon() | ||
|
|
||
| fhistosGood= ROOT.TFile("histos_good.root", "RECREATE") | ||
| def addBin(i): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. te falta pasarle self como argumento |
||
| bin[i]=+1 | ||
| return bin[i] | ||
|
|
||
|
|
||
| h_pt.Write() | ||
|
|
||
| fhistosGood.Close() | ||
|
|
||
| def selector(muon,pt_min): | ||
|
|
||
| def selector(muon,pt_min,eta_max,distance,dB_max,isolation,normChi2_max,numValidHits): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lo mismo que el anterior: self como argumento |
||
|
|
||
| i=0 | ||
| # Minimum transverse momentum (pt) and maximum eta angle | ||
| if muon.getPt() > pt_min : | ||
|
|
||
| if muon.getIsGlobalMuon(): | ||
|
|
||
| i=+1 | ||
| self.bin.addBin(i) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no está bien, bin es una lista y no puede llamar al método addBin de la clase. bin pasado como parámetro a la función selector y addbin (o directamente quitar esta últimafunción) lo veo mejor ;) |
||
| return True | ||
|
|
||
| if muon.getIsTrackerMuon(): | ||
|
|
||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
|
|
||
| if muon.getPt() >self.pt_min: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No hace falta poner self.pt_min ya que es la variable que le pasas como parámetro |
||
|
|
||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
| if muon.getEta()< self.eta_max: | ||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
| return False | ||
| if muon.getdB()< self.dB_max: | ||
|
|
||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
|
|
||
| if ((muon.getIsolation_sumPt+getIsolation_emEt()+getIsolation_hadEt)/muon.getPt())<self.isolation: | ||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
|
|
||
| if abs(muon.getvertex_z()-muon.getVertex_Z())< self.distance: | ||
|
|
||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
| if muon.getNormChi2()<self.normChi2_max: | ||
|
|
||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
| if muon.getNumberOfValidHits()>self.numValidHits: | ||
|
|
||
| i=+1 | ||
| self.bin.addBin(i) | ||
| return True | ||
|
|
||
| #Last bin for the efficiency.Just the number of good muons. | ||
| i=+1 | ||
| self.bin.addBin(i) | ||
|
|
||
| return True | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Si los cortes no los pasa retornará false no? Porque sino siempre te diría que el Muon es selected! |
||
|
|
||
| def addBin(i): | ||
| bin[i]=0 | ||
|
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chorrada: Pero es good poner aquí un printMuon() para el debug que en mi codigo lo dejo y no lo quito :P