SND@LHC Software
Loading...
Searching...
No Matches
conditionsDatabase.demo.drifttubeMonitoring Namespace Reference

Functions

 pyExit ()
 
 compareAlignment ()
 
 surveyVSfairship ()
 
 checkZtilts ()
 
 dispTrack3D (theTrack)
 
 displayDTLayers ()
 
 addText ()
 
 plotEvent (n=-1)
 
 stationInfo (hit)
 
 DTEfficiencyFudgefactor (method=-1)
 
 MakeKeysToDThits (minToT=-999)
 
 studyLateDTHits (nevents=1000, nStart=0)
 
 nicePrintout (hits)
 
 plotHitMaps (onlyPlotting=False)
 
 hitMapsFromFittedTracks ()
 
 plotHitMapsOld (onlyPlotting=False)
 
 printScalers ()
 
 plotRPCHitmap ()
 
 plotRPCExample ()
 
 plotTimeOverThreshold (N, Debug=False)
 
 materialEffects (switch)
 
 extractMinAndMax ()
 
 extractRTPanda (hname='TDC1000_x')
 
 makeRTrelations ()
 
 RT (hit, t)
 
 checkMCSmearing ()
 
 checkMassOfResonances ()
 
 check4muon (m, debug=False)
 
 minbias ()
 
 originMCmuons ()
 
 yBeam ()
 
 MCJpsiProd (onlyPlotting=False)
 
 extrapolateToPlane (fT, z, cplusplus=True)
 
 displayTrack (theTrack, debug=False)
 
 plotMuonTaggerTrack (muTracks)
 
 findSimpleEvent (event, nmin=2, nmax=6)
 
 fitTracks (nMax=-1, simpleEvents=True, withDisplay=False, nStart=0, debug=False, PR=1, withRT=False, chi2UL=3)
 
 momDisplay ()
 
 bestTracks ()
 
 fitTrack (hitlist, Pstart=3.)
 
 getSlopes (cl1, cl2, view='_x')
 
 testPR (onlyHits=False)
 
 plotTracklets (track_hits)
 
 printClustersPerStation (clusters, s, view)
 
 ghostFraction (aTrack)
 
 findDTClusters (removeBigClusters=True)
 
 findDTClustersDebug1 (n, tmp)
 
 findDTClustersDebug2 (L)
 
 findTracks (PR=1, linearTrackModel=False, withCloneKiller=True)
 
 overlap (a, b)
 
 tuneMCefficiency (tkey)
 
 countMeasurements (aTrack, PR=1)
 
 methodD ()
 
 cloneKiller (trackCandidates)
 
 makeLinearExtrapolations (t1t2, t3t4)
 
 testClusters (nEvent=-1, nTot=1000)
 
 printResiduals (aTrack)
 
 plotBiasedResiduals (nEvent=-1, nTot=1000, PR=11, onlyPlotting=False, minP=3.)
 
 investigateActiveArea ()
 
 plotSigmaRes ()
 
 calculateRTcorrection ()
 
 testConvOfGausses ()
 
 analyzeSingleDT ()
 
 plot2dResiduals (minEntries=-1)
 
 binoEff (n=4, k=2)
 
 DTeffWithRPCTracks (Nevents=0, onlyPlotting=False, fHisto=None)
 
 checkTrackEfficiencyPerSpill ()
 
 efficiencyEstimates (method=2, MCdata=False)
 
 printTrackMeasurements (atrack, PR=1)
 
 debugTrackFit (nEvents, nStart=0, simpleEvents=True, singleTrack=True, PR=1)
 
 plotLinearResiduals ()
 
 mergeHistosForMomResol (withFitPoints=False)
 
 hitResolution ()
 
 checkRPCAcceptance ()
 
 matchedRPCHits (aTrack, maxDistance=10.)
 
 RPCResolution ()
 
 plotRPCExtrap (nEvent=-1, nTot=1000, PR=1, onlyPlotting=False)
 
 debugRPCstrips ()
 
 debugRPCYCoordinate ()
 
 strawPosition ()
 
 RPCPosition ()
 
 correctAlignment (hit)
 
 loopTracks (r, w)
 
 FCN (npar, gin, f, par, iflag)
 
 makeFit ()
 
 debugGeometrie ()
 
 residualLoop (nstart=0, nend=50000)
 
 correctAlignmentRPC (hit, v)
 
 debugRPCposition ()
 
 grouper (iterable, grouping)
 
 muonTaggerClustering (PR=11)
 
 testForSameDetID (nEvent=-1, nTot=1000)
 
 clusterSizesPerLayer (nevents)
 
 studyDeltaRays (onlyPlots=False)
 
 DTreconstructible ()
 
 studyGhosts ()
 
 studyGhostTracks (nStart=0, nEnd=0, chi2UL=3, pxLow=5.)
 
 studyScintillator ()
 
 myVertex (t1, t2, PosDir, xproj=False)
 
 findV0 (nstart=0, nmax=-1, PR=1)
 
 getEvent (n)
 
 makeRTrelPersistent (RTrelations)
 
 makeAlignmentConstantsPersistent ()
 
 importAlignmentConstants ()
 
 importRTrel ()
 
 importRTCorrection ()
 
 analyzeRTrel ()
 
 init (database='muflux_RTrelations.pkl', remake=False, withReco=False)
 
 monitorMasterTrigger ()
 
 disableBranches ()
 
 checkForDiMuon ()
 
 muonOrigin ()
 
 splitOffBoostedEvents ()
 
 plotDTPoints (onlyPlotting=False)
 
 plotFitPoints ()
 
 plotEnergyLoss ()
 
 checkMCEffTuning ()
 
 ghostSuppression (hname="sumHistos--simulation10GeV-withDeadChannels.root")
 
 MCcomparison (pot=-1, pMin=5., pMax=300., ptMax=4., simpleEffCor=0.023, effCor=False, eric=False, version="-repro", withOverFlow=False, withDisplay=True, cuts='', noTitle=False)
 
 synchFigures ()
 
 singlePtSlices ()
 
 printSources ()
 
 MCcomparisonHitmaps (MC='1GeV', first=False)
 
 MCchecks ()
 
 countTracks (analyse=False)
 
 compareRuns (runs=[])
 
 plotTDCExample ()
 
 energyLossRPC ()
 
 plotResidualExample ()
 
 residualsExamples ()
 
 plotEffMethod2Example ()
 
 plotWithRPCTrackEffExample ()
 
 plotRPCResidualsExample ()
 
 plotRPC3Example ()
 
 mergeGoodRuns (excludeRPC=False, path='.', fromEOS=True)
 
 findHighMomEvents ()
 
 fcn (npar, gin, f, par, iflag)
 
 doFit (p0=5.7, p1=0.17)
 
 doFitByHand ()
 
 additionalMomSmearing ()
 
 myPrint (obj, aname)
 
 copyRTRelation ()
 
 recoStep0 ()
 
 recoStep1 (PR=11)
 
 getParOfRTcorrectio ()
 
 recoStep2 ()
 
 recoMuonTaggerTracks ()
 
 anaResiduals ()
 

Variables

 PDG = ROOT.TDatabasePDG.Instance()
 
 timer = ROOT.TStopwatch()
 
 gErrorIgnoreLevel
 
bool zeroField = False
 
bool DAFfitter = True
 
bool withMaterial = True
 
bool MCdata = False
 
float MCsmearing = 0.022
 before RT correction: MCsmearing=0.04 # + 0.027**2 -> 0.05

 
dict cuts = {}
 
 vbot = ROOT.TVector3()
 
 vtop = ROOT.TVector3()
 
dict alignConstants = {}
 
dict h = {}
 
dict log = {}
 
bool debug = False
 
dict views = {1:['_x','_u'],2:['_x','_v'],3:['_x'],4:['_x']}
 
dict viewsI = {1:[0,1],2:[0,2],3:[0],4:[0]}
 
dict viewC = {0:"_x",1:"_u",2:"_v"}
 
dict muSources = {'eta':221,'omega':223,'phi':333,'rho0':113,'eta_prime':331}
 
dict muSourcesIDs = muSources.values()
 
 rnr = ROOT.TRandom()
 
 parser = ArgumentParser()
 
 dest
 
 help
 
 required
 
 default
 
 options = parser.parse_args()
 
list fnames = []
 
 tmp = open(options.listOfFiles)
 
 fname = x.replace('\n','')
 
 f = ROOT.TFile.Open(fname)
 
 sTree = f.cbmsim
 
list rnames = []
 
list rname = rnames[0]
 
 ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py")
 
 fgeo = ROOT.TFile.Open(options.geoFile)
 
 upkl = Unpickler(options.geoFile)
 
 run = ROOT.FairRunSim()
 
 rtdb = run.GetRuntimeDb()
 
 modules = charmDet_conf.configure(run,ShipGeo)
 
 sGeo = ROOT.gGeoManager
 
 nav = sGeo.GetCurrentNavigator()
 
 top = sGeo.GetTopVolume()
 
bool saveGeofile = False
 
dict xpos = {}
 
dict xposb = {}
 
dict ypos = {}
 
dict yposb = {}
 
dict zpos = {}
 
list residuals = [0.]*24
 
dict Nchannels = {1:12,2:12,3:48,4:48}
 
dict survey = {}
 
dict daniel = {}
 
 api_factory = APIFactory()
 
 conditionsDB = api_factory.construct_DB_API()
 
dict Lcorrection = {}
 
dict surveyXYZ = {}
 
dict Langle = {}
 
dict delx = surveyXYZ[s+'01'][0]-surveyXYZ[s+'04'][0]
 
dict dely = surveyXYZ[s+'01'][1]-surveyXYZ[s+'04'][1]
 
 a
 
dict delta = daniel[s+'1'][0]-daniel[s+'2'][0]
 
dict rc = h['lengthCalibration'].Fill(delta-45.2)
 
dict rn = {}
 
 test = ROOT.MufluxSpectrometerHit(10002012,0.)
 
dict deltaZ = zpos['T1X']-(vbot[2]+vtop[2])/2.
 
int n = 10002012
 
dict start = daniel['T1_MA_01'][0]
 
 angleu1 = ROOT.TMath.ATan2((daniel['T1_MB_01'][0]-daniel['T1_MB_04'][0]),(daniel['T1_MB_01'][1]-daniel['T1_MB_04'][1]))
 
 angleu2 = ROOT.TMath.ATan2((daniel['T1_MB_02'][0]-daniel['T1_MB_03'][0]),(daniel['T1_MB_02'][1]-daniel['T1_MB_03'][1]))
 
tuple angleu = (angleu1+angleu2)/2.
 
tuple angle = -angleu
 
 tx = tx/4.
 
 ty = ty/4.
 
str p = 'T1_MB_0'+str(i)
 
int L = 110.
 
dict xnom = start - delta * i
 
int ynom = L/2.
 
 anglev1 = ROOT.TMath.ATan2((daniel['T2_MC_02'][0]-daniel['T2_MC_03'][0]),(daniel['T2_MC_02'][1]-daniel['T2_MC_03'][1]))
 
 anglev2 = ROOT.TMath.ATan2((daniel['T2_MC_01'][0]-daniel['T2_MC_04'][0]),(daniel['T2_MC_01'][1]-daniel['T2_MC_04'][1]))
 
tuple anglev = (anglev1+anglev2)/2.
 
 r = ROOT.TMath.Sqrt(delx**2+dely**2)
 
dict rpc = {}
 
dict DT = {}
 
bool withTDC = True
 
bool withDefaultAlignment = True
 
dict viewDict = {0:'_x',1:'_u',2:'_v'}
 
dict tdcIds
 
dict xLayers = {}
 
dict channels = {}
 
int v = 0
 
int myDetID = s * 1000 + v * 100 + p * 10 + l
 
int noiseThreshold = 10
 
list noisyChannels = []
 
 deadChannels4MC = ROOT.std.vector('int')()
 
 deadChannelsRPC4MC = ROOT.std.vector('int')()
 
 gol = sGeo.GetTopVolume().GetNode("volGoliath_1")
 
 zgoliath = gol.GetMatrix().GetTranslation()[2]
 
 vol = nav.GetCurrentNode()
 
 shape = vol.GetVolume().GetShape()
 
 local = array('d',[0,0,0])
 
 globOrigin = array('d',[0,0,0])
 
 loc = array('d',[0,0,0])
 
 glob = array('d',[0,0,0])
 
 zRPC1 = glob[2]
 
 node = nav.GetCurrentNode()
 
 dx = node.GetVolume().GetShape().GetDX()
 
 dy = node.GetVolume().GetShape().GetDY()
 
 xSHiP = ROOT.TTreeReader(sTree)
 
 muflux_Reco = ROOT.MufluxReco(xSHiP)
 
 method
 
 gMan = ROOT.gGeoManager
 
 geoMat = ROOT.genfit.TGeoMaterialInterface()
 
 bfield = ROOT.genfit.FairShipFields()
 
 fM = ROOT.genfit.FieldManager.getInstance()
 
 fitter = ROOT.genfit.DAF()
 
 parallelToZ = ROOT.TVector3(0., 0., 1.)
 
 Bx
 
 By
 
 Bz
 
float sigma_spatial = 0.25
 
bool Debug = False
 
 minHitsPerCluster
 
 maxHitsPerCluster
 
 topA
 
 botA
 
 topB
 
 botB
 
dict clusters = {}
 
dict pl = {0:'00',1:'01',2:'10',3:'11'}
 
 myGauss = ROOT.TF1('gauss','abs([0])/(abs([2])*sqrt(2*pi))*exp(-0.5*((x-[1])/[2])**2)+abs([3])',4)
 
 exclude_layer = None
 
 myGauss2 = ROOT.TF1('test','abs([0])/(abs([2])*sqrt(2*pi))*exp(-0.5*((x-[1])/[2])**2)+abs( [3]+[6]*x+[7]*x**2 )+abs([4])/(abs([5])*sqrt(2*pi))*exp(-0.5*((x-[1])/[5])**2)',8)
 
dict alignCorrection = {}
 
dict slopeX
 
dict slopeY = {2:[0,0,0,0]}
 
bool withCorrections = True
 
tuple alignCorrectionTMP = (conditionsDB.get_condition_by_name_and_tag("muflux/driftTubes", "alignCorrection", "muflux/driftTubes_align_2020-03-23"))["values"]
 
dict strawPositionsBotTop = {}
 
dict RPCPositionsBotTop = {}
 
dict listOfTracks = {}
 
dict RTrelations = {}
 
list zeroFieldData = ['SPILLDATA_8000_0515970150_20180715_220030.root']
 
dict hMC = {}
 
dict hCharm = {}
 
dict hMC10GeV = {}
 
dict hMC0 = {}
 
dict hMC2 = {}
 
dict hMCD = {}
 
dict hMCrec0 = {}
 
dict hMCrec2 = {}
 
dict hCharm0 = {}
 
dict hCharm2 = {}
 
dict hCharmD = {}
 
dict hCharmrec0 = {}
 
dict hCharmrec2 = {}
 
dict hMC10GeV0 = {}
 
dict hMC10GeV2 = {}
 
dict hMC10GeVrec0 = {}
 
dict hMC10GeVrec2 = {}
 
dict hMC10GeVD = {}
 
dict hruns = {}
 
list vetoLayer = []
 
str database = 'muflux_RTrelations.pkl'
 
 PR
 
 minP
 
 onlyPlotting
 

Function Documentation

◆ additionalMomSmearing()

conditionsDatabase.demo.drifttubeMonitoring.additionalMomSmearing ( )

Definition at line 7430 of file drifttubeMonitoring.py.

7430def additionalMomSmearing():
7431 hname = 'MCp/pt_x'
7432 folname = 'S'+hname
7433# true resolution: sigma = [0.36/100.,0.036/100.]
7434 fudge = 2.
7435 sigma = [0.36/100.*fudge,0.036/100.*fudge]
7436 h[folname]=h[hname].Clone(folname)
7437 h[folname].Reset()
7438 for n in range(1,h[hname].GetNbinsX()+1):
7439 P = h[hname].GetBinCenter(n)
7440 N = h[hname].GetBinContent(n)
7441 sig = (sigma[0]+P*sigma[1])*P
7442 for n in range(int(N+0.5)):
7443 p = rnr.Gaus(P,sig)
7444 rc = h[folname].Fill(p)
7445 ut.makeIntegralDistrib(h,hname)
7446 h[hname].Draw()
7447 h[folname].SetLineColor(ROOT.kBlue)
7448 h[folname].Draw('same')

◆ addText()

conditionsDatabase.demo.drifttubeMonitoring.addText ( )

Definition at line 899 of file drifttubeMonitoring.py.

899def addText():
900 rc = h[ 'simpleDisplay'].cd(1)
901 h['yprojtxt'] = ROOT.TLatex(200,100,'Y projection')
902 h['xprojtxt'] = ROOT.TLatex(600,-20,'X projection')
903 h['xprojtxt'].SetTextColor(ROOT.kMagenta)
904 h['yprojtxt'].SetTextColor(ROOT.kCyan)
905 h['xprojtxt'].Draw()
906 h['yprojtxt'].Draw()
907 myPrint(h[ 'simpleDisplay'],'EventDisplay')

◆ analyzeRTrel()

conditionsDatabase.demo.drifttubeMonitoring.analyzeRTrel ( )

Definition at line 5352 of file drifttubeMonitoring.py.

5352def analyzeRTrel():
5353 global fnames
5354 fnames = []
5355 for x in os.listdir('.'):
5356 if x.find('_RT')>0 and x.find('histos')<0: fnames.append(x)
5357 importRTrel()
5358 for x in RTrelations[fnames[0]]['tMinAndTmax']:
5359 ut.bookHist(h,x+'Tmin',x+'Tmin',100,-130.,-30.)
5360 ut.bookHist(h,x+'Tmax',x+'Tmax',600,1100.,1700.)
5361 for fname in RTrelations:
5362 for x in RTrelations[fname]['tMinAndTmax']:
5363 rc = h[x+'Tmin'].Fill(RTrelations[fname]['tMinAndTmax'][x][0])
5364 rc = h[x+'Tmax'].Fill(RTrelations[fname]['tMinAndTmax'][x][1])
5365 ut.bookCanvas(h,'RTMins','RT Min',1200,900,7,5)
5366 ut.bookCanvas(h,'RTMaxs','RT Max',1200,900,7,5)
5367 keys = RTrelations[fnames[0]]['tMinAndTmax'].keys()
5368 keys.sort()
5369 for n in range(1,35):
5370 tc = h['RTMins'].cd(n)
5371 h[keys[n-1]+'Tmin'].Draw()
5372 tc = h['RTMaxs'].cd(n)
5373 h[keys[n-1]+'Tmax'].Draw()
5374
5375# to START

◆ analyzeSingleDT()

conditionsDatabase.demo.drifttubeMonitoring.analyzeSingleDT ( )

Definition at line 3248 of file drifttubeMonitoring.py.

3248def analyzeSingleDT():
3249 keys = xpos.keys()
3250 keys.sort()
3251 for detID in keys:
3252 histo = h['biasResX_'+str(detID)+'_projx']
3253 mean,rms = -999.,0.
3254 if histo.GetSumOfWeights()>25:
3255 fitResult = histo.Fit('gaus','SQ','',-0.5,0.5)
3256 rc = fitResult.Get()
3257 fitFunction = histo.GetFunction('gauss')
3258 if not fitFunction : fitFunction = myGauss
3259 if not rc:
3260 # print "simple gaus fit failed"
3261 fitFunction.SetParameter(0,histo.GetEntries()*histo.GetBinWidth(1))
3262 fitFunction.SetParameter(1,0.)
3263 fitFunction.SetParameter(2,0.1)
3264 fitFunction.SetParameter(3,1.)
3265 else:
3266 fitFunction.SetParameter(0,rc.GetParams()[0]*ROOT.TMath.Sqrt(2*ROOT.TMath.Pi())*rc.GetParams()[2])
3267 fitFunction.SetParameter(1,rc.GetParams()[1])
3268 fitFunction.SetParameter(2,rc.GetParams()[2])
3269 fitFunction.SetParameter(3,0.)
3270 fitResult = histo.Fit(fitFunction,'SQ','',-0.3,0.3)
3271 rc = fitResult.Get()
3272 if rc:
3273 mean = rc.GetParams()[1]
3274 rms = rc.GetParams()[2]
3275 uf = histo.GetBinContent(0)
3276 of = histo.GetBinContent(histo.GetNbinsX()+1)
3277 if mean < -900: print "channel:%i : not enough statistics, integral=%i, under- over-flow: %i,%i"%(detID,histo.GetSumOfWeights(),uf,of)
3278 else: print "channel:%i : mean=%6.3Fmm, sigma=%6.3Fmm"%(detID,mean*10,rms*10)
3279

◆ anaResiduals()

conditionsDatabase.demo.drifttubeMonitoring.anaResiduals ( )

Definition at line 7647 of file drifttubeMonitoring.py.

7647def anaResiduals():
7648 if sTree.GetBranch('FitTracks_refitted'):
7649 PR = 3
7650 elif sTree.GetBranch('FitTracks'):
7651 PR = 1
7652 else:
7653 print "this file has no tracks",sTree.GetCurrentFile().GetName()
7654 return
7655 muflux_Reco.trackKinematics(3.)
7656 if MCdata and sTree.GetCurrentFile().GetName().find('Jpsi')<0:
7657 MCchecks()
7658 else:
7659 printScalers()
7660 plotRPCExtrap(PR)
7661 norm = h['TrackMult'].GetEntries()
7662 print '*** Track Stats ***',norm
7663 ut.writeHists(h,'histos-analysis-'+rname)

◆ bestTracks()

conditionsDatabase.demo.drifttubeMonitoring.bestTracks ( )

Definition at line 2012 of file drifttubeMonitoring.py.

2012def bestTracks():
2013 theTracks1 = findTracks(PR=11)
2014 theTracks2 = findTracks(PR=12)
2015 bestTracks = cloneKiller(theTracks1 + theTracks2)
2016 return bestTracks

◆ binoEff()

conditionsDatabase.demo.drifttubeMonitoring.binoEff (   n = 4,
  k = 2 
)

Definition at line 3313 of file drifttubeMonitoring.py.

3313def binoEff(n=4,k=2):
3314 totEff = 0
3315 for i in range(k,n+1): totEff += ROOT.TMath.Binomial(n,i)*eff**i*(1-eff)**(n-i)
3316 print "global efficiency = %5.4F %i %i"%(totEff,n,k)
3317

◆ calculateRTcorrection()

conditionsDatabase.demo.drifttubeMonitoring.calculateRTcorrection ( )

Definition at line 3155 of file drifttubeMonitoring.py.

3155def calculateRTcorrection():
3156 hkeys = h.keys()
3157 for hist in hkeys:
3158 if not hist.find('proj')<0: continue
3159 if not hist.find('slice')<0: continue
3160 if not hist.find('LR')<0: continue
3161 if not hist.find('biasResDist2Wire')<0: continue
3162 if not hist == 'biasResDist' and not hist.find('biasResDist_')==0: continue
3163 v=hist.replace('biasResDist','')
3164 h['RTcorr'+v]=ROOT.TGraph()
3165 N = 0
3166 tmpx = h[hist].ProjectionX()
3167 hresol = 'resVsDr'+v
3168 h[hresol]=tmpx.Clone(hresol)
3169 h[hresol].SetTitle('resolution as function of driftRadius')
3170 h[hresol].Reset()
3171 for n in range(1,h[hist].GetNbinsX()):
3172 if tmpx.GetBinCenter(n)>1.8: break
3173 name = hist+'slice'+str(n)
3174 h[name] = h[hist].ProjectionY(name,n,n+1)
3175 fitResult = h[name].Fit('gaus','SQ','',-0.2,0.2)
3176 rc = fitResult.Get()
3177 if rc:
3178 #print hist+'slice'+str(n),rc.GetParams()[1],rc.GetParams()[2]
3179 h['RTcorr'+v].SetPoint(N,tmpx.GetBinCenter(n),rc.GetParams()[1])
3180 h[hresol].SetBinContent(n,rc.GetParams()[2])
3181 N+=1
3182 if not h.has_key('RTCorrection'):
3183 ut.bookCanvas(h,key='RTCorrection',title='RTCorrection',nx=1200,ny=1400,cx=1,cy=2)
3184 ut.bookCanvas(h,'dummy',' ',900,600,1,1)
3185 case = {'dummy':1,'RTCorrection':1}
3186 for z in case:
3187 tc = h[z].cd(case[z])
3188 h['RTcorr'].SetLineColor(ROOT.kMagenta)
3189 h['RTcorr'].SetLineWidth(2)
3190 h['hRTCorrection']=h['resVsDr'].Clone('hRTCorrection')
3191 h['hRTCorrection'].SetTitle(';drift radius [cm]; mean difference [cm]')
3192 h['hRTCorrection'].SetStats(0)
3193 h['hRTCorrection'].SetMaximum(0.02)
3194 h['hRTCorrection'].SetMinimum(-0.06)
3195 h['hRTCorrection'].Reset()
3196 h['hRTCorrection'].SetLineColor(0)
3197 h['hRTCorrection'].Draw()
3198 keys = h.keys()
3199 for x in keys:
3200 if x.find('RTcorr')!=0: continue
3201 if not x.find('LR')<0 or not x.find('Par')<0: continue
3202 h[x].Draw()
3203 rc = h[x].Fit('pol3','SQ')
3204 fitresult = rc.Get()
3205 h[x+'Par'+x]=[fitresult.Parameter(0),fitresult.Parameter(1),fitresult.Parameter(2),fitresult.Parameter(3)]
3206 if z=='dummy': myPrint(h['dummy'],'RTCorrection')
3207 case = {'RTCorrection':2}
3208 for z in case:
3209 tc = h[z].cd(case[z])
3210 h['resVsDr'].SetLineColor(ROOT.kMagenta)
3211 h['resVsDr'].SetLineWidth(2)
3212 h['resVsDr'].SetMaximum(0.2)
3213 h['resVsDr'].SetMinimum(-0.06)
3214 h['resVsDr'].SetTitle(';drift radius [cm]; sigma [cm]')
3215 h['resVsDr'].SetStats(0)
3216 h['resVsDr'].Draw()
3217 for x in h:
3218 if x.find('resVsDr')!=0: continue
3219 if x.find('u')>0 or x.find('v')>0:
3220 h[x].SetLineColor(ROOT.kGreen)
3221 elif x.find('_3')>0 or x.find('_4')>0:
3222 h[x].SetLineColor(ROOT.kRed)
3223 h[x].Draw('same')

◆ check4muon()

conditionsDatabase.demo.drifttubeMonitoring.check4muon (   m,
  debug = False 
)

Definition at line 1527 of file drifttubeMonitoring.py.

1527def check4muon(m,debug=False):
1528 check = False
1529 mo = m.GetMotherId()
1530 while mo>0:
1531 m = sTree.MCTrack[mo]
1532 mo = m.GetMotherId()
1533 if debug: print m.GetPdgCode()
1534 if abs(m.GetPdgCode())==13:
1535 check = True
1536 break
1537 return check
1538

◆ checkForDiMuon()

conditionsDatabase.demo.drifttubeMonitoring.checkForDiMuon ( )

Definition at line 5452 of file drifttubeMonitoring.py.

5452def checkForDiMuon():
5453 boost = False
5454 for t in sTree.MCTrack:
5455 if abs(t.GetPdgCode())!=13: continue
5456 moID = abs(sTree.MCTrack[t.GetMotherId()].GetPdgCode())
5457 if moID in muSourcesIDs:
5458 boost = True
5459 break
5460 pName = t.GetProcName().Data()
5461 if not( pName.find('Lepton pair')<0 and pName.find('Positron annihilation')<0 and pName.find('Hadronic inelastic')<0 ):
5462 boost = True
5463 break
5464 return boost

◆ checkMassOfResonances()

conditionsDatabase.demo.drifttubeMonitoring.checkMassOfResonances ( )

Definition at line 1518 of file drifttubeMonitoring.py.

1518def checkMassOfResonances():
1519 ut.bookHist(h,'mass','mass',100,0.,2.)
1520 for event in sTree:
1521 for m in event.MCTrack:
1522 p = m.GetPdgCode()
1523 if not h.has_key(str(p)):
1524 h[str(p)]=h['mass'].Clone(str(p))
1525 rc=h[str(p)].Fill(m.GetMass())
1526

◆ checkMCEffTuning()

conditionsDatabase.demo.drifttubeMonitoring.checkMCEffTuning ( )

Definition at line 5724 of file drifttubeMonitoring.py.

5724def checkMCEffTuning():
5725 charmNorm = {1:0.176,10:0.424}
5726 beautyNorm = {1:0., 10:0.01218}
5727 sim10fact = 1.8/(65.*(1.-0.016)) # normalize 10GeV to 1GeV stats, 1.6% of 10GeV stats not processed.
5728 sources = {"":1.,"Hadronic inelastic":100.,"Lepton pair":100.,"Positron annihilation":100.,"charm":1./charmNorm[10],"beauty":1./beautyNorm[10]}
5729 interestingHistos = []
5730 for a in ['p/pt']:
5731 for x in ['','mu']:
5732 for source in sources: interestingHistos.append(a+x+source)
5733 ut.readHists(hMC, '../momDistributions-mbias.root',interestingHistos)
5734 ut.readHists(hCharm, '../momDistributions-charm.root',interestingHistos)
5735 ut.readHists(hMC10GeV, '../momDistributions-10GeVTR.root',interestingHistos)
5736 ut.readHists(hMCD, 'momDistributions-1GeV-mbias-withDeadChannels.root',interestingHistos)
5737 ut.readHists(hCharmD, 'momDistributions-1GeV-charm-withDeadChannels.root ',interestingHistos)
5738 ut.readHists(hMC10GeVD, 'momDistributions-10GeV-mbias-withDeadChannels.root ',interestingHistos)
5739 ut.readHists(hMC0, '../momDistributions-1GeV-mbias-effTuned-M0.root',interestingHistos)
5740 ut.readHists(hMC2, '../momDistributions-1GeV-mbias-effTuned-M2.root', interestingHistos)
5741 ut.readHists(hMCrec0, '../momDistributions-1GeV-mbias-effTuned-M0-reco.root',interestingHistos)
5742 ut.readHists(hMCrec2, '../momDistributions-1GeV-mbias-effTuned-M2-reco.root',interestingHistos)
5743 ut.readHists(hCharm0, '../momDistributions-1GeV-charm-effTuned-M0.root',interestingHistos)
5744 ut.readHists(hCharm2, '../momDistributions-1GeV-charm-effTuned-M2.root', interestingHistos)
5745 ut.readHists(hCharmrec0,'../momDistributions-1GeV-charm-effTuned-M0-reco.root',interestingHistos)
5746 ut.readHists(hCharmrec2,'../momDistributions-1GeV-charm-effTuned-M2-reco.root',interestingHistos)
5747 ut.readHists(hMC10GeV0, '../momDistributions-10GeV-mbias-effTuned-M0.root',interestingHistos)
5748 ut.readHists(hMC10GeV2, '../momDistributions-10GeV-mbias-effTuned-M2.root',interestingHistos)
5749 ut.readHists(hMC10GeVrec0,'../momDistributions-10GeV-mbias-effTuned-M0-reco.root',interestingHistos)
5750 ut.readHists(hMC10GeVrec2,'../momDistributions-10GeV-mbias-effTuned-M2-reco.root',interestingHistos)
5751 a= 'p/pt_projx'
5752 print "with deadChannels / default"
5753 print "1GeV mbias:",hMCD[a].GetEntries()/hMC[a].GetEntries()
5754 print "1GeV charm:",hCharmD[a].GetEntries()/hCharm[a].GetEntries()
5755 print "10GeV :",hMC10GeVD[a].GetEntries()/hMC10GeV[a].GetEntries()
5756 print "method 0 / default"
5757 print "1GeV mbias:",hMC0[a].GetEntries()/hMC[a].GetEntries(),hMCrec0[a].GetEntries()/hMC[a].GetEntries()
5758 print "1GeV charm:",hCharm0[a].GetEntries()/hCharm[a].GetEntries(),hCharmrec0[a].GetEntries()/hCharm[a].GetEntries()
5759 print "10GeV :",hMC10GeV0[a].GetEntries()/hMC10GeV[a].GetEntries(),hMC10GeVrec0[a].GetEntries()/hMC10GeV[a].GetEntries()
5760 print "method 2 / default"
5761 print "1GeV mbias:",hMC2[a].GetEntries()/hMC[a].GetEntries(),hMCrec2[a].GetEntries()/hMC[a].GetEntries()
5762 print "1GeV charm:",hCharm2[a].GetEntries()/hCharm[a].GetEntries(),hCharmrec2[a].GetEntries()/hCharm[a].GetEntries()
5763 print "10GeV :",hMC10GeV2[a].GetEntries()/hMC10GeV[a].GetEntries(),hMC10GeVrec2[a].GetEntries()/hMC10GeV[a].GetEntries()
5764# effect on mom distribution of eff tuning
5765 #methods = {'default':[hMC,hCharm,hMC10GeV],'M0':[hMC0,hCharm0,hMC10GeV0],'M2':[hMC2,hCharm2,hMC10GeV2],'M0rec':[hMCrec0,hCharmrec0,hMC10GeVrec0],'M2rec':[hMCrec2,hCharmrec2,hMC10GeVrec2]}
5766 methods = {'default':[hMC,hCharm,hMC10GeV],'M0rec':[hMCrec0,hCharmrec0,hMC10GeVrec0],'M2rec':[hMCrec2,hCharmrec2,hMC10GeVrec2],'D':[hMCD,hCharmD,hMC10GeVD]}
5767 colors = {'M0':ROOT.kRed,'M2':ROOT.kCyan,'M0rec':ROOT.kMagenta,'M2rec':ROOT.kBlue,'D':ROOT.kOrange}
5768 for m in methods:
5769 h['MC'+m+a] = methods[m][0][a].Clone('MC'+m+a)
5770 h['MC'+m+a].Add(methods[m][1][a],charmNorm[1])
5771 h['MC10'+m+a] = methods[m][2][a].Clone('MC'+m+a)
5772 h['MC10'+m+a].Add(methods[m][2][a.replace("_","charm_")],-1.+charmNorm[10])
5773 h['MC10'+m+a].Add(methods[m][2][a.replace("_","beauty_")],-1.+beautyNorm[10])
5774 h['MC10'+m+a].Scale(sim10fact)
5775 for n in range(1,h['MC'+m+a].GetNbinsX()+1):
5776 if h['MC'+m+a].GetBinCenter(n)<6:
5777 h['MC'+m+a].SetBinContent(n,0.)
5778 h['MC'+m+a].SetBinError(n,0.)
5779 if h['MC'+m+a].GetBinCenter(n)>5.5: # >20: take only 10GeV MC due to resolution effects
5780 h['MC'+m+a].SetBinContent(n,h['MC10'+m+a].GetBinContent(n))
5781 h['MC'+m+a].SetBinError(n,h['MC10'+m+a].GetBinError(n))
5782 h['MC'+m+a].Rebin(5)
5783 ut.makeIntegralDistrib(h,'MC'+m+a)
5784 t = 'MC-Comparison eff tuning'
5785 if not h.has_key(t): ut.bookCanvas(h,key=t,title='MC-Comparison eff tuning',nx=900,ny=600,cx=1,cy=1)
5786 tc = h[t].cd(1)
5787 h['leg'+t]=ROOT.TLegend(0.55,0.65,0.85,0.85)
5788 n = 0
5789 plot = '' # 'I-'
5790 for m in methods:
5791 if m == 'default':continue
5792 ihist = plot+m+'OverDefault'
5793 h[ihist] = h[plot+'MC'+m+a].Clone(ihist)
5794 h[ihist].Divide(h[plot+'MCdefault'+a])
5795 h[ihist].SetLineColor(colors[m])
5796 h[ihist].GetXaxis().SetRangeUser(5,400)
5797 h[ihist].SetStats(0)
5798 h[ihist].SetMaximum(1.1)
5799 h[ihist].SetMinimum(0.8)
5800 h[ihist].SetTitle('efficiency correction as function of momentum ;#it{p} [GeV/c];efficiency correction')
5801 if n == 0: h[ihist].Draw()
5802 else: h[ihist].Draw('same')
5803 n+=1
5804 h['leg'+t].AddEntry(h[ihist],'method '+m+' / default','PL')
5805 h['leg'+t].Draw()
5806 myPrint(h[t],'MCcomparison-Efficiency-Tuning')
5807

◆ checkMCSmearing()

conditionsDatabase.demo.drifttubeMonitoring.checkMCSmearing ( )

Definition at line 1491 of file drifttubeMonitoring.py.

1491def checkMCSmearing():
1492 ut.bookHist(h,'spr','spatial resolution MC',100,-1.,1.)
1493 ut.bookHist(h,'MCposX','diff position X',100,-1.,1.)
1494 ut.bookHist(h,'nMeasMC','number of hits per track',50,-0.5,49.5)
1495 for i in range(sTree.GetEntries()):
1496 trackID = {}
1497 rc = sTree.GetEvent(i)
1498 if sTree.Digi_MufluxSpectrometerHits.GetEntries() != sTree.MufluxSpectrometerPoint.GetEntries():
1499 print "digi does not agree with MC, break"
1500 break
1501 for n in range(sTree.Digi_MufluxSpectrometerHits.GetEntries()):
1502 p = sTree.Digi_MufluxSpectrometerHits[n]
1503 pmc = sTree.MufluxSpectrometerPoint[n]
1504 mcp = pmc.GetTrackID()
1505 if mcp<0: continue
1506 if abs(sTree.MCTrack[mcp].GetPdgCode())!=13: continue
1507 t = p.GetDigi()
1508 # r = (t-sTree.ShipEventHeader.GetEventTime())*ShipGeo.MufluxSpectrometer.v_drift
1509 r = RT(p,t)
1510 rc = h['spr'].Fill(r-pmc.dist2Wire())
1511 vbot,vtop = strawPositionsBotTop[p.GetDetectorID()]
1512 rc = h['MCposX'].Fill(pmc.GetX()-vbot[0]+r)
1513 rc = h['MCposX'].Fill(pmc.GetX()-vbot[0]-r)
1514 if not trackID.has_key(mcp): trackID[mcp]=[]
1515 trackID[mcp].append(n)
1516 for mcp in trackID:
1517 rc=h['nMeasMC'].Fill(len(trackID[mcp]))

◆ checkRPCAcceptance()

conditionsDatabase.demo.drifttubeMonitoring.checkRPCAcceptance ( )

Definition at line 4118 of file drifttubeMonitoring.py.

4118def checkRPCAcceptance():
4119 Ntracks,inAcc = 0,0
4120 for n in range(sTree.GetEntries()):
4121 rc = sTree.GetEvent(n)
4122 for aTrack in sTree.FitTracks:
4123 st = aTrack.getFitStatus()
4124 if not st.isFitConverged(): continue
4125 if not aTrack.getNumPointsWithMeasurement()>0: continue
4126 sta = aTrack.getFittedState(0)
4127 if sta.getMomMag() < 5.: continue
4128 rc,pos,mom = extrapolateToPlane(aTrack,cuts['zRPC1'])
4129 if not rc: continue
4130 Ntracks+=1
4131 if pos[0]>cuts['xLRPC1'] and pos[0]<cuts['xRRPC1'] and pos[1]>cuts['yBRPC1'] and pos[1]<cuts['yTRPC1']:
4132 inAcc+=1
4133 print "number of tracks ",Ntracks," in acceptance ",inAcc,"=","%F5.2"%(inAcc/float(Ntracks)*100),"%"
4134

◆ checkTrackEfficiencyPerSpill()

conditionsDatabase.demo.drifttubeMonitoring.checkTrackEfficiencyPerSpill ( )

Definition at line 3640 of file drifttubeMonitoring.py.

3640def checkTrackEfficiencyPerSpill():
3641 path = "/media/truf/disk2/home/truf/ShipSoft/ship-ubuntu-1710-48/zeroField"
3642 ut.bookHist(h,'Teff','efficiency',100,0.9,1.0)
3643 goodFiles=[]
3644 interestingHistos = []
3645 for k in range(1,5):
3646 interestingHistos.append('upStreamOcc'+str(k))
3647 interestingHistos.append('upStreamOccWithTrack'+str(k))
3648 interestingHistos.append('upStreamOccWithTrack_mu'+str(k))
3649 interestingHistos.append('upStreamOccWithTrack_muX'+str(k))
3650 interestingHistos.append('upStreamOccWithTrack_Chi2'+str(k))
3651 interestingHistos.append('upStreamOccWithTrack_Chi2mu'+str(k))
3652 for f in os.listdir(path):
3653 if f.find("histos-DTEffSPILLDATA_")==0:
3654 for x in interestingHistos:
3655 if h.has_key(x): h[x].Reset()
3656 print " now analyzing histo",f
3657 fHisto=path+"/"+f
3658 ut.readHists(h,fHisto,interestingHistos)
3659 try:
3660 if h['upStreamOccWithTrack_Chi21'].GetEntries()<1: continue
3661 Ntag = h['upStreamOcc1'].GetEntries()
3662 Ntrack = h['upStreamOccWithTrack1'].GetEntries()
3663 Nmu = h['upStreamOccWithTrack_mu1'].GetEntries()
3664 NmuX = h['upStreamOccWithTrack_muX1'].GetEntries()
3665 NChi2 = h['upStreamOccWithTrack_Chi21'].GetEntries()
3666 NChi2mu = h['upStreamOccWithTrack_Chi2mu1'].GetEntries()
3667 except:
3668 continue
3669 print "====== Ntags=",Ntag
3670 print "average track eff = %5.2F%%"%( (Ntrack*100.)/Ntag)
3671 print "average track mu eff = %5.2F%%"%( (Nmu*100.)/Ntag)
3672 print "average track Chi2 eff = %5.2F%%"%( (NChi2*100.)/Ntag)
3673 print "average track Chi2 mu eff = %5.2F%%"%( (NChi2mu*100.)/Ntag)
3674 print "average chi2 eff on top of = %5.2F%%"%( (NChi2*100.)/Ntrack)
3675 print "average chi2 eff on top of mu = %5.2F%%"%( (NChi2mu*100.)/Nmu)
3676 rc = h['Teff'].Fill(float(Ntrack)/Ntag)
3677 goodFiles.append(fHisto)
3678 h['Teff'].Draw()
3679 cmd = "hadd -f DTEff.root "
3680 for f in goodFiles:
3681 cmd+=f+' '
3682 os.system(cmd)
3683

◆ checkZtilts()

conditionsDatabase.demo.drifttubeMonitoring.checkZtilts ( )

Definition at line 823 of file drifttubeMonitoring.py.

823def checkZtilts():
824 # station 1 and 2 01: +x,+y 02: -x,+y, 03: -x,-y 04: +x,-y
825 for s in ['T1_MA_','T1_MB_','T2_MC_','T2_MD_']:
826 meanZ = 0
827 for x in ['01','02','03','04']:
828 meanZ += daniel[s+x][2]
829 meanZ = meanZ/4.
830 rms = 0
831 for x in ['01','02','03','04']:
832 rms += (daniel[s+x][2]-meanZ)**2
833 rms = ROOT.TMath.Sqrt(rms)
834 diffTopBot = daniel[s+'01'][2]-daniel[s+'04'][2],daniel[s+'02'][2]-daniel[s+'03'][2]
835 diffLefRig = daniel[s+'01'][2]-daniel[s+'02'][2],daniel[s+'04'][2]-daniel[s+'03'][2]
836 print s,meanZ,rms,' top/bot ',diffTopBot,' left/right ',diffLefRig
837 # station 1 and 2 01: +x,+y 02: -x,+y, 03: -x,-y 04: +x,-y
838 for s in ['T3','T4']:
839 meanZ = 0
840 for y in ['_T','_B']:
841 for x in ['01','02','03','04','05','06','07','08']:
842 meanZ += daniel[s+y+x][2]
843 print s+y+x,daniel[s+y+x][2]
844 meanZ = meanZ/16.
845 rms = 0
846 for y in ['_T','_B']:
847 for x in ['01','02','03','04','05','06','07','08']:
848 rms += (daniel[s+y+x][2]-meanZ)**2
849 rms = ROOT.TMath.Sqrt(rms)
850 print s,meanZ,rms
851
852

◆ cloneKiller()

conditionsDatabase.demo.drifttubeMonitoring.cloneKiller (   trackCandidates)

Definition at line 2757 of file drifttubeMonitoring.py.

2757def cloneKiller(trackCandidates):
2758# if all x measurements identical take the one with most u,v
2759# if tracks share >50% of downstream hits, take the one with max measurements
2760 detIDs = {}
2761 for j in range( len(trackCandidates) ):
2762 detIDs[j]=countMeasurements(trackCandidates[j],PR=11)
2763 for j in range(len(detIDs)-1):
2764 if len(detIDs[j]['xDown'])==0: continue
2765 tj = float(len(detIDs[j]['xDown']))
2766 sj = trackCandidates[j].getFitStatus()
2767 for k in range(j+1,len(detIDs)):
2768 if len(detIDs[k]['xDown'])==0: continue
2769 # not yet ready
2770 #if len(detIDs[j]['xAll'])==len(detIDs[k]['xAll']):
2771 # if len(overlap(detIDs[j]['xAll'],detIDs[k]['xAll']))==len(detIDs[j]['xAll']):
2772# only differ in stereo
2773 # if len(detIDs['uv']
2774 o = overlap(detIDs[j]['xDown'],detIDs[k]['xDown'])
2775 tk = float(len(detIDs[k]['xDown']))
2776 if max(len(o)/tj,len(o)/tk)>0.49:
2777 sk = trackCandidates[k].getFitStatus()
2778 if sj.getNdf() < sk.getNdf()-cuts['deltaNdf']: detIDs[j]['xDown']=[]
2779 elif sk.getNdf() < sj.getNdf()-cuts['deltaNdf']: detIDs[k]['xDown']=[]
2780 elif sj.getChi2()/sj.getNdf() < sk.getChi2()/sk.getNdf(): detIDs[k]['xDown']=[]
2781 elif sk.getChi2()/sk.getNdf() < sj.getChi2()/sj.getNdf(): detIDs[j]['xDown']=[]
2782 else: detIDs[j]['xDown']=[]
2783 if Debug: print "j,k",j,sj.getNdf(),sj.getChi2(),sj.getChi2()/sj.getNdf(),len(detIDs[j]['xDown']),len(detIDs[j]['uv']),' | ', k,sk.getNdf(),sk.getChi2(),sk.getChi2()/sk.getNdf(),len(detIDs[k]['xDown']),len(detIDs[k]['uv'])
2784 if len(detIDs[j]['xDown'])==0: break
2785 cloneKilledTracks = []
2786 j=-1
2787 for aTrack in trackCandidates:
2788 j+=1
2789 if Debug: print "clone killer at work",j,len(detIDs[j]['xDown'])
2790 if len(detIDs[j]['xDown'])>0:
2791 cloneKilledTracks.append(aTrack)
2792 j=-1
2793 for aTrack in trackCandidates:
2794 j+=1
2795 if len(detIDs[j]['xDown'])==0: aTrack.Delete()
2796 return cloneKilledTracks
2797

◆ clusterSizesPerLayer()

conditionsDatabase.demo.drifttubeMonitoring.clusterSizesPerLayer (   nevents)

Definition at line 4953 of file drifttubeMonitoring.py.

4953def clusterSizesPerLayer(nevents):
4954 ut.bookHist(h,'ToverT','Time over threshold',3000,-1000.,2000.)
4955 for s in range(1,5):
4956 for view in views[s]:
4957 for l in range(4):
4958 ut.bookHist(h,'multHits_'+str(s)+view+str(l),'DT cluster size',16,-0.5,15.5)
4959 for Nr in range(nevents):
4960 rc = sTree.GetEvent(Nr)
4961 spectrHitsSorted = ROOT.nestedList()
4962 muflux_Reco.sortHits(sTree.Digi_MufluxSpectrometerHits,spectrHitsSorted,True)
4963 for s in range(1,5):
4964 for view in viewsI[s]:
4965 for l in range(4):
4966 allHits=[]
4967 for x in spectrHitsSorted[view][s][l]:
4968 allHits.append(x.GetDetectorID()%1000)
4969 clustersPerLayer = dict(enumerate(grouper(allHits,1), 1))
4970 for Acl in clustersPerLayer:
4971 rc = h['multHits_'+str(s)+viewC[view]+str(l)].Fill(len(clustersPerLayer[Acl]))
4972 if len(clustersPerLayer[Acl])>3:
4973 for aHit in spectrHitsSorted[view][s][l]:
4974 #print Nr,s,view,l,aHit.GetDetectorID()%1000,aHit.GetWidth()
4975 h['ToverT'].Fill(aHit.GetTimeOverThreshold())
4976 ut.bookCanvas(h,key='clusSizes',title='Cluster sizes per Layer',nx=1600,ny=1200,cx=4,cy=6)
4977 j=1
4978 for s in range(1,5):
4979 for view in views[s]:
4980 for l in range(4):
4981 tc=h['clusSizes'].cd(j)
4982 tc.SetLogy(1)
4983 hname = 'multHits_'+str(s)+viewC[view]+str(l)
4984 h[hname+'x']=h[hname].Clone(hname+'x')
4985 h[hname+'x'].Scale(1./float(h[hname].GetEntries()))
4986 h[hname+'x'].Draw()
4987 j+=1
4988

◆ compareAlignment()

conditionsDatabase.demo.drifttubeMonitoring.compareAlignment ( )

Definition at line 686 of file drifttubeMonitoring.py.

686def compareAlignment():
687 ut.bookHist(h,'alignCompare','compare Alignments',100,-120.,120.,100,-120.,120.)
688 ut.bookHist(h,'alignCompareDiffs','compare Alignments',100,-1.,1.)
689 keys = xpos.keys()
690 keys.sort()
691 for d in keys:
692 test = ROOT.MufluxSpectrometerHit(d,0.)
693 test.MufluxSpectrometerEndPoints(vbot,vtop)
694 statnb,vnb,pnb,lnb,view,channelID,tdcId,nRT = stationInfo(test)
695 angle = ROOT.TMath.ATan2(-vtop[0]+vbot[0],-vtop[1]+vbot[1])/ROOT.TMath.Pi()*180
696 L = ROOT.TMath.Sqrt( (vbot[0]-vtop[0])**2+(vbot[1]-vtop[1])**2)
697 if view=='_x': vbotD,vtopD = ROOT.TVector3(xpos[d],L/2.,zpos[d]),ROOT.TVector3(xpos[d],-L/2.,zpos[d])
698 else: vbotD,vtopD = ROOT.TVector3(xposb[d],yposb[d],zpos[d]),ROOT.TVector3(xpos[d],ypos[d],zpos[d])
699 angleD = ROOT.TMath.ATan2(vtopD[0]-vbotD[0],vtopD[1]-vbotD[1])/ROOT.TMath.Pi()*180
700 if abs(vtop[0]-vbot[0])<1:
701 x0 = (vtop[0]+vbot[0])/2.
702 else:
703 m = (vtop[1]-vbot[1])/(vtop[0]-vbot[0])
704 b = vtop[1]-m*vtop[0]
705 x0 = -b/m
706 if abs(vtopD[0]-vbotD[0])<1:
707 x0D = (vtopD[0]+vbotD[0])/2.
708 else:
709 mD = (vtopD[1]-vbotD[1])/(vtopD[0]-vbotD[0])
710 bD = vtopD[1]-mD*vtopD[0]
711 x0D = -bD/mD
712 diff = x0-x0D
713 z = (vbot[2]+vtop[2])/2.
714 txt = ""
715 if abs(diff)>0.1 : txt = "!!! "
716 if abs(z-vbotD[2])>0.1: txt+= "!!z"
717 print "%s %i x/y pos from Daniel %7.4F %7.4F %7.4F %7.4F %7.4F from FairShip %7.4F %7.4F %7.4F %7.4F %7.4F diff %5.4F zdiff %5.4F"\
718 %(txt,d,x0D,angleD,vbotD[1],vtopD[1],vbotD[2],x0,angle,vtop[1],vbot[1],vbot[2],(x0D-x0)*10.,(z-vbotD[2])*10)
719 if abs(vbot[2]-vtop[2])>0.1: print "!!! z tilt",vbot[2],vtop[2]
720 rc = h['alignCompare'].Fill(x0D,x0)
721 rc = h['alignCompareDiffs'].Fill(x0D-x0)
722 z0_D = zpos['T1X']/10.
723 test = ROOT.MufluxSpectrometerHit(10002001,0.)
724 test.MufluxSpectrometerEndPoints(vbot,vtop)
725 z0_F = (vbot[2]+vtop[2])/2.
726# distance to T1 u
727 test = ROOT.MufluxSpectrometerHit(11002001,0.)
728 test.MufluxSpectrometerEndPoints(vbot,vtop)
729 z1_U = (vbot[2]+vtop[2])/2. - z0_F
730 print "distance T1 X to T1 U:",zpos['T1U']/10.-z0_D,z1_U
731# distance to T2 V
732 test = ROOT.MufluxSpectrometerHit(20002001,0.)
733 test.MufluxSpectrometerEndPoints(vbot,vtop)
734 z2_V = (vbot[2]+vtop[2])/2. - z0_F
735 print "distance T1 X to T2 V:",zpos['T2V']/10.-z0_D,z2_V
736# distance to T2 X
737 test = ROOT.MufluxSpectrometerHit(21002001,0.)
738 test.MufluxSpectrometerEndPoints(vbot,vtop)
739 z2_X = (vbot[2]+vtop[2])/2. - z0_F
740 print "distance T1 X to T2 X:",zpos['T2X']/10.-z0_D,z2_X
741# distance to T3 X
742 test = ROOT.MufluxSpectrometerHit(30002001,0.)
743 test.MufluxSpectrometerEndPoints(vbot,vtop)
744 z3_X = (vbot[2]+vtop[2])/2. - z0_F
745 print "distance T1 X to T3 X:",(zpos['T3aX']+zpos['T3bX']+zpos['T3cX']+zpos['T3dX'])/(4*10.)-z0_D,z3_X
746# distance to T4 X
747 test = ROOT.MufluxSpectrometerHit(40002001,0.)
748 test.MufluxSpectrometerEndPoints(vbot,vtop)
749 z4_X = (vbot[2]+vtop[2])/2. - z0_F
750 print "distance T1 X to T4 X:",(zpos['T4aX']+zpos['T4bX']+zpos['T4cX']+zpos['T4dX'])/(4*10.)-z0_D,z4_X
751#

◆ compareRuns()

conditionsDatabase.demo.drifttubeMonitoring.compareRuns (   runs = [])

Definition at line 6969 of file drifttubeMonitoring.py.

6969def compareRuns(runs=[]):
6970 # runs = [2307,2357,2359,2360,2361,2365,2366,2395,2396]
6971 # runs = [2200,2201,2202,2203,2205,2206,2207,2208,2276]
6972 eventStats = {}
6973 noField = [2199,2200,2201]
6974 intermediateField = [2383,2388,2389,2390,2392,2395,2396]
6975 noTracks = [2334, 2335, 2336, 2337, 2345, 2389,2390]
6976 ROOT.gStyle.SetPalette(ROOT.kGreenPink)
6977 interestingHistos=['Trscalers','p/pt','p/ptmu']
6978 if len(runs)==0:
6979 keyword = 'RUN_8000_2'
6980 temp = os.listdir('.')
6981 for x in temp:
6982 if x.find(keyword)<0: continue
6983 if not os.path.isdir(x): continue
6984 r = int(x[x.rfind('/')+1:].split('_')[2])
6985 if r in noField: continue
6986 if not hruns.has_key(r):
6987 runs.append(r)
6988 hruns[r]={}
6989 ut.readHists(hruns[r],'momDistributions-'+r+'.root',interestingHistos)
6990 else:
6991 for r in runs:
6992 if not hruns.has_key(r):
6993 hruns[r]={}
6994 ut.readHists(hruns[r],'momDistributions_RUN_8000_'+str(r)+'.root')
6995 runs.sort()
6996 first = True
6997 j=0
6998 if not h.has_key('RunComparison'):
6999 ut.bookCanvas(h,key='RunComparison',title='Momentum',nx=1600,ny=1200,cx=1,cy=0)
7000 ut.bookCanvas(h,key='EventStatistics',title='Event Statistics',nx=1800,ny=800,cx=1,cy=0)
7001 ut.bookHist(h,'HEventStatistics','Event Statistics;run number',100,2000,3000)
7002 h['legRunComparison']=ROOT.TLegend(0.35,0.16,0.86,0.46)
7003 tc = h['RunComparison'].cd(1)
7004 tc.SetLogy(1)
7005 for r in runs:
7006 first = False
7007 hname = 'p/pt_projx'
7008 if not hruns[r].has_key('Trscalers'):
7009 print "!!!!! no entry for RUN",r
7010 continue
7011 print ">>>>>> statistics for RUN",r
7012 N = hruns[r]['Trscalers'].GetBinContent(1)
7013 print "number of events",hruns[r]['Trscalers'].GetBinContent(1)
7014 print "events with tracks %5.2F%%"%(hruns[r]['Trscalers'].GetBinContent(2)/hruns[r]['Trscalers'].GetBinContent(1)*100)
7015 print "tracks/event %5.2F%%"%(hruns[r]['Trscalers'].GetBinContent(3)/hruns[r]['Trscalers'].GetBinContent(1)*100)
7016 print "ratio of muon tagged tracks / all tracks %5.2F%%"%(hruns[r]['p/ptmu'].GetEntries()/(hruns[r]['p/pt'].GetEntries()+1E-6))
7017 print "mean p %5.2F GeV/c, rms %5.2F GeV/c"%(hruns[r][hname].GetMean(),hruns[r][hname].GetRMS())
7018 eventStats[r]=[hruns[r]['Trscalers'].GetBinContent(2)/hruns[r]['Trscalers'].GetBinContent(1),
7019 hruns[r]['Trscalers'].GetBinContent(3)/hruns[r]['Trscalers'].GetBinContent(1),
7020 hruns[r][hname].GetMean(),
7021 hruns[r]['Trscalers'].GetBinContent(2),
7022 hruns[r]['p/ptmu'].GetEntries()/(hruns[r]['p/pt'].GetEntries()+1E-6)]
7023 hruns[r][hname].Scale(1/N)
7024 hruns[r][hname].SetLineWidth(3)
7025 hruns[r][hname].SetStats(0)
7026 hruns[r][hname].SetTitle(str(r))
7027 if first:
7028 hruns[r][hname].Draw('PLC PMC')
7029 first = False
7030 else: hruns[r][hname].Draw('same PLC PMC')
7031 h['legRunComparison'].AddEntry(hruns[r][hname],str(r),'PL')
7032 j+=1
7033 tc.BuildLegend()
7034 tc = h['EventStatistics'].cd(1)
7035 h['eventStats1']=ROOT.TGraph(len(eventStats))
7036 h['eventStats2']=ROOT.TGraph(len(eventStats))
7037 h['eventStats3']=ROOT.TGraph(len(eventStats))
7038 h['eventStats4']=ROOT.TGraph(len(eventStats))
7039 n=0
7040 for r in eventStats:
7041 h['eventStats1'].SetPoint(n,r,eventStats[r][0])
7042 h['eventStats2'].SetPoint(n,r,eventStats[r][1])
7043 h['eventStats3'].SetPoint(n,r,eventStats[r][2]/100.)
7044 h['eventStats4'].SetPoint(n,r,eventStats[r][4]/5.)
7045 n+=1
7046
7047 h['legruns']=ROOT.TLegend(0.35,0.12,0.86,0.42)
7048 h['eventStats1'].SetMarkerColor(ROOT.kBlue)
7049 h['eventStats1'].SetMarkerSize(1.5)
7050 h['eventStats1'].SetMarkerStyle(34)
7051 h['eventStats2'].SetMarkerColor(ROOT.kBlue-4)
7052 h['eventStats2'].SetMarkerSize(1.5)
7053 h['eventStats2'].SetMarkerStyle(24)
7054 h['eventStats2'].SetMarkerColor(3)
7055 h['eventStats3'].SetMarkerColor(ROOT.kRed)
7056 h['eventStats3'].SetMarkerSize(1.0)
7057 h['eventStats3'].SetMarkerStyle(47)
7058 h['eventStats4'].SetMarkerColor(ROOT.kMagenta)
7059 h['eventStats4'].SetMarkerSize(1.5)
7060 h['eventStats4'].SetMarkerStyle(29)
7061 h['eventStats1'].SetTitle('Run statistics Data Quality')
7062 h['eventStats1'].SetMinimum(-0.01)
7063 h['eventStats1'].SetMaximum(0.25)
7064 h['eventStats1'].Draw('AP')
7065 lg = h['legruns'].AddEntry(h['eventStats1'],'N events with tracks / N events','PL')
7066 lg.SetTextColor(h['eventStats1'].GetMarkerColor())
7067 # h['legruns'].AddEntry(h['eventStats2'],'N of tracks / N events','PL')
7068 lg = h['legruns'].AddEntry(h['eventStats3'],'mean momentum [GeV /100]','PL')
7069 lg.SetTextColor(h['eventStats1'].GetMarkerColor())
7070 lg = h['legruns'].AddEntry(h['eventStats4'],'N of mu tracks / N of tracks /5','PL')
7071 lg.SetTextColor(h['eventStats1'].GetMarkerColor())
7072 # h['eventStats2'].Draw('P')
7073 h['eventStats3'].Draw('P')
7074 h['eventStats4'].Draw('P')
7075 h['legruns'].Draw('same')
7076 myPrint(h['EventStatistics'],'DataQualityPlot')
7077 return eventStats

◆ copyRTRelation()

conditionsDatabase.demo.drifttubeMonitoring.copyRTRelation ( )

Definition at line 7456 of file drifttubeMonitoring.py.

7456def copyRTRelation():
7457 f = sTree.GetCurrentFile()
7458 fname = f.GetName()
7459 rawName = fname.replace('_RT.root','.root')
7460 ftemp = fname.replace('_RT.root','_RTx.root')
7461 os.system('cp '+rawName +' '+ftemp)
7462 h['TDCMapsX'] = f.histos.Get('TDCMapsX').Clone('TDCMapsX')
7463 h['hitMapsX'] = f.histos.Get('hitMapsX').Clone('hitMapsX')
7464 h['RTrelations'] = f.histos.Get('RTrelations').Clone('RTrelations')
7465 h['TDC2R_py'] = f.histos.Get('TDC2R_py').Clone('TDC2R_py')
7466 f.Close()
7467 f = ROOT.TFile.Open(ftemp,'update')
7468 event = f.Get("cbmsim")
7469 if not event:
7470 print "Problem with making RTrel persistent, file",f,f.ls()
7471 return -1
7472 f.cd('')
7473 f.mkdir('RT')
7474 f.cd('RT')
7475 for s in RTrelations[fname]:
7476 if s.find('rt')<0: continue
7477 RTrelations[fname][s].Write()
7478 pkl = Pickler(f)
7479 pkl.dump(h['tMinAndTmax'],'tMinAndTmax')
7480 f.cd('')
7481 f.mkdir('histos')
7482 f.histos.cd('')
7483 h['TDCMapsX'].Write()
7484 h['hitMapsX'].Write()
7485 h["RTrelations"].Write()
7486 f.Write("",ROOT.TFile.kOverwrite)
7487 f.Close()

◆ correctAlignment()

conditionsDatabase.demo.drifttubeMonitoring.correctAlignment (   hit)

Definition at line 4546 of file drifttubeMonitoring.py.

4546def correctAlignment(hit):
4547 detID = hit.GetDetectorID()
4548 vbot,vtop = ROOT.TVector3(), ROOT.TVector3()
4549 rc = hit.MufluxSpectrometerEndPoints(vbot,vtop)
4550 if withDefaultAlignment and not withCorrections: return vbot,vtop
4551 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
4552 if withDefaultAlignment and withCorrections:
4553 x= (2*p+l)
4554 if s==1 and view=='_u': x+=4
4555 if s==2 and view=='_v': x+=8
4556 if s==2 and view=='_x': x+=12
4557 if s==3 :
4558 x+=16
4559 if vbot[0]>0:x+=4
4560 if s==4:
4561 x+=24
4562 if vbot[0]>0:x+=4
4563 for i in range(3):
4564 vbot[i] = vbot[i]+alignCorrection[x][i]
4565 vtop[i] = vtop[i]+alignCorrection[x][i]
4566 return vbot,vtop
4567 if view=='_x':
4568 vbot[0]=xpos[detID]
4569 vtop[0]=xpos[detID]
4570 else:
4571 # make same mistake as in geometry, top is with y<0 and bot with y>0:
4572 vtop[0]=xposb[detID]
4573 vtop[1]=yposb[detID]
4574 vbot[0]=xpos[detID]
4575 vbot[1]=ypos[detID]
4576 vbot[2]=zpos[detID]
4577 vtop[2]=zpos[detID]
4578 pl= (2*p+l)
4579 x = pl
4580 if s==1 and view=='_u': x = pl+4
4581 if s==2 and view=='_v': x = pl+8
4582 if s==2 and view=='_x': x = pl+12
4583 if s==3 :
4584 x=pl+16
4585 if vbot[0]>0:x+=4
4586 if s==4:
4587 x=pl+24
4588 if vbot[0]>0:x+=4
4589 if s==3:
4590 vbot[0] += slopeX[s][pl]*vbot[0]
4591 vtop[0] += slopeX[s][pl]*vtop[0]
4592 if s==2:
4593 vbot[0] += (slopeY[s][pl]*vbot[1] + slopeX[s][pl]*vbot[0])
4594 vtop[0] += (slopeY[s][pl]*vtop[1] + slopeX[s][pl]*vtop[0])
4595 for i in range(3):
4596 vbot[i] = vbot[i]+alignCorrection[x][i]
4597 vtop[i] = vtop[i]+alignCorrection[x][i]
4598 return vbot,vtop
4599

◆ correctAlignmentRPC()

conditionsDatabase.demo.drifttubeMonitoring.correctAlignmentRPC (   hit,
  v 
)

Definition at line 4803 of file drifttubeMonitoring.py.

4803def correctAlignmentRPC(hit,v):
4804 hit.EndPoints(vtop,vbot)
4805 if not sTree.GetBranch('MuonTaggerPoint'):
4806 if v==1:
4807 vbot[0] = -vbot[0] -1.21
4808 vtop[0] = -vtop[0] -1.21
4809 else:
4810 vbot[1] = vbot[1] -1.21
4811 vtop[1] = vtop[1] -1.21
4812 else:
4813 if v==1:
4814 vbot[0] = vbot[0] -1.049
4815 vtop[0] = vtop[0] -1.049
4816 else:
4817 vbot[1] = vbot[1] -0.53
4818 vtop[1] = vtop[1] -0.53
4819
4820 return vbot,vtop
4821

◆ countMeasurements()

conditionsDatabase.demo.drifttubeMonitoring.countMeasurements (   aTrack,
  PR = 1 
)

Definition at line 2684 of file drifttubeMonitoring.py.

2684def countMeasurements(aTrack,PR=1):
2685 mStatistics = {'x1':[],'x2':[],'x3':[],'x4':[],'xAll':[],'xDown':[],'xUp':[],'uv':[],'u':[],'v':[]}
2686 if PR==1 and sTree.GetBranch("TrackInfos") or PR==3 and sTree.GetBranch("TrackInfos_refitted"):
2687 if PR==1: trInfo = sTree.TrackInfos[aTrack]
2688 if PR==3: trInfo = sTree.TrackInfos_refitted[aTrack]
2689 for n in range(trInfo.N()):
2690 detID = trInfo.detId(n)
2691 hit = ROOT.MufluxSpectrometerHit(detID,0)
2692 s,v,p,l,view,channelID,tdcId,mdoduleId = stationInfo(hit)
2693 if trInfo.wL(n) <0.1 and trInfo.wR(n) <0.1: continue
2694 if view != '_x':
2695 mStatistics['uv'].append(detID)
2696 if view == '_u': mStatistics['u'].append(detID)
2697 if view == '_v': mStatistics['v'].append(detID)
2698 else:
2699 mStatistics['xAll'].append(detID)
2700 mStatistics['x'+str(s)].append(detID)
2701 if s > 2: mStatistics['xDown'].append(detID)
2702 else: mStatistics['xUp'].append(detID)
2703 else:
2704 for p in aTrack.getPointsWithMeasurement():
2705 rawM = p.getRawMeasurement()
2706 info = p.getFitterInfo()
2707 if not info: continue
2708 detID = rawM.getDetId()
2709 test = ROOT.MufluxSpectrometerHit(detID,0.)
2710 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(test)
2711 if info.getWeights()[0] <0.1 and info.getWeights()[1] <0.1: continue
2712 if view != '_x':
2713 mStatistics['uv'].append(detID)
2714 if view != '_u': mStatistics['u'].append(detID)
2715 if view != '_v': mStatistics['v'].append(detID)
2716 else: mStatistics['xAll'].append(detID)
2717 if s > 2: mStatistics['xDown'].append(detID)
2718 return mStatistics

◆ countTracks()

conditionsDatabase.demo.drifttubeMonitoring.countTracks (   analyse = False)

Definition at line 6931 of file drifttubeMonitoring.py.

6931def countTracks(analyse=False):
6932 NfitTracks = [0,0]
6933 NfitTracks_refitted = [0,0]
6934 EventsWithTracks = [0,0]
6935 if not analyse:
6936 for event in sTree:
6937 if event.FitTracks.GetEntries()>0: EventsWithTracks[0]+=1
6938 if event.FitTracks_refitted.GetEntries()>0: EventsWithTracks[1]+=1
6939 NfitTracks[0] +=event.FitTracks.GetEntries()
6940 NfitTracks_refitted[0]+=event.FitTracks_refitted.GetEntries()
6941 for atrack in sTree.FitTracks:
6942 fst = atrack.getFitStatus()
6943 if fst.isFitConverged(): NfitTracks[1]+=1
6944 for atrack in sTree.FitTracks_refitted:
6945 fst = atrack.getFitStatus()
6946 if fst.isFitConverged(): NfitTracks_refitted[1]+=1
6947 print "run, number of original tracks",sTree.GetCurrentFile(),NfitTracks, " number of refitted tracks",NfitTracks_refitted, " lumi:",EventsWithTracks
6948 else:
6949 for r in os.listdir('.'):
6950 if not r.find('RUN_8000_')==0: continue
6951 for l in os.listdir(r):
6952 f = open(r+'/'+l)
6953 txt = f.readlines()
6954 tmp = txt[len(txt)-1].split('[')
6955 if tmp[0].find('run')!=0: continue
6956 fitted = tmp[1].split(']')[0]
6957 NfitTracks[0] += int(fitted.split(',')[0])
6958 NfitTracks[1] += int(fitted.split(',')[1])
6959 refitted = tmp[2].split(']')[0]
6960 NfitTracks_refitted[0] += int(refitted.split(',')[0])
6961 NfitTracks_refitted[1] += int(refitted.split(',')[1])
6962 refitted = tmp[3].split(']')[0]
6963 EventsWithTracks[0] += int(refitted.split(',')[0])
6964 EventsWithTracks[1] += int(refitted.split(',')[1])
6965 print "number of original tracks",NfitTracks, " number of refitted tracks",NfitTracks_refitted," lumi counts:",EventsWithTracks
6966 print "ratios",NfitTracks_refitted[0]/float(NfitTracks[0]),NfitTracks_refitted[1]/float(NfitTracks[1]),EventsWithTracks[1]/float(EventsWithTracks[0])
6967

◆ debugGeometrie()

conditionsDatabase.demo.drifttubeMonitoring.debugGeometrie ( )

Definition at line 4670 of file drifttubeMonitoring.py.

4670def debugGeometrie():
4671 test = ROOT.MufluxSpectrometerHit(10002012,0)
4672 test.MufluxSpectrometerEndPoints(vbot,vtop)
4673 print vtop[1],vbot[1]
4674 test = ROOT.MufluxSpectrometerHit(11002012,0)
4675 test.MufluxSpectrometerEndPoints(vbot,vtop)
4676 m = (vtop[1]-vbot[1])/((vtop[0]-vbot[0]))
4677 b = vtop[1] - m*vtop[0]
4678 start = -b/m
4679 print vtop[1],vbot[1]
4680 statnb,vnb,pnb,lnb,view,channelID,tdcId,nRT = stationInfo(test)
4681 nav = ROOT.gGeoManager.GetCurrentNavigator()
4682 prefix = "Station_"+str(statnb)+str(view)+"_plane_"+str(pnb)+"_"
4683 plane = prefix+str(statnb)+str(vnb)+str(pnb)+"00000"
4684 layer = prefix+"layer_"+str(lnb)+"_"+str(statnb)+str(vnb)+str(pnb)+str(lnb)+"0000"
4685 wire = "gas_"+str(test.GetDetectorID())
4686 if statnb<3: wire = "gas_12_"+str(test.GetDetectorID())
4687 stat = "volDriftTube"+str(statnb)+"_"+str(statnb)
4688 path = "/"+stat+"/"+plane+"/"+layer+"/"+wire
4689 rc = nav.cd(path)
4690 W = nav.GetCurrentNode()
4691 S = W.GetVolume().GetShape()
4692 top = array('d',[0,0,S.GetDZ()])
4693 bot = array('d',[0,0,-S.GetDZ()])
4694 Gtop = array('d',[0,0,0])
4695 Gbot = array('d',[0,0,0])
4696 nav.LocalToMaster(top, Gtop)
4697 nav.LocalToMaster(bot, Gbot)
4698
4699 o = [S.GetOrigin()[0],S.GetOrigin()[1],S.GetOrigin()[2]]
4700 local = array('d',o)
4701 globOrigin = array('d',[0,0,0])
4702 nav.LocalToMaster(local,globOrigin)
4703
4704#new idea for residuals:
4705#4 rounds, in each round one layer from all stations is switched off

◆ debugRPCposition()

conditionsDatabase.demo.drifttubeMonitoring.debugRPCposition ( )

Definition at line 4822 of file drifttubeMonitoring.py.

4822def debugRPCposition():
4823 ut.bookHist(h,'RPCXY','RPC XY True - digi',100,-5.,5.,100,-5.,5.)
4824 for n in range(sTree.GetEntries()):
4825 rc=sTree.GetEvent(n)
4826 for hit in sTree.Digi_MuonTaggerHits:
4827 hit.EndPoints(vtop,vbot)
4828 for point in sTree.MuonTaggerPoint:
4829 if point.GetDetectorID()//10000 != hit.GetDetectorID()//10000: continue
4830 rc=h['RPCXY'].Fill(point.GetX()-(vtop[0]+vbot[0])/2.,point.GetY()-(vtop[1]+vbot[1])/2.)

◆ debugRPCstrips()

conditionsDatabase.demo.drifttubeMonitoring.debugRPCstrips ( )

Definition at line 4465 of file drifttubeMonitoring.py.

4465def debugRPCstrips():
4466 ut.bookHist(h,'RPCstrips','RPC strips',1000,-100.,100.,1000,-100.,100.)
4467 h['RPCstrips'].Draw()
4468 s=1
4469 for v in range(2):
4470 for c in range(1,185):
4471 if v==0 and c>105: continue
4472 if v==1 and c<12: continue
4473 if c%5==0:
4474 h['RPCstrip'+str(v)+str(c)]=ROOT.TGraph()
4475 detID = s*10000+v*1000+c
4476 vbot,vtop = RPCPositionsBotTop[detID]
4477 h['RPCstrip'+str(v)+str(c)].SetPoint(0,vtop[0],vtop[1])
4478 h['RPCstrip'+str(v)+str(c)].SetPoint(1,vbot[0],vbot[1])
4479 if v == 0: h['RPCstrip'+str(v)+str(c)].SetLineColor(ROOT.kRed)
4480 if v == 1: h['RPCstrip'+str(v)+str(c)].SetLineColor(ROOT.kBlue)
4481 h['RPCstrip'+str(v)+str(c)].Draw('same')

◆ debugRPCYCoordinate()

conditionsDatabase.demo.drifttubeMonitoring.debugRPCYCoordinate ( )

Definition at line 4482 of file drifttubeMonitoring.py.

4482def debugRPCYCoordinate():
4483 ut.bookHist(h,'y1y2','y1 vs y2 of RPC',100,-100.,100.,100,-100.,100.)
4484 for n in range(10000):
4485 rc = sTree.GetEvent(n)
4486 if not findSimpleEvent(sTree): continue
4487 for hit in sTree.Digi_MuonTaggerHits:
4488 channelID = hit.GetDetectorID()
4489 s = channelID/10000
4490 v = (channelID-10000*s)/1000
4491 if v==0 and s==1:
4492 vbot,vtop = RPCPositionsBotTop[channelID]
4493 y1 = (vtop[1]+vbot[1])/2.
4494 for hit in sTree.Digi_MuonTaggerHits:
4495 channelID = hit.GetDetectorID()
4496 s = channelID/10000
4497 v = (channelID-10000*s)/1000
4498 if v==0 and s==2:
4499 vbot,vtop = RPCPositionsBotTop[channelID]
4500 y2 = (vtop[1]+vbot[1])/2.
4501 rc = h['y1y2'].Fill(y1,y2)
4502

◆ debugTrackFit()

conditionsDatabase.demo.drifttubeMonitoring.debugTrackFit (   nEvents,
  nStart = 0,
  simpleEvents = True,
  singleTrack = True,
  PR = 1 
)

Definition at line 3845 of file drifttubeMonitoring.py.

3845def debugTrackFit(nEvents,nStart=0,simpleEvents=True,singleTrack=True,PR=1):
3846 matches={'good':[],'bad':[]}
3847 ut.bookHist(h,'residuals','all residuals',100,-1.,1.)
3848 ut.bookHist(h,'extrapX','extrap in X',100,-20.,20.)
3849 ut.bookHist(h,'extrapY','extrap in Y',100,-20.,20.)
3850 ut.bookHist(h,'fitfail_good','fitfailure by channel for good events',700,0.5,700.5)
3851 ut.bookHist(h,'fitfail_bad','fitfailure by channel for bad events',700,0.5,700.5)
3852#
3853 fitFailures=[{},{}]
3854 fitSuccess =[{},{}]
3855 for n in range(nStart,nStart+nEvents):
3856 rc = sTree.GetEvent(n)
3857 if simpleEvents:
3858 if not findSimpleEvent(sTree): continue
3859 tracks = findTracks(PR)
3860 if singleTrack and len(tracks)!=1: continue
3861# select RPC tracks with good Y info
3862 clusters, RPCtracks = muonTaggerClustering()
3863 if len(RPCtracks['X'])>1 or len(RPCtracks['Y'])>1: print n,len(RPCtracks['X']),len(RPCtracks['Y'])
3864 if len(RPCtracks['X'])!=1 or len(RPCtracks['Y'])!=1: continue
3865 X = RPCtracks['X'][0][0]*zRPC1+RPCtracks['X'][0][1]
3866 Y = RPCtracks['Y'][0][0]*zRPC1+RPCtracks['Y'][0][1]
3867 track_index = -1
3868 for atrack in tracks:
3869 track_index +=1
3870 st = atrack.getFitStatus()
3871 if not st.isFitConverged(): continue
3872 rc,pos,mom = extrapolateToPlane(atrack,zRPC1)
3873 if not rc: continue
3874 if abs(pos[0]-X)>5. : continue # not worth checking Y
3875 delta = pos[1]-Y
3876 if Debug: print "event# %i difference in X,Y %5.3F %5.3F "%(n,pos[0]-X,delta)
3877 rc = h['extrapX'].Fill(pos[0]-X)
3878 rc = h['extrapY'].Fill(delta)
3879 if abs(delta)<10. : matches['good'].append(n) # within ~3sigma
3880 else :
3881 matches['bad'].append(n)
3882 print "event# %i difference in X,Y %5.3F %5.3F "%(n,pos[0]-X,delta)
3883 Nmeas = atrack.getNumPointsWithMeasurement()
3884 if Nmeas>2: Npoints = Nmeas
3885 else:
3886 tr = sTree.TrackInfos[track_index]
3887 Npoints = tr.N()
3888 for kp in range(Npoints):
3889 wL,wR = -999,-999
3890 if Nmeas>2:
3891 p = atrack.getPointsWithMeasurement()[kp]
3892 rawM = p.getRawMeasurement()
3893 detID = rawM.getDetId()
3894 info = p.getFitterInfo()
3895 if info:
3896 wL = info.getWeights()[0]
3897 wR = info.getWeights()[1]
3898 else:
3899 detID = tr.detId(kp)
3900 wL = tr.wL(kp)
3901 wR = tr.wR(kp)
3902 if abs(delta)<10.: k=0
3903 elif abs(pos[1]-Y)>50.: k=1
3904 else: continue
3905 if wL<0.1 and wR < 0.1:
3906# record failure rate
3907 if not detID in fitFailures[k]: fitFailures[k][detID]=0
3908 fitFailures[k][detID]+=1
3909 else:
3910 if not detID in fitSuccess[k]: fitSuccess[k][detID]=0
3911 fitSuccess[k][detID]+=1
3912# upstream 12 channel, downstream 48
3913# 4 4 4 4 4 4 = 576
3914 for k in range(2):
3915 for detID in fitFailures[k]:
3916 test = ROOT.MufluxSpectrometerHit(detID,0)
3917 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(test)
3918 vbot,vtop = strawPositionsBotTop[detID]
3919 x = channelID
3920 if s > 2: x+= (s-2)*200 + 48*(2*l+p)
3921 else:
3922 if view == '_u': x+=50
3923 elif view == '_v': x+=100
3924 elif s==2: x+=150
3925 x+=12*(2*l+p)
3926 r = 1
3927 if fitSuccess[k].has_key(detID): r=fitFailures[k][detID]/float(fitSuccess[k][detID]+fitFailures[k][detID])
3928 if k==0: rc=h['fitfail_good'].SetBinContent(x,r)
3929 else: rc=h['fitfail_bad'].SetBinContent(x,r)
3930# only look at the pathological cases
3931 print "Summary: good matches: %i bad matches: %i failure rate %5.2F"%(
3932 len(matches['good']),len(matches['bad']),len(matches['bad'])/float(len(matches['bad'])+len(matches['good']) ) )
3933 ROOT.gROOT.FindObject('c1').cd()
3934 h['extrapY'].Draw()
3935 return matches
3936

◆ disableBranches()

conditionsDatabase.demo.drifttubeMonitoring.disableBranches ( )

Definition at line 5443 of file drifttubeMonitoring.py.

5443def disableBranches():
5444 # if sTree.GetBranchStatus("FitTracks"): sTree.SetBranchStatus("FitTracks",0)
5445 if sTree.GetBranchStatus("Digi_BeamCounters"): sTree.SetBranchStatus("Digi_BeamCounters",0)
5446 if sTree.GetBranchStatus("Digi_LateMufluxSpectrometerHits"): sTree.SetBranchStatus("Digi_LateMufluxSpectrometerHits",0)
5447 if sTree.GetBranchStatus("Digi_MufluxSpectrometerHits"): sTree.SetBranchStatus("Digi_MufluxSpectrometerHits",0)
5448 if sTree.GetBranchStatus("Digi_Scintillators"): sTree.SetBranchStatus("Digi_Scintillators",0)
5449 if sTree.GetBranchStatus("Digi_Triggers"): sTree.SetBranchStatus("Digi_Triggers",0)
5450 if sTree.GetBranchStatus("Digi_MasterTrigger"): sTree.SetBranchStatus("Digi_MasterTrigger",0)
5451 if sTree.GetBranchStatus("Digi_MuonTaggerHits"): sTree.SetBranchStatus("Digi_MuonTaggerHits",0)

◆ displayDTLayers()

conditionsDatabase.demo.drifttubeMonitoring.displayDTLayers ( )

Definition at line 877 of file drifttubeMonitoring.py.

877def displayDTLayers():
878 ut.bookHist(h,'upstream','upstream layers',12,-0.5,11.5,30,-0.5,29.5)
879 if not h.has_key('layerDisplay'): ut.bookCanvas(h,key='layerDisplay',title='Upstream Layers',nx=1600,ny=1200,cx=1,cy=0)
880 h['upstreamG'] = ROOT.TGraph()
881 h['upstreamG'].Set(0)
882 h['upstreamG'].SetMarkerStyle(8)
883 h['upstreamG'].SetMarkerSize(2)
884 n=0
885 for hit in sTree.Digi_MufluxSpectrometerHits:
886 detID = hit.GetDetectorID()
887 if detID<0: continue # feature for converted data in February'19
888 statnb,vnb,pnb,lnb,view,channelID,tdcId,nRT = stationInfo(hit)
889 nr = detID%100
890 y = 2*pnb+lnb+(statnb-1)*16
891 if view=='_u': y+=8
892 if view=='_x' and statnb>1: y+=8
893 h['upstreamG'].SetPoint(n,nr,y)
894 n+=1
895 tc = h['layerDisplay'].cd(1)
896 h['upstream'].Draw()
897 h['upstreamG'].Draw('sameP')
898

◆ displayTrack()

conditionsDatabase.demo.drifttubeMonitoring.displayTrack (   theTrack,
  debug = False 
)

Definition at line 1778 of file drifttubeMonitoring.py.

1778def displayTrack(theTrack,debug=False):
1779 zstart = 0
1780 nPoints = 100
1781 delz = 1000./nPoints
1782 nt = len(h['dispTrack'])
1783 h['dispTrack'].append( ROOT.TGraph(nPoints) )
1784 h['dispTrackY'].append( ROOT.TGraph(nPoints) )
1785 for nP in range(nPoints):
1786 zstart+=delz
1787 rc,pos,mom = extrapolateToPlane(theTrack,zstart)
1788 if not rc: print "dispTrack extrap failed"
1789 else:
1790 h['dispTrack'][nt].SetPoint(nP,zstart,pos[0])
1791 h['dispTrackY'][nt].SetPoint(nP,zstart,pos[1])
1792 if debug:
1793 bfield.get(pos[0],pos[1],pos[2],Bx,By,Bz)
1794 print "%5.2F %5.2F %5.2F %5.2F %5.2F %5.2F %5.2F %5.2F %5.2F "%(pos[0],pos[1],pos[2],Bx,By,Bz,mom[0],mom[1],mom[2])
1795 # ptkick 1.03 / dalpha
1796 if nP ==0:
1797 fitStatus = theTrack.getFitStatus()
1798 print "trackinfo P/Pt/chi2/DoF/Ndf:%6.2F %6.2F %6.2F %6.2F"%(mom.Mag(),mom.Pt(),fitStatus.getChi2()/fitStatus.getNdf(),fitStatus.getNdf())
1799 st = theTrack.getFittedState(0)
1800 # if st.getPDG()*st.getCharge()>0: print "something wrong here",st.getPDG(),st.getCharge()
1801 if debug:
1802 N = theTrack.getNumPointsWithMeasurement()
1803 momU = theTrack.getFittedState(0).getMom()
1804 momD = theTrack.getFittedState(N-1).getMom()
1805 dalpha = momU[0]/momU[2] - ( momD[0]/momD[2] )
1806 slopeA = momU[0]/momU[2]
1807 slopeB = momD[0]/momD[2]
1808 posU = theTrack.getFittedState(0).getPos()
1809 posD = theTrack.getFittedState(N-1).getPos()
1810 bA = posU[0]-slopeA*posU[2]
1811 bB = posD[0]-slopeB*posD[2]
1812 x1 = zgoliath*slopeA+bA
1813 x2 = zgoliath*slopeB+bB
1814 delx = x2-x1
1815 rc = h['delx'].Fill(delx)
1816 print "mom from pt kick=",1.03/dalpha
1817 for j in range(theTrack.getNumPointsWithMeasurement()):
1818 st = theTrack.getFittedState(j)
1819 pos,mom = st.getPos(), st.getMom()
1820 print "%i %5.2F %5.2F %5.2F %5.2F %5.2F %5.2F %i %i "%(j,pos[0],pos[1],pos[2],mom[0],mom[1],mom[2],st.getPDG(),st.getCharge())
1821 h['dispTrack'][nt].SetLineColor(ROOT.kMagenta)
1822 h['dispTrack'][nt].SetLineWidth(3)
1823 h['dispTrackY'][nt].SetLineColor(ROOT.kOrange)
1824 h['dispTrackY'][nt].SetLineWidth(3)
1825 h['dispTrackY'][nt].SetLineStyle(10)
1826 h['simpleDisplay'].cd(1)
1827 h['dispTrack'][nt].Draw('same')
1828 h['dispTrackY'][nt].Draw('same')
1829 h[ 'simpleDisplay'].Update()
1830 dispTrack3D(theTrack)

◆ dispTrack3D()

conditionsDatabase.demo.drifttubeMonitoring.dispTrack3D (   theTrack)

Definition at line 860 of file drifttubeMonitoring.py.

860def dispTrack3D(theTrack):
861 zstart = 0
862 nPoints = 100
863 delz = 1000./nPoints
864 nt = len(h['dispTrack3D'])
865 h['dispTrack3D'].append( ROOT.TPolyLine3D(nPoints) )
866 h['dispTrack3D'][nt].SetLineWidth(3)
867 h['dispTrack3D'][nt].SetLineColor(ROOT.kBlack)
868 for nP in range(nPoints):
869 zstart+=delz
870 rc,pos,mom = extrapolateToPlane(theTrack,zstart)
871 if not rc: print "extrap failed"
872 else:
873 h['dispTrack3D'][nt].SetPoint(nP,pos[0],pos[1],pos[2])
874 rc = ROOT.gROOT.FindObject('c1').cd()
875 h['dispTrack3D'][nt].Draw('oglsame')
876 rc = ROOT.gROOT.FindObject('c1').Update()

◆ doFit()

conditionsDatabase.demo.drifttubeMonitoring.doFit (   p0 = 5.7,
  p1 = 0.17 
)

Definition at line 7384 of file drifttubeMonitoring.py.

7384def doFit(p0=5.7,p1=0.17):
7385# prepare histos
7386 x='mu'
7387 pMin = 5.
7388 for a in ['p/pt','p/px']:
7389 for H in [h,hMC,hCharm]:
7390 H[a+'_x'+x] = H[a+x].ProjectionX(a+'_x'+x)
7391 a = 'p/Abspx'
7392 for H in [h,hMC,hCharm]:
7393 H[a+'_y'+x] = H[a+x].ProjectionY(a+'_y'+x,h[a+'_x'+x].FindBin(pMin),h[a+'_x'+x].GetNbinsX())
7394 npar = 2
7395 gMinuit = ROOT.TMinuit(npar)
7396 gMinuit.SetMaxIterations(100000)
7397 gMinuit.SetFCN(fcn)
7398 vstart = array('d',[p0,p1])
7399 step = array('d',[2.,2.])
7400 ierflg = ROOT.Long(0)
7401 name = [ROOT.TString("dataMC"),ROOT.TString("charmMbias")]
7402 for i in range(npar): gMinuit.mnparm(i, name[i], vstart[i], step[i], 0.,0.,ierflg)
7403 #gMinuit.FixParameter(0)
7404 gMinuit.mnexcm("SIMPLEX",vstart,npar,ierflg)
7405 gMinuit.mnexcm("MIGRAD",vstart,npar,ierflg)
7406 pot = ROOT.Double()
7407 charmNorm = ROOT.Double()
7408 e = ROOT.Double()
7409 gMinuit.GetParameter(0,pot,e)
7410 gMinuit.GetParameter(1,charmNorm,e)
7411 print "RESULT:",abs(pot), abs(charmNorm)
7412 MCcomparison(abs(pot), pMin,1.0,abs(charmNorm))

◆ doFitByHand()

conditionsDatabase.demo.drifttubeMonitoring.doFitByHand ( )

Definition at line 7413 of file drifttubeMonitoring.py.

7413def doFitByHand():
7414 p0min = 1.
7415 p0max = 10.
7416 p1min = 0.1
7417 p1max = 5.
7418 N = 100
7419 chi2Max = 1E10
7420 pChi2Min = [1.,1.]
7421 for p0 in numpy.linspace(p0min,p0max,N):
7422 for p1 in numpy.linspace(p1min,p1max,N):
7423 p=[p0,p1]
7424 chi2=[0]
7425 fcn(2,0,chi2,p,2)
7426 if chi2[0]<chi2Max:
7427 pChi2Min = [p0,p1]
7428 chi2Max=chi2[0]
7429 print chi2Max,pChi2Min

◆ DTEfficiencyFudgefactor()

conditionsDatabase.demo.drifttubeMonitoring.DTEfficiencyFudgefactor (   method = -1)

Definition at line 1066 of file drifttubeMonitoring.py.

1066def DTEfficiencyFudgefactor(method=-1):
1067 if method <1: effFudgeFactors = {"u":1.1, "v":1.1, "x2":1.1, "x3":1.1, "x1":1.1,"x4":1.1}
1068 if method ==0: effFudgeFactors = {"x1":0.97, "u":0.95, "x2":0.96, "v":0.96, "x3":0.92, "x4":0.97} # method 0
1069 if method ==2: effFudgeFactors = {"x1":0.94, "u":0.93, "x2":0.95, "v":0.93, "x3":0.90, "x4":0.94} # method 2
1070 for x in effFudgeFactors: muflux_Reco.setEffFudgeFactor(x,effFudgeFactors[x])
1071
1072# C++ reconstruction/monitoring

◆ DTeffWithRPCTracks()

conditionsDatabase.demo.drifttubeMonitoring.DTeffWithRPCTracks (   Nevents = 0,
  onlyPlotting = False,
  fHisto = None 
)

Definition at line 3318 of file drifttubeMonitoring.py.

3318def DTeffWithRPCTracks(Nevents=0,onlyPlotting=False,fHisto=None):
3319 # /eos/experiment/ship/user/odurhan/muflux-recodata/RUN_8000_2199
3320 addCuts = {'':0,'Chi2<':0.7,'Dely<':5,'Delx<':2,'All':1}
3321 align2RPC = {4:[-1.,3.2],3:[-2.,5.],2:[-6.,8.],1:[-6.,8.]}
3322 stationDetIDs = {'x1':[10002001,10002012],'u':[11002001,11002012],'x2':[21102001,21102012],
3323 'v':[20112001,20112012],'x3':[30002001,30002048],'x4':[40002001,40002048]}
3324 stationZ = {}
3325 for s in range(1,5):
3326 vbot,vtop = strawPositionsBotTop[stationDetIDs['x'+str(s)][0]]
3327 z = (vbot[2]+vtop[2])/2.
3328 xmin = (vbot[0]+vtop[0])/2.
3329 vbot,vtop = strawPositionsBotTop[stationDetIDs['x'+str(s)][1]]
3330 xmax = (vbot[0]+vtop[0])/2.
3331 stationZ[s] = [z,xmin,xmax]
3332 if not onlyPlotting:
3333 if Nevents==0: Nevents = sTree.GetEntries()
3334 for tag_s in range(1,5):
3335 ut.bookHist(h,'upStreamOcc'+str(tag_s),"station 1&2",200,-0.5,199.5)
3336 ut.bookHist(h,'upStreamOccWithTrack'+str(tag_s),"station 1&2",200,-0.5,199.5)
3337 ut.bookHist(h,'upStreamOccWithTrack_mu'+str(tag_s),"station 1&2",200,-0.5,199.5)
3338 ut.bookHist(h,'upStreamOccWithTrack_muX'+str(tag_s),"station 1&2",200,-0.5,199.5)
3339 ut.bookHist(h,'upStreamOccWithTrack_Chi2'+str(tag_s),"station 1&2",200,-0.5,199.5)
3340 ut.bookHist(h,'upStreamOccWithTrack_Chi2mu'+str(tag_s),"station 1&2",200,-0.5,199.5)
3341 for tag_s in range(1,5):
3342 for s in range(1,5):
3343 ut.bookHist(h,'hitsIn'+str(s)+'_'+str(tag_s),'number of hits '+str(s),10,-0.5,9.5)
3344 ut.bookHist(h,'hits' +str(s)+'_'+str(tag_s),'number of hits in layer '+str(s),7,-0.5,6.5)
3345 for l in range(4):
3346 if tag_s==1: ut.bookHist(h,'distX' +str(s)+str(l),'distance of RPC track to hit '+str(s)+str(l),100,-10.,10.)
3347 ut.bookHist(h,'distXref'+str(s)+str(l)+'_'+str(tag_s),'distance of refitted RPC track to hit '+str(s)+str(l),100,-10.,10.)
3348 Ntot = [0,0,0,0,0]
3349 Ntrack = [0,0,0,0,0]
3350 Ineff = 0
3351 view = 0
3352 for n in range(Nevents):
3353 rc = sTree.GetEvent(n)
3354 anyTrack = {}
3355 if len(sTree.RPCTrackX)!=1 or len(sTree.RPCTrackY)!=1 : continue
3356 clusters = findDTClusters()
3357 # require u and v clusters, but no too many
3358 if len(clusters[1][1])==0 or len(clusters[1][1])>2: continue
3359 if len(clusters[2][2])==0 or len(clusters[2][2])>2: continue
3360#
3361 spectrHitsSorted = ROOT.nestedList()
3362 candidates= {1:{0:[],1:[],2:[],3:[]}, 2:{0:[],1:[],2:[],3:[]}, 3:{0:[],1:[],2:[],3:[]},4:{0:[],1:[],2:[],3:[]}}
3363 muflux_Reco.sortHits(sTree.Digi_MufluxSpectrometerHits,spectrHitsSorted,False)
3364 stationOcc={}
3365 for k in range(1,7):
3366 stationOcc[k]=0;
3367 s = k
3368 t = 0
3369 if k==5:
3370 s=1
3371 t=1
3372 elif k==6:
3373 s=2
3374 t=2
3375 for l in range(4):
3376 stationOcc[k]+=spectrHitsSorted[t][s][l].size()
3377 upStreamOcc = stationOcc[1]+stationOcc[5]+stationOcc[2]+stationOcc[6]
3378 for mu in sTree.RPCTrackX:
3379 # mu.m()*z + mu.b()
3380 for s in range(1,5):
3381 # only take simple events with one cluster per tagging station max
3382 if len(clusters[s][0]) > 1: continue
3383 for cl in clusters[s][0]:
3384 for clhit in cl:
3385 hit = clhit[0]
3386 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
3387 z = (vbot[2]+vtop[2])/2.
3388 x = (vbot[0]+vtop[0])/2.
3389 xExtr = mu.m()*z + mu.b()
3390 diff = x-xExtr - align2RPC[s][0]
3391 temp = stationInfo(hit) # s,v,p,l,view,channelID,tdcId,nRT
3392 l = 2*temp[2]+temp[3]
3393 if abs(diff)<align2RPC[s][1]: candidates[s][l].append(hit)
3394 rc = h['distX'+str(s)+str(l)].Fill(diff)
3395 # tagging with station tag_s, require only one candidate.
3396 for tag_s in range(1,5):
3397 unique = True
3398 for l in candidates[tag_s]:
3399 if len(candidates[tag_s][l])>1: unique = False
3400 if not unique: continue
3401 pos={}
3402 zRPC1 = 880.
3403 pos[zRPC1] = mu.m()*zRPC1 + mu.b()
3404 for l in candidates[tag_s]:
3405 for hit in candidates[tag_s][l]:
3406 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
3407 pos[(vbot[2]+vtop[2])/2.]=(vbot[0]+vtop[0])/2.
3408# with drift time problem of LR ambiguity
3409 withTDC = False
3410 if withTDC:
3411 tdc = hit.GetDigi()
3412 distance = RT(hit,tdc)
3413 pos[(vbot[2]+vtop[2])/2.]=(vbot[0]+vtop[0])/2. + distance
3414 pos[(vbot[2]+vtop[2])/2.]=(vbot[0]+vtop[0])/2. - distance
3415 if len(pos)<3: continue # 1 RPC point + >1 DT point
3416 coefficients = numpy.polyfit(pos.keys(),pos.values(),1)
3417# check that track is in acceptance
3418 inAcc=True
3419 for s in stationZ:
3420 xExtr = coefficients[0]*stationZ[s][0] + coefficients[1]
3421 if xExtr<stationZ[s][1] or xExtr>stationZ[s][2]: inAcc = False
3422 if not inAcc: continue
3423 rc = h['upStreamOcc'+str(tag_s)].Fill(upStreamOcc)
3424 anyTrack[s] = False
3425# up to here, track found for given RPC + tagging station tag_s
3426 goodTracks = {'':[],'Chi2<':[],'mu':[],'muX':[],'Chi2<mu':[]}
3427 k=-1
3428 for aTrack in sTree.FitTracks:
3429 k+=1
3430# default cuts:
3431 fitStatus = aTrack.getFitStatus()
3432 if not fitStatus.isFitConverged(): continue
3433 hitsPerStation = countMeasurements(k,1)
3434 if len(hitsPerStation['x1'])<2 or len(hitsPerStation['x2'])<2 or len(hitsPerStation['x3'])<2 or len(hitsPerStation['x4'])<2: continue
3435 goodTracks[''].append(k)
3436 chi2OK = fitStatus.getChi2()/fitStatus.getNdf() < addCuts['Chi2<']
3437 if chi2OK: goodTracks['Chi2<'].append(k)
3438# check that track is matched to RPC
3439 posRPC=ROOT.TVector3()
3440 momRPC=ROOT.TVector3()
3441 rc = muflux_Reco.extrapolateToPlane(aTrack,cuts["zRPC1"], posRPC, momRPC)
3442 X=ROOT.kFALSE
3443 Y=ROOT.kFALSE
3444 for hit in sTree.RPCTrackX:
3445 Xpos = hit.m()*cuts["zRPC1"]+hit.b()
3446 dist = ROOT.TMath.Abs(posRPC[0]-Xpos)
3447 if dist<cuts["muTrackMatchX"]: X=ROOT.kTRUE
3448 for hit in sTree.RPCTrackY:
3449 Ypos = hit.m()*cuts["zRPC1"]+hit.b()
3450 dist = ROOT.TMath.Abs(posRPC[1]-Ypos)
3451 if dist<cuts["muTrackMatchY"]: Y=ROOT.kTRUE
3452 if X and Y: goodTracks['mu'].append(k)
3453 if X: goodTracks['muX'].append(k)
3454 if X and Y and chi2OK: goodTracks['Chi2<mu'].append(k)
3455 for c in goodTracks:
3456 for x in goodTracks[c]:
3457 if c=='':
3458 rc = h['upStreamOccWithTrack'+str(tag_s)].Fill(upStreamOcc)
3459 Ntrack[tag_s] += 1
3460 if c=='mu':
3461 rc = h['upStreamOccWithTrack_mu'+str(tag_s)].Fill(upStreamOcc)
3462 anyTrack[s] = True
3463 if c=='muX': rc = h['upStreamOccWithTrack_muX'+str(tag_s)].Fill(upStreamOcc)
3464 if c=='Chi2<': rc = h['upStreamOccWithTrack_Chi2'+str(tag_s)].Fill(upStreamOcc)
3465 if c=='Chi2<mu': rc = h['upStreamOccWithTrack_Chi2mu'+str(tag_s)].Fill(upStreamOcc)
3466 Ntot[tag_s] += 1
3467 nhits={1:0,2:0,3:0,4:0}
3468 for s in range(1,5):
3469 for l in range(4):
3470 first = True
3471 for hit in spectrHitsSorted[view][s][l]:
3472 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
3473 z = (vbot[2]+vtop[2])/2.
3474 x = (vbot[0]+vtop[0])/2.
3475 xExtr = coefficients[0]*z + coefficients[1]
3476 rc = h['distXref'+str(s)+str(l)+'_'+str(tag_s)].Fill(x-xExtr)
3477 if abs(x-xExtr)<5.:
3478 if first:
3479 nhits[s]+=1
3480 first = False
3481 h['hits'+str(s)+'_'+str(tag_s)].Fill(l)
3482 h['hitsIn'+str(s)+'_'+str(tag_s)].Fill(nhits[s])
3483 # if (tag_s==1 or tag_s==2) and nhits[s]==0: print "no hits in station ",s,' event ',n
3484 if nhits[4] < 2: Ineff+=1
3485 for s in anyTrack:
3486 if not anyTrack[s] and Debug: print "no fitted track found",n
3487 for tag_s in range(1,5):
3488 for s in range(1,5):
3489 h['hits'+str(s)+'_'+str(tag_s)].SetBinContent(6,Ntot[tag_s])
3490 h['hits'+str(s)+'_'+str(tag_s)].SetBinContent(7,Ntrack[tag_s])
3491 print "rough estimate of station inefficiency:",float(Ineff)/(Ntot[tag_s]+1E-5)
3492 ut.writeHists(h,'histos-DTEff'+rname)
3493 else:
3494# analysis part
3495 ut.bookHist(h,'effLayer','efficiency per Layer',24,-0.5,23.5)
3496 if not h.has_key('hits1_1'):
3497 if fHisto: ut.readHists(h,fHisto)
3498 else: ut.readHists(h,'DTEff.root')
3499 effPerLayer = {}
3500 for tag_s in range(1,5):
3501 t = 'tagstation'+str(tag_s)
3502 if not h.has_key(t):
3503 ut.bookCanvas(h,key=t,title='with tagging station '+str(tag_s),nx=1600,ny=1200,cx=4,cy=4)
3504 print "analysis with tagging station ",tag_s
3505 effPerLayer[tag_s] = {}
3506 for s in range(1,5):
3507 for l in range(4):
3508 j = (s-1)*4+l+1
3509 h[t].cd(j)
3510 hname = 'distXref'+str(s)+str(l)+'_'+str(tag_s)
3511 fitFunction = myGauss
3512 fitFunction.SetParameter(0,h[hname].GetEntries()*h[hname].GetBinWidth(1))
3513 fitFunction.SetParameter(1,0.)
3514 fitFunction.SetParameter(2,1.2)
3515 fitFunction.SetParameter(3,0.)
3516 fitResult = h[hname].Fit(fitFunction,'SQ','',-10.,10.)
3517 rc = fitResult.Get()
3518 background = rc.Parameter(3) * h[hname].GetNbinsX()
3519 bckInterval = float(h[hname].GetNbinsX() - (h[hname].FindBin(4.) - h[hname].FindBin(-4.)) )
3520 backgroundBinary = h[hname].Integral(1,h[hname].FindBin(-4.)) + h[hname].Integral(h[hname].FindBin(4.),h[hname].GetNbinsX())
3521 estSignalBinary = h[hname].GetSumOfWeights() - backgroundBinary/bckInterval*h[hname].GetNbinsX()
3522 signal1 = h[hname].GetSumOfWeights()-background
3523 signal2 = rc.Parameter(0)
3524 err = ROOT.TMath.Sqrt(float(h['hits'+str(s)+'_'+str(tag_s)].GetBinContent(6))-estSignalBinary)/float(h['hits'+str(s)+'_'+str(tag_s)].GetBinContent(6))
3525 # print "debug",tag_s,s,l,':',signal1,signal2,estSignalBinary,err
3526 signal = estSignalBinary
3527 effPerLayer[tag_s][10*s+l] = signal / float(h['hits'+str(s)+'_'+str(tag_s)].GetBinContent(6))
3528 if tag_s == 1 and s!=1 or tag_s == 2 and s==1:
3529 L = j
3530 if s>1: L+=4
3531 if s>2: L+=4
3532 h['effLayer'].SetBinContent(L,effPerLayer[tag_s][10*s+l])
3533 h['effLayer'].SetBinError(L,err)
3534# remove self tagging from plot
3535 h[t].Update()
3536 for p in h[t].GetListOfPrimitives():
3537 if not p : continue
3538 pname = p.GetName()
3539 for l in range(4):
3540 test = t+'_'+str((tag_s-1)*4+l+1)
3541 if pname == test: p.Delete()
3542 myPrint(h[t],'DTeffPerLayer-station'+str(tag_s)+'_res')
3543 print "tagging station : 1 2 3 4"
3544 for s in range(1,5):
3545 for l in range(4):
3546 text = "efficiencies for station %i layer %i:"%(s,l)
3547 for tag_s in range(1,5):
3548 text+=" %5.2F%% "%(effPerLayer[tag_s][10*s+l]*100)
3549 print text
3550 ut.bookHist(h,'DTeffPerLayer','DT hit efficiency per layer',50,0.5,50.5)
3551 choice = {1:[2,ROOT.kRed],2:[1,ROOT.kGreen],3:[1,ROOT.kBlue],4:[1,ROOT.kMagenta]}
3552#
3553 j = 0
3554 for s in range(1,5):
3555 for view in ['_x','_u','_v']:
3556 if s>2 and view != '_x': continue
3557 if s==1 and view == '_v' or s==2 and view == '_u': continue
3558 if view !='_x':
3559 j+=4
3560 continue
3561 tag_s = choice[s][0]
3562 for l in range(4):
3563 j+=1
3564 h['DTeffPerLayer'].SetBinContent(j,effPerLayer[tag_s][10*s+l])
3565 h['DTeffPerLayer'].SetMinimum(0.6)
3566 h['DTeffPerLayer'].SetMaximum(1.0)
3567 h['DTeffPerLayer'].SetStats(0)
3568 ut.bookCanvas(h,'ct','',700,500,1,1)
3569 ut.bookCanvas(h,'c2','',700,500,1,1)
3570 h['ct'].cd(1)
3571 h['effLayer'].SetMaximum(1.)
3572 h['effLayer'].SetMinimum(0.5)
3573 h['effLayer'].SetStats(0)
3574 h['effLayer'].SetMarkerStyle(21)
3575 h['effLayer'].SetMarkerColor(h['effLayer'].GetLineColor())
3576 h['effLayer'].GetXaxis().SetLabelSize(0.05)
3577 h['effLayer'].GetYaxis().SetLabelSize(0.05)
3578 h['effLayer'].Draw()
3579 fitResult = h['effLayer'].Fit('pol0','SQ','',0.,24.)
3580 rc=fitResult.Get()
3581 h['Efftxt'] = ROOT.TLatex(2,0.60,'mean efficiency = %5.2F'%(rc.GetParams()[0]))
3582 h['Efftxt'].Draw()
3583 myPrint(h['ct'],'EffLayerWithRPCTracks')
3584# inefficiency per station
3585 first = True
3586 h['leghits']=ROOT.TLegend(0.51,0.41,0.84,0.59)
3587 h['c2'].cd(1)
3588 for s in choice:
3589 tag_s = choice[s][0]
3590 ntags = h['hits4_'+str(tag_s)].GetBinContent(6)
3591 xHits = h['hitsIn'+str(s)+'_'+str(tag_s)]
3592 inEff = xHits.GetBinContent(1)+xHits.GetBinContent(2)
3593 xx = 'tmphitsIn'+str(s)+'_'+str(tag_s)
3594 h[xx]=xHits.Clone(xx)
3595 h[xx].Scale(1./ntags)
3596 h[xx].SetStats(0)
3597 h[xx].SetLineColor(choice[s][1])
3598 h[xx].SetLineWidth(2)
3599 h[xx].SetMarkerStyle(20)
3600 if first:
3601 h[xx].GetXaxis().SetRangeUser(-0.5,5.5)
3602 h[xx].GetXaxis().SetLabelSize(0.05)
3603 h[xx].GetXaxis().SetTitleSize(0.04)
3604 h[xx].GetYaxis().SetLabelSize(0.05)
3605 h[xx].SetTitle(';number of hits;occurence per track')
3606 h[xx].Draw()
3607 first = False
3608 else: h[xx].Draw('same')
3609 ltext = xHits.GetName().split('_')[0].replace('hitsIn','hits in station ')
3610 rc = h['leghits'].AddEntry(h[xx],ltext,'PL')
3611 print "station %i ineff=%5.2F%%"%(s,inEff/ntags*100.)
3612 recoEff = 0
3613 for tag_s in range(1,5):
3614 ntags = h['hits4_'+str(tag_s)].GetBinContent(6)
3615 ntracks = h['hits4_'+str(tag_s)].GetBinContent(7)
3616 recoEff += ntracks/ntags
3617 print "track eff %i ineff=%5.2F%%"%(tag_s,ntracks/ntags*100.)
3618 print "average track eff = %5.2F%%"%(recoEff/4.*100.)
3619 for x in ['upStreamOcc','upStreamOccWithTrack','upStreamOccWithTrack_mu','upStreamOccWithTrack_muX','upStreamOccWithTrack_Chi2','upStreamOccWithTrack_Chi2mu']:
3620 # only take average of tags in upstream station
3621 h[x] = h[x+str(1)].Clone(x)
3622 h[x].Add(h[x+str(2)])
3623 h[x].Scale(1./2.)
3624 Ntag = h['upStreamOcc'].GetEntries()
3625 Ntrack = h['upStreamOccWithTrack'].GetEntries()
3626 Nmu = h['upStreamOccWithTrack_mu'].GetEntries()
3627 NmuX = h['upStreamOccWithTrack_muX'].GetEntries()
3628 NChi2 = h['upStreamOccWithTrack_Chi2'].GetEntries()
3629 NChi2mu = h['upStreamOccWithTrack_Chi2mu'].GetEntries()
3630 print "====== Ntags=",Ntag
3631 print "average track eff = %5.2F%%"%( (Ntrack*100.)/Ntag)
3632 print "average track mu eff = %5.2F%%"%( (Nmu*100.)/Ntag)
3633 print "average track Chi2 eff = %5.2F%%"%( (NChi2*100.)/Ntag)
3634 print "average track Chi2 mu eff = %5.2F%%"%( (NChi2mu*100.)/Ntag)
3635 print "average chi2 eff on top of = %5.2F%%"%( (NChi2*100.)/Ntrack)
3636 print "average chi2 eff on top of mu = %5.2F%%"%( (NChi2mu*100.)/Nmu)
3637 h['leghits'].Draw()
3638 myPrint(h['c2'],'DTeffHitsPerStation')
3639

◆ DTreconstructible()

conditionsDatabase.demo.drifttubeMonitoring.DTreconstructible ( )

Definition at line 5038 of file drifttubeMonitoring.py.

5038def DTreconstructible():
5039 trackList={}
5040 pTrue ={}
5041 minZ = 9999
5042 for point in sTree.MufluxSpectrometerPoint:
5043 trackID = point.GetTrackID()
5044 if trackID<0 :continue
5045 if not trackList.has_key(trackID):
5046 trackList[trackID]= {1:0,2:0,3:0,4:0,5:0,6:0}
5047 detID = point.GetDetectorID()
5048 hit = ROOT.MufluxSpectrometerHit(detID,0)
5049 info = hit.StationInfo()
5050 s=info[0]
5051 if info[4]>0: s=4+info[4]
5052 trackList[trackID][s]+=1
5053 if point.GetZ()<minZ:
5054 minZ = point.GetZ()
5055 pTrue[trackID]=ROOT.TVector3(point.GetPx(),point.GetPy(),point.GetPz())
5056 return trackList,pTrue
5057

◆ efficiencyEstimates()

conditionsDatabase.demo.drifttubeMonitoring.efficiencyEstimates (   method = 2,
  MCdata = False 
)

Definition at line 3684 of file drifttubeMonitoring.py.

3684def efficiencyEstimates(method=2,MCdata=False):
3685 if h['biasResDist'].GetEntries()==0:
3686 h.clear()
3687 if not MCdata: ut.readHists(h,'residuals.root')
3688 else:
3689 ut.readHists(h,'residuals-mbias.root')
3690 ut.readHists(h,'residuals-charm.root')
3691 print "don't forget to set MCdata = True for MC"
3692 hinweis={}
3693 hinweis[0] = "method 0: use biasResDistX, count entries between -0.5 and 0.5"
3694 hinweis[1] = "method 1: use biasResDistX, but take signal from single gauss fit"
3695 hinweis[2] = "method 2: use biasRes, subtract background from fit on number of entries"
3696 hinweis[3] = "method 3: use biasRes, take signal from double gauss fit"
3697 if not h.has_key('biasedResiduals'): plotBiasedResiduals(onlyPlotting=True)
3698 Ntracks = h['biasResTrackMom'].GetEntries()
3699 ut.bookHist(h,'effLayer','efficiency per Layer;continuous layer number',24,-0.5,23.5)
3700 ut.bookHist(h,'effLayerBinary','efficiency per Layer;continuous layer number',24,-0.5,23.5)
3701 if not h.has_key('biasResDistX_1_x1'):
3702 for s in range(1,5):
3703 for view in ['_x','_u','_v']:
3704 if s>2 and view != '_x': continue
3705 if s==1 and view == '_v' or s==2 and view == '_u': continue
3706 for l in range(0,4):
3707 hname = 'biasResDistX_'+str(s)+view+str(l)
3708 h[hname] = h['biasResDist_'+str(s)+view+str(l)].ProjectionY().Clone(hname)
3709 j = 0
3710 h['effDict'] = {}
3711 print "efficiencies using ",hinweis[method]
3712 for s in range(1,5):
3713 for view in ['_x','_u','_v']:
3714 if s>2 and view != '_x': continue
3715 if s==1 and view == '_v' or s==2 and view == '_u': continue
3716 effStation = 0
3717 effStationBinary = 0
3718 for l in range(0,4):
3719 tc = h['biasedResiduals'].cd(j+1)
3720 if method == 0 or method == 1: hname = 'biasResDistX_'+str(s)+view+str(l)
3721 else: hname = 'biasResXL_'+str(s)+view+str(l)+'_projx'
3722 xmin = -3.5
3723 xmax = 3.5
3724 if method==0 or method==1:
3725 xmin = -0.7
3726 xmax = 0.7
3727 fitResult = h[hname].Fit('gaus','SQ','',xmin,xmax)
3728 rc = fitResult.Get()
3729 fitFunction = h[hname].GetFunction('DoubleGauss')
3730 if not fitFunction : fitFunction = myGauss2
3731 if not rc:
3732 print "simple gaus fit failed"
3733 fitFunction.SetParameter(0,h[hname].GetEntries()*h[hname].GetBinWidth(1))
3734 fitFunction.SetParameter(1,0.)
3735 fitFunction.SetParameter(2,0.1)
3736 fitFunction.SetParameter(3,1.)
3737 fitFunction.SetParameter(4,0.)
3738 fitFunction.SetParameter(5,1.)
3739 else:
3740 fitFunction.SetParameter(0,rc.GetParams()[0]*ROOT.TMath.Sqrt(2*ROOT.TMath.Pi())*rc.GetParams()[2])
3741 fitFunction.SetParameter(1,rc.GetParams()[1])
3742 fitFunction.SetParameter(2,rc.GetParams()[2])
3743 fitFunction.SetParameter(3,0.)
3744 fitFunction.SetParameter(4,fitFunction.GetParameter(0)*0.1)
3745 fitFunction.SetParameter(5,fitFunction.GetParameter(2)*10.)
3746 if method == 2 :
3747 fitFunction.FixParameter(4,0.)
3748 fitFunction.FixParameter(5,1.)
3749 fitResult = h[hname].Fit(fitFunction,'SQ','',xmin,xmax)
3750 h[hname].Draw()
3751 rc = fitResult.Get()
3752 if method == 0: estSignal = h[hname].Integral(375,625)
3753 elif method == 1 or method == 3: estSignal = ( abs(rc.GetParams()[0])+abs(rc.GetParams()[4]))/h[hname].GetBinWidth(1)
3754 elif method == 2:
3755 imin,imax = h[hname].FindBin(xmin),h[hname].FindBin(xmax)
3756 estSignal = h[hname].Integral(imin,imax) - abs(rc.GetParams()[3]) * (imax-imin+1)
3757 bckInterval = float(h[hname].GetNbinsX() - (h[hname].FindBin(4.) - h[hname].FindBin(-4.)) )
3758 backgroundBinary = h[hname].Integral(1,h[hname].FindBin(-4.)) + h[hname].Integral(h[hname].FindBin(4.),h[hname].GetNbinsX())
3759 estSignalBinary = h[hname].GetSumOfWeights() - backgroundBinary/bckInterval*h[hname].GetNbinsX()
3760 effBinary = estSignalBinary/float(2*Ntracks)
3761 effBinaryError = ROOT.TMath.Sqrt(2*Ntracks-estSignalBinary)/float(2*Ntracks)
3762 effStationBinary += effBinary
3763 rc = h['effLayerBinary'].SetBinContent(j,effBinary)
3764 rc = h['effLayerBinary'].SetBinError(j,effBinaryError)
3765 eff = estSignal/float(Ntracks)
3766 effError = ROOT.TMath.Sqrt(Ntracks-estSignal)/float(Ntracks)
3767 if method==2:
3768 print "eff for %s = %5.2F binary %5.2F"%(hname,eff,effBinary)
3769 else:
3770 print "eff for %s = %5.2F"%(hname,eff)
3771 h['effDict'][hname]=eff
3772 effStation += eff
3773 rc = h['effLayer'].SetBinContent(j,eff)
3774 rc = h['effLayer'].SetBinError(j,effError)
3775 j+=1
3776 if method==2:
3777 print "station, %i %s, average efficiency: %5.3F binary %5.2F"%(s,view,effStation/4.,effStationBinary/4.)
3778 else:
3779 print "station, %i %s, average efficiency: %5.3F"%(s,view,effStation/4.)
3780 for p in h['biasedResiduals'].GetListOfPrimitives(): p.SetLogy(1)
3781 tc1 = ROOT.gROOT.FindObject('c1')
3782 tc1.SetWindowSize(1200,800)
3783 tc1.cd()
3784 h['effLayer'].SetMaximum(1.)
3785 h['effLayer'].SetMinimum(0.)
3786 h['effLayer'].SetStats(0)
3787 h['effLayer'].SetMarkerStyle(21)
3788 h['effLayer'].SetMarkerColor(h['effLayer'].GetLineColor())
3789 h['effLayerBinary'].SetStats(0)
3790 fitResult = h['effLayer'].Fit('pol0','SQ','',0.,22.)
3791 rc=fitResult.Get()
3792 h['Efftxt'] = ROOT.TLatex(2,0.60,'mean efficiency = %5.2F'%(rc.GetParams()[0]))
3793 h['Efftxt'].Draw()
3794 txt = 'effEstimate-method'+str(method)
3795 if MCdata: txt = 'MC'+txt
3796 if method==2:
3797 fitResult = h['effLayerBinary'].Fit('pol0','SQ','',0.,22.)
3798 rc=fitResult.Get()
3799 h['EfftxtBinary'] = ROOT.TLatex(2,0.56,'mean efficiency (binary) = %5.2F'%(rc.GetParams()[0]))
3800 h['EfftxtBinary'].SetTextColor(ROOT.kMagenta)
3801 h['effLayerBinary'].SetLineColor(ROOT.kMagenta)
3802 h['effLayerBinary'].SetMarkerStyle(8)
3803 h['effLayerBinary'].SetMarkerColor(h['effLayerBinary'].GetLineColor())
3804 h['effLayerBinary'].GetFunction('pol0').SetLineColor(h['effLayerBinary'].GetLineColor())
3805 h['effLayer'].GetFunction('pol0').SetLineColor(h['effLayer'].GetLineColor())
3806 h['effLayer'].GetXaxis().SetLabelSize(0.04)
3807 h['effLayer'].GetXaxis().SetTitleSize(0.04)
3808 h['effLayer'].GetYaxis().SetLabelSize(0.04)
3809 h['effLayer'].Draw()
3810 h['effLayer'].SetMinimum(0.5)
3811 h['effLayerBinary'].Draw('same')
3812 h['EfftxtBinary'].Draw()
3813 h['Efftxt'].Draw()
3814 myPrint(tc1,txt+'-summary')
3815

◆ energyLossRPC()

conditionsDatabase.demo.drifttubeMonitoring.energyLossRPC ( )

Definition at line 7140 of file drifttubeMonitoring.py.

7140def energyLossRPC():
7141 ut.bookHist(h,'eloss12','energy loss between stations 1 and 2;dE [GeV]',100,0.,5.)
7142 ut.bookHist(h,'eloss345','energy loss between stations 3,4 and 5;dE [GeV]',100,0.,5.)
7143 for n in range(sTree.GetEntries()):
7144 rc=sTree.GetEvent(n)
7145 E={}
7146 for p in sTree.MuonTaggerPoint:
7147 if abs(p.PdgCode())!=13: continue
7148 tid = p.GetTrackID()
7149 if not E.has_key(tid): E[tid]={}
7150 s=p.GetDetectorID()//10000
7151 mom=ROOT.TVector3(p.GetPx(),p.GetPy(),p.GetPz())
7152 E[tid][s]=mom.Mag()
7153 for t in E:
7154 for s in range(1,5):
7155 if E[t].has_key(s):
7156 if E[t].has_key(s+1):
7157 if s==1: rc = h['eloss12'].Fill(E[t][s]-E[t][s+1])
7158 else: rc = h['eloss345'].Fill(E[t][s]-E[t][s+1])
7159 ut.bookCanvas(h,'cx',' ',1200,600,1,1)
7160 h['cx'].cd(1)
7161 h['eloss345'].SetLineColor(ROOT.kMagenta)
7162 h['eloss12'].SetLineColor(ROOT.kBlue)
7163 h['eloss12'].SetTitle(';dE [GeV]')
7164 h['eloss12'].SetStats(0)
7165 h['eloss345scaled']=h['eloss345'].Clone('eloss345scaled')
7166 h['eloss345scaled'].Scale(1./3.)
7167 h['eloss345scaled'].SetTitle(';dE [GeV]')
7168 h['eloss345scaled'].SetStats(0)
7169 h['eloss345scaled'].Draw('hist')
7170 h['eloss12'].Draw('same')
7171 myPrint(h['cx'],'energyLossBetweenRPCs')

◆ extractMinAndMax()

conditionsDatabase.demo.drifttubeMonitoring.extractMinAndMax ( )

Definition at line 1395 of file drifttubeMonitoring.py.

1395def extractMinAndMax():
1396 h['tMinAndTmax']={}
1397 for p in h['TDCMapsX'].GetListOfPrimitives():
1398 for x in p.GetListOfPrimitives():
1399 if x.InheritsFrom('TH1'):
1400 p.cd()
1401 p.Update()
1402 tmin = 1000.
1403 tmax = -1.
1404 for n in range(1,x.GetNbinsX()-2):
1405 if x.GetBinContent(n)>2 and x.GetBinContent(n+1)>x.GetBinContent(n)+2 and x.GetBinContent(n+10)>x.GetBinContent(n):
1406 tmin = x.GetBinCenter(n)
1407 break
1408 tmp = x.Clone('tmp')
1409 tmp.Rebin(10)
1410 runningMean = 0
1411 mean = tmp.GetBinContent(tmp.FindBin(tmp.GetMean()))
1412 for m in range(tmp.GetNbinsX()-1,0,-1):
1413 runningMean=max(tmp.Integral(m,tmp.GetNbinsX()) / float(tmp.GetNbinsX()-m),2)
1414 if tmp.GetBinContent(m)>mean/5.:
1415 tmax = tmp.GetBinCenter(m)
1416 break
1417 h['tMinAndTmax'][x.GetName()]=[tmin,tmax]
1418 h[x.GetName()+'tMin'] = ROOT.TArrow(tmin,-5.,tmin,0.8,0.05,">")
1419 h[x.GetName()+'tMax'] = ROOT.TArrow(tmax,-5.,tmax,0.8,0.05,">")
1420 h[x.GetName()+'tMin'].SetLineColor(ROOT.kRed)
1421 h[x.GetName()+'tMax'].SetLineColor(ROOT.kRed)
1422 h[x.GetName()+'tMin'].Draw()
1423 h[x.GetName()+'tMax'].Draw()
1424 p.Update()
1425

◆ extractRTPanda()

conditionsDatabase.demo.drifttubeMonitoring.extractRTPanda (   hname = 'TDC1000_x')

Definition at line 1426 of file drifttubeMonitoring.py.

1426def extractRTPanda(hname= 'TDC1000_x'):
1427 R = ShipGeo.MufluxSpectrometer.InnerTubeDiameter/2. # = 3.63*u.cm
1428 h['rt'+hname] = ROOT.TGraph()
1429 h['rt'+hname].SetName('rt'+hname)
1430 n0 = h[hname].FindBin(h['tMinAndTmax'][hname][0])
1431 n1 = h[hname].FindBin(h['tMinAndTmax'][hname][1])
1432 Ntot = 0
1433 for n in range(n0,n1):
1434 Ntot += h[hname].GetBinContent(n)
1435 for n in range(n0,n1):
1436 N = 0
1437 for k in range(n0,n):
1438 N+=h[hname].GetBinContent(k)
1439 h['rt'+hname].SetPoint(n-n0,h[hname].GetBinCenter(n), N/float(Ntot+1E-20)*R)
1440 h['rt'+hname].SetTitle('rt'+hname)
1441 h['rt'+hname].SetLineWidth(2)
1442 if not hname.find('TDC1')<0: h['rt'+hname].SetLineColor(ROOT.kBlue)
1443 elif not hname.find('TDC2')<0: h['rt'+hname].SetLineColor(ROOT.kCyan)
1444 elif not hname.find('TDC3')<0: h['rt'+hname].SetLineColor(ROOT.kGreen)
1445 elif not hname.find('TDC4')<0: h['rt'+hname].SetLineColor(ROOT.kGreen+2)
1446 h['RTrelations'].cd(1)
1447 h['legRT'].AddEntry(h['rt'+hname],h['rt'+hname].GetTitle(),'PL')
1448 h['rt'+hname].Draw('same')
1449

◆ extrapolateToPlane()

conditionsDatabase.demo.drifttubeMonitoring.extrapolateToPlane (   fT,
  z,
  cplusplus = True 
)

Definition at line 1678 of file drifttubeMonitoring.py.

1678def extrapolateToPlane(fT,z,cplusplus=True):
1679 rc,pos,mom = False,None,None
1680 fst = fT.getFitStatus()
1681 if not fst.isFitConverged(): return rc,pos,mom
1682# try C++
1683 if cplusplus:
1684 pos = ROOT.TVector3()
1685 mom = ROOT.TVector3()
1686 try:
1687 trackLength = muflux_Reco.extrapolateToPlane(fT,z,pos,mom)
1688 rc = True
1689 except:
1690 rc = False
1691# etrapolate to a plane perpendicular to beam direction (z)
1692 else:
1693 if z > DT['Station_1_x_plane_0_layer_0_10000000'][2]-10 and z < DT['Station_4_x_plane_1_layer_1_40110000'][2] + 10:
1694# find closest measurement
1695 mClose = 0
1696 mZmin = 999999.
1697 M = min(fT.getNumPointsWithMeasurement(),30) # for unknown reason, get stuck for track with large measurements
1698 for m in range(0,M):
1699 # print "extr to state m",m,fT.getNumPointsWithMeasurement()
1700 # if not fT.getPointWithMeasurementAndFitterInfo(m,rep): continue
1701 try: st = fT.getFittedState(m)
1702 except:
1703 print "cannot get fitted state"
1704 continue
1705 Pos = st.getPos()
1706 if abs(z-Pos.z())<mZmin:
1707 mZmin = abs(z-Pos.z())
1708 mClose = m
1709 fstate = fT.getFittedState(mClose)
1710 NewPosition = ROOT.TVector3(0., 0., z)
1711 pdgcode = -int(13*fstate.getCharge())
1712 rep = ROOT.genfit.RKTrackRep( pdgcode )
1713 state = ROOT.genfit.StateOnPlane(rep)
1714 pos,mom = fstate.getPos(),fstate.getMom()
1715 rep.setPosMom(state,pos,mom)
1716 try:
1717 rep.extrapolateToPlane(state, NewPosition, parallelToZ )
1718 pos,mom = state.getPos(),state.getMom()
1719 rc = True
1720 except:
1721 print 'error with extrapolation: z=',z/u.m,'m',pos.X(),pos.Y(),pos.Z(),mom.X(),mom.Y(),mom.Z()
1722 error = "extrapolateToPlane: error with extrapolation: z=%7.3F m %7.3F %7.3F %7.3F %7.3F %7.3F %7.3F "%(z/u.m,pos.X(),pos.Y(),pos.Z(),mom.X(),mom.Y(),mom.Z())
1723 ut.reportError(error)
1724 if Debug: print error
1725 rc = False
1726 return rc,pos,mom
1727 else:
1728 if z < DT['Station_1_x_plane_0_layer_0_10000000'][2]:
1729# use linear extrapolation from first state
1730 fstate = fT.getFittedState(0)
1731 elif z > DT['Station_4_x_plane_1_layer_1_40110000'][2]:
1732 M = min(fT.getNumPointsWithMeasurement()-1,30)
1733 try:
1734 fstate = fT.getFittedState(fT.getNumPointsWithMeasurement()-1)
1735 except:
1736 fstate = fT.getFittedState(0)
1737 pos,mom = fstate.getPos(),fstate.getMom()
1738# use linear extrap
1739 lam = (z-pos[2])/mom[2]
1740 pos[2]=z
1741 pos[0]=pos[0]+lam*mom[0]
1742 pos[1]=pos[1]+lam*mom[1]
1743 rc = True
1744 return rc,pos,mom
1745

◆ FCN()

conditionsDatabase.demo.drifttubeMonitoring.FCN (   npar,
  gin,
  f,
  par,
  iflag 
)

Definition at line 4618 of file drifttubeMonitoring.py.

4618def FCN(npar, gin, f, par, iflag):
4619#calculate chisquare
4620 chisq = 0
4621 for p in range(16):
4622 alignCorrection[p]=[par[p],0,0]
4623 r, w = os.pipe()
4624 pid = os.fork() # bypassing memory issues with running genfit
4625 if pid == 0:
4626 chisq = loopTracks(r,w)
4627 else:
4628 print("In the parent process after forking the child {}".format(pid))
4629 finished = os.waitpid(0, 0)
4630 print(finished)
4631 os.close(w)
4632 r=os.fdopen(r)
4633 f[0] = float(r.read())
4634 print "FCN returns",f[0],len(listOfTracks)
4635 print "T1x",par[0],par[1],par[2],par[3]
4636 print "T1u",par[4],par[5],par[6],par[7]
4637 print "T2v",par[8],par[9],par[10],par[11]
4638 print "T2x",par[12],par[13],par[14],par[15]
4639 return

◆ fcn()

conditionsDatabase.demo.drifttubeMonitoring.fcn (   npar,
  gin,
  f,
  par,
  iflag 
)

Definition at line 7368 of file drifttubeMonitoring.py.

7368def fcn(npar, gin, f, par, iflag):
7369#calculate chisquare
7370 x='mu'
7371 chisq = 0
7372 dataMC = abs(par[0])
7373 charmMbias = abs(par[1])
7374 for proj in ['p/Abspx_y'+x,'p/pt'+x+'_x']:
7375 for n in range(1, h[proj].GetNbinsX()+1 ):
7376 if proj == 'p/pt'+x+'_x' and h[proj].GetBinCenter(n)<5: continue
7377 delta = h[proj].GetBinContent(n) - dataMC*(hMC[proj].GetBinContent(n)+charmMbias*hCharm[proj].GetBinContent(n))
7378 errSq = h[proj].GetBinContent(n) + dataMC**2*hMC[proj].GetBinContent(n)+\
7379 (dataMC*charmMbias)**2*hCharm[proj].GetBinContent(n)
7380 if errSq>0: chisq += delta**2/errSq
7381 f[0] = chisq
7382 if iflag !=2: print par[0],par[1],chisq
7383 return

◆ findDTClusters()

conditionsDatabase.demo.drifttubeMonitoring.findDTClusters (   removeBigClusters = True)

Definition at line 2297 of file drifttubeMonitoring.py.

2297def findDTClusters(removeBigClusters=True):
2298 spectrHitsSorted = ROOT.nestedList()
2299 muflux_Reco.sortHits(sTree.Digi_MufluxSpectrometerHits,spectrHitsSorted,True)
2300 if Debug: nicePrintout(spectrHitsSorted)
2301 clusters = {}
2302 for s in range(1,5):
2303 clusters[s]={}
2304 for view in viewsI[s]:
2305 allHits = {}
2306 ncl=0
2307 for l in range(4):
2308 allHits[l]={}
2309 for hit in spectrHitsSorted[view][s][l]:
2310 channelID = hit.GetDetectorID()%1000
2311 allHits[l][channelID]=hit
2312 if removeBigClusters:
2313 clustersPerLayer = {}
2314 for l in range(4):
2315 clustersPerLayer[l] = dict(enumerate(grouper(allHits[l].keys(),1), 1))
2316 for Acl in clustersPerLayer[l]:
2317 if len(clustersPerLayer[l][Acl])>cuts['maxClusterSize']: # kill cross talk brute force
2318 for x in clustersPerLayer[l][Acl]:
2319 dead = allHits[l].pop(x)
2320 if Debug: print "pop",s,viewC[view],l,x
2321 ncl=0
2322 tmp={}
2323 tmp[ncl]=[]
2324 perLayerUsedHits = {0:[],1:[],2:[],3:[]}
2325 for level in [1]:
2326 for i in range(1,Nchannels[s]+1):
2327 perLayer = {0:0,1:0,2:0,3:0}
2328 for i0 in range( max(1,i-1),min(Nchannels[s]+1,i+2)):
2329 if allHits[0].has_key(i0):
2330 tmp[ncl].append(allHits[0][i0])
2331 perLayer[0]=i0
2332 for i1 in range( max(1,i-1), min(Nchannels[s]+1,i+2)):
2333 if allHits[1].has_key(i1):
2334 tmp[ncl].append(allHits[1][i1])
2335 perLayer[1]=i1
2336 for i2 in range( max(1,i-1), min(Nchannels[s]+1,i+2)):
2337 if allHits[2].has_key(i2):
2338 tmp[ncl].append(allHits[2][i2])
2339 perLayer[2]=i2
2340 for i3 in range( max(1,i-1), min(Nchannels[s]+1,i+2)):
2341 if allHits[3].has_key(i3):
2342 tmp[ncl].append(allHits[3][i3])
2343 perLayer[3]=i3
2344 if ( (perLayer[0]>0) + (perLayer[1]>0) + (perLayer[2]>0) + (perLayer[3]>0) ) > level:
2345 # at least 2 hits per station
2346 ncl+=1
2347 tmp[ncl]=[]
2348 if len(tmp[ncl])==0: tmp.pop(ncl)
2349# cleanup, outliers
2350 tmpClean = {}
2351 for ncl in tmp:
2352 test = []
2353 mean = 0
2354 for hit in tmp[ncl]:
2355 bot,top = strawPositionsBotTop[hit.GetDetectorID()]
2356 x = (bot[0]+top[0])/2.
2357 mean+=x
2358 test.append([hit,x])
2359 mean=mean/float(len(test))
2360# more cleanup, outliers
2361 tmpClean[ncl]=[]
2362 for cl in test:
2363 if abs(mean-cl[1])<2.5 :
2364 tmpClean[ncl].append(cl[0])
2365# cleanup, remove lists contained in another list
2366 clusters[s][view]=[]
2367 if len(tmpClean)>0:
2368 ncl = 0
2369 marked = []
2370 for n1 in range(len(tmpClean)):
2371 if len(tmpClean[n1])==0: continue
2372 contained = False
2373 for n2 in range(len(tmpClean)):
2374 if n1==n2: continue
2375 if n2 in marked: continue
2376 if set(tmpClean[n1]) <= set(tmpClean[n2]):
2377 contained = True
2378 break
2379 if contained: marked.append(n1)
2380 for n1 in range(len(tmpClean)):
2381 if len(tmpClean[n1])<2: continue
2382 if n1 in marked: continue
2383 test = []
2384 mean = 0
2385 for hit in tmpClean[n1]:
2386 bot,top = strawPositionsBotTop[hit.GetDetectorID()]
2387 x = (bot[0]+top[0])/2.
2388 z = (bot[2]+top[2])/2.
2389 mean+=x
2390 test.append([hit,x,z,hit.GetDetectorID()%1000])
2391 mean=mean/float(len(test))
2392# more cleanup, outliers
2393 clusters[s][view].append([])
2394 for cl in test:
2395 if abs(mean-cl[1])<2.5: clusters[s][view][ncl].append(cl)
2396 if len(clusters[s][view][ncl])==0:
2397 clusters[s][view].pop(ncl)
2398 else: ncl+=1
2399 rc = h['clsN'].Fill(ncl)
2400# eventually split too big clusters for stero layers:
2401 for s in [1,2]:
2402 for view in viewsI[s]:
2403 if view==0:continue
2404 tmp = {}
2405 check = {}
2406 for cl in clusters[s][view]:
2407 if len(cl)>5:
2408 for hit in cl:
2409 if not tmp.has_key(hit[3]):
2410 tmp[hit[3]] =[]
2411 check[hit[3]]=[]
2412 if hit[0].GetDetectorID() in check[hit[3]]: continue
2413 tmp[hit[3]].append(hit)
2414 check[hit[3]].append(hit[0].GetDetectorID())
2415 for n in tmp:
2416 if len(tmp[n])>1:
2417 clusters[s][view].append(tmp[n])
2418 if Debug:
2419 for s in range(1,5):
2420 for view in viewsI[s]:
2421 printClustersPerStation(clusters,s,view)
2422 return clusters
2423
set(INCLUDE_DIRECTORIES ${SYSTEM_INCLUDE_DIRECTORIES} ${VMC_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/shipdata ${CMAKE_SOURCE_DIR}/shipLHC ${CMAKE_SOURCE_DIR}/analysis/cuts ${CMAKE_SOURCE_DIR}/analysis/tools ${FMT_INCLUDE_DIR}) include_directories($
Definition CMakeLists.txt:1

◆ findDTClustersDebug1()

conditionsDatabase.demo.drifttubeMonitoring.findDTClustersDebug1 (   n,
  tmp 
)

Definition at line 2424 of file drifttubeMonitoring.py.

2424def findDTClustersDebug1(n,tmp):
2425 for hit in tmp[n]:
2426 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
2427 bot,top = strawPositionsBotTop[hit.GetDetectorID()]
2428 print s,v,p*2+l,channelID,(bot[0]+top[0])/2.
2429

◆ findDTClustersDebug2()

conditionsDatabase.demo.drifttubeMonitoring.findDTClustersDebug2 (   L)

Definition at line 2430 of file drifttubeMonitoring.py.

2430def findDTClustersDebug2(L):
2431 for l in L:
2432 for hit in L[l]:
2433 print stationInfo(hit),hit.GetTimeOverThreshold()
2434

◆ findHighMomEvents()

conditionsDatabase.demo.drifttubeMonitoring.findHighMomEvents ( )

Definition at line 7356 of file drifttubeMonitoring.py.

7356def findHighMomEvents():
7357 for d in os.listdir('.'):
7358 if os.path.isdir(d):
7359 for f in os.listdir(d):
7360 if f.find('ntuple-')==0:
7361 s = f.replace('ntuple-','')
7362 ff = ROOT.TFile.Open(os.environ['EOSSHIP']+'/eos/experiment/ship/user/truf/muflux-sim/10GeV-withDeadChannels/'+d+'/'+s)
7363 sTree=ff.cbmsim
7364 for event in sTree:
7365 for m in sTree.MCTrack:
7366 if abs(m.GetPdgCode())==13 and m.GetP()>350: sTree.MCTrack.Dump()
7367

◆ findSimpleEvent()

conditionsDatabase.demo.drifttubeMonitoring.findSimpleEvent (   event,
  nmin = 2,
  nmax = 6 
)

Definition at line 1852 of file drifttubeMonitoring.py.

1852def findSimpleEvent(event,nmin=2,nmax=6):
1853 spectrHitsSorted = ROOT.nestedList()
1854 muflux_Reco.sortHits(sTree.Digi_MufluxSpectrometerHits,spectrHitsSorted,True)
1855 nH = {1:0,2:0,3:0,4:0}
1856 passed = True
1857 for s in range(1,5):
1858 for l in range(4):
1859 for hit in spectrHitsSorted[0][s][l]: nH[s]+=1
1860 if nH[s]<nmin or nH[s]>nmax: passed = False
1861 nu = 0
1862 for l in range(4):
1863 for hit in spectrHitsSorted[1][1][l]: nu+=1
1864 if nu<nmin or nu>nmax: passed = False
1865 nv = 0
1866 for l in range(4):
1867 for hit in spectrHitsSorted[2][2][l]: nv+=1
1868 if nv<nmin or nv>nmax: passed = False
1869 return passed
1870

◆ findTracks()

conditionsDatabase.demo.drifttubeMonitoring.findTracks (   PR = 1,
  linearTrackModel = False,
  withCloneKiller = True 
)

Definition at line 2435 of file drifttubeMonitoring.py.

2435def findTracks(PR = 1,linearTrackModel = False,withCloneKiller=True):
2436 if PR == 3:
2437 if sTree.GetBranch('FitTracks_refitted'): return sTree.FitTracks_refitted
2438 print "findTracks called with PR=3 but FitTracks_refitted does not exist. "
2439 return None
2440 if PR == 1:
2441 if sTree.GetBranch('FitTracks'): return sTree.FitTracks
2442 print "findTracks called with PR=1 but FitTracks does not exist. "
2443 return None
2444 if PR == 12 :
2445 trackCandidates = testPR()
2446 if len(trackCandidates)>1: trackCandidates=cloneKiller(trackCandidates)
2447 return trackCandidates
2448 if PR == 13: # refit tracks
2449 trackCandidates=[]
2450 keysToDThits = MakeKeysToDThits(cuts['lateArrivalsToT'])
2451 for itrack in range(sTree.FitTracks.GetEntries()):
2452 trInfo = sTree.TrackInfos[itrack]
2453 oTrack = sTree.FitTracks[itrack]
2454 P = 5.
2455 fst = oTrack.getFitStatus()
2456 if fst.isFitConverged() and fst.getNdf()>1:
2457 try:
2458 sta = oTrack.getFittedState(0)
2459 P = sta.getMomMag()
2460 except:
2461 print "cannot get fittedState(0)"
2462 hitList=[]
2463 for n in range(trInfo.N()):
2464 detID = trInfo.detId(n)
2465 hitList.append(keysToDThits[detID][0])
2466 aTrack = fitTrack(hitList,P)
2467 if type(aTrack) == type(1): continue
2468 trackCandidates.append(aTrack)
2469 return trackCandidates
2470# switch of trackfit material effect in first pass
2471 materialEffects(False)
2472 keysToDThits=MakeKeysToDThits(cuts['lateArrivalsToT'])
2473 vbot,vtop = strawPositionsBotTop[30002001]
2474 T3z = vbot[2]
2475 T3ytop = vtop[1]
2476 T3ybot = vbot[1]
2477 trackCandidates = []
2478 clusters = findDTClusters(removeBigClusters=True)
2479 # now we have to make a loop over all combinations
2480 allStations = True
2481 for s in range(1,5):
2482 if len(clusters[s][0])==0: allStations = False
2483 if len(clusters[1][1])==0 or len(clusters[2][2])==0: allStations = False
2484 if allStations:
2485 t1t2cand = []
2486 # list of lists of cluster1, cluster2, x
2487 t3t4cand = []
2488 h['dispTrackSeg'] = []
2489 nTrx = -1
2490 for cl1 in clusters[1][0]:
2491 for cl2 in clusters[2][0]:
2492 slopeA,bA = getSlopes(cl1,cl2)
2493 x1 = zgoliath*slopeA+bA
2494 t1t2cand.append([cl1,cl2,x1,slopeA,bA])
2495 nTrx+=1
2496 if Debug:
2497 nt = len(h['dispTrackSeg'])
2498 h['dispTrackSeg'].append( ROOT.TGraph(2) )
2499 h['dispTrackSeg'][nt].SetPoint(0,0.,bA)
2500 h['dispTrackSeg'][nt].SetPoint(1,400.,slopeA*400+bA)
2501 h['dispTrackSeg'][nt].SetLineColor(ROOT.kRed+nTrx)
2502 h['dispTrackSeg'][nt].SetLineWidth(2)
2503 h['simpleDisplay'].cd(1)
2504 h['dispTrackSeg'][nt].Draw('same')
2505 nt+=1
2506 for cl1 in clusters[3][0]:
2507 for cl2 in clusters[4][0]:
2508 slopeA,bA = getSlopes(cl1,cl2)
2509 x1 = zgoliath*slopeA+bA
2510 t3t4cand.append([cl1,cl2,x1,slopeA,bA])
2511 if Debug:
2512 nt = len(h['dispTrackSeg'])
2513 h['dispTrackSeg'].append( ROOT.TGraph(2) )
2514 h['dispTrackSeg'][nt].SetPoint(0,300.,slopeA*300+bA)
2515 h['dispTrackSeg'][nt].SetPoint(1,900.,slopeA*900+bA)
2516 h['dispTrackSeg'][nt].SetLineColor(ROOT.kBlue)
2517 h['dispTrackSeg'][nt].SetLineWidth(2)
2518 h['simpleDisplay'].cd(1)
2519 h['dispTrackSeg'][nt].Draw('same')
2520 nt+=1
2521 if Debug:
2522 print "trackCandidates",len(t1t2cand),len(t3t4cand)
2523 h['simpleDisplay'].Update()
2524 nTrx = -1
2525 for nt1t2 in range(len(t1t2cand)):
2526 t1t2 = t1t2cand[nt1t2]
2527 nTrx+=1
2528 for nt3t4 in range(len(t3t4cand)):
2529 t3t4 = t3t4cand[nt3t4]
2530 delx = t3t4[2]-t1t2[2]
2531 h['delx'].Fill(delx)
2532# check also extrapolations at t1 t2, or t3 t4
2533# makes only sense for zero field
2534 if linearTrackModel: makeLinearExtrapolations(t1t2,t3t4)
2535 if abs(delx) < cuts['delxAtGoliath']:
2536# check for matching u and v hits, make uv combination and check extrap to
2537 stereoHits = {}
2538 if Debug: print "stereo clusters",len(clusters[1][1]),len(clusters[2][2])
2539 for nu in range(len(clusters[1][1])):
2540 stereoHits[1]={}
2541 clu = clusters[1][1][nu]
2542 mean_u = 0
2543 n_u = 0
2544 for cl in clu:
2545 botA,topA = strawPositionsBotTop[cl[0].GetDetectorID()]
2546 z = (botA[2]+topA[2])/2.
2547 sl = (botA[1]-topA[1])/(botA[0]-topA[0])
2548 b = topA[1]-sl*topA[0]
2549 yest = sl*(t1t2[3]*topA[2]+t1t2[4])+b
2550 rc = h['yest'].Fill(yest)
2551 if yest > botA[1]+cuts['yMax'] : continue
2552 if yest < topA[1]-cuts['yMax'] : continue
2553 stereoHits[1][cl[0].GetDetectorID()]=[cl[0],sl,b,yest,z]
2554 mean_u+=yest
2555 n_u+=1
2556 mean_u = mean_u/float(n_u)
2557 if Debug: print "0 stereo u",len(stereoHits[1])
2558 for x in stereoHits[1].keys():
2559 delta = stereoHits[1][x][3]-mean_u
2560 rc = h['delta_mean_uv'].Fill(delta)
2561 if abs(delta)>cuts['hitDist']: stereoHits[1].pop(x)
2562# new idea, calulate average of y coordinates, reject hits with distance > 2.5cm!!!!!
2563 for nv in range(len(clusters[2][2])):
2564 mean_v = 0
2565 n_v = 0
2566 stereoHits[2]={}
2567 clv = clusters[2][2][nv]
2568 for cl in clv:
2569 botA,topA = strawPositionsBotTop[cl[0].GetDetectorID()]
2570 z = (botA[2]+topA[2])/2.
2571 sl = (botA[1]-topA[1])/(botA[0]-topA[0])
2572 b = topA[1]-sl*topA[0]
2573 yest = sl*(t1t2[3]*topA[2]+t1t2[4])+b
2574 rc = h['yest'].Fill(yest)
2575 if yest > botA[1]+cuts['yMax'] : continue
2576 if yest < topA[1]-cuts['yMax'] : continue
2577 stereoHits[2][cl[0].GetDetectorID()]=[cl[0],sl,b,yest,z]
2578 mean_v+=yest
2579 n_v+=1
2580 mean_v = mean_v/float(n_v)
2581 if Debug: print "1 stereo v",len(stereoHits[2])
2582 for x in stereoHits[2].keys():
2583 delta = stereoHits[2][x][3]-mean_v
2584 rc = h['delta_mean_uv'].Fill(delta)
2585 if abs(delta)>cuts['hitDist']: stereoHits[2].pop(x)
2586#
2587 if Debug: print "stereo u v",len(stereoHits[1]),len(stereoHits[2])
2588 if len(stereoHits[1])<cuts['minLayersUV'] or len(stereoHits[2])<cuts['minLayersUV']: continue
2589 slopeA,bA = getSlopes(stereoHits[1],stereoHits[2],'_uv')
2590 if Debug:
2591 print "y slope",slopeA,bA
2592 print '----> u'
2593 for x in stereoHits[1]: print stereoHits[1][x][3],stereoHits[1][x][4]
2594 print '----> v'
2595 for x in stereoHits[2]: print stereoHits[2][x][3],stereoHits[2][x][4]
2596 # remove unphysical combinations, pointing outside t3
2597 yAtT3 = T3z*slopeA + bA
2598 if Debug: print "uv",nu,nv,yAtT3,T3ybot ,T3ytop , (yAtT3 - T3ybot) > 2*cuts['yMax'] ,(T3ytop - yAtT3) > 2*cuts['yMax']
2599 if (yAtT3 - T3ybot) > 2*cuts['yMax'] or (T3ytop - yAtT3) > 2*cuts['yMax'] : continue
2600 if Debug:
2601 nt = len(h['dispTrackSeg'])
2602 h['dispTrackSeg'].append( ROOT.TGraph(2) )
2603 h['dispTrackSeg'][nt].SetPoint(0,0.,bA)
2604 h['dispTrackSeg'][nt].SetPoint(1,900.,slopeA*900+bA)
2605 h['dispTrackSeg'][nt].SetLineColor(ROOT.kGreen+nTrx)
2606 h['dispTrackSeg'][nt].SetLineWidth(2)
2607 h['simpleDisplay'].cd(1)
2608 h['dispTrackSeg'][nt].Draw('same')
2609 h['simpleDisplay'].Update()
2610 nt+=1
2611#
2612 hitList = []
2613 for p in range(2):
2614 for cl in t1t2[p]: hitList.append(cl[0])
2615 for p in stereoHits:
2616 for cl in stereoHits[p]: hitList.append(stereoHits[p][cl][0])
2617 for p in range(2):
2618 for cl in t3t4[p]: hitList.append(cl[0])
2619# add late arrivals
2620 if cuts['lateArrivalsToT']<3000:
2621 tmp=[]
2622 for x in hitList:
2623 l = len(keysToDThits[x.GetDetectorID()])
2624 for k in range(1,l):
2625 key = keysToDThits[x.GetDetectorID()][k]
2626 tmp.append(sTree.Digi_LateMufluxSpectrometerHits[key])
2627 hitList=hitList+tmp
2628 if linearTrackModel:
2629 trackCandidates = hitList
2630 else:
2631 if zeroField: momFromptkick = 1000.
2632 else: momFromptkick=ROOT.TMath.Abs(1.03/(t3t4[3]-t1t2[3]+1E-20))
2633 if Debug: print "fit track t1t2 %i t3t4 %i stereo %i,%i, with hits %i, delx %6.3F, pstart %6.3F"%(nt1t2,nt3t4,nu,nv,len(hitList),delx,momFromptkick)
2634 aTrack = fitTrack(hitList,momFromptkick)
2635 if Debug: print "result of trackFit",aTrack
2636 if type(aTrack) != type(1):
2637# check if track is still in acceptance:
2638 rc,pos,mom = extrapolateToPlane(aTrack,T3z)
2639 reject = False
2640 if ( (pos[1] - T3ybot) > 1.2*cuts['yMax'] or (T3ytop - pos[1]) > 1.2*cuts['yMax'] ): reject = True
2641 mStatistics = countMeasurements(aTrack,PR)
2642 if len(mStatistics['u'])<cuts['minLayersUV'] or len(mStatistics['v'])<cuts['minLayersUV']: reject = True # require 2 measurements in each view
2643 if not reject:
2644 # check ghostrate, only MC
2645 if MCdata:
2646 ghFraction,mcTrackID = ghostFraction(aTrack)
2647 aTrack.setMcTrackId( int(mcTrackID*1000+int(ghFraction*100+0.5) ) )
2648 if Debug: print "ghost fraction: ", ghFraction,mcTrackID
2649 trackCandidates.append(aTrack)
2650 else:
2651 aTrack.Delete()
2652 if Debug:
2653 print "track rejected, outside T3 acceptance or not enough u/v measurements"
2654 print (pos[1] - T3ybot) > 1.2*cuts['yMax'] , (T3ytop - pos[1]) > 1.2*cuts['yMax'] , \
2655 len(mStatistics['u'])<2, len(mStatistics['v'])<2
2656 if withMaterial: materialEffects(True)
2657 if withCloneKiller:
2658 if len(trackCandidates)>1: trackCandidates = cloneKiller(trackCandidates)
2659 if Debug: print "# tracks after clonekiller = ",len(trackCandidates)
2660 if withMaterial:
2661 for aTrack in trackCandidates:
2662 fitter.processTrack(aTrack)
2663 if Debug: printTrackMeasurements(aTrack,PR)
2664# switch on trackfit material effect for final fit
2665 return trackCandidates
2666

◆ findV0()

conditionsDatabase.demo.drifttubeMonitoring.findV0 (   nstart = 0,
  nmax = -1,
  PR = 1 
)

Definition at line 5185 of file drifttubeMonitoring.py.

5185def findV0(nstart=0,nmax=-1,PR=1):
5186 if nmax<0: nmax = sTree.GetEntries()
5187 ut.bookHist(h,'doca','distance between two tracks',100,0.,50.)
5188 ut.bookHist(h,'nRPC','matchedRPCHits',50,0.,50.)
5189 ut.bookHist(h,'v0mass_wc','V0 mass wrong charge combinations',100,0.2,1.8,100,-120.,120.)
5190 ut.bookHist(h,'v0mass','V0 mass ',100,0.2,1.8,100,-120.,120.)
5191 mass = PDG.GetParticle(211).Mass()
5192 for n in range(nstart,nmax):
5193 rc = sTree.GetEvent(n)
5194 tracks = findTracks(PR)
5195 if len(tracks)<2: continue
5196 PosDir = {}
5197 tr = 0
5198 for aTrack in tracks:
5199 st = aTrack.getFitStatus()
5200 if not st.isFitConverged(): continue
5201 if st.getNdf()<12: continue
5202 inAcc, nRPC = matchedRPCHits(aTrack)
5203 rc = h['nRPC'].Fill(nRPC)
5204 if not inAcc: continue
5205 if nRPC > 5: continue
5206 xx = aTrack.getFittedState()
5207 PosDir[tr] = [xx.getPos(),xx.getDir(),ROOT.TLorentzVector(),xx.getCharge(),aTrack.getFitStatus().getNdf()]
5208 mom = xx.getMom()
5209 E = ROOT.TMath.Sqrt( mass*mass + mom.Mag2() )
5210 PosDir[tr][2].SetPxPyPzE(mom.x(),mom.y(),mom.z(),E)
5211 tr+=1
5212 for tr1 in range(tr-1):
5213 for tr2 in range(tr1+1,tr):
5214 xv,yv,zv,doca = myVertex(0,1,PosDir)
5215 V0Mom = PosDir[0][2]+PosDir[1][2]
5216 rc = h['doca'].Fill(doca)
5217 print n,doca,zv,V0Mom.M(),PosDir[0][3],PosDir[1][3],PosDir[0][4],PosDir[1][4]
5218 if doca > 5: continue
5219 if PosDir[tr1][3]*PosDir[tr2][3]< 0: rc = h['v0mass'].Fill(V0Mom.M(),zv)
5220 else: rc = h['v0mass_wc'].Fill(V0Mom.M(),zv)

◆ fitTrack()

conditionsDatabase.demo.drifttubeMonitoring.fitTrack (   hitlist,
  Pstart = 3. 
)

Definition at line 2017 of file drifttubeMonitoring.py.

2017def fitTrack(hitlist,Pstart=3.):
2018# need measurements
2019 global fitter
2020 hitPosLists={}
2021 trID = 0
2022 posM = ROOT.TVector3(0, 0, 20.)
2023 momM = ROOT.TVector3(0,0,Pstart*u.GeV)
2024# approximate covariance
2025 covM = ROOT.TMatrixDSym(6)
2026 resolution = sigma_spatial
2027 if not withTDC: resolution = 10*sigma_spatial
2028 for i in range(3): covM[i][i] = resolution*resolution
2029 # covM[0][0]=resolution*resolution*100.
2030 for i in range(3,6): covM[i][i] = ROOT.TMath.Power(resolution / (4.*2.) / ROOT.TMath.Sqrt(3), 2)
2031 rep = ROOT.genfit.RKTrackRep(13)
2032# start state
2033 state = ROOT.genfit.MeasuredStateOnPlane(rep)
2034 rep.setPosMomCov(state, posM, momM, covM)
2035# create track
2036 seedState = ROOT.TVectorD(6)
2037 seedCov = ROOT.TMatrixDSym(6)
2038 rep.get6DStateCov(state, seedState, seedCov)
2039 theTrack = ROOT.genfit.Track(rep, seedState, seedCov)
2040 unSortedList = {}
2041 tmpList = {}
2042 k=0
2043 if MCdata: detIDToKey = MakeKeysToDThits()
2044 else: detIDToKey=MakeKeysToDThits(cuts['lateArrivalsToT'])
2045 for nhit in hitlist:
2046 numHit = 0
2047 if type(nhit)==type(1):
2048 hit = sTree.Digi_MufluxSpectrometerHits[nhit]
2049 numHit = nhit
2050 else: hit = nhit
2051 tdc = hit.GetDigi()
2052 if type(nhit)!=type(1):
2053 detID = hit.GetDetectorID()
2054 keyList = detIDToKey[detID]
2055 numHit = keyList[0]
2056 if len(keyList)>2:
2057 found = False
2058 tdc = hit.GetDigi()
2059 for x in range(1,len(keyList)):
2060 numHit = keyList[x]
2061 if sTree.Digi_MufluxSpectrometerHits[numHit].GetDigi()==tdc:
2062 found = True
2063 break
2064 if not found: print "fittrack: digi not found, something wrong here",tdc
2065 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
2066 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
2067 distance = 0
2068 if withTDC: distance = RT(hit,tdc)
2069 tmp = array('d',[vtop[0],vtop[1],vtop[2],vbot[0],vbot[1],vbot[2],distance])
2070 unSortedList[k] = [ROOT.TVectorD(7,tmp),hit.GetDetectorID(),numHit,view]
2071 tmpList[k] = vtop[2]
2072 k+=1
2073 sorted_z = sorted(tmpList.items(), key=operator.itemgetter(1))
2074 for k in sorted_z:
2075 tp = ROOT.genfit.TrackPoint() # note how the point is told which track it belongs to
2076 hitCov = ROOT.TMatrixDSym(7)
2077 hitCov[6][6] = resolution*resolution
2078 # if unSortedList[k[0]][3] != '_x': hitCov[6][6] = 4*resolution*resolution
2079 measurement = ROOT.genfit.WireMeasurement(unSortedList[k[0]][0],hitCov,1,6,tp) # the measurement is told which trackpoint it belongs to
2080 measurement.setMaxDistance(ShipGeo.MufluxSpectrometer.InnerTubeDiameter/2.)
2081 measurement.setDetId(unSortedList[k[0]][1])
2082 # if Debug: print "trackfit add detid",unSortedList[k[0]][1],unSortedList[k[0]][0][6]
2083 measurement.setHitId(unSortedList[k[0]][2])
2084 tp.addRawMeasurement(measurement) # package measurement in the TrackPoint
2085 theTrack.insertPoint(tp) # add point to Track
2086 if not theTrack.checkConsistency():
2087 print "track not consistent"
2088 theTrack.Delete()
2089 return -2
2090# do the fit
2091 timer.Start()
2092 try: fitter.processTrack(theTrack) # processTrackWithRep(theTrack,rep,True)
2093 except:
2094 print "fit failed"
2095 timer.Stop()
2096 theTrack.Delete()
2097 return -1
2098 # print "time to fit the track",timer.RealTime()
2099 if timer.RealTime()>1: # make a new fitter, didn't helped
2100 error = "fitTrack::very long fit time %8.6F %6i"%(timer.RealTime(),len(hitlist))
2101 ut.reportError(error)
2102 if Debug: print error
2103 fitStatus = theTrack.getFitStatus()
2104 if Debug: print "Fit result: converged chi2 Ndf",fitStatus.isFitConverged(),fitStatus.getChi2(),fitStatus.getNdf()
2105 if not fitStatus.isFitConverged():
2106 theTrack.Delete()
2107 return -1
2108 if Debug:
2109 chi2 = fitStatus.getChi2()/fitStatus.getNdf()
2110 fittedState = theTrack.getFittedState()
2111 P = fittedState.getMomMag()
2112 print "track fitted Ndf #Meas P",fitStatus.getNdf(), theTrack.getNumPointsWithMeasurement(),P
2113 for p in theTrack.getPointsWithMeasurement():
2114 rawM = p.getRawMeasurement()
2115 info = p.getFitterInfo()
2116 if not info: continue
2117 detID = rawM.getDetId()
2118 test = ROOT.MufluxSpectrometerHit(detID,0.)
2119 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(test)
2120 print s,view,2*p+l,channelID,"weights",info.getWeights()[0],info.getWeights()[1]
2121 if fitStatus.getNdf() < cuts['Ndf']:
2122 theTrack.Delete()
2123 return -2
2124 return theTrack
2125

◆ fitTracks()

conditionsDatabase.demo.drifttubeMonitoring.fitTracks (   nMax = -1,
  simpleEvents = True,
  withDisplay = False,
  nStart = 0,
  debug = False,
  PR = 1,
  withRT = False,
  chi2UL = 3 
)

Definition at line 1871 of file drifttubeMonitoring.py.

1871def fitTracks(nMax=-1,simpleEvents=True,withDisplay=False,nStart=0,debug=False,PR=1,withRT=False,chi2UL=3):
1872# simpleEvents=True: select special clean events for testing track fit
1873 for x in ['p/pt','p/px','p/Abspx','Nmeasurements','chi2','xy','pxpy','TDC2R','p1/p2','pt1/pt2',
1874 'p/ptmu','p/pxmu','p/Abspxmu','Nmeasurementsmu','chi2mu','xymu','pxpymu']: h[x].Reset()
1875 if not withDisplay and not Debug and not simpleEvents:
1876 muflux_Reco.trackKinematics(3.)
1877 momDisplay()
1878 return
1879 for n in range(nStart,sTree.GetEntries()):
1880 rc = sTree.GetEvent(n)
1881 if MCdata:
1882 if sTree.Digi_MufluxSpectrometerHits.GetEntries() != sTree.MufluxSpectrometerPoint.GetEntries():
1883 print "digi does not agree with MC, break",n
1884 break
1885 if PR<10 and sTree.ShipEventHeader.GetUniqueID()==1: continue # non reconstructed events
1886 if not withDisplay and n%10000==0: print "event #",n
1887 if nMax==0: break
1888 if simpleEvents and simpleEvents<2:
1889 if not findSimpleEvent(sTree): continue
1890 if withDisplay:
1891 print "event #",n
1892 plotEvent(n)
1893 theTracks = findTracks(PR)
1894 if simpleEvents==2 and len(theTracks)<simpleEvents: continue
1895 RPCclusters, RPCtracks = muonTaggerClustering(PR)
1896 if withDisplay: plotMuonTaggerTrack(RPCtracks)
1897 N = -1
1898 if len(theTracks)>0:
1899 for aTrack in theTracks:
1900 N+=1
1901 fitStatus = aTrack.getFitStatus()
1902 if not fitStatus.isFitConverged(): continue
1903# track quality
1904 if PR<10: hitsPerStation = countMeasurements(N,PR)
1905 else: hitsPerStation = countMeasurements(aTrack,PR)
1906 if len(hitsPerStation['x1'])<2: continue
1907 if len(hitsPerStation['x2'])<2: continue
1908 if len(hitsPerStation['x3'])<2: continue
1909 if len(hitsPerStation['x4'])<2: continue
1910 chi2 = fitStatus.getChi2()/fitStatus.getNdf()
1911 fittedState = aTrack.getFittedState()
1912 P = fittedState.getMomMag()
1913 Px,Py,Pz = fittedState.getMom().x(),fittedState.getMom().y(),fittedState.getMom().z()
1914 if Debug:
1915 if abs(Py/Pz)>0.15: print 'event with large angle track:',n
1916 rc = h['chi2'].Fill(chi2)
1917 rc = h['Nmeasurements'].Fill(fitStatus.getNdf())
1918 if chi2 > chi2UL: continue
1919 rc = h['p/pt'].Fill(P,ROOT.TMath.Sqrt(Px*Px+Py*Py))
1920 rc = h['p/px'].Fill(P,Px)
1921 rc = h['p/Abspx'].Fill(P,abs(Px))
1922 pos = fittedState.getPos()
1923 rc = h['xy'].Fill(pos[0],pos[1])
1924 rc = h['pxpy'].Fill(Px/Pz,Py/Pz)
1925# check for muon tag
1926 rc,posRPC,momRPC = extrapolateToPlane(aTrack,zRPC1)
1927 if rc:
1928 tagged = {'X':False,'Y':False}
1929 for proj in ['X','Y']:
1930 for m in RPCtracks[proj]:
1931 if abs(posRPC[0]-m[0]*zRPC1+m[1]) < cuts['muTrackMatch'+proj]: tagged[proj]=True
1932 if tagged['X'] and tagged['Y'] : # within ~3sigma of any mutrack
1933 rc = h['chi2mu'].Fill(chi2)
1934 rc = h['Nmeasurementsmu'].Fill(fitStatus.getNdf())
1935 rc = h['p/ptmu'].Fill(P,ROOT.TMath.Sqrt(Px*Px+Py*Py))
1936 rc = h['p/pxmu'].Fill(P,Px)
1937 rc = h['p/Abspxmu'].Fill(P,abs(Px))
1938 rc = h['xymu'].Fill(pos[0],pos[1])
1939 rc = h['pxpymu'].Fill(Px/Pz,Py/Pz)
1940#
1941 if len(theTracks)==2 and N==0:
1942 bTrack = theTracks[1]
1943 fitStatus = bTrack.getFitStatus()
1944 if not fitStatus.isFitConverged(): continue
1945 chi2 = fitStatus.getChi2()/fitStatus.getNdf()
1946 fittedState = bTrack.getFittedState()
1947 Pb = fittedState.getMomMag()
1948 Pbx,Pby,Pbz = fittedState.getMom().x(),fittedState.getMom().y(),fittedState.getMom().z()
1949 if chi2 > chi2UL: continue
1950 rc = h['p1/p2'].Fill(P,Pb)
1951 rc = h['pt1/pt2'].Fill(ROOT.TMath.Sqrt(Px*Px+Py*Py),ROOT.TMath.Sqrt(Pbx*Pbx+Pby*Pby))
1952 if withRT:
1953 for hit in sTree.Digi_MufluxSpectrometerHits:
1954 if not hit.hasTimeOverThreshold(): continue
1955 rc = RT(hit,hit.GetDigi())
1956 if withDisplay:
1957 for theTrack in theTracks:
1958 fitStatus = theTrack.getFitStatus()
1959 if not fitStatus.isFitConverged(): continue
1960 displayTrack(theTrack,debug)
1961 next = raw_input("Next (Ret/Quit): ")
1962 if next<>'': break
1963 if len(theTracks)>0: nMax-=1
1964 if not hasattr(theTracks,'Class'):
1965 for theTrack in theTracks: theTrack.Delete()
1966 momDisplay()

◆ getEvent()

conditionsDatabase.demo.drifttubeMonitoring.getEvent (   n)

Definition at line 5221 of file drifttubeMonitoring.py.

5221def getEvent(n):
5222 global rname
5223 rc = sTree.GetEvent(n)
5224 if sTree.GetListOfFiles().GetEntries()>1:
5225 temp = sTree.GetCurrentFile().GetName()
5226 curFile = temp[temp.rfind('/')+1:]
5227 if curFile != rname:
5228 rname = curFile
5229 if withTDC:
5230 h['tMinAndTmax'] = RTrelations[rname]['tMinAndTmax']
5231 for s in h['tMinAndTmax']: h['rt'+s] = RTrelations[rname]['rt'+s]
5232 if withDefaultAlignment: importAlignmentConstants()
5233

◆ getParOfRTcorrectio()

conditionsDatabase.demo.drifttubeMonitoring.getParOfRTcorrectio ( )

Definition at line 7548 of file drifttubeMonitoring.py.

7548def getParOfRTcorrectio():
7549 keys = h.keys()
7550 for x in keys:
7551 if x.find('RTcorr')!=0: continue
7552 if not x.find('LR')<0 or not x.find('Par')<0: continue
7553 txt = " pars['"+x+"'] = ["
7554 for x in h[x+'Par'+x]:
7555 txt+=" %7.5F, "%(x)
7556 txt+=']'
7557 print txt.replace(', ]',']')

◆ getSlopes()

conditionsDatabase.demo.drifttubeMonitoring.getSlopes (   cl1,
  cl2,
  view = '_x' 
)

Definition at line 2126 of file drifttubeMonitoring.py.

2126def getSlopes(cl1,cl2,view='_x'):
2127 x,z=[],[]
2128 for cl in [cl1,cl2]:
2129 for hit in cl:
2130 if view=='_x':
2131 x.append(hit[1])
2132 z.append(hit[2])
2133 else:
2134 x.append(cl[hit][3])
2135 z.append(cl[hit][4])
2136 line = numpy.polyfit(z,x,1)
2137 return line[0],line[1]
2138

◆ ghostFraction()

conditionsDatabase.demo.drifttubeMonitoring.ghostFraction (   aTrack)

Definition at line 2280 of file drifttubeMonitoring.py.

2280def ghostFraction(aTrack):
2281 trackIDs = {}
2282 for p in aTrack.getPointsWithMeasurement():
2283 rawM = p.getRawMeasurement()
2284 info = p.getFitterInfo()
2285 if not info: continue
2286 if info.getWeights()[0] <0.1 and info.getWeights()[1] <0.1: continue
2287 detID = rawM.getDetId()
2288 theKey = rawM.getHitId()
2289 trackID = sTree.MufluxSpectrometerPoint[theKey].GetTrackID()
2290 if not trackIDs.has_key(trackID): trackIDs[trackID]=0
2291 trackIDs[trackID]+=1
2292 sorted_trackIDs = sorted(trackIDs.items(), key=operator.itemgetter(1),reverse=True)
2293 sz = trackIDs.values()
2294 ghFrac = 1.-sorted_trackIDs[0][1]/float(sum(sz))
2295 return ghFrac,sorted_trackIDs[0][0]
2296

◆ ghostSuppression()

conditionsDatabase.demo.drifttubeMonitoring.ghostSuppression (   hname = "sumHistos--simulation10GeV-withDeadChannels.root")

Definition at line 5808 of file drifttubeMonitoring.py.

5808def ghostSuppression(hname = "sumHistos--simulation10GeV-withDeadChannels.root"):
5809 interestingHistos = []
5810 cuts = {'':ROOT.kBlue,'All':ROOT.kCyan,'Chi2<':ROOT.kGreen,'Delx<':ROOT.kOrange,'Dely<':ROOT.kMagenta}
5811 for c in cuts:
5812 for a in ['p/pt','Chi2/DoF']:
5813 for x in ['','mu']:
5814 interestingHistos.append(c+a+x)
5815 ut.readHists(h,hname,interestingHistos)
5816 for c in cuts:
5817 for a in ['p/pt','Chi2/DoF']:
5818 for x in ['','mu']:
5819 h[c+a+x].SetLineColor(cuts[c])
5820 h[c+a+x+'_projx'].SetLineColor(cuts[c])
5821 h[c+a+x+'2d'] = h[c+'p/pt'+x].Rebin2D(10,10,c+a+x+'2d')
5822 h[c+a+x+'_projy'].SetLineColor(cuts[c])
5823 for x in ['','mu']:
5824 print "==== ",x
5825 ntracks = {}
5826 for c in cuts:
5827 ntracks[c] = h[c+'p/pt'+x+'_projx'].Integral(5,15)
5828 h[c+x] = h[c+'p/pt'+x+'_projx'].Clone(c+x)
5829 if c=='':
5830 h['p/pt'+x+'_projx'].Draw()
5831 else:
5832 h[c+'p/pt'+x+'_projx'].Draw('same')
5833 h[c+x].Divide(h['p/pt'+x+'_projx'])
5834 h[c+'p/pt'+x+'2d'].Divide(h['p/pt'+x+'2d'])
5835 for c in ntracks:
5836 if c=='': continue
5837 print "%s efficiency=%5.3F"%(c,ntracks[c]/ntracks[''])
5838

◆ grouper()

conditionsDatabase.demo.drifttubeMonitoring.grouper (   iterable,
  grouping 
)

Definition at line 4831 of file drifttubeMonitoring.py.

4831def grouper(iterable,grouping):
4832 prev = None
4833 group = []
4834 iterable.sort()
4835 for item in iterable:
4836 if not prev or item - prev <= grouping:
4837 group.append(item)
4838 else:
4839 yield group
4840 group = [item]
4841 prev = item
4842 if group:
4843 yield group

◆ hitMapsFromFittedTracks()

conditionsDatabase.demo.drifttubeMonitoring.hitMapsFromFittedTracks ( )

Definition at line 1168 of file drifttubeMonitoring.py.

1168def hitMapsFromFittedTracks():
1169 for s in range(1,5):
1170 for p in range(2):
1171 for l in range(2):
1172 xLayers[s][p][l]['_x'].Reset()
1173 if s==1: xLayers[s][p][l]['_u'].Reset()
1174 if s==2: xLayers[s][p][l]['_v'].Reset()
1175 for event in sTree:
1176 nt = -1
1177 for aTrack in event.FitTracks:
1178 nt+=1
1179 fst = aTrack.getFitStatus()
1180 if not fst.isFitConverged(): continue
1181 sta = aTrack.getFittedState(0)
1182 if sta.getMomMag() < 5.: continue
1183 trInfo = event.TrackInfos[nt]
1184 for n in range(trInfo.N()):
1185 if trInfo.wL(n) <0.1 and trInfo.wR(n) <0.1: continue
1186 detID = trInfo.detId(n)
1187 hit = ROOT.MufluxSpectrometerHit(detID,0)
1188 s,v,p,l,view,channelID,tdcId,mdoduleId = stationInfo(hit)
1189 rc = xLayers[s][p][l][view].Fill(channelID)
1190 ut.writeHists(h,'histos-HitmapsFromFittedTracks-'+rname)

◆ hitResolution()

conditionsDatabase.demo.drifttubeMonitoring.hitResolution ( )

Definition at line 4107 of file drifttubeMonitoring.py.

4107def hitResolution():
4108 ut.bookHist(h,'hitResol','hit resolution',100,-0.5,0.5)
4109 for n in range(sTree.GetEntries()):
4110 rc = sTree.GetEvent(n)
4111 for k in range(sTree.Digi_MufluxSpectrometerHits.GetEntries()):
4112 hit = sTree.Digi_MufluxSpectrometerHits[k]
4113 trueHit = sTree.MufluxSpectrometerPoint[k]
4114 hit.MufluxSpectrometerEndPoints(vbot,vtop)
4115 TDC = hit.GetDigi() - (vtop[0]-trueHit.GetX())/(ROOT.TMath.C() *100./1000000000.0)
4116 distance = RT('x',TDC)
4117 h['hitResol'].Fill(distance - trueHit.dist2Wire())

◆ importAlignmentConstants()

conditionsDatabase.demo.drifttubeMonitoring.importAlignmentConstants ( )

Definition at line 5286 of file drifttubeMonitoring.py.

5286def importAlignmentConstants():
5287 global alignConstants
5288 alignConstants = {}
5289 RPCPosition()
5290 if not sTree.GetCurrentFile().Get('alignConstants') or withCorrections:
5291 for straw in xpos:
5292 hit = ROOT.MufluxSpectrometerHit(straw,0.)
5293 strawPositionsBotTop[hit.GetDetectorID()]=correctAlignment(hit)
5294 print "importing alignment constants from code"
5295 return
5296 try:
5297 alignConstants = ast.literal_eval(json.dumps((conditionsDB.get_condition_by_name_and_tag("muflux/driftTubes", "alignConstants", "TUE2019"))["values"]))
5298 print "importing alignment constants from file",sTree.GetCurrentFile().GetName()
5299 strawPosition()
5300 except:
5301 print "loading of alignment constants failed for file",sTree.GetCurrentFile().GetName()

◆ importRTCorrection()

conditionsDatabase.demo.drifttubeMonitoring.importRTCorrection ( )

Definition at line 5318 of file drifttubeMonitoring.py.

5318def importRTCorrection():
5319 pars = {}
5320 pars['RTcorr_3_x2'] = [ 0.00831, -0.07374, 0.02906, 0.00208]
5321 pars['RTcorr_3_x3'] = [ 0.00681, -0.07238, 0.02892, 0.00166]
5322 pars['RTcorr_3_x0'] = [ 0.01101, -0.09078, 0.04499, -0.00141]
5323 pars['RTcorr_3_x1'] = [ 0.01742, -0.09704, 0.05228, -0.00443]
5324 pars['RTcorr_1_x0'] = [ 0.01154, -0.12568, 0.05343, 0.00328]
5325 pars['RTcorr_1_x1'] = [ 0.01198, -0.12964, 0.06247, -0.00039]
5326 pars['RTcorr_1_x2'] = [ 0.01161, -0.12784, 0.06131, -0.00023]
5327 pars['RTcorr_1_x3'] = [ 0.01347, -0.13834, 0.07343, -0.00372]
5328 pars['RTcorr_4_x3'] = [ 0.01728, -0.10018, 0.04357, 0.00202]
5329 pars['RTcorr_4_x2'] = [ 0.00721, -0.09512, 0.04784, 0.00004]
5330 pars['RTcorr_4_x1'] = [ 0.00657, -0.09035, 0.04213, 0.00092]
5331 pars['RTcorr_4_x0'] = [ 0.00574, -0.08853, 0.03935, 0.00204]
5332 pars['RTcorr_2_x1'] = [ 0.00924, -0.12481, 0.06797, -0.00409]
5333 pars['RTcorr_2_x0'] = [ 0.02527, -0.14195, 0.07045, -0.00305]
5334 pars['RTcorr_2_x3'] = [ 0.00816, -0.11859, 0.06268, -0.00366]
5335 pars['RTcorr_2_x2'] = [ 0.00889, -0.11218, 0.04914, 0.00214]
5336 pars['RTcorr_2_v3'] = [ 0.00148, -0.08058, 0.01316, 0.01340]
5337 pars['RTcorr_2_v2'] = [ 0.00443, -0.08887, 0.01707, 0.01278]
5338 pars['RTcorr_2_v1'] = [ 0.01399, -0.11404, 0.04792, 0.00191]
5339 pars['RTcorr_2_v0'] = [ 0.00164, -0.10222, 0.03695, 0.00631]
5340 pars['RTcorr_1_u3'] = [ 0.01792, -0.11791, 0.04498, 0.00483]
5341 pars['RTcorr_1_u2'] = [ 0.00220, -0.09611, 0.04685, 0.00020]
5342 pars['RTcorr_1_u1'] = [ -0.00148, -0.07691, 0.00984, 0.01453]
5343 pars['RTcorr_1_u0'] = [ 0.00043, -0.07272, 0.01027, 0.01312]
5344 pars['RTcorr'] = [ 0.00863, -0.10303, 0.04328, 0.00299]
5345 h['RTcorr'] = ROOT.TGraph()
5346 for s in range(1,5):
5347 for view in views[s]:
5348 for l in range(4):
5349 fun = 'RTcorrFun_'+str(s)+view+str(l)
5350 h[fun]=ROOT.TF1(fun,'[0]+[1]*x+[2]*x*x+[3]*x*x*x',4)
5351 for k in range(4): h[fun].SetParameter(k,pars[fun.replace('Fun','')][k])

◆ importRTrel()

conditionsDatabase.demo.drifttubeMonitoring.importRTrel ( )

Definition at line 5302 of file drifttubeMonitoring.py.

5302def importRTrel():
5303 for fname in fnames:
5304 if len(fnames)==1: f=sTree.GetCurrentFile()
5305 else: f = ROOT.TFile.Open(fname)
5306 rname = fname[fname.rfind('/')+1:]
5307 upkl = Unpickler(f)
5308 RTrelations[rname]={}
5309 try:
5310 RTrelations[rname]['tMinAndTmax'] = upkl.load('tMinAndTmax')
5311 for x in RTrelations[rname]['tMinAndTmax']: RTrelations[rname]['rt'+x]=f.RT.Get('rt'+x)
5312 h['tMinAndTmax'] = RTrelations[rname]['tMinAndTmax']
5313 for s in h['tMinAndTmax']: h['rt'+s] = RTrelations[rname]['rt'+s]
5314 except:
5315 print "loading of RT failed for file",rname
5316 if len(fnames)!=1: f.Close()
5317 importRTCorrection()

◆ init()

conditionsDatabase.demo.drifttubeMonitoring.init (   database = 'muflux_RTrelations.pkl',
  remake = False,
  withReco = False 
)

Definition at line 5378 of file drifttubeMonitoring.py.

5378def init(database='muflux_RTrelations.pkl',remake=False,withReco=False):
5379 global withTDC,RTrelations
5380 if os.path.exists(database): RTrelations = pickle.load(open(database))
5381 N = sTree.GetEntries()
5382 if not RTrelations.has_key(rname) or remake:
5383 withTDC = False
5384 sTree.SetBranchStatus("FitTracks",0)
5385 plotBiasedResiduals(PR=11)
5386 print "start making RT relations"
5387 makeRTrelations() # should be done after first pass with track reco, requires large number of events > 10000
5388 RTrelations[rname] = {'tMinAndTmax':h['tMinAndTmax']}
5389 for s in h['tMinAndTmax']: RTrelations[rname]['rt'+s] = h['rt'+s]
5390 fpkl=open(database,'w')
5391 pickle.dump(RTrelations,fpkl)
5392 fpkl.close()
5393 else:
5394 h['tMinAndTmax'] = RTrelations[rname]['tMinAndTmax']
5395 for s in h['tMinAndTmax']: h['rt'+s] = RTrelations[rname]['rt'+s]
5396 withTDC = True
5397 if withReco:
5398 plotBiasedResiduals(PR=13)
5399 plotRPCExtrap(PR=13)
5400 ut.writeHists(h,'histos-'+rname,plusCanvas=True)
5401#

◆ investigateActiveArea()

conditionsDatabase.demo.drifttubeMonitoring.investigateActiveArea ( )

Definition at line 3136 of file drifttubeMonitoring.py.

3136def investigateActiveArea():
3137 r = 1.815
3138 h['biasResDist2_projx'].Draw()
3139 h['tubeLine']=ROOT.TLine(r,0,r,2000)
3140 h['tubeLine'].SetLineColor(ROOT.kRed)
3141 h['tubeLine'].Draw('same')
3142 h['tubeLineX']=ROOT.TLine(r-0.19,0,r-0.19,2000)
3143 h['tubeLineX'].SetLineColor(ROOT.kMagenta)
3144 h['tubeLineX'].Draw('same')
3145

◆ loopTracks()

conditionsDatabase.demo.drifttubeMonitoring.loopTracks (   r,
  w 
)

Definition at line 4600 of file drifttubeMonitoring.py.

4600def loopTracks(r,w):
4601 os.close(r)
4602 w = os.fdopen(w, 'w')
4603 chisq=0
4604 for Nr in listOfTracks:
4605 rc=sTree.GetEvent(Nr)
4606 hitlist = listOfTracks[Nr]
4607 aTrack = fitTrack(hitlist,1.)
4608 if type(aTrack) != type(1):
4609 fitStatus = aTrack.getFitStatus()
4610 chisq+=fitStatus.getChi2()/fitStatus.getNdf()
4611 else: chisq+=10
4612 chisq = chisq/len(listOfTracks)
4613 print "chisq=",chisq
4614 w.write(str(chisq))
4615 w.close()
4616 os._exit(0)
4617

◆ makeAlignmentConstantsPersistent()

conditionsDatabase.demo.drifttubeMonitoring.makeAlignmentConstantsPersistent ( )

Definition at line 5274 of file drifttubeMonitoring.py.

5274def makeAlignmentConstantsPersistent():
5275 ftemp=sTree.GetCurrentFile()
5276 ftemp.cd('histos')
5277 momDisplay()
5278 h['mom'].Write()
5279 strawPositionsP = {}
5280 for straw in xpos:
5281 vbot,vtop = strawPositionsBotTop[straw]
5282 strawPositionsP[straw]={'top':[vtop[0],vtop[1],vtop[2]],'bot':[vbot[0],vbot[1],vbot[2]]}
5283 alignConstants={'strawPositions':strawPositionsP,'alignCorrection':alignCorrection}
5284 conditionsDB.add_condition("muflux/driftTubes", "alignConstants", "TUE2019", "2020-03-24", loads(dumps(alignConstants)))
5285

◆ makeFit()

conditionsDatabase.demo.drifttubeMonitoring.makeFit ( )

Definition at line 4641 of file drifttubeMonitoring.py.

4641def makeFit():
4642# new idea, first loop over N events, store hits of all track candidates
4643# then make loop over tracks and fit, sum track chi2
4644 for Nr in range(50000):
4645 rc = sTree.GetEvent(Nr)
4646 if not findSimpleEvent(sTree): continue
4647 track_hits = testPR(onlyHits=True)
4648 if len(track_hits)!=1: continue
4649 listOfTracks[Nr]= []
4650 for nhit in track_hits[0]: listOfTracks[Nr].append(nhit)
4651 npar = 24
4652 ierflg = ROOT.Long(0)
4653 gMinuit = ROOT.TMinuit(npar) # https://root.cern.ch/download/minuit.pdf
4654 gMinuit.SetFCN(FCN)
4655 gMinuit.SetErrorDef(0.5)
4656 vstart = array('d',[0]*npar)
4657 for p in range(16):
4658 vstart[p] = alignCorrection[p][0]
4659 p = 0
4660 for s in ['T1_x','T1_u','T2_v','T2_x','T3_x','T4_x']:
4661 for l in range(4):
4662 gMinuit.mnparm(p, s+str(l), vstart[p], 0.5, 0.,0.,ierflg)
4663 p+=1
4664 for p in range(4,24):gMinuit.FixParameter(p)
4665 strat = array('d',[0])
4666 gMinuit.mnexcm("SET STR",strat,1,ierflg) # 0 faster, 2 more reliable
4667 gMinuit.mnexcm("SIMPLEX",vstart,npar,ierflg)
4668 gMinuit.mnexcm("MIGRAD",vstart,npar,ierflg)
4669

◆ MakeKeysToDThits()

conditionsDatabase.demo.drifttubeMonitoring.MakeKeysToDThits (   minToT = -999)

Definition at line 1080 of file drifttubeMonitoring.py.

1080def MakeKeysToDThits(minToT=-999):
1081 keysToDThits={}
1082 key = -1
1083 for hit in sTree.Digi_MufluxSpectrometerHits:
1084 key+=1
1085 #if not hit.hasTimeOverThreshold(): continue
1086 if not hit.isValid() and MCdata: continue
1087 detID=hit.GetDetectorID()
1088 if detID<0: continue # feature for converted data in February'19
1089 if keysToDThits.has_key(detID):
1090 prevTDC = sTree.Digi_MufluxSpectrometerHits[keysToDThits[detID][0]].GetDigi()
1091 prevToT = sTree.Digi_MufluxSpectrometerHits[keysToDThits[detID][0]].GetTimeOverThreshold()
1092 # print "MakeKeysToDThits, non unique Digi_MufluxSpectrometerHits",detID,hit.GetDigi(),hit.GetTimeOverThreshold(),hit.hasTimeOverThreshold(),prevTDC,prevToT
1093 if hit.hasTimeOverThreshold(): keysToDThits[detID]=[key]
1094 else:
1095 keysToDThits[detID]=[key]
1096 key = -1
1097 for hit in sTree.Digi_LateMufluxSpectrometerHits:
1098 key+=1
1099 if not hit.isValid() and MCdata: continue
1100 if not hit.hasTimeOverThreshold(): continue
1101 if hit.GetTimeOverThreshold()<minToT : continue
1102 detID=hit.GetDetectorID()
1103 if not keysToDThits.has_key(detID):
1104 print "MakeKeysToDThits, late hit but no first one",detID
1105 keysToDThits[detID]=[-1]
1106 keysToDThits[detID].append(key)
1107 return keysToDThits
1108
1109

◆ makeLinearExtrapolations()

conditionsDatabase.demo.drifttubeMonitoring.makeLinearExtrapolations (   t1t2,
  t3t4 
)

Definition at line 2798 of file drifttubeMonitoring.py.

2798def makeLinearExtrapolations(t1t2,t3t4):
2799 for hit in sTree.Digi_MufluxSpectrometerHits:
2800 if not hit.hasTimeOverThreshold(): continue
2801 if hit.GetDetectorID() in noisyChannels: continue
2802 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
2803 if view != '_x': continue
2804 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
2805 z = (vbot[2]+vtop[2])/2.
2806 x = (vbot[0]+vtop[0])/2.
2807 if s < 3: track = t3t4
2808 else: track = t1t2
2809 delX = x - (track[3]*z+track[4])
2810 h['linearRes'+str(s)+view+str(2*p+l)].Fill(delX,x)
2811 track = t3t4
2812 for hit in sTree.Digi_MuonTaggerHits:
2813 channelID = hit.GetDetectorID()
2814 s = channelID/10000
2815 v = (channelID-10000*s)/1000
2816 if v!=1: continue # only x info
2817 vtop,vbot = RPCPositionsBotTop[channelID]
2818 z = (vtop[2]+vbot[2])/2.
2819 x = (vtop[0]+vbot[0])/2.
2820 delX = x - (track[3]*z+track[4])
2821 h['RPCResX_'+str(s)+str(v)].Fill(delX,x)
2822

◆ makeRTrelations()

conditionsDatabase.demo.drifttubeMonitoring.makeRTrelations ( )

Definition at line 1450 of file drifttubeMonitoring.py.

1450def makeRTrelations():
1451 if not h.has_key('RTrelations'):
1452 ut.bookCanvas(h,key='RTrelations',title='RT relations',nx=800,ny=500,cx=1,cy=1)
1453 h['RTrelations'].cd(1)
1454 x = h['TDC0']
1455 h['emptyHist'] = ROOT.TH2F('empty',' ;[ns];[cm] ',100,x.GetBinCenter(1),x.GetBinCenter(x.GetNbinsX()),100,0.,2.)
1456 h['emptyHist'].SetStats(0)
1457 h['emptyHist'].Draw()
1458 extractMinAndMax() # this has to run after filling TDC histos from trackfit!!
1459 h['legRT'] = ROOT.TLegend(0.76,0.11,0.997,0.869)
1460 for p in h['TDCMapsX'].GetListOfPrimitives():
1461 for o in p.GetListOfPrimitives():
1462 if o.InheritsFrom('TH1'): extractRTPanda(hname=o.GetName())
1463 h['legRT'].Draw('same')
1464

◆ makeRTrelPersistent()

conditionsDatabase.demo.drifttubeMonitoring.makeRTrelPersistent (   RTrelations)

Definition at line 5239 of file drifttubeMonitoring.py.

5239def makeRTrelPersistent(RTrelations):
5240 for fname in fnames:
5241 rname = fname[fname.rfind('/')+1:]
5242 newName = rname.replace('.root','_RT.root')
5243 if fname.find('eos')<0:
5244 copyfile(fname,newName)
5245 else:
5246 for l in range(10):
5247 rc = os.system("xrdcp -f $EOSSHIP"+fname+" "+newName)
5248 if rc == 0: break
5249 time.sleep(30)
5250 if rc != 0:
5251 print "Problem with copying file",fname,rc
5252 continue
5253 ftemp = ROOT.TFile.Open(newName,'update')
5254 sTree = ftemp.Get("cbmsim")
5255 if not sTree:
5256 print "Problem with making RTrel persistent, file",ftemp,ftemp.ls()
5257 continue
5258 ftemp.cd('')
5259 ftemp.mkdir('RT')
5260 ftemp.cd('RT')
5261 for s in RTrelations:
5262 if s.find('rt')<0: continue
5263 RTrelations[s].Write()
5264 pkl = Pickler(ftemp)
5265 pkl.dump(h['tMinAndTmax'],'tMinAndTmax')
5266 ftemp.cd('')
5267 ftemp.mkdir('histos')
5268 ftemp.histos.cd('')
5269 h['TDCMapsX'].Write()
5270 h['hitMapsX'].Write()
5271 h["RTrelations"].Write()
5272 ftemp.Write("",ROOT.TFile.kOverwrite)
5273 ftemp.Close()

◆ matchedRPCHits()

conditionsDatabase.demo.drifttubeMonitoring.matchedRPCHits (   aTrack,
  maxDistance = 10. 
)

Definition at line 4135 of file drifttubeMonitoring.py.

4135def matchedRPCHits(aTrack,maxDistance=10.):
4136 matchedHits={1:{0:[],1:[]},2:{0:[],1:[]},3:{0:[],1:[]},4:{0:[],1:[]},5:{0:[],1:[]}}
4137 rc,pos,mom = extrapolateToPlane(aTrack,zRPC1)
4138 Nmatched = 0
4139 inAcc = False
4140 if rc:
4141 if pos[0]>cuts['xLRPC1'] and pos[0]<cuts['xRRPC1'] and pos[1]>cuts['yBRPC1'] and pos[1]<cuts['yTRPC1']:
4142 inAcc = True
4143 for hit in sTree.Digi_MuonTaggerHits:
4144 if hit.GetDetectorID() in deadChannelsRPC4MC: continue
4145 channelID = hit.GetDetectorID()
4146 s = channelID/10000
4147 v = (channelID-10000*s)/1000
4148 vtop,vbot = RPCPositionsBotTop[channelID]
4149 z = (vtop[2]+vbot[2])/2.
4150 rc,pos,mom = extrapolateToPlane(aTrack,z)
4151 if not rc:
4152 error = "RPCextrap: plotRPCExtrap failed"
4153 ut.reportError(error)
4154 if Debug: print error
4155 continue
4156 if v==0:
4157 Y = (vtop[1]+vbot[1])/2.
4158 res = pos[1] - Y
4159 else:
4160 X = (vtop[0]+vbot[0])/2.
4161 res = pos[0] - X
4162 if abs(res)<maxDistance:
4163 matchedHits[s][v].append(hit)
4164 for s in matchedHits:
4165 for v in matchedHits[s]:
4166 Nmatched+= len(matchedHits[s][v])
4167 return inAcc,Nmatched
4168

◆ materialEffects()

conditionsDatabase.demo.drifttubeMonitoring.materialEffects (   switch)

Definition at line 1383 of file drifttubeMonitoring.py.

1383def materialEffects(switch):
1384 mat = ROOT.genfit.MaterialEffects.getInstance()
1385 if not switch:
1386 mat.setNoEffects()
1387 else:
1388 mat.setMscModel('GEANE')
1389 mat.setEnergyLossBetheBloch(True)
1390 mat.setNoiseBetheBloch(True)
1391 mat.setNoiseCoulomb(True)
1392 mat.setEnergyLossBrems(True)
1393 mat.setNoiseBrems(True)
1394

◆ MCchecks()

conditionsDatabase.demo.drifttubeMonitoring.MCchecks ( )

Definition at line 6909 of file drifttubeMonitoring.py.

6909def MCchecks():
6910 mult={}
6911 mult['0']=0
6912 for n in range(sTree.GetEntries()):
6913 rc=sTree.GetEvent(n)
6914 if n%10000==0: print n
6915 muon={}
6916 for m in sTree.MCTrack:
6917 if abs(m.GetPdgCode())==13:
6918 mult['0']+=1
6919 p = m.GetProcName().Data()
6920 if not muon.has_key(p): muon[p]=0
6921 muon[p]+=1
6922 if len(muon)==0:
6923 print "MCchecks",sTree.GetCurrentFile().GetName()
6924 sTree.MCTrack.Dump()
6925 for p in muon:
6926 if not mult.has_key(p): mult[p]={}
6927 N = muon[p]
6928 if not mult[p].has_key(N): mult[p][N]=0
6929 mult[p][N]+=1
6930 return mult

◆ MCcomparison()

conditionsDatabase.demo.drifttubeMonitoring.MCcomparison (   pot = -1,
  pMin = 5.,
  pMax = 300.,
  ptMax = 4.,
  simpleEffCor = 0.023,
  effCor = False,
  eric = False,
  version = "-repro",
  withOverFlow = False,
  withDisplay = True,
  cuts = '',
  noTitle = False 
)

Definition at line 5839 of file drifttubeMonitoring.py.

5839def MCcomparison(pot = -1, pMin = 5.,pMax=300.,ptMax = 4.,simpleEffCor=0.023,effCor=False,eric=False,version="-repro",withOverFlow=False,withDisplay=True,cuts='',noTitle=False):
5840 # possible cuts: '', 'All', 'Chi2<', 'Delx<', 'Dely<'
5841 # efficiency MC larger than data, 0.105 for cuts = All, but only for muon tagged!
5842 # otherwise only Chi2 cut, 0.034
5843 # covered cases: cuts = '', simpleEffCor=0.024, simpleEffCorMu=0.024
5844 # covered cases: cuts = 'Chi2<', simpleEffCor=0.058, simpleEffCorMu=0.058
5845 # covered cases: cuts = 'All', simpleEffCor=0.058, simpleEffCorMu=0.129
5846 simpleEffCorMu = simpleEffCor
5847 if cuts=='All':
5848 simpleEffCorMu = simpleEffCor + 0.130
5849 simpleEffCor += 0.056
5850 if cuts=='Chi2<':
5851 simpleEffCor += 0.056
5852 simpleEffCorMu = 0.021
5853
5854 label = 'MC-Comparison'+cuts.replace('<','')
5855 # 1GeV mbias, 1.806 Billion PoT
5856 # 1GeV charm, 10.21 Billion PoT, 10 files
5857 # 10GeV MC, 66.02 Billion PoT
5858 # 10GeV charm 153.90 Billion PoT
5859 # using 626 POT/mu-event and preliminary counting of good tracks -> 12.63 -> pot factor 7.02
5860 # using 710 POT/mu-event, full field
5861 # mbias POT/ charm POT = 0.177 (1GeV), 0.429 (10GeV)
5862 MCStats = 1.806E9
5863 MC10Stats = 66.02E9
5864 mcSysError = 0.03
5865 daSysError = 0.021
5866 sim10fact = MCStats/(MC10Stats) # normalize 10GeV to 1GeV stats
5867 muPerPot = 710 # 626
5868 charmNorm = {1:MCStats/10.21E9,10:MC10Stats/153.90E9}
5869 beautyNorm = {1:0., 10:0.01218}
5870 sources = {"":1.,"Hadronic inelastic":100.,"Lepton pair":100.,"Positron annihilation":100.,
5871 "charm":1./charmNorm[10],"beauty":1./beautyNorm[10],"Di-muon P8":100.,"invalid":1.}
5872 if len(hMC)==0:
5873 interestingHistos = ['Trscalers','chi2']
5874 for a in ['p/pt','pz/Abspx','p1/p2','p1/p2s']:
5875 for x in ['','mu','ymu']:
5876 for source in sources:
5877 c = cuts
5878 if x=='' and ( cuts == 'Delx' or cuts == 'Dely' or cuts == 'All' ): c=''
5879 if x=='ymu' and ( cuts == 'Delx' or cuts == 'All' ): c=''
5880 interestingHistos.append(c+a+x+source)
5881 if cuts == '':
5882 ut.readHists(h, 'momDistributions'+version+'.root',interestingHistos)
5883 else:
5884 ut.readHists(h, 'sumHistos'+version+'.root',interestingHistos)
5885
5886 # uncorrected MC histos
5887 # version = "-withDeadChannels"
5888 # version = "-noDeadChannels"
5889 # version = "-0"
5890 if not effCor:
5891 if cuts == '':
5892 ut.readHists(hMC, 'momDistributions-1GeV-mbias'+version+'.root',interestingHistos)
5893 ut.readHists(hCharm,'momDistributions-1GeV-charm'+version+'.root',interestingHistos)
5894 ut.readHists(hMC10GeV,'momDistributions-10GeV-mbias'+version+'.root',interestingHistos)
5895 else:
5896 ut.readHists(hMC, 'sumHistos--simulation1GeV'+version+'.root',interestingHistos)
5897 ut.readHists(hCharm,'sumHistos--simulation1GeV'+version+'-charm.root',interestingHistos)
5898 ut.readHists(hMC10GeV,'sumHistos--simulation10GeV'+version+'.root',interestingHistos)
5899 # if eric: ut.readHists(hMC10GeV,'momDistributions-10GeV.root',interestingHistos)
5900 else:
5901 ut.readHists(hMC, '../momDistributions-1GeV-mbias-effTuned-M0-reco.root',interestingHistos)
5902 ut.readHists(hMC, '../momDistributions-1GeV-mbias-effTuned-M2.root', interestingHistos)
5903 ut.readHists(hCharm,'../momDistributions-1GeV-charm-effTuned-M0-reco.root',interestingHistos)
5904 ut.readHists(hCharm,'../momDistributions-1GeV-charm-effTuned-M2.root', interestingHistos)
5905 ut.readHists(hMC10GeV,'../momDistributions-10GeV-mbias-effTuned-M0-reco.root',interestingHistos)
5906 ut.readHists(hMC10GeV,'../momDistributions-10GeV-mbias-effTuned-M2.root',interestingHistos)
5907 MCStats = MCStats*2. # because of average of two MC samples same stats
5908
5909 if cuts != "":
5910 for a in ['p/pt','pz/Abspx','p1/p2','p1/p2s','Trscalers','RPCResX/Y']:
5911 for x in ['','mu','ymu']:
5912 for source in sources:
5913 theCut = cuts
5914 if cuts == 'All' and x=='': theCut='Chi2<'
5915 if h.has_key(theCut+a+x+source):
5916 h[a+x+source]= h[theCut+a+x+source].Clone(a+x+source)
5917 hMC[a+x+source]= hMC[theCut+a+x+source].Clone(a+x+source)
5918 hCharm[a+x+source]= hCharm[theCut+a+x+source].Clone(a+x+source)
5919 hMC10GeV[a+x+source]= hMC10GeV[theCut+a+x+source].Clone(a+x+source)
5920
5921 for a in ['p/pt','pz/Abspx','p1/p2','p1/p2s']:
5922 for x in ['','mu']:
5923 if a.find('p1/p2')==0 and x!='': continue
5924 for hstore in [hMC,hCharm,hMC10GeV]:
5925# for new category "G4default", subtract dimuons made by SHiP modification to G4
5926 hstore[a+x+"G4default"]=hstore[a+x].Clone(a+x+"G4default")
5927 hstore[a+x+"G4default"].Add(hstore[a+x+"Hadronic inelastic"],-1.)
5928# subtract invalid case from main distribution
5929 # hstore[a+x].Add(hstore[a+x+"invalid"],-1.)
5930 if pot <0: # (default, use Hans normalization)
5931 POTdata = h['Trscalers'].GetBinContent(2) * muPerPot
5932 if version=="-repro": POTdata=POTdata/0.994 # events with refitted tracks slightly less than with fitted tracks
5933 MCscaleFactor = POTdata / MCStats
5934 # used until June 17, wrong!, number of tracks, should be number of events with tracks: POTdata = h['Trscalers'].GetBinContent(3) * muPerPot
5935 print "PoT data",POTdata / 1E9,"+/-",POTdata*daSysError / 1E9, " billion"
5936 norm={}
5937 norm[''] = MCscaleFactor * (1.-simpleEffCor)
5938 norm['mu'] = MCscaleFactor * (1.-simpleEffCorMu)
5939 for a in ['p/pt','pz/Abspx','p1/p2','p1/p2s']:
5940 for x in ['','mu']:
5941 if a.find('p1/p2')==0 and x=='mu': continue
5942# for 1GeV MC
5943 h['MC'+a+x] = hMC[a+x].Clone('MC'+a+x)
5944 h['MC'+a+x].Add(hCharm[a+x],charmNorm[1])
5945 h['MC'+a+x].Scale(norm[x])
5946 for source in sources:
5947 if source == "" or source == "beauty": continue
5948 xxx = a+x+source
5949 if source == "charm":
5950 h['MC'+xxx] = hCharm[a+x].Clone('MC'+xxx)
5951 h['MC'+xxx].Scale(charmNorm[1])
5952 else:
5953 h['MC'+xxx] = hMC[xxx].Clone('MC'+xxx)
5954 h['MC'+xxx].Scale(norm[x])
5955# for 10GeV MC
5956 h['MC10'+a+x] = hMC10GeV[a+x].Clone('MC10'+a+x)
5957# special treatment for 10GeV to get weights right
5958 if eric: # data with boosted channels
5959 for source in sources:
5960 if source == "": continue
5961 xxx = a+x+source
5962 h['MC10'+a+x].Add(hMC10GeV[xxx],-1.+1./sources[source])
5963 h['MC10'+xxx] = hMC10GeV[xxx].Clone('MC10'+xxx)
5964 h['MC10'+xxx].Scale(1./sources[source])
5965 h['MC10'+xxx].Scale(sim10fact) # scale it to 1GeV MC statistics
5966 h['MC10'+a+x].Scale(sim10fact)
5967 else:
5968 h['MC10'+a+x].Add(hMC10GeV[a+x+"charm"],-1.+charmNorm[10])
5969 h['MC10'+a+x].Add(hMC10GeV[a+x+"beauty"],-1.+beautyNorm[10])
5970 for source in sources:
5971 if source == "": continue
5972 xxx = a+x+source
5973 h['MC10'+xxx] = hMC10GeV[xxx].Clone('MC10'+xxx)
5974 if source == "charm" or source == "beauty": h['MC10'+xxx].Scale(sim10fact/sources[source]*norm[x])
5975 else: h['MC10'+xxx].Scale(sim10fact*norm[x])
5976 h['MC10'+a+x].Scale(sim10fact*norm[x])
5977# now we should have all distributions of different sources with correct weigths, except pi K decays
5978 h['MC10'+a+x+"Decay"]=h['MC10'+a+x].Clone('MC10'+a+x+"Decay")
5979 h['MC'+a+x+"Decay"]=h['MC'+a+x].Clone('MC'+a+x+"Decay")
5980 for s in sources:
5981 if s=='': continue
5982 h['MC10'+a+x+"Decay"].Add(h['MC10'+a+x+s],-1.)
5983 if s!= "beauty": h['MC'+a+x+"Decay"].Add(h['MC'+a+x+s],-1.)
5984# increase contributions from decay
5985 #h['MC10'+a+x].Add(h['MC10'+a+x+"Decay"],0.4)
5986 #h['MC'+a+x].Add(h['MC'+a+x+"Decay"],0.4)
5987# increase contributions from charm
5988 #h['MC10'+a+x].Add(h['MC10'+a+x+"charm"],2.0)
5989 #h['MC'+a+x].Add(h['MC'+a+x+"charm"],2.0)
5990
5991#
5992 optSorted = ['','MC','MC10','MCcharm','MCDi-muon P8','MCHadronic inelastic','MCLepton pair','MCPositron annihilation',
5993 'MC10charm','MC10Hadronic inelastic','MC10Di-muon P8','MC10Lepton pair','MC10Positron annihilation'] # decay removed, only covers part
5994 opt = {'':['hist',ROOT.kBlue,'data'],'MC':['same',ROOT.kRed,'MC inclusive'],'MC10':['same',ROOT.kRed,'MC 10GeV total'],
5995 'MCcharm':['same',ROOT.kGreen,'Charm'],'MC10charm':['same',ROOT.kGreen,'Charm'],
5996 'MCHadronic inelastic':['same',ROOT.kCyan+1,'Decays to di-muons (GEANT4)'],
5997 'MC10Hadronic inelastic':['same',ROOT.kCyan+1,'Decays to di-muons (GEANT4)'],
5998 'MCLepton pair':['same',ROOT.kGreen+1,'Photon conversion'],'MCPositron annihilation':['same',ROOT.kRed+2,'Positron annihilation'],
5999 'MC10Lepton pair':['same',ROOT.kGreen+1,'Photon conversion'],'MC10Positron annihilation':['same',ROOT.kRed+2,'Positron annihilation'],
6000 'MCDi-muon P8':['same',ROOT.kCyan,'Decays to di-muons (PYTHIA8)'],
6001 'MC10Di-muon P8':['same',ROOT.kCyan,'Decays to di-muons (PYTHIA8)']}
6002 ptMaxBin = h['p/pt'].GetYaxis().FindBin(ptMax)
6003 ptInterval = [ [pMin,10.],[10.,25.],[25.,50.],[50.,75.],[75.,100.],[100.,125.],[125.,150.],[150.,200.],[200.,250.],[250.,300.] ,[300.,400.] ]
6004 ptIntervalRebin = [ 1, 1, 1, 1, 1, 1, 2, 2, 4, 4, 4 ]
6005 for x in ['','mu']:
6006 for a in ['p/pt','pz/Abspx','p1/p2']:
6007 if a=='p1/p2' and x=='mu': continue
6008 for source in sources:
6009 xxx = a+x+source
6010 h['MC10'+xxx+'_x'] = h['MC10'+xxx].ProjectionX('MC10'+xxx+'_x',1,ptMaxBin)
6011 if source == "": h[xxx+'_x'] = h[xxx].ProjectionX(xxx+'_x',1,ptMaxBin)
6012 if source == "beauty": continue
6013 h['MC'+xxx+'_x'] = h['MC'+xxx].ProjectionX('MC'+xxx+'_x',1,ptMaxBin)
6014
6015 for x in ['','mu']:
6016 for i1 in opt:
6017 i = i1
6018 source = ""
6019 if not i.find('MC10')<0:
6020 i = 'MC10'
6021 source = i1.split('MC10')[1]
6022 elif not i.find('MC')<0:
6023 i = 'MC'
6024 source = i1.split('MC')[1]
6025 z = x+source
6026# MC 1 GeV should agree with data above P>5GeV
6027# MC 10 GeV should agree with data above P>20GeV
6028 if i == "MC":
6029# pt, combine 1 GeV and 10GeV MC
6030 h[i+'p/pt'+z+'_y'] =h[i+'p/pt'+z].ProjectionY(i+'p/pt'+z+'_y' ,h[i+'p/pt'+x+'_x'].FindBin(pMin),h[i+'p/pt'+x+'_x'].FindBin(20.))
6031 tmp = h[i+'10p/pt'+z].ProjectionY('tmp',h[i+'p/pt'+x+'_x'].FindBin(20.)+1,h[i+'p/pt'+x+'_x'].FindBin(pMax))
6032# attempt to make pt/px distribution with 1 GeV and 10 GeV MC
6033 h[i+'p/pt'+z+'_y'].Add(tmp)
6034# px
6035 h[i+'pz/Abspx'+z+'_y']=h[i+'pz/Abspx'+z].ProjectionY(i+'pz/Abspx'+z+'_y',h[i+'pz/Abspx'+x+'_x'].FindBin(pMin),h[i+'pz/Abspx'+x+'_x'].FindBin(20.))
6036 tmp = h[i+'10pz/Abspx'+z].ProjectionY('tmp',h[i+'pz/Abspx'+x+'_x'].FindBin(20)+1,h[i+'pz/Abspx'+x+'_x'].FindBin(pMax))
6037 h[i+'pz/Abspx'+z+'_y'].Add(tmp)
6038# p,pz
6039 h[i+'totp/pt'+z+'_x']=h[i+'10p/pt'+z+'_x'].Clone(i+'totp/pt'+z+'_x')
6040 h[i+'totpz/Abspx'+z+'_x']=h[i+'10pz/Abspx'+z+'_x'].Clone(i+'totpz/Abspx'+z+'_x')
6041 for k in range(h[i+'totp/pt'+z+'_x'].FindBin(pMin),h[i+'totp/pt'+z+'_x'].FindBin(20.)+1):
6042 h[i+'totp/pt'+z+'_x'].SetBinContent(k,h[i+'p/pt'+z+'_x'].GetBinContent(k))
6043 h[i+'totpz/Abspx'+z+'_x'].SetBinContent(k,h[i+'pz/Abspx'+z+'_x'].GetBinContent(k))
6044# interval
6045 for pInterval in ptInterval:
6046 interval = '_y'+str(pInterval[0])+'-'+str(pInterval[1])
6047 if pInterval[0]<20:
6048 h[i+'p/pt'+z+interval] =h[i+'p/pt'+z].ProjectionY(i+'p/pt'+z+interval ,h[i+'p/pt'+x+'_x'].FindBin(pInterval[0]),h[i+'p/pt'+x+'_x'].FindBin(20.))
6049 tmp = h[i+'10p/pt'+z].ProjectionY('tmp',h[i+'p/pt'+x+'_x'].FindBin(20.)+1,h[i+'p/pt'+x+'_x'].FindBin(pInterval[1]))
6050# attempt to make pt/px distribution with 1 GeV and 10 GeV MC
6051 h[i+'p/pt'+z+interval].Add(tmp)
6052 h[i+'pz/Abspx'+z+interval]=h[i+'pz/Abspx'+z].ProjectionY(i+'pz/Abspx'+z+interval,h[i+'pz/Abspx'+x+'_x'].FindBin(pInterval[0]),h[i+'pz/Abspx'+x+'_x'].FindBin(20.))
6053 tmp = h[i+'10pz/Abspx'+z].ProjectionY('tmp',h[i+'pz/Abspx'+x+'_x'].FindBin(20.)+1,h[i+'pz/Abspx'+x+'_x'].FindBin(pInterval[1]))
6054 h[i+'pz/Abspx'+z+interval].Add(tmp)
6055 else:
6056 h[i+'p/pt'+z+interval] =h[i+'p/pt'+z].ProjectionY(i+'p/pt'+z+interval ,h[i+'p/pt'+x+'_x'].FindBin(pInterval[0]),h[i+'p/pt'+x+'_x'].FindBin(pInterval[1]))
6057 h[i+'pz/Abspx'+z+interval]=h[i+'pz/Abspx'+z].ProjectionY(i+'pz/Abspx'+z+interval,h[i+'pz/Abspx'+x+'_x'].FindBin(pInterval[0]),h[i+'pz/Abspx'+x+'_x'].FindBin(pInterval[1]))
6058 h[i+'p/pt'+z+interval].SetTitle('#it{p}_{T} for '+str(pInterval[0])+' < #it{p} < '+str(pInterval[1]))
6059 h[i+'pz/Abspx'+z+interval].SetTitle('|#it{p}_{X}| for '+str(pInterval[0])+' < #it{p} < '+str(pInterval[1]))
6060 else:
6061 h[i+'p/pt'+z+'_y'] =h[i+'p/pt'+z].ProjectionY(i+'p/pt'+z+'_y' ,h[i+'p/pt'+x+'_x'].FindBin(pMin),h[i+'p/pt'+x+'_x'].GetNbinsX())
6062 h[i+'pz/Abspx'+z+'_y']=h[i+'pz/Abspx'+z].ProjectionY(i+'pz/Abspx'+z+'_y',h[i+'pz/Abspx'+x+'_x'].FindBin(pMin),h[i+'pz/Abspx'+x+'_x'].GetNbinsX())
6063 for pInterval in ptInterval:
6064 interval = '_y'+str(pInterval[0])+'-'+str(pInterval[1])
6065 h[i+'p/pt'+z+interval] =h[i+'p/pt'+z].ProjectionY(i+'p/pt'+z+interval ,h[i+'p/pt'+x+'_x'].FindBin(pInterval[0]),h[i+'p/pt'+x+'_x'].FindBin(pInterval[1]))
6066 h[i+'pz/Abspx'+z+interval]=h[i+'pz/Abspx'+z].ProjectionY(i+'pz/Abspx'+z+interval,h[i+'pz/Abspx'+x+'_x'].FindBin(pInterval[0]),h[i+'pz/Abspx'+x+'_x'].FindBin(pInterval[1]))
6067 h[i+'p/pt'+z+interval].SetTitle('#it{p}_{T} for '+str(pInterval[0])+' < #it{p}/(GeV/c) < '+str(pInterval[1]))
6068 h[i+'pz/Abspx'+z+interval].SetTitle('|#it{p}_{X}| for '+str(pInterval[0])+' < #it{p} < '+str(pInterval[1]))
6069# for integral distribution combine 1 and 10 GeV first with tot histos made above.
6070 for x in ['','mu']:
6071 for i1 in opt:
6072 i = i1
6073 source = ""
6074 if not i.find('MC10')<0:
6075 i = 'MC10'
6076 source = i1.split('MC10')[1]
6077 elif not i.find('MC')<0:
6078 i = 'MC'
6079 source = i1.split('MC')[1]
6080 z = x+source
6081 for a in ['p/pt','pz/Abspx']:
6082 if i == "MC": hname = i+'tot'+a+z+'_x'
6083 elif i == "MC10": continue # taken care by adding 1 and 10 -> tot
6084 else: hname = i+a+z+'_x'
6085 h[hname+'original']=h[hname].Clone(hname+'original')
6086 if not withOverFlow:
6087 for n in range(h[hname].FindBin(pMax),h[hname].GetNbinsX()+2):
6088 h[hname].SetBinContent(n,0.)
6089 h[hname].SetBinError(n,0.)
6090 ut.makeIntegralDistrib(h,hname,withOverFlow)
6091 h['I-'+hname].GetXaxis().SetRangeUser(pMin,pMax)
6092 if i == "MC":
6093 h['I-'+i+a+z+'_x']=h['I-'+hname].Clone('I-'+i+a+z+'_x')
6094 ut.makeIntegralDistrib(h,i+a+z+'_y',withOverFlow)
6095 if i != "MC10":
6096 h['I-'+i+'p/pt'+z+'_x'].SetTitle(' ;x [GeV/c]; #SigmaN/PoT with #it{p}>x')
6097 h['I-'+i+'p/pt'+z+'_x'].Scale(1./POTdata)
6098 h['I-'+i+'pz/Abspx'+z+'_x'].SetTitle(' ;x [GeV/c]; #SigmaN/PoT with #it{p}>x')
6099 h['I-'+i+'pz/Abspx'+z+'_x'].Scale(1./POTdata)
6100 h['I-'+i+'pz/Abspx'+z+'_y'].SetTitle(' ;x [GeV/c]; #SigmaN/PoT with #it{p}_{X}>x')
6101 h['I-'+i+'pz/Abspx'+z+'_y'].Scale(1./POTdata)
6102 h['I-'+i+'p/pt'+z+'_y'].SetTitle(' ;x [GeV/c]; #SigmaN/PoT with #it{p}_{T}>x')
6103 h['I-'+i+'p/pt'+z+'_y'].Scale(1./POTdata)
6104
6105 bz = "%iGeV/c"%(h[i+'p/pt'+z+'_x'].GetBinWidth(1))
6106 h[i+'p/pt'+z+'_x'].SetTitle('#it{p} ;#it{p} [GeV/c]; N/'+bz+'/PoT')
6107 h[i+'p/pt'+z+'_x'].Scale(1./POTdata)
6108
6109 bz = "%iGeV/c"%(h[i+'pz/Abspx'+z+'_x'].GetBinWidth(1))
6110 h[i+'pz/Abspx'+z+'_x'].SetTitle('#it{p}_{z} ;#it{p}_{z} [GeV/c]; N/'+bz+'/PoT')
6111 h[i+'pz/Abspx'+z+'_x'].Scale(1./POTdata)
6112
6113 bz = "%iMeV/c"%(1000*h[i+'pz/Abspx'+z+'_y'].GetBinWidth(1))
6114 h[i+'pz/Abspx'+z+'_y'].SetTitle('#it{p}_{x} ;#it{p}_{x} [GeV/c]; N/'+bz+'/PoT')
6115 h[i+'pz/Abspx'+z+'_y'].Scale(1./POTdata)
6116
6117 bz = "%iMeV/c"%(1000*h[i+'p/pt'+z+'_y'].GetBinWidth(1))
6118 h[i+'p/pt'+z+'_y'].SetTitle('#it{p}_{T} ;#it{p}_{T} [GeV/c]; N/'+bz+'/PoT')
6119 h[i+'p/pt'+z+'_y'].Scale(1./POTdata)
6120
6121 ut.bookCanvas(h,'output','',1200,800,1,1)
6122 for d in ['','I-']:
6123 for x in ['','mu']:
6124 t = d+'MC-Comparison'+x
6125 if not h.has_key(t):
6126 ut.bookCanvas(h,key=t,title=d+' MC / Data '+x,nx=1800,ny=900,cx=4,cy=2)
6127 ut.bookCanvas(h,key='simple'+t,title=d+' MC / Data '+x,nx=1800,ny=900,cx=4,cy=2)
6128# start with pz
6129 if not withDisplay: return
6130 tc = 1
6131 rc = h[t].cd(tc)
6132 rc.SetLogy(1)
6133 rc.SetLeftMargin(0.2)
6134 h['leg'+t+str(tc)]=ROOT.TLegend(0.50,0.61,0.96,0.93)
6135 mx1 = ut.findMaximumAndMinimum(h[d+'pz/Abspx'+x+'_x'])[1]
6136 mx2 = ut.findMaximumAndMinimum(h[d+'MCpz/Abspx'+x+'_x'])[1]
6137 hMax = max(mx1,mx2)
6138 for i1 in optSorted:
6139 i = i1
6140 source = ""
6141 if not i.find('MC10')<0:
6142 if d != "":continue
6143 i = 'MC10'
6144 source = i1.split('MC10')[1]
6145 elif not i.find('MC')<0:
6146 i = 'MC'
6147 source = i1.split('MC')[1]
6148 xx = x+source
6149 histo = h[d+i+'pz/Abspx'+xx+'_x']
6150 histo.SetMaximum(hMax*5.)
6151 histo.SetLineWidth(1)
6152 histo.SetMarkerSize(1)
6153 histo.SetLineColor(opt[i1][1])
6154 histo.SetStats(0)
6155 if i =='':
6156 histo.SetMinimum( histo.GetBinContent(histo.FindBin(pMax)-1)*0.01 )
6157 histo.GetXaxis().SetRangeUser(pMin,pMax)
6158 if i =='MC' and d=='': histo.GetXaxis().SetRangeUser(pMin,30.)
6159 if i =='MC10': histo.GetXaxis().SetRangeUser(20.,pMax)
6160 if d != '': histo.GetXaxis().SetRangeUser(pMin,pMax)
6161 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6162 if noTitle: histo.SetTitle('')
6163 histo.Draw(opt[i1][0])
6164 h['leg'+t+str(tc)].Draw('same')
6165# go to linear projection
6166 tc = 5
6167 rc = h[t].cd(tc)
6168 rc.SetLeftMargin(0.2)
6169 h['leg'+t+str(tc)]=ROOT.TLegend(0.42,0.54,0.88,0.86)
6170 for i1 in optSorted:
6171 i = i1
6172 source = ""
6173 if not i.find('MC10')<0:
6174 if d != "":continue
6175 i = 'MC10'
6176 source = i1.split('MC10')[1]
6177 elif not i.find('MC')<0:
6178 i = 'MC'
6179 source = i1.split('MC')[1]
6180 xx = x+source
6181 h['lin'+d+i+'pz/Abspx'+xx+'_x']=h[d+i+'pz/Abspx'+xx+'_x'].Clone('lin'+d+i+'pz/Abspx'+xx+'_x')
6182 histo = h['lin'+d+i+'pz/Abspx'+xx+'_x']
6183 if i=='': histo.GetXaxis().SetRangeUser(pMin,120)
6184 if i =='MC' and d=='': histo.GetXaxis().SetRangeUser(pMin,30.)
6185 if i =='MC10': histo.GetXaxis().SetRangeUser(20.,pMax)
6186 histo.SetMaximum(hMax*1.1)
6187 histo.SetMinimum(0.)
6188 if noTitle: histo.SetTitle('')
6189 histo.Draw(opt[i1][0])
6190 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6191 h['leg'+t+str(tc)].Draw('same')
6192# then px
6193 tc = 2
6194 rc = h[t].cd(tc)
6195 rc.SetLogy(1)
6196 rc.SetLeftMargin(0.2)
6197 h['leg'+t+str(tc)]=ROOT.TLegend(0.50,0.61,0.96,0.93)
6198 mx1 = ut.findMaximumAndMinimum(h[d+'pz/Abspx'+x+'_y'])[1]
6199 mx2 = ut.findMaximumAndMinimum(h[d+'MCpz/Abspx'+x+'_y'])[1]
6200 hMax = max(mx1,mx2)
6201 for i1 in optSorted:
6202 i = i1
6203 source = ""
6204 if not i.find('MC10')<0: continue
6205 elif not i.find('MC')<0:
6206 i = 'MC'
6207 source = i1.split('MC')[1]
6208 if i=='MC10': continue
6209 xx = x+source
6210 histo = h[d+i+'pz/Abspx'+xx+'_y']
6211 histo.SetMaximum(hMax*5.)
6212 histo.SetLineWidth(1)
6213 histo.SetMarkerSize(1)
6214 histo.SetLineColor(opt[i1][1])
6215 histo.SetStats(0)
6216 if i =='':
6217 histo.SetMinimum( histo.GetBinContent(histo.FindBin(ptMax))*0.01 )
6218 histo.GetXaxis().SetRangeUser(0.,ptMax)
6219 if noTitle: histo.SetTitle('')
6220 histo.Draw(opt[i1][0])
6221 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6222 h['leg'+t+str(tc)].Draw('same')
6223# linear
6224 tc = 6
6225 rc = h[t].cd(tc)
6226 rc.SetLeftMargin(0.2)
6227 h['leg'+t+str(tc)]=ROOT.TLegend(0.42,0.54,0.88,0.86)
6228 for i1 in optSorted:
6229 i = i1
6230 source = ""
6231 if not i.find('MC10')<0: continue
6232 elif not i.find('MC')<0:
6233 i = 'MC'
6234 source = i1.split('MC')[1]
6235 if i=='MC10': continue
6236 xx = x+source
6237 h['lin'+d+i+'pz/Abspx'+xx+'_y']=h[d+i+'pz/Abspx'+xx+'_y'].Clone('lin'+d+i+'pz/Abspx'+xx+'_y')
6238 histo = h['lin'+d+i+'pz/Abspx'+xx+'_y']
6239 if i=='': histo.GetXaxis().SetRangeUser(0.,2.)
6240 histo.SetMaximum(hMax*1.1)
6241 histo.SetMinimum(0.)
6242 if noTitle: histo.SetTitle('')
6243 histo.Draw(opt[i1][0])
6244 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6245 h['leg'+t+str(tc)].Draw('same')
6246# now P
6247 tc = 3
6248 rc = h[t].cd(tc)
6249 rc.SetLogy(1)
6250 rc.SetLeftMargin(0.2)
6251 h['leg'+t+str(tc)]=ROOT.TLegend(0.50,0.61,0.96,0.93)
6252 mx1 = ut.findMaximumAndMinimum(h[d+'p/pt'+x+'_x'])[1]
6253 mx2 = ut.findMaximumAndMinimum(h[d+'MCp/pt'+x+'_x'])[1]
6254 hMax = max(mx1,mx2)
6255 for i1 in optSorted:
6256 i = i1
6257 source = ""
6258 if not i.find('MC10')<0:
6259 if d != "":continue
6260 i = 'MC10'
6261 source = i1.split('MC10')[1]
6262 elif not i.find('MC')<0:
6263 i = 'MC'
6264 source = i1.split('MC')[1]
6265 xx = x+source
6266 histo = h[d+i+'p/pt'+xx+'_x']
6267 histo.SetMaximum(hMax*5.)
6268 histo.SetLineWidth(1)
6269 histo.SetMarkerSize(1)
6270 histo.SetLineColor(opt[i1][1])
6271 histo.SetStats(0)
6272 if i =='':
6273 histo.SetMinimum( histo.GetBinContent(histo.FindBin(pMax)-1)*0.01 )
6274 histo.GetXaxis().SetRangeUser(pMin,pMax)
6275 if d != '': histo.GetXaxis().SetRangeUser(pMin,pMax)
6276 if i =='MC' and d=='': histo.GetXaxis().SetRangeUser(pMin,30.)
6277 if i =='MC10': histo.GetXaxis().SetRangeUser(20.,pMax)
6278 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6279 if noTitle: histo.SetTitle('')
6280 histo.Draw(opt[i1][0])
6281 h['output'].cd().SetLogy(1)
6282 histo.Draw(opt[i1][0])
6283 rc = h[t].cd(tc)
6284 h['leg'+t+str(tc)].Draw('same')
6285 rc = h['output'].cd()
6286 h['leg'+t+str(tc)].Draw('same')
6287 myPrint(h['output'],label+d+x+'_P')
6288# linear
6289 tc = 7
6290 rc = h[t].cd(tc)
6291 rc.SetLeftMargin(0.2)
6292 h['leg'+t+str(tc)]=ROOT.TLegend(0.42,0.54,0.88,0.86)
6293 for i1 in optSorted:
6294 i = i1
6295 source = ""
6296 if not i.find('MC10')<0:
6297 if d != "":continue
6298 i = 'MC10'
6299 source = i1.split('MC10')[1]
6300 elif not i.find('MC')<0:
6301 i = 'MC'
6302 source = i1.split('MC')[1]
6303 xx = x+source
6304 h['lin'+d+i+'p/pt'+xx+'_x']=h[d+i+'p/pt'+xx+'_x'].Clone('lin'+d+i+'p/pt'+xx+'_x')
6305 histo = h['lin'+d+i+'p/pt'+xx+'_x']
6306 if i=='': histo.GetXaxis().SetRangeUser(pMin,120)
6307 if i =='MC' and d=='': histo.GetXaxis().SetRangeUser(pMin,30.)
6308 if i =='MC10': histo.GetXaxis().SetRangeUser(20.,pMax)
6309 histo.SetMaximum(hMax*1.1)
6310 histo.SetMinimum(0.)
6311 if noTitle: histo.SetTitle('')
6312 histo.Draw(opt[i1][0])
6313 h['output'].cd().SetLogy(0)
6314 histo.Draw(opt[i1][0])
6315 rc = h[t].cd(tc)
6316 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6317 h['leg'+t+str(tc)].Draw('same')
6318 rc = h['output'].cd()
6319 h['leg'+t+str(tc)].Draw('same')
6320 myPrint(h['output'],label+d+x+'_linP')
6321# and Pt
6322 tc = 4
6323 rc = h[t].cd(tc)
6324 rc.SetLogy(1)
6325 rc.SetLeftMargin(0.2)
6326 h['leg'+t+str(tc)]=ROOT.TLegend(0.50,0.61,0.96,0.93)
6327 mx1 = ut.findMaximumAndMinimum(h[d+'p/pt'+x+'_y'])[1]
6328 mx2 = ut.findMaximumAndMinimum(h[d+'MCp/pt'+x+'_y'])[1]
6329 hMax = max(mx1,mx2)
6330 for i1 in optSorted:
6331 i = i1
6332 source = ""
6333 if not i.find('MC10')<0:continue
6334 elif not i.find('MC')<0:
6335 i = 'MC'
6336 source = i1.split('MC')[1]
6337 if i=='MC10': continue # Pt/Px distributions from 1GeV and 10GeV are merged into one
6338 xx = x+source
6339 histo = h[d+i+'p/pt'+xx+'_y']
6340 histo.SetMaximum(hMax*5.)
6341 histo.SetLineWidth(1)
6342 histo.SetMarkerSize(1)
6343 histo.SetLineColor(opt[i1][1])
6344 histo.SetStats(0)
6345 if i =='':
6346 histo.SetMinimum( histo.GetBinContent(histo.FindBin(ptMax))*0.01 )
6347 histo.GetXaxis().SetRangeUser(0.,ptMax)
6348 if noTitle: histo.SetTitle('')
6349 histo.Draw(opt[i1][0])
6350 h['output'].cd().SetLogy(1)
6351 histo.Draw(opt[i1][0])
6352 rc = h[t].cd(tc)
6353 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6354 h['leg'+t+str(tc)].Draw('same')
6355 rc = h['output'].cd()
6356 h['leg'+t+str(tc)].Draw('same')
6357 myPrint(h['output'],label+d+x+'_Pt')
6358# linear
6359 tc = 8
6360 rc = h[t].cd(tc)
6361 rc.SetLeftMargin(0.2)
6362 h['leg'+t+str(tc)]=ROOT.TLegend(0.42,0.54,0.88,0.86)
6363 for i1 in optSorted:
6364 i = i1
6365 source = ""
6366 if not i.find('MC10')<0:continue
6367 elif not i.find('MC')<0:
6368 i = 'MC'
6369 source = i1.split('MC')[1]
6370 if i=='MC10': continue
6371 xx = x+source
6372 h['lin'+d+i+'p/pt'+xx+'_y']=h[d+i+'p/pt'+xx+'_y'].Clone('lin'+d+i+'p/pt'+xx+'_y')
6373 histo = h['lin'+d+i+'p/pt'+xx+'_y']
6374 if i=='': histo.GetXaxis().SetRangeUser(0.,2.)
6375 histo.SetMaximum(hMax*1.1)
6376 histo.SetMinimum(0.)
6377 if noTitle: histo.SetTitle('')
6378 histo.Draw(opt[i1][0])
6379 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(histo,opt[i1][2],'PL')
6380 h['output'].cd().SetLogy(0)
6381 histo.Draw(opt[i1][0])
6382 rc = h[t].cd(tc)
6383 h['leg'+t+str(tc)].Draw('same')
6384 h[t].Update()
6385 myPrint(h[t],label+d+x)
6386 rc = h['output'].cd()
6387 h['leg'+t+str(tc)].Draw('same')
6388 myPrint(rc,label+d+x+'_linPt')
6389
6390# simplified version
6391 tc = 1
6392 ts = 'simple'+t
6393 rc = h[ts].cd(tc)
6394 rc.SetLogy(1)
6395 rc.SetLeftMargin(0.2)
6396 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6397 for i in ['','MC','MC10']:
6398 if i=='MC10' and d != "":continue
6399 source = ""
6400 xx = x+source
6401 histo = h[d+i+'pz/Abspx'+xx+'_x']
6402 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(histo,opt[i][2],'PL')
6403 histo.SetMinimum(1E-10)
6404 if noTitle: histo.SetTitle('')
6405 histo.Draw(opt[i][0])
6406 h['leg'+ts+str(tc)].Draw('same')
6407 tc = 2
6408 rc = h[ts].cd(tc)
6409 rc.SetLogy(1)
6410 rc.SetLeftMargin(0.2)
6411 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6412 for i in ['','MC']:
6413 source = ""
6414 xx = x+source
6415 histo = h[d+i+'pz/Abspx'+xx+'_y']
6416 histo.SetMinimum(1E-10)
6417 if noTitle: histo.SetTitle('')
6418 histo.Draw(opt[i][0])
6419 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(h[d+i+'pz/Abspx'+xx+'_y'],opt[i][2],'PL')
6420 h['leg'+ts+str(tc)].Draw('same')
6421 tc = 3
6422 ts = 'simple'+t
6423 rc = h[ts].cd(tc)
6424 rc.SetLogy(1)
6425 rc.SetLeftMargin(0.2)
6426 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6427 hMax = max(mx1,mx2)
6428 for i in ['','MC','MC10']:
6429 if i=='MC10' and d != "":continue
6430 source = ""
6431 xx = x+source
6432 histo = h[d+i+'p/pt'+xx+'_x']
6433 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(histo,opt[i][2],'PL')
6434 if noTitle: histo.SetTitle('')
6435 histo.SetMinimum(1E-10)
6436 histo.Draw(opt[i][0])
6437 h['leg'+ts+str(tc)].Draw('same')
6438 tx = h['dummy'].cd()
6439 tx.SetLogy(1)
6440 for i in ['','MC','MC10']:
6441 if i=='MC10' and d != "":continue
6442 source = ""
6443 xx = x+source
6444 histo = h[d+i+'p/pt'+xx+'_x']
6445 if noTitle: histo.SetTitle('')
6446 histo.Draw(opt[i][0])
6447 h['leg'+ts+str(tc)].Draw('same')
6448 myPrint(h['dummy'],label+'-simple-P'+d+x)
6449 tc = 4
6450 rc = h[ts].cd(tc)
6451 rc.SetLogy(1)
6452 rc.SetLeftMargin(0.2)
6453 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6454 for i in ['','MC']:
6455 source = ""
6456 xx = x+source
6457 histo = h[d+i+'p/pt'+xx+'_y']
6458 if noTitle: histo.SetTitle('')
6459 histo.SetMinimum(1E-10)
6460 histo.Draw(opt[i][0])
6461 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(histo,opt[i][2],'PL')
6462 h['leg'+ts+str(tc)].Draw('same')
6463 tx = h['dummy'].cd()
6464 tx.SetLogy(1)
6465 for i in ['','MC']:
6466 if i=='MC10' and d != "":continue
6467 source = ""
6468 xx = x+source
6469 histo = h[d+i+'p/pt'+xx+'_y']
6470 if noTitle: histo.SetTitle('')
6471 histo.Draw(opt[i][0])
6472 h['leg'+ts+str(tc)].Draw('same')
6473 myPrint(h['dummy'],label+'-simple-Pt'+d+x)
6474 tc = 5
6475 rc.SetLeftMargin(0.2)
6476 rc = h[ts].cd(tc)
6477 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6478 for i in ['','MC','MC10']:
6479 if i=='MC10' and d != "":continue
6480 source = ""
6481 xx = x+source
6482 histo = h['lin'+d+i+'pz/Abspx'+xx+'_x']
6483 if noTitle: histo.SetTitle('')
6484 histo.Draw(opt[i][0])
6485 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(histo,opt[i][2],'PL')
6486 h['leg'+ts+str(tc)].Draw('same')
6487 tc = 6
6488 rc = h[ts].cd(tc)
6489 rc.SetLeftMargin(0.2)
6490 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6491 for i in ['','MC']:
6492 source = ""
6493 xx = x+source
6494 histo = h['lin'+d+i+'pz/Abspx'+xx+'_y']
6495 if noTitle: histo.SetTitle('')
6496 histo.Draw(opt[i][0])
6497 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(histo,opt[i][2],'PL')
6498 h['leg'+ts+str(tc)].Draw('same')
6499 tc = 7
6500 rc = h[ts].cd(tc)
6501 rc.SetLeftMargin(0.2)
6502 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6503 for i in ['','MC','MC10']:
6504 if i=='MC10' and d != "":continue
6505 source = ""
6506 xx = x+source
6507 histo = h['lin'+d+i+'p/pt'+xx+'_x']
6508 if noTitle: histo.SetTitle('')
6509 histo.Draw(opt[i][0])
6510 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(histo,opt[i][2],'PL')
6511 h['leg'+ts+str(tc)].Draw('same')
6512 tc = 8
6513 rc.SetLeftMargin(0.2)
6514 rc = h[ts].cd(tc)
6515 h['leg'+ts+str(tc)]=ROOT.TLegend(0.50,0.68,0.88,0.88)
6516 for i in ['','MC']:
6517 source = ""
6518 xx = x+source
6519 histo = h['lin'+d+i+'p/pt'+xx+'_y']
6520 if noTitle: histo.SetTitle('')
6521 histo.Draw(opt[i][0])
6522 if i.find('MC10')<0: h['leg'+ts+str(tc)].AddEntry(histo,opt[i][2],'PL')
6523 h['leg'+ts+str(tc)].Draw('same')
6524 h[ts].Update()
6525 myPrint(h[ts],label+'-simple-'+d+x)
6526 for Aproj in ['p/pt']:
6527 withAllTracks=False
6528 for x in ['','mu']:
6529# old printout
6530 if Aproj == 'p/pt':
6531 if x != '': print "=== muon tagged ===="
6532 else: print "=== all tracks ===="
6533 for P in [5.,10.,50.,100.,150.,200.,300.]:
6534 nbin = h[Aproj+x+'_x'].FindBin(P)
6535 print "data/MC P>%5i GeV: %5.2F"%(int(P),h['I-'+Aproj+x+'_x'].GetBinContent(nbin-1)/h['I-MC'+Aproj+x+'_x'].GetBinContent(nbin-1))
6536 n5 = h[Aproj+x+'_x'].FindBin(5.)
6537 n300 = h[Aproj+x+'_x'].FindBin(300.)
6538 n450 = h[Aproj+x+'_x'].FindBin(450.)
6539 n480 = h[Aproj+x+'_x'].FindBin(480.)
6540 n500 = h[Aproj+x+'_x'].FindBin(500.)
6541 ghostRateMC = h['MCtot'+Aproj+x+'_xoriginal'].Integral(n450,n500-1)/20.*295./h['MCtot'+Aproj+x+'_xoriginal'].Integral(n5,n300)
6542 ghostRateData = h[Aproj+x+'_xoriginal'].Integral(n450,n500-1)/20.*295./h[Aproj+x+'_xoriginal'].Integral(n5,n300)
6543 print "ghostRate MC: %5.2FperMille ghostRate Data: %5.2FperMille"%(ghostRateMC*1000,ghostRateData*1000)
6544# as in the note, n500 includes overflow
6545 ratioGhostsMC = h['MCtot'+Aproj+x+'_xoriginal'].Integral(n450,n500-1)/h['MCtot'+Aproj+x+'_xoriginal'].Integral(n450,n500)
6546 ratioGhostsData = h[Aproj+x+'_xoriginal'].Integral(n450,n500-1)/h[Aproj+x+'_xoriginal'].Integral(n450,n500)
6547 ratioGhostsDataMC = h[Aproj+x+'_xoriginal'].Integral(n450,n500-1)/h['MCtot'+Aproj+x+'_xoriginal'].Integral(n450,n500-1)
6548 print "tracks [450-500]/[>450] = MC: %5.2F, data: %5.2F. Absolute data/MC=%5.2F"%(ratioGhostsMC,ratioGhostsData,ratioGhostsDataMC)
6549# make ratio plots
6550 proj = Aproj
6551 for xx in [x+'_x',x+'_y']:
6552 h['I-'+proj+xx+'Ratio'] =h['I-'+proj+xx].Clone('I-'+proj+xx+'Ratio')
6553 h['I-'+proj+xx+'RatioG4'] =h['I-'+proj+xx].Clone('I-'+proj+xx+'RatioG4')
6554 h['I-'+proj+xx+'RatioG4noCharm']=h['I-'+proj+xx].Clone('I-'+proj+''+x+'_xRatioG4noCharm')
6555 for mc in ['I-MC']:
6556 h[mc+proj+xx+'G4'] =h[mc+proj+xx].Clone(mc+proj+xx+'G4')
6557 h[mc+proj+xx+'G4'].Add(h[mc+proj+xx.replace('_','Hadronic inelastic_')],-1.)
6558 h[mc+proj+xx+'G4noCharm']=h[mc+proj+xx].Clone('I-MC'+proj+''+x+'_xG4noCharm')
6559 h[mc+proj+xx+'G4noCharm'].Add(h[mc+proj+xx.replace('_','Hadronic inelastic_')],-1.)
6560 h[mc+proj+xx+'G4noCharm'].Add(h[mc+proj+xx.replace('_','charm_')],-1.)
6561 for c in ['','G4','G4noCharm']:
6562 ratio = h['I-'+proj+xx+'Ratio'+c]
6563 for mx in range(1,ratio.GetNbinsX()+1):
6564 Nmc = h['I-MC'+proj+xx+c].GetBinContent(mx)
6565 ratio.SetBinContent(mx,ratio.GetBinContent(mx)/Nmc)
6566 if withAllTracks and x == '': continue
6567 t = 'MC-Comparison ratios'+proj+xx
6568 if not h.has_key(t):
6569 ut.bookCanvas(h,key=t,title='Data / MC',nx=900,ny=600,cx=1,cy=1)
6570 h[t].cd(1)
6571 h['leg'+t]=ROOT.TLegend(0.11,0.67,0.56,0.86)
6572 histo = h['I-'+proj+xx+'Ratio']
6573 histo.SetLineColor(ROOT.kBlue)
6574 histo.SetMaximum(3.)
6575 if xx.find('_x')<0:
6576 histo.GetXaxis().SetRangeUser(0.,ptMax)
6577 else:
6578 histo.GetXaxis().SetRangeUser(pMin,pMax)
6579 histo.SetMinimum(0.0)
6580 histo.SetTitle('Ratio Data/MC '+h['I-'+proj+xx+'Ratio'].GetTitle())
6581 if noTitle: histo.SetTitle('')
6582 histo.Draw()
6583 h['leg'+t].AddEntry(histo,'Ratio Data / MC muon tagged tracks','PL')
6584 histo = h['I-'+proj+xx+'RatioG4']
6585 histo.SetLineColor(ROOT.kMagenta)
6586 if noTitle: histo.SetTitle('')
6587 histo.SetMaximum(3.)
6588 if noTitle: histo.SetTitle('')
6589 histo.Draw('same')
6590 h['leg'+t].AddEntry(histo,'muon tagged tracks no G4 dimuon ','PL')
6591 histo = h['I-'+proj+xx+'RatioG4noCharm']
6592 histo.SetLineColor(ROOT.kCyan)
6593 histo.SetMaximum(3.)
6594 histo.Draw('same')
6595 h['leg'+t].AddEntry(histo,'muon tagged tracks no G4 dimuon no charm ','PL')
6596 if noTitle: histo.SetTitle('')
6597 h['leg'+t].Draw('same')
6598 myPrint(h[t],label+'Ratios'+Aproj.replace('/',''))
6599# now in 2D
6600 asymVersion = False
6601 t = 'MC-Comparison ratios'+proj+'2D'
6602 if not h.has_key(t):
6603 ut.bookCanvas(h,key=t,title='Data / MC',nx=1800,ny=900,cx=1,cy=1)
6604 h[t].cd(1)
6605 ROOT.gStyle.SetPaintTextFormat("5.2f")
6606# first make a combination of 1GeV and 10GeV
6607 hname = 'MCtot'+proj+x
6608 h[hname]=h['MC'+proj+x].Clone(hname)
6609 h[hname].Reset()
6610 h['Data'+proj+x]=h[proj+x].Clone('Data'+proj+x)
6611 tmpx = h[hname].ProjectionX()
6612 tmpy = h[hname].ProjectionY()
6613 for mx in range(1,h[hname].GetNbinsX()+1):
6614 for my in range(1,h[hname].GetNbinsY()+1):
6615 if tmpx.GetBinCenter(mx)<5.:
6616 h['Data'+proj+x].SetBinContent(mx,my,0.)
6617 h['Data'+proj+x].SetBinError(mx,my,0.)
6618 elif tmpx.GetBinCenter(mx)<20.:
6619 h[hname].SetBinContent(mx,my,h['MC'+proj+x].GetBinContent(mx,my))
6620 h[hname].SetBinError(mx,my,h['MC'+proj+x].GetBinError(mx,my))
6621 else:
6622 h[hname].SetBinContent(mx,my,h['MC10'+proj+x].GetBinContent(mx,my))
6623 h[hname].SetBinError(mx,my,h['MC10'+proj+x].GetBinError(mx,my))
6624 h['Data'+proj+x+'rebin'] = h[proj+x].Rebin2D(25,5,'Data'+proj+x+'rebin')
6625 h['MC'+proj+x+'rebin'] = h[hname].Rebin2D(25,5,'MC'+proj+x+'rebin')
6626 h[proj+x+'Ratio']=h['MC'+proj+x+'rebin'].Clone(proj+x+'Ratio')
6627 for mx in range(1,h[proj+x+'Ratio'].GetNbinsX()+1):
6628 for my in range(1,h[proj+x+'Ratio'].GetNbinsY()+1):
6629 Nmc = h['MC'+proj+x+'rebin'].GetBinContent(mx,my)
6630 Nda = h['Data'+proj+x+'rebin'].GetBinContent(mx,my)
6631 eNmc = h['MC'+proj+x+'rebin'].GetBinError(mx,my)
6632 eNda = h[proj+x+'Ratio'].GetBinError(mx,my)
6633 if Nmc>10 and Nda>10:
6634 if asymVersion:
6635 R = (Nda-Nmc)/(Nda+Nmc)
6636 sig_data = ROOT.TMath.Sqrt(eNda**2+(Nda*daSysError)**2)
6637 sig_MC = ROOT.TMath.Sqrt(eNmc**2+(Nmc*mcSysError)**2)
6638 e1 = 2*Nda/(Nda+Nmc)**2
6639 e2 = 2*Nmc/(Nda+Nmc)**2
6640 eR = ROOT.TMath.Sqrt( (e1*sig_MC)**2+(e2*sig_data)**2 )
6641 else: # ratio version
6642 R = (Nda/Nmc)
6643 eR = ROOT.TMath.Sqrt( (R/Nmc*eNmc)**2+(R/Nda*eNda)**2 )
6644 else:
6645 R = 0. # -1 # R = 0
6646 eR = 0.
6647 h[proj+x+'Ratio'].SetBinContent(mx,my,R)
6648 h[proj+x+'Ratio'].SetBinError(mx,my,eR)
6649 histo = h[proj+x+'Ratio']
6650 histo.SetMinimum(-1.)
6651 histo.SetMaximum(+1.)
6652 histo.GetXaxis().SetRangeUser(pMin,pMax)
6653 histo.GetYaxis().SetRangeUser(0.,ptMax)
6654 histo.SetStats(0)
6655 histo.SetMarkerSize(1.2)
6656 if noTitle: histo.SetTitle('')
6657 histo.Draw('texte')
6658 myPrint(h[t],label+'Ratios2D'+proj.replace('/',''))
6659# data
6660 t='pPt2d'
6661 if not h.has_key(t):
6662 ut.bookCanvas(h,key=t,title='Data',nx=1200,ny=900,cx=1,cy=1)
6663 tc = h[t].cd()
6664 tc.SetLogz(1)
6665 histo = h['p/ptmu']
6666 histo.SetMinimum(0.)
6667 histo.SetMaximum(5.E6)
6668 histo.GetXaxis().SetRangeUser(0,pMax)
6669 histo.GetYaxis().SetRangeUser(0,ptMax-0.1)
6670 histo.GetXaxis().SetTitleOffset(1.7)
6671 histo.GetXaxis().SetTitle(' #it{p} [GeV/c]')
6672 histo.GetYaxis().SetTitle(' #it{p}_{T} [GeV/c] ')
6673 histo.GetYaxis().SetTitleOffset(1.7)
6674 tc.SetTheta(26.4)
6675 tc.SetPhi(-135.6)
6676 histo.SetStats(0)
6677 if noTitle: histo.SetTitle('')
6678 histo.Draw('lego')
6679 myPrint(h[t],label+'DatapPt')
6680
6681# pt in slices of P
6682 for t in ['MC-Comparison Pt']:
6683 if not h.has_key(t):
6684 if pMax > 310: ut.bookCanvas(h,key=t,title=' MC / Data '+t.split(' ')[1],nx=1800,ny=900,cx=6,cy=2)
6685 else: ut.bookCanvas(h,key=t,title=' MC / Data '+t.split(' ')[1],nx=1800,ny=900,cx=5,cy=2)
6686 y = 1
6687 for pInterval in ptInterval:
6688 if pInterval[1] > pMax: continue
6689 if pInterval[1]<11: x = ''
6690 else: x = 'mu'
6691 interval = '_y'+str(pInterval[0])+'-'+str(pInterval[1])
6692 tc = h[t].cd(y)
6693 rebinValue = ptIntervalRebin[y-1]
6694 y+=1
6695 h['leg'+t+str(tc)]=ROOT.TLegend(0.42,0.54,0.88,0.86)
6696 for i1 in optSorted:
6697 i = i1
6698 source = ""
6699 if not i.find('MC10')<0:
6700 i = 'MC10'
6701 source = i1.split('MC10')[1]
6702 elif not i.find('MC')<0:
6703 i = 'MC'
6704 source = i1.split('MC')[1]
6705 if i=='MC10': continue
6706 xx = x+source
6707 proj = 'p/pt'
6708 if t.find('Px')>0: proj = 'pz/Abspx'
6709 hname = i+proj+xx+interval
6710 mx1 = ut.findMaximumAndMinimum(h[ proj+x+interval])[1]
6711 mx2 = ut.findMaximumAndMinimum(h['MC'+proj+x+interval])[1]
6712 hMaPx = max(mx1,mx2)
6713 if rebinValue>1:
6714 h[hname].Rebin(rebinValue)
6715 h[hname].Scale(1./rebinValue)
6716 h[hname].GetXaxis().SetRangeUser(0.,ptMax)
6717 h[hname].SetMaximum(hMaPx*1.1)
6718 h[hname].SetMinimum(0.)
6719 h[hname].SetStats(0)
6720 h[hname].SetLineWidth(1)
6721 h[hname].SetMarkerSize(1)
6722 h[hname].SetLineColor(opt[i1][1])
6723 h[hname].Draw(opt[i][0])
6724 if i.find('MC10')<0: h['leg'+t+str(tc)].AddEntry(h[hname],opt[i1][2],'PL')
6725 h['leg'+t+str(tc)].Draw('same')
6726 h[t].Update()
6727 myPrint(h[t],label+t.replace('MC-Comparison ',''))
6728# printout rate
6729 print " interval data MC ratio data/MC charm per 1E9 PoT / GeV/c "
6730 for pInterval in ptInterval:
6731 if pInterval[1]<11: x = ''
6732 else: x = 'mu'
6733 interval = '_y'+str(pInterval[0])+'-'+str(pInterval[1])
6734 proj = 'p/pt'
6735 hname = proj+x+interval
6736 err=ROOT.Double()
6737 data = h[hname].IntegralAndError(0,h[hname].FindBin(ptMax),err)/POTdata/(pInterval[1]-pInterval[0])*1E9
6738 sig_data=err/POTdata/(pInterval[1]-pInterval[0])*1E9
6739 sig_data = ROOT.TMath.Sqrt(sig_data**2+(data*daSysError)**2)
6740 mc = h['MC'+hname].IntegralAndError(0,h[hname].FindBin(ptMax),err)/POTdata/(pInterval[1]-pInterval[0])*1E9
6741 sig_MC = err/POTdata/(pInterval[1]-pInterval[0])*1E9
6742 sig_MC = ROOT.TMath.Sqrt(sig_MC**2+(mc*mcSysError)**2)
6743 mcCharm = h['MC'+hname.replace('_y','charm_y')].IntegralAndError(0,h[hname].FindBin(ptMax),err)/POTdata/(pInterval[1]-pInterval[0])*1E9
6744 ratio = data/mc
6745 sig_ratio = ROOT.TMath.Sqrt( (ratio/data*sig_data)**2+(ratio/mc*sig_MC)**2)
6746 sig_Charm=err/POTdata/(pInterval[1]-pInterval[0])*1E9
6747 sig_Charm=ROOT.TMath.Sqrt(sig_Charm**2+(mcCharm*mcSysError)**2)
6748 print "%11s %7.2E +/- %7.2E %7.2E +/- %7.2E %5.2F +/- %5.2F %6.2E +/- %6.2E"%(str(pInterval[0])+'-'+str(pInterval[1]),data,sig_data,mc,sig_MC,ratio,sig_ratio,mcCharm,sig_Charm)
6749# printout mean pt
6750 print " interval data MC charm mean PT [GeV/c] "
6751 for pInterval in ptInterval:
6752 if pInterval[1]<11: x = ''
6753 else: x = 'mu'
6754 interval = '_y'+str(pInterval[0])+'-'+str(pInterval[1])
6755 proj = 'p/pt'
6756 hname = proj+x+interval
6757 data = h[hname].GetMean()
6758 mc = h['MC'+hname].GetMean()
6759 mcCharm = h['MC'+hname.replace('_y','charm_y')].GetMean()
6760 print "%11s %5.2G %5.2G %5.2G "%(str(pInterval[0])+'-'+str(pInterval[1]),data,mc,mcCharm)
6761 singlePtSlices()
6762# some code for 2 track events
6763 osign = {'':'opposite sign','s':'same sign'}
6764 txt = {6:'P>5GeV/c',21:'P>20GeV/c'}
6765 pLimit = 400
6766 for s in osign:
6767 pad = 1
6768 rebin = False #5
6769 for case in txt:
6770 t = '2trackOverAll'+osign[s]+txt[case]
6771 if not h.has_key(t): ut.bookCanvas(h,key=t,title=' momentum of muons in 2-track events '+osign[s],nx=800,ny=800,cx=1,cy=1)
6772 tc = h[t].cd(pad)
6773 h['leg'+t+str(pad)+s]=ROOT.TLegend(0.42,0.54,0.88,0.86)
6774 hn = 'p1p2'+txt[case]+s
6775 h[hn] = h['p1/p2'+s].ProjectionX(hn,case,h['p1/p2'+s].GetYaxis().FindBin(pMax))
6776 h[hn].Add(h['p1/p2'+s].ProjectionY('p1p2y'+txt[case]+s,case,h['p1/p2'+s].GetXaxis().FindBin(pMax)) )
6777 if rebin>1: h[hn].Rebin(rebin)
6778 norm = h['p/ptmu_x'].Integral(case,h['p/ptmu_x'].FindBin(pMax))*POTdata
6779 h[hn].Scale(1./norm)
6780 h[hn].SetTitle('P in 2-track events '+txt[case]+'; GeV/c;N2/Nall with P > / ')
6781 h[hn].SetStats(0)
6782 h[hn].SetMaximum(0.5)
6783 h[hn].SetMinimum(2E-6)
6784 ut.makeIntegralDistrib(h,hn,withOverFlow)
6785 Ihn = 'I-'+hn
6786 h[Ihn].GetXaxis().SetRangeUser(case,pLimit)
6787 if noTitle: h[Ihn].SetTitle('')
6788 h[Ihn].Draw()
6789 h['leg'+t+str(pad)+s].AddEntry(h[hn],opt[''][2],'PL')
6790 tc.SetLogy()
6791# now MC
6792 if case < 20: mchist = 'MCp1/p2'+s
6793 else: mchist = 'MC10p1/p2'+s
6794 hn='MCp1p2'+txt[case]+s
6795 h[hn] = h[mchist].ProjectionX(hn,case,h[mchist].GetYaxis().FindBin(pMax))
6796 h[hn].Add(h[mchist].ProjectionY('MCp1p2y'+txt[case]+s,case,h[mchist].GetYaxis().FindBin(pMax)) )
6797 if rebin>1: h[hn].Rebin(rebin)
6798 if case < 20: norm = h['MCp/ptmu_x'].Integral(case,h['MCp/ptmu_x'].FindBin(pMax))*POTdata
6799 else: norm = h['MC10p/ptmu_x'].Integral(case,h['MC10p/ptmu_x'].FindBin(pMax))*POTdata
6800 h[hn].Scale(1./norm)
6801 h[hn].SetStats(0)
6802 h[hn].SetTitle('P in 2-track events, one track with '+txt[case]+'; GeV/c')
6803 h[hn].SetLineColor(opt['MC'][1])
6804 ut.makeIntegralDistrib(h,hn,withOverFlow)
6805 Ihn = 'I-'+hn
6806 if noTitle: h[Ihn].SetTitle('')
6807 h[Ihn].Draw('same')
6808 h[Ihn].GetXaxis().SetRangeUser(case,pLimit)
6809 h['leg'+t+str(pad)+s].AddEntry(h[hn],opt['MC'][2],'PL')
6810 tc.SetLogy()
6811 for i1 in optSorted:
6812 if i1.find('MC')<0: continue
6813 if i1.find('MC10')<0 and case==21: continue
6814 if not i1.find('MC10')<0 and case==6: continue
6815 if not i1.find('MC10')<0:
6816 i = 'MC10'
6817 source = i1.split('MC10')[1]
6818 elif not i.find('MC')<0:
6819 i = 'MC'
6820 source = i1.split('MC')[1]
6821 if source == '': continue
6822 hn='MCp1p2'+source+txt[case]+s
6823 h[hn] = h[i+'p1/p2'+s+source].ProjectionX(hn,case,h[i+'p1/p2'+s+source].GetYaxis().FindBin(pMax))
6824 h[hn].Add(h[i+'p1/p2'+s+source].ProjectionY(i+'p1/p2y'+source+txt[case]+s,case,h[i+'p1/p2'+s+source].GetXaxis().FindBin(pMax)))
6825 if rebin>1: h[hn].Rebin(5)
6826 h[hn].SetLineColor(opt[i1][1])
6827 h[hn].SetStats(0)
6828 h[hn].Scale(1./norm)
6829 ut.makeIntegralDistrib(h,hn,withOverFlow)
6830 Ihn = 'I-'+hn
6831 if noTitle: h[Ihn].SetTitle('')
6832 h[Ihn].Draw('same')
6833 h[Ihn].GetXaxis().SetRangeUser(case,pMax)
6834 h['leg'+t+str(pad)+s].AddEntry(h[hn],opt[i1][2],'PL')
6835 h['leg'+t+str(pad)+s].Draw('same')
6836 pad +=1
6837 myPrint(h[t],label+'2Tracks'+osign[s]+str(case))

◆ MCcomparisonHitmaps()

conditionsDatabase.demo.drifttubeMonitoring.MCcomparisonHitmaps (   MC = '1GeV',
  first = False 
)

Definition at line 6875 of file drifttubeMonitoring.py.

6875def MCcomparisonHitmaps(MC='1GeV',first=False):
6876# MC
6877 t='hitMapsX'
6878 if first:
6879 global h
6880 ut.readHists(h,"HitmapsFromFittedTracks-"+MC+"-mbias.root")
6881 plotHitMapsOld(onlyPlotting=True)
6882 f = ROOT.TFile('TCanvas-HitmapsFromFittedTracks-'+MC+'-mbias.root','recreate')
6883 h[t].Write()
6884 f.Close()
6885 for s in range(1,5):
6886 for p in range(2):
6887 for l in range(2):
6888 xLayers[s][p][l]['_x'].Reset()
6889 if s==1: xLayers[s][p][l]['_u'].Reset()
6890 if s==2: xLayers[s][p][l]['_v'].Reset()
6891 #ut.readHists(h,"HitmapsFromFittedTracks.root")
6892 ut.readHists(h,"histos-HitmapsFromFittedTracks-"+rname)
6893 plotHitMapsOld(onlyPlotting=True)
6894 h['fMC'+t]=ROOT.TFile('TCanvas-HitmapsFromFittedTracks-'+MC+'-mbias.root')
6895 h['TMC'+t]= h['fMC'+t].GetListOfKeys()[0].ReadObj()
6896 for n in range(1,25):
6897 tc = h[t].cd(n)
6898 tmp = h['TMC'+t].GetPad(n)
6899 for obj in tmp.GetListOfPrimitives():
6900 if obj.Class().GetName().find('TH1')<0: continue
6901 NMC = obj.GetEntries()
6902 NDA = tc.FindObject(obj.GetName()).GetEntries()
6903 obj.Scale(NDA/NMC)
6904 newName = 'MC'+obj.GetName()
6905 h[newName]=obj.Clone(newName)
6906 h[newName].SetLineColor(ROOT.kRed)
6907 h[newName].Draw('histsame')
6908 myPrint(h[t],'MCcomparison-hitmaps')

◆ MCJpsiProd()

conditionsDatabase.demo.drifttubeMonitoring.MCJpsiProd (   onlyPlotting = False)

Definition at line 1603 of file drifttubeMonitoring.py.

1603def MCJpsiProd(onlyPlotting=False):
1604 beam = yBeam()
1605 names = {}
1606 for c in [221,223,113,331,333,443]:
1607 names[c] = PDG.GetParticle(c).GetName()
1608 if not onlyPlotting:
1609 for c in names:
1610 name = names[c]
1611 ut.bookHist(h,name+'PandPt','P and Pt of original '+name,100,0.,400.,100,0.,10.)
1612 ut.bookHist(h,name+'PandPt_rec','P and Pt of original '+name+' for muons reconstructed',100,0.,400.,100,0.,10.)
1613 ut.bookHist(h,name+'Y','rapidity of original '+name,80,-2.,6.)
1614 ut.bookHist(h,name+'Y_rec','rapidity of reconstructed '+name,80,-2.,6.)
1615 for n in range(sTree.GetEntries()):
1616 rc=sTree.GetEvent(n)
1617 for m in range(sTree.MCTrack.GetEntries()):
1618 p = sTree.MCTrack[m]
1619 if p.GetPdgCode() in names:
1620 rc=h[names[p.GetPdgCode()]+'PandPt'].Fill(p.GetP(),p.GetPt())
1621 rc=h[names[p.GetPdgCode()]+'Y'].Fill(p.GetRapidity()-beam)
1622 nRec = 0
1623 for k in range(sTree.FitTracks.GetEntries()):
1624 mu = sTree.TrackInfos[k].McTrack()
1625 if mu<0: continue
1626 if sTree.MCTrack[mu].GetMotherId()==m: nRec += 1
1627 if nRec == 2:
1628 rc=h[names[p.GetPdgCode()]+'PandPt_rec'].Fill(p.GetP(),p.GetPt())
1629 rc=h[names[p.GetPdgCode()]+'Y_rec'].Fill(p.GetRapidity()-beam)
1630 break
1631 ut.writeHists(h,'histos-Jpsi'+rname)
1632 else:
1633 ut.readHists(h,'JpsiKinematics-1GeV-mbias.root')
1634 ut.readHists(h,'JpsiKinematics-1GeV-charm.root')
1635 ut.readHists(h,'JpsiKinematics-10GeV.root')
1636 h['lowMassPandPt_rec']=h[names[443]+'PandPt_rec'].Clone('lowMassPandPt_rec')
1637 h['lowMassPandPt']=h[names[443]+'PandPt'].Clone('lowMassPandPt')
1638 for c in names:
1639 h['lowMassPandPt_rec'].Add(h[names[c]+'PandPt_rec'])
1640 h['lowMassPandPt'].Add(h[names[c]+'PandPt'])
1641 names['lowMass']='lowMass'
1642 for c in names:
1643 ut.bookCanvas(h,'acc'+names[c],names[c]+' acceptance',1200,800,1,3)
1644 for x in [names[c]+'PandPt_rec',names[c]+'PandPt']:
1645 h[x].GetYaxis().SetRangeUser(0.,5.)
1646 h[x].SetStats(0)
1647 h[x].SetTitle(h[x].GetTitle()+';#it{p} [GeV/c];#it{p}_{T} [GeV/c]')
1648 h[names[c]+'recoEff']=ROOT.TEfficiency(h[names[c]+'PandPt_rec'],h[names[c]+'PandPt'])
1649 ROOT.gStyle.SetPalette(ROOT.kTemperatureMap)
1650 tc = h['acc'+names[c]].cd(1)
1651 h[names[c]+'PandPt'].Draw('colz')
1652 tc = h['acc'+names[c]].cd(2)
1653 h[names[c]+'PandPt_rec'].Draw('colz')
1654 tc = h['acc'+names[c]].cd(3)
1655 h[names[c]+'recoEff'].Draw('colz')
1656 tc.Update()
1657 h[names[c]+'recoEff'].GetPaintedHistogram().GetYaxis().SetRangeUser(0.,5.)
1658 tc.Update()
1659 myPrint(h['acc'+names[c]],names[c]+'Acceptance')
1660 for c in names:
1661 ut.bookCanvas(h,'accRap'+names[c],names[c]+' acceptance',1200,800,1,2)
1662 for x in [names[c]+'Y_rec',names[c]+'Y']:
1663 h[x].SetStats(0)
1664 h[x].SetTitle(h[x].GetTitle()+';rapidity Y;')
1665 h[names[c]+'YrecoEff']=ROOT.TEfficiency(h[names[c]+'Y_rec'],h[names[c]+'Y'])
1666 ROOT.gStyle.SetPalette(ROOT.kTemperatureMap)
1667 tc = h['accRap'+names[c]].cd(1)
1668 h[names[c]+'Y'].Draw()
1669 h[names[c]+'Y_rec'].SetLineColor(ROOT.kMagenta)
1670 h[names[c]+'Y_rec'].Draw('same')
1671 tc = h['accRap'+names[c]].cd(2)
1672 h[names[c]+'YrecoEff'].Draw()
1673 myPrint(h['accRap'+names[c]],names[c]+'RapAcceptance')
1674
1675
1676# from TrackExtrapolateTool

◆ mergeGoodRuns()

conditionsDatabase.demo.drifttubeMonitoring.mergeGoodRuns (   excludeRPC = False,
  path = '.',
  fromEOS = True 
)

Definition at line 7330 of file drifttubeMonitoring.py.

7330def mergeGoodRuns(excludeRPC=False,path='.',fromEOS=True):
7331 #path = '/media/truf/disk2/home/truf/ShipSoft/ship-ubuntu-1710-64'
7332 noField = [2199,2200,2201]
7333 intermediateField = [2383,2388,2389,2390,2392,2395,2396]
7334 noTracks = [2334, 2335, 2336, 2337, 2345, 2389, 2390]
7335 RPCbad = [2144,2154,2183,2192,2210,2211,2217,2218,2235,2236,2237,2240,2241,2243,2291,2345,2359]
7336 badRuns = [2142, 2143, 2144, 2149]
7337 keyword = 'RUN_8000_2'
7338 temp = os.listdir(path)
7339 cmd = 'hadd -f momDistributions.root '
7340 for x in temp:
7341 if x.find(keyword)<0: continue
7342 if not fromEOS:
7343 if not os.path.isdir(path+'/'+x): continue
7344 r = int(x[x.rfind('/')+1:].split('_')[2])
7345 if r in badRuns or r in noTracks or r in intermediateField or r in noField : continue
7346 if excludeRPC and (r in RPCbad or (r>2198 and r < 2275)) : continue
7347 test = path+'/'+x+'/momDistributions.root '
7348 if not os.path.isfile(test.replace(' ','')):
7349 print "no file found, skip run:",x,test
7350 continue
7351 else:
7352 if x.find("momDistributions-RUN_8000_2")!=0: continue
7353 test = x+" "
7354 cmd += test
7355 os.system(cmd)

◆ mergeHistosForMomResol()

conditionsDatabase.demo.drifttubeMonitoring.mergeHistosForMomResol (   withFitPoints = False)

Definition at line 3972 of file drifttubeMonitoring.py.

3972def mergeHistosForMomResol(withFitPoints=False):
3973 # 1GeV mbias, 1.8 Billion PoT
3974 # 1GeV charm, 10.2 Billion PoT, 10 files
3975 # 10GeV MC, 65 Billion PoT
3976 # 10GeV charm 153.3 Billion PoT
3977 versions = ['-repro',"-0"] # ","-multHits" -noDeadChannels -withDeadChannels"
3978 MCStats = 1.806E9
3979 MC10Stats = 66.02E9
3980 sim10fact = MCStats/(MC10Stats) # normalize 10GeV to 1GeV stats
3981 charmNorm = {1:MCStats/10.21E9,10:MC10Stats/153.90E9}
3982 beautyNorm = {1:0., 10:0.01218}
3983 sources = {"":1.,"Hadronic inelastic":100.,"Lepton pair":100.,"Positron annihilation":100.,
3984 "charm":1./charmNorm[10],"beauty":1./beautyNorm[10],"Di-muon P8":100.,"invalid":1.}
3985 if len(hMC)==0:
3986 interestingHistos = []
3987 for a in ['trueMom','recoMom','momResol','curvResol','Fitpoints_u1','Fitpoints_v2','Fitpoints_x1','Fitpoints_x2','Fitpoints_x3','Fitpoints_x4']:
3988 for source in sources: interestingHistos.append(a+source)
3989 for v in versions:
3990 h[v]={'1GeV':{},'1GeVCharm':{},'10GeV':{}}
3991 if v.find('repro')<0:
3992 ut.readHists(h[v]['1GeV'], 'momDistributions-1GeV-mbias'+v+'.root',interestingHistos)
3993 ut.readHists(h[v]['1GeVCharm'], 'momDistributions-1GeV-charm'+v+'.root',interestingHistos)
3994 ut.readHists(h[v]['10GeV'], 'momDistributions-10GeV-mbias'+v+'.root',interestingHistos)
3995 else:
3996 ut.readHists(h[v]['1GeV'], 'sumHistos--simulation1GeV'+v+'.root',interestingHistos)
3997 ut.readHists(h[v]['1GeVCharm'], 'sumHistos--simulation1GeV'+v+'-charm.root',interestingHistos)
3998 ut.readHists(h[v]['10GeV'], 'sumHistos--simulation10GeV'+v+'.root',interestingHistos)
3999 for res in versions:
4000 for a in ['trueMom','recoMom','Fitpoints_u1','Fitpoints_v2','Fitpoints_x1','Fitpoints_x2','Fitpoints_x3','Fitpoints_x4']:
4001 if a.find('Fit')==0 and not withFitPoints: continue
4002 h['MC'+res+a] = h[res]['1GeV'][a].Clone('MC'+res+a)
4003 h['MC'+res+a].Add(h[res]['1GeVCharm'][a],charmNorm[1])
4004 h['MC10'+res+a] = h[res]['10GeV'][a].Clone('MC10'+res+a)
4005# special treatment for 10GeV to get weights right
4006 h['MC10'+res+a].Add(h[res]['10GeV'][a+"charm"],-1.+charmNorm[10])
4007 h['MC10'+res+a].Add(h[res]['10GeV'][a+"beauty"],-1.+beautyNorm[10])
4008 h['MC10'+res+a].Scale(sim10fact)
4009 # 2d histos, only for resolution plot, don't care about mom distribution'
4010 h["momResol"+res] = h[res]['1GeV']["momResol"].Clone()
4011 h["momResol"+res].Add(h[res]['1GeVCharm']["momResol"])
4012 h["momResol"+res].Add(h[res]['10GeV']["momResol"])
4013 # use 1 GeV below 20GeV and 10 GeV above
4014 for a in ['trueMom','recoMom']:
4015 h[res+a]=h["MC10"+res+a].Clone()
4016 for n in range(h[a].GetNbinsX()):
4017 if h[res+a].GetBinCenter(n)<20. :
4018 h[res+a].SetBinContent(n,h["MC"+res+a].GetBinContent(n))
4019 h[res+'trueMom'].SetLineColor(ROOT.kGreen)
4020 ut.makeIntegralDistrib(h,res+'trueMom')
4021 ut.makeIntegralDistrib(h,res+'recoMom')
4022 h['I-'+res+'trueMom'].SetTitle(' ;x [GeV/c]; #SigmaN/PoT with P>x')
4023 h['I-'+res+'trueMom'].Scale(1./MCStats)
4024 h['I-'+res+'recoMom'].Scale(1./MCStats)
4025 h['I-'+res+'trueMom'].SetMinimum(5E-11)
4026 h['I-'+res+'trueMom'].SetStats(0)
4027 h['I-'+res+'trueMom'].GetXaxis().SetRangeUser(5.,500.)
4028# true mom, reco mom
4029 t = "true Mom"
4030 if not h.has_key(t): ut.bookCanvas(h,t,'true and reco momentum',900,600,1,1)
4031 tc=h[t].cd(1)
4032 tc.SetLogy()
4033 v = '-repro'
4034#
4035 h['I--0trueMom'].Draw()
4036 h['I--0recoMom'].Draw('same')
4037 h['I-'+v+'recoMom'].SetLineColor(ROOT.kMagenta)
4038 h['I-'+v+'recoMom'].Draw('same')
4039 h['leg'+t]=ROOT.TLegend(0.31,0.67,0.85,0.85)
4040 h['leg'+t].AddEntry(h['I--0trueMom'],'true momentum ','PL')
4041 h['leg'+t].AddEntry(h['I--0recoMom'],'reconstructed momentum 270#mum','PL')
4042 h['leg'+t].AddEntry(h['I-'+v+'recoMom'],'reconstructed momentum 350#mum','PL')
4043 h['leg'+t].Draw()
4044 myPrint(h[t],'True-Reco')
4045#
4046 fSqrt = ROOT.TF1('momResol','sqrt([0]**2+x**2*[1]**2)',2)
4047 fSqrt.SetParName(0,'constant')
4048 fSqrt.SetParName(1,'linear')
4049 t = 'momResolution'
4050 if not h.has_key(t): ut.bookCanvas(h,t,'momentum Resolution',900,600,1,1)
4051 tc=h[t].cd(1)
4052 for res in ['-0',v]:
4053 hname = 'momResol'+res
4054 h[hname+'P'] = h[hname].ProjectionY(hname+'P')
4055 h[hname+'P'].Reset()
4056 h[hname+'Perr']=h[hname+'P'].Clone(hname+'Perr')
4057 for n in range(1,h[hname+'P'].GetNbinsX()+1):
4058 h[hname+str(n)] = h[hname].ProjectionX(hname+str(n),n,n)
4059 if h[hname+str(n)].GetEntries()<50: continue
4060 if n>10: h[hname+str(n)].Rebin(5)
4061 fitFunction = h[hname+str(n)].GetFunction('gauss')
4062 if not fitFunction: fitFunction = myGauss
4063 fitFunction.SetParameter(0,h[hname+str(n)].GetMaximum()*0.02)
4064 fitFunction.SetParameter(1,0.)
4065 fitFunction.SetParameter(2,0.01)
4066 fitFunction.FixParameter(3,0.)
4067 fitResult = h[hname+str(n)].Fit(fitFunction,'SQ','',-1.,1.)
4068 rc = fitResult.Get()
4069 if not rc: continue
4070 mean = rc.GetParams()[1]
4071 rms = rc.GetParams()[2]
4072 print n,mean,rms
4073 h[hname+'Perr'].SetBinContent(n,mean)
4074 h[hname+'Perr'].SetBinError(n,abs(rms))
4075 h[hname+'P'].SetBinContent(n,abs(rms))
4076 h[hname+'P'].Fit('pol1','QW','',0.,300.)
4077 fitFun = h[hname+'P'].GetFunction('pol1')
4078 fSqrt.SetParameter(0,fitFun.GetParameter(0))
4079 fSqrt.SetParameter(1,fitFun.GetParameter(1))
4080 h[hname+'P'].Fit(fSqrt,'QW','',0.,300.)
4081 h['leg'+t]=ROOT.TLegend(0.14,0.75,0.64,0.87)
4082 for res in ['-0',v]:
4083 hname = 'momResol'+res
4084 h[hname+'P'].SetTitle('momentum resolution function of momentum;#it{p} [GeV/c];#sigma_{#it{p}} / #it{p}')
4085 h[hname+'P'].SetStats(0)
4086 h[hname+'P'].SetMaximum(0.15)
4087 fSqrt = h[hname+'P'].GetFunction('momResol')
4088 p0 = "%4.3F"%(100*fSqrt.GetParameter(0))
4089 p1 = "%4.3F"%(100*fSqrt.GetParameter(1))
4090 if res != '-0':
4091 h['text'+res] = ROOT.TLatex(21.,0.073,'#sigma_{#it{p}}/#it{p} = ('+p0+' #oplus '+p1+'#times#it{p})%')
4092 h[hname+'P'].Draw('same')
4093 h[hname+'P'].SetLineColor(ROOT.kMagenta)
4094 h['text'+res].SetTextColor(ROOT.kMagenta)
4095 h['leg'+t].AddEntry(h[hname+'P'],'adjusted 350#mum','PL')
4096 else:
4097 h['text'+res] = ROOT.TLatex(120.,0.01,'#sigma_{#it{p}}/#it{p} = ('+p0+' #oplus '+p1+'#times#it{p})%')
4098 h['text'+res].SetTextColor(ROOT.kBlue)
4099 h[hname+'P'].GetXaxis().SetRangeUser(0.,330)
4100 h[hname+'P'].SetMaximum(max(h[hname+'P'].GetMaximum(),h['momResol-0P'].GetMaximum()))
4101 h[hname+'P'].Draw()
4102 h['leg'+t].AddEntry(h[hname+'P'],'default 270#mum ','PL')
4103 h['text'+res].Draw('same')
4104 h['leg'+t].Draw()
4105 myPrint(h[t],'momentumResolution')
4106

◆ methodD()

conditionsDatabase.demo.drifttubeMonitoring.methodD ( )

Definition at line 2719 of file drifttubeMonitoring.py.

2719def methodD():
2720 for s in range(1,5):
2721 for view in ['_x','_u','_v']:
2722 for l in range(4):
2723 if view=='_u' and s!=1: continue
2724 if view=='_v' and s!=2: continue
2725 ut.bookHist(h,'used-'+str(s)+view+str(l),'channel used in fit',200,-0.5,199.5)
2726 ut.bookHist(h,'w-'+str(s)+view+str(l),'sum of weight',100,0.,2.)
2727 for n in range(sTree.GetEntries()):
2728 rc = sTree.GetEvent(n)
2729 nTrack = -1
2730 for aTrack in sTree.FitTracks:
2731 nTrack+=1
2732 fitStatus = aTrack.getFitStatus()
2733 if not fitStatus.isFitConverged(): continue
2734 pMom0 = aTrack.getFittedState(0).getMomMag()
2735 if pMom0 < 1.: continue
2736 trInfo = sTree.TrackInfos[nTrack]
2737 h['used-1_x0'].Fill(199)
2738 for n in range(trInfo.N()):
2739 detID = trInfo.detId(n)
2740 hit = ROOT.MufluxSpectrometerHit(detID,0)
2741 s,v,p,l,view,channelID,tdcId,mdoduleId = stationInfo(hit)
2742 w = trInfo.wL(n) + trInfo.wR(n)
2743 h['used-'+str(s)+view+str(2*p+l)].Fill(channelID)
2744 h['w-'+str(s)+view+str(2*p+l)].Fill(w)
2745 h['w']=h['w-1_x1'].Clone('w')
2746 h['w'].Reset()
2747 for s in range(1,5):
2748 for view in ['_x','_u','_v']:
2749 for l in range(4):
2750 if view=='_u' and s!=1: continue
2751 if view=='_v' and s!=2: continue
2752 N = h['used-'+str(s)+view+str(l)].GetEntries()
2753 if s==1 and view=='_x' and l==0: N = N - h['used-1_x0'].GetBinContent(200)
2754 rc = h['w'].Add(h['w-'+str(s)+view+str(l)])
2755 print s,view,l,N/h['used-1_x0'].GetBinContent(200)
2756

◆ minbias()

conditionsDatabase.demo.drifttubeMonitoring.minbias ( )

Definition at line 1539 of file drifttubeMonitoring.py.

1539def minbias():
1540# onurs files, ~18 M POT
1541 #f=ROOT.TFile.Open(os.environ['EOSSHIP']+'/eos/experiment/ship/user/truf/muflux-sim/ship.conical.FixedTarget-TGeant4_merged_dig.root')
1542 ut.bookHist(h,'mom','momentum',400,0.,400.)
1543 N=-1
1544 for event in sTree:
1545 N+=1
1546 n=-1
1547 for track in event.FitTracks:
1548 n+=1
1549 info = event.TrackInfos[n]
1550 mcID = info.McTrack()
1551 if mcID<0: continue
1552 pid = event.MCTrack[mcID].GetPdgCode()
1553 hname = 'mom'+str(pid)
1554 if not h.has_key(hname): h[hname]=h['mom'].Clone(hname)
1555 sta = track.getFittedState(0)
1556 mu=False
1557 if abs(pid)!=13: mu = check4muon(event.MCTrack[mcID],True)
1558 if not mu: rc = h[hname].Fill(sta.getMomMag())
1559 if abs(pid)!=13:
1560 print N,pid, event.MCTrack[mcID].GetStartZ(),event.MCTrack[event.MCTrack[mcID].GetMotherId()].GetPdgCode(),mu
1561 #sTree.MCTrack.Dump()
1562 h['stats']={}
1563 h['stats10']={}
1564 for x in h:
1565 if len(x)<4 or x.find('mom')!=0 or not x.find('momRes')<0: continue
1566 pid = int(x.replace('mom',''))
1567 pname = PDG.GetParticle(pid).GetName()
1568 h['stats'][pname]=h[x].GetEntries()
1569 h['stats10'][pname]=h[x].GetEntries() - h[x].Integral(0,h['mom'].FindBin(10.))
1570 sorted_pnames = sorted(h['stats'].items(), key=operator.itemgetter(1))
1571 for p in sorted_pnames:
1572 print "%7s : %5.2F / 1M PoT"%(p[0],p[1]/18.)
1573 print "with P>10GeV"
1574 sorted_pnames = sorted(h['stats10'].items(), key=operator.itemgetter(1))
1575 for p in sorted_pnames:
1576 print "%7s : %5.2F / 1M PoT"%(p[0],p[1]/18.)
1577
1578

◆ momDisplay()

conditionsDatabase.demo.drifttubeMonitoring.momDisplay ( )

Definition at line 1967 of file drifttubeMonitoring.py.

1967def momDisplay():
1968 ROOT.gStyle.SetPalette(ROOT.kGreenPink)
1969 for x in ['','mu']:
1970 t = 'mom'+x
1971 if not h.has_key(t): ut.bookCanvas(h,key=t,title='trackfit'+x,nx=1200,ny=600,cx=4,cy=2)
1972 rc = h[t].cd(1)
1973 h['p/pt'+x].SetStats(0)
1974 rc = h['p/pt'+x].Draw('colz')
1975 rc = h[t].cd(2)
1976 rc.SetLogy(1)
1977 h['p/pt'+x+'_x']=h['p/pt'+x].ProjectionX()
1978 h['p/pt'+x+'_x'].SetName('p/pt'+x+'_x')
1979 h['p/pt'+x+'_x'].SetTitle('#it{p}[GeV/c]')
1980 h['p/pt'+x+'_x'].Draw()
1981 rc = h[t].cd(3)
1982 h['p/pt'+x+'_y']=h['p/pt'+x].ProjectionY()
1983 h['p/pt'+x+'_y'].SetName('p/pt'+x+'_y')
1984 h['p/pt'+x+'_y'].SetTitle('#it{p}_{T} [GeV/c]')
1985 h['p/pt'+x+'_y'].Draw()
1986 h[t].Update()
1987 stats = h['p/pt'+x+'_x'].FindObject('stats')
1988 stats.SetOptStat(11111111)
1989 rc = h[t].cd(4)
1990 h['chi2'+x].Draw()
1991 rc = h[t].cd(5)
1992 h['Nmeasurements'+x].Draw()
1993 rc = h[t].cd(6)
1994 h['xy'+x].Draw('colz')
1995 rc = h[t].cd(7)
1996 h['pxpy'+x].Draw('colz')
1997 rc = h[t].cd(8)
1998 if x=='' and h['TDC2R'].GetEntries()>0:
1999 h['TDC2R_projx'] = h['TDC2R'].ProjectionY()
2000 h['TDC2R_projx'].SetTitle('RT Relation r projection')
2001 h['TDC2R_projx'].SetXTitle('drift distance [cm]')
2002 h['TDC2R_projx'].Draw()
2003 else:
2004 h['px'+x]=h['p/pt'+x].ProjectionX()
2005 h['px'+x].SetName('px'+x)
2006 h['px'+x].SetTitle('#it{p} [GeV/c]')
2007 h['px'+x].Draw()
2008 h[t].Update()
2009

◆ monitorMasterTrigger()

conditionsDatabase.demo.drifttubeMonitoring.monitorMasterTrigger ( )

Definition at line 5402 of file drifttubeMonitoring.py.

5402def monitorMasterTrigger():
5403 ut.bookHist(h,'masterTrigger','t of master trigger',1000,200.,400.)
5404 ut.bookHist(h,'delay','delay time',1000,-2000.,2000.)
5405 ut.bookHist(h,'tdcCor','corrected TDC time',1000,-2000.,3000.)
5406 ut.bookHist(h,'tdc', 'TDC time from hit', 1000,-2000.,3000.)
5407 ut.bookHist(h,'tdc#4','TDC 4', 1000,-2000.,10000.)
5408 for n in range(sTree.GetEntries()):
5409 rc=sTree.GetEvent(n)
5410 for mt in sTree.Digi_MasterTrigger:
5411 rc = h['masterTrigger'].Fill(mt.GetDigi())
5412 if sTree.Digi_MasterTrigger.GetEntries()==0:
5413 rc = h['masterTrigger'].Fill(201.)
5414 else:
5415 tdcDict = {}
5416 for k in range(sTree.Digi_Triggers.GetEntries()):
5417 hit = sTree.Digi_Triggers[k]
5418 if tdcDict.has_key(k):
5419 print "Error, double trigger TDC ID",k
5420 if not hit.GetDigi()<tdcDict[k]: continue
5421 tdcDict[hit.GetTDC()]=hit.GetDigi()
5422 if not tdcDict.has_key(4):
5423 h['masterTrigger'].Fill(210+4)
5424 continue
5425 else: rc = h['tdc#4'].Fill(tdcDict[4])
5426 delay = sTree.Digi_MasterTrigger[0].GetDigi() - tdcDict[4]
5427 rc = h['delay'].Fill(delay)
5428 for hit in sTree.Digi_MufluxSpectrometerHits:
5429 detID=hit.GetDetectorID()
5430 if detID<0: continue # feature for converted data in February'19
5431 rc = h['tdc'].Fill(hit.GetDigi())
5432 if not hit.hasDelay():
5433 tdcID = hit.GetTDC()
5434 if not tdcDict.has_key(tdcID):
5435 h['masterTrigger'].Fill(210+tdcID*10)
5436 if hit.hasTrigger() : print "this should not happen, no trigger but hasTrigger",n
5437 continue
5438 if not hit.hasTrigger() : print "this should not happen, trigger but hasTrigger false",n
5439 lt = tdcDict[tdcID]
5440 tdcCor = hit.GetDigi() - delay - lt - 1323.0 # default value used to make the correction during conversion
5441 rc = h['tdcCor'].Fill(tdcCor)
5442

◆ muonOrigin()

conditionsDatabase.demo.drifttubeMonitoring.muonOrigin ( )

Definition at line 5465 of file drifttubeMonitoring.py.

5465def muonOrigin():
5466 muonO= {}
5467 muonO2 = {}
5468 doubleProc = [0,0,0]
5469 N = sTree.GetEntries()
5470 for n in range(N):
5471 rc=sTree.GetEvent(n)
5472 # if sTree.FitTracks.GetEntries()==0: continue
5473 muP = 0
5474 processed = []
5475 for hit in sTree.MufluxSpectrometerPoint:
5476 i=hit.GetTrackID()
5477 if i<0: continue
5478 if i in processed: continue
5479 processed.append(i)
5480 t=sTree.MCTrack[i]
5481 if abs(t.GetPdgCode())!=13: continue
5482 moID = abs(sTree.MCTrack[t.GetMotherId()].GetPdgCode())
5483 pName = t.GetProcName().Data()
5484 if muP!=0:
5485 if pName!=muP:
5486 # print "two muons, two processes",n,muP,pName
5487 doubleProc[1] +=1
5488 else:
5489 muP = pName
5490 if not muonO.has_key(pName):
5491 muonO[pName]=0
5492 muonO2[pName]={}
5493 if not muonO2[pName].has_key(moID): muonO2[pName][moID]=0
5494 muonO[pName]+=1
5495 muonO2[pName][moID]+=1
5496 if len(processed)>0: doubleProc[0] +=1
5497 sorted_o = sorted(muonO.items(), key=operator.itemgetter(1))
5498 for p in sorted_o:
5499 print "%30s %5.2F %%"%(p[0],p[1]/float(doubleProc[0])*100.)
5500 for p in ['Primary particle emission', 'Decay']:
5501 print "for process ",p
5502 sorted_p = sorted(muonO2[p].items(), key=operator.itemgetter(1))
5503 for x in sorted_p:
5504 part = PDG.GetParticle(x[0])
5505 if not part: particleName = str(x[0])
5506 else: particleName = PDG.GetParticle(x[0]).GetName()
5507 print " %20s %5.2F %%"%(particleName,x[1]/float(doubleProc[0])*100.)
5508 print "double process ",doubleProc
5509 return
5510

◆ muonTaggerClustering()

conditionsDatabase.demo.drifttubeMonitoring.muonTaggerClustering (   PR = 11)

Definition at line 4847 of file drifttubeMonitoring.py.

4847def muonTaggerClustering(PR=11):
4848 hitsPerStation={}
4849 clustersPerStation={}
4850 tracks = {}
4851 if sTree.GetBranch('RPCTrackY') and PR==1:
4852 for view in ['X','Y']:
4853 tracks[view] = []
4854 for aTrack in eval('sTree.RPCTrack'+view):
4855 tracks[view].append([aTrack.m(),aTrack.b()])
4856 return clustersPerStation,tracks
4857 for s in range(1,6):
4858 for l in range(2):
4859 hitsPerStation[10*s+l]=[]
4860 clustersPerStation[10*s+l]=[]
4861 for m in sTree.Digi_MuonTaggerHits:
4862 if m.GetDetectorID() in deadChannelsRPC4MC: continue
4863 layer = m.GetDetectorID()/1000
4864 channel = m.GetDetectorID()%1000
4865 hitsPerStation[layer].append(channel)
4866 for l in range(2):
4867 for s in range(1,6):
4868 L = len(hitsPerStation[10*s+l])
4869 if L<1: continue
4870 temp = dict(enumerate(grouper(hitsPerStation[10*s+l],cuts['muTaggerCluster_grouping']), 1))
4871 clustersPerStation[10*s+l]={}
4872 for cl in temp:
4873 if len(temp[cl])>cuts['muTaggerCluster_max']: continue
4874 clusCentre = 0
4875 zCentre = 0
4876 for hit in temp[cl]:
4877 vbot,vtop = RPCPositionsBotTop[(10*s+l)*1000+hit]
4878 clusCentre+=vbot[1-l]
4879 zCentre+=(vbot[2]+vtop[2])/2.
4880 clusCentre = clusCentre/float(len(temp[cl]))
4881 zCentre = zCentre/float(len(temp[cl]))
4882 clusCentre = (int(clusCentre*1000) + float(s)/10.)/1000. # encode station number
4883 clustersPerStation[10*s+l][cl]=[temp[cl],clusCentre,zCentre]
4884 if l==0: view = 'Y'
4885 else: view = 'X'
4886 tracks[view] = []
4887 test = []
4888 for s in range(1,6):
4889 for cl in clustersPerStation[10*s+l]:
4890 test.append(clustersPerStation[10*s+l][cl][1])
4891 tmp = dict(enumerate(grouper(test,cuts['muTaggerCluster_sep']), 1))
4892 trackCand = []
4893 for x in tmp:
4894 if len(tmp[x])>2: trackCand.append(tmp[x])
4895 for n in trackCand:
4896 zpositions = []
4897 for coord in n:
4898# find z position
4899 found = False
4900 for s in range(1,6):
4901 if found: break
4902 for cl in clustersPerStation[10*s+l]:
4903 if clustersPerStation[10*s+l][cl][1]==coord:
4904 zpositions.append(clustersPerStation[10*s+l][cl][2])
4905 found = True
4906 break
4907 tmp = list(zpositions)
4908 test = dict(enumerate(grouper(tmp,10.), 1))
4909 if len(test)>2:
4910 coefficients = numpy.polyfit(zpositions,n,1)
4911 tracks[view].append(coefficients)
4912 return clustersPerStation,tracks
4913

◆ myPrint()

conditionsDatabase.demo.drifttubeMonitoring.myPrint (   obj,
  aname 
)

Definition at line 7449 of file drifttubeMonitoring.py.

7449def myPrint(obj,aname):
7450 name = aname.replace('/','')
7451 obj.Update()
7452 obj.Print(name+'.root')
7453 obj.Print(name+'.pdf')
7454 obj.Print(name+'.png')
7455 obj.Print(name+'.eps')

◆ myVertex()

conditionsDatabase.demo.drifttubeMonitoring.myVertex (   t1,
  t2,
  PosDir,
  xproj = False 
)

Definition at line 5156 of file drifttubeMonitoring.py.

5156def myVertex(t1,t2,PosDir,xproj=False):
5157 # closest distance between two tracks
5158 # d = |pq . u x v|/|u x v|
5159 if not xproj:
5160 a = ROOT.TVector3(PosDir[t1][0](0) ,PosDir[t1][0](1) ,PosDir[t1][0](2))
5161 u = ROOT.TVector3(PosDir[t1][1](0) ,PosDir[t1][1](1) ,PosDir[t1][1](2))
5162 c = ROOT.TVector3(PosDir[t2][0](0) ,PosDir[t2][0](1) ,PosDir[t2][0](2))
5163 v = ROOT.TVector3(PosDir[t2][1](0) ,PosDir[t2][1](1) ,PosDir[t2][1](2))
5164 else:
5165 a = ROOT.TVector3(PosDir[t1][0](0) ,0, PosDir[t1][0](2))
5166 u = ROOT.TVector3(PosDir[t1][1](0), 0, PosDir[t1][1](2))
5167 c = ROOT.TVector3(PosDir[t2][0](0) ,0, PosDir[t2][0](2))
5168 v = ROOT.TVector3(PosDir[t2][1](0), 0, PosDir[t2][1](2))
5169
5170 pq = a-c
5171 uCrossv = u.Cross(v)
5172 dist = pq.Dot(uCrossv)/(uCrossv.Mag()+1E-8)
5173 # u.a - u.c + s*|u|**2 - u.v*t = 0
5174 # v.a - v.c + s*v.u - t*|v|**2 = 0
5175 E = u.Dot(a) - u.Dot(c)
5176 F = v.Dot(a) - v.Dot(c)
5177 A,B = u.Mag2(), -u.Dot(v)
5178 C,D = u.Dot(v), -v.Mag2()
5179 t = -(C*E-A*F)/(B*C-A*D)
5180 X = c.x()+v.x()*t
5181 Y = c.y()+v.y()*t
5182 Z = c.z()+v.z()*t
5183 return X,Y,Z,abs(dist)
5184

◆ nicePrintout()

conditionsDatabase.demo.drifttubeMonitoring.nicePrintout (   hits)

Definition at line 1129 of file drifttubeMonitoring.py.

1129def nicePrintout(hits):
1130 t0 = 0
1131 if MCdata:
1132 t0 = sTree.ShipEventHeader.GetEventTime()
1133 print "station layer channels (tdc MCTrackID) ..."
1134 else : print "station layer channels (tdc time-over-threshold) ..."
1135 lateText = []
1136 keysToDThits=MakeKeysToDThits(cuts['lateArrivalsToT'])
1137 for s in range(1,5):
1138 for v in [0,1,2]:
1139 if v==2 and s!=2:continue
1140 if v==1 and s!=1:continue
1141 for l in range(4):
1142 txt = str(s) + ' '+viewC[v]+' '+str(l)+' : '
1143 tdc = ''
1144 for hit in hits[v][s][l]:
1145 statnb,vnb,pnb,lnb,view,channelID,tdcId,nRT = stationInfo(hit)
1146 txt+=str(channelID)+' '
1147 if MCdata:
1148 detID = hit.GetDetectorID()
1149 MCTrackID = sTree.MufluxSpectrometerPoint[keysToDThits[detID][0]].GetTrackID()
1150 tdc+="%5.0F %5i "%(hit.GetDigi()-t0,MCTrackID)
1151 else:
1152 tdc+="%5.0F %5.0F "%(hit.GetDigi()-t0,hit.GetTimeOverThreshold())
1153 lateArrivals = len(keysToDThits[hit.GetDetectorID()])
1154 if lateArrivals>1 and not MCdata:
1155 tmp = str(s) + ' '+viewC[v]+' '+str(l)+' : '+str(channelID)+' '
1156 for n in range(1,len(keysToDThits[hit.GetDetectorID()])):
1157 key = keysToDThits[hit.GetDetectorID()][n]
1158 lHit = sTree.Digi_LateMufluxSpectrometerHits[key]
1159 tmp+="%5.0F %5.0F "%(lHit.GetDigi()-t0,lHit.GetTimeOverThreshold())
1160 lateText.append(tmp)
1161 print "%-20s %s"%(txt,tdc)
1162 print "---- channels with late hits",len(lateText)
1163 for txt in lateText: print txt

◆ originMCmuons()

conditionsDatabase.demo.drifttubeMonitoring.originMCmuons ( )

Definition at line 1579 of file drifttubeMonitoring.py.

1579def originMCmuons():
1580 ut.bookHist(h,'origin z/r','origin, z vs r',1000,-600.,600.,100,0.,10.)
1581 ut.bookHist(h,'origin z/r mu','origin of muons, z vs r',1000,-600.,600.,100,0.,10.)
1582 ut.bookHist(h,'origin z/r muJpsi','origin of muons Jpsi, z vs r',1000,-600.,600.,100,0.,10.)
1583 for i in range(sTree.GetEntries()):
1584 rc = sTree.GetEvent(i)
1585 first = True
1586 for m in sTree.MCTrack:
1587 r = ROOT.TMath.Sqrt(m.GetStartX()**2+m.GetStartY()**2)
1588 if first:
1589 first = False
1590 rc = h['origin z/r'].Fill(m.GetStartZ(),r)
1591 if abs(m.GetPdgCode())!=13:continue
1592 rc = h['origin z/r mu'].Fill(m.GetStartZ(),r)
1593 if abs(sTree.MCTrack[m.GetMotherId()].GetPdgCode())!=443:continue
1594 rc = h['origin z/r muJpsi'].Fill(m.GetStartZ(),r)

◆ overlap()

conditionsDatabase.demo.drifttubeMonitoring.overlap (   a,
  b 
)

Definition at line 2667 of file drifttubeMonitoring.py.

2667def overlap(a,b):
2668 return [x for x in a if x in b]
2669

◆ plot2dResiduals()

conditionsDatabase.demo.drifttubeMonitoring.plot2dResiduals (   minEntries = -1)

Definition at line 3280 of file drifttubeMonitoring.py.

3280def plot2dResiduals(minEntries=-1):
3281 if not h.has_key('biasedResiduals2dX'):
3282 ut.bookCanvas(h,key='biasedResiduals2dX',title='biasedResiduals function of X',nx=1600,ny=1200,cx=4,cy=6)
3283 ut.bookCanvas(h,key='biasedResiduals2dY',title='biasedResiduals function of Y',nx=1600,ny=1200,cx=4,cy=6)
3284 j=1
3285 for s in range(1,5):
3286 for view in ['_x','_u','_v']:
3287 if s>2 and view != '_x': continue
3288 if s==1 and view == '_v' or s==2 and view == '_u': continue
3289 for l in range(0,4):
3290 hname = 'biasResX_'+str(s)+view+str(l)
3291 if h[hname].GetEntries()<1: continue
3292 print s,view,l,h[hname].GetEntries()
3293 for p in ['X','Y']:
3294 hname = 'biasRes'+p+'_'+str(s)+view+str(l)
3295 rc = h['biasedResiduals2d'+p].cd(j)
3296 if minEntries >0: h[hname].SetMinimum(minEntries)
3297 h[hname].Draw('box')
3298 j+=1
3299

◆ plotBiasedResiduals()

conditionsDatabase.demo.drifttubeMonitoring.plotBiasedResiduals (   nEvent = -1,
  nTot = 1000,
  PR = 11,
  onlyPlotting = False,
  minP = 3. 
)

Definition at line 2871 of file drifttubeMonitoring.py.

2871def plotBiasedResiduals(nEvent=-1,nTot=1000,PR=11,onlyPlotting=False,minP=3.):
2872 timerStats = {'fit':0,'analysis':0,'prepareTrack':0,'extrapTrack':0,'fillRes':0}
2873 if not onlyPlotting:
2874 h['biasResDist'].Reset()
2875 h['biasResDist2'].Reset()
2876 h['biasResDistLR']=h['biasResDist'].Clone('biasResDistLR')
2877 if not h.has_key('hitMapsX'): plotHitMaps()
2878 for s in xLayers:
2879 for p in xLayers[s]:
2880 for l in xLayers[s][p]:
2881 for view in xLayers[s][p][l]:
2882 h[xLayers[s][p][l][view].GetName()].Reset()
2883 hkey = str(s)+view+str(2*p+l)
2884 h['biasResDist_'+hkey].Reset()
2885 h['biasResDistLR_'+hkey]=h['biasResDist_'+hkey].Clone('biasResDistLR_'+hkey)
2886 h['biasResDist2Wire_'+hkey] = h['biasResDist2'].Clone('biasResDist2Wire_'+hkey)
2887 ut.bookHist(h,'distIfNoHit_'+hkey,'shortest distance to wire if no hit',100,0.,5.)
2888 for n in range(576/cuts['RTsegmentation'] ): h['TDC'+str(n)].Reset()
2889#
2890 pos = ROOT.TVector3()
2891 mom = ROOT.TVector3()
2892 eventRange = [0,sTree.GetEntries()]
2893 if not nEvent<0: eventRange = [nEvent,nEvent+nTot]
2894 timerStats = {'fit':0,'analysis':0,'prepareTrack':0,'extrapTrack':0,'fillRes':0}
2895 for Nr in range(eventRange[0],eventRange[1]):
2896 getEvent(Nr)
2897 h['T0tmp'].Reset()
2898 if Nr%10000==0: print "now at event",Nr,' of ',sTree.GetEntries(),sTree.GetCurrentFile().GetName(),time.ctime()
2899 if not findSimpleEvent(sTree): continue
2900 timer.Start()
2901 trackCandidates = findTracks(PR)
2902 timerStats['fit']+=timer.RealTime()
2903 if len(trackCandidates)==1:
2904 timer.Start()
2905 spectrHitsSorted = ROOT.nestedList()
2906 muflux_Reco.sortHits(sTree.Digi_MufluxSpectrometerHits,spectrHitsSorted,True)
2907 for aTrack in trackCandidates:
2908 fst = aTrack.getFitStatus()
2909 if not fst.isFitConverged(): continue
2910 try:
2911 sta = aTrack.getFittedState(0)
2912 except:
2913 print "problem with getting state, event",sTree.GetCurrentFile().GetName(),Nr
2914 continue
2915 if sta.getMomMag() < minP and not zeroField: continue
2916# check for muon tag to remove ghost tracks
2917 muonTag = False
2918 RPCclusters, RPCtracks = muonTaggerClustering(PR=11)
2919 if len(RPCtracks['X'])==1 and len(RPCtracks['Y'])==1:
2920 posRPC = ROOT.TVector3()
2921 momRPC = ROOT.TVector3()
2922 rc = muflux_Reco.extrapolateToPlane(aTrack,cuts["zRPC1"], posRPC, momRPC)
2923 Xpos = RPCtracks['X'][0][0]*cuts["zRPC1"]+RPCtracks['X'][0][1]
2924 distX = ROOT.TMath.Abs(posRPC[0]-Xpos)
2925 Ypos = RPCtracks['Y'][0][0]*cuts["zRPC1"]+RPCtracks['Y'][0][1]
2926 distY = ROOT.TMath.Abs(posRPC[1]-Ypos)
2927 if abs(distX)<cuts['muTrackMatchX'] and abs(distY)<cuts['muTrackMatchY']: muonTag = True
2928 if not muonTag: continue
2929# check for hits in each station
2930 stations={1:0,2:0,3:0,4:0}
2931 for p in aTrack.getPoints():
2932 rawM = p.getRawMeasurement()
2933 s = rawM.getDetId()/10000000
2934 if s < 1 or s > 4:
2935 print "error with rawM", rawM.getDetId()
2936 stations[s]+=1
2937 if not (stations[1]>1 and stations[2]>1 and stations[3]>1 and stations[4]>1) : continue
2938 rc = h['biasResTrackMom'].Fill(sta.getMomMag())
2939 timerStats['prepareTrack']+=timer.RealTime()
2940 timer.Start()
2941 for s in range(1,5):
2942 for view in viewsI[s]:
2943 for l in range(4):
2944 hitFound = False
2945 for hit in spectrHitsSorted[view][s][l]:
2946 ss,vv,pp,ll,vw,channelID,tdcId,nRT = stationInfo(hit)
2947 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
2948 z = (vbot[2]+vtop[2])/2.
2949 timer.Start()
2950 # rc,pos,mom = extrapolateToPlane(aTrack,z)
2951 trackLength = muflux_Reco.extrapolateToPlane(aTrack,z,pos,mom)
2952 timerStats['extrapTrack']+=timer.RealTime()
2953 timer.Start()
2954 if not rc:
2955 error = "plotBiasedResiduals: extrapolation failed"
2956 ut.reportError(error)
2957 continue
2958 distance = 0
2959 if withTDC or MCdata:
2960 distance = RT(hit,hit.GetDigi())
2961 #d = (vbot[0] - vtop[0])*pos[1] - (vbot[1] - vtop[1])*pos[0] + vtop[0]*vbot[1] - vbot[0]*vtop[1]
2962 #d = -d/ROOT.TMath.Sqrt( (vtop[0]-vbot[0])**2+(vtop[1]-vbot[1])**2) # to have same sign as difference in X
2963 normal = mom.Cross(vtop-vbot)
2964 d = normal.Dot(pos-vbot)/normal.Mag()
2965 res = abs(d) - distance
2966 h['biasResDist'].Fill(distance,res)
2967 h['biasResDist2'].Fill(abs(d),res)
2968 if abs(res) < 0.2: hitFound = True
2969 hkey = str(ss)+vw+str(2*pp+ll)
2970 h['biasResDist2Wire_'+hkey].Fill(abs(d),res)
2971 h['biasResDist_'+hkey].Fill(distance,res)
2972 m = (vtop[0]-vbot[0])/(vtop[1]-vbot[1])
2973 b = vtop[0]-m*vtop[1]
2974 if pos[0]<m*pos[1]+b:
2975 # left of wire
2976 d = -abs(d)
2977 resR = d - distance
2978 resL = d + distance
2979 h['biasResDistLR'].Fill(distance,resR)
2980 h['biasResDistLR'].Fill(distance,resL)
2981 h['biasResDistLR_'+hkey].Fill(distance,resR)
2982 h['biasResDistLR_'+hkey].Fill(distance,resL)
2983 h['biasResXLA_'+hkey].Fill(res,pos[0])
2984 h['biasResYLA_'+hkey].Fill(res,pos[1])
2985 h['biasResX_'+hkey].Fill(resR,pos[0])
2986 h['biasResY_'+hkey].Fill(resR,pos[1])
2987 h['biasResXL_'+hkey].Fill(resR,pos[0])
2988 h['biasResYL_'+hkey].Fill(resR,pos[1])
2989 h['biasResX_'+hkey].Fill(resL,pos[0])
2990 h['biasResY_'+hkey].Fill(resL,pos[1])
2991 h['biasResXL_'+hkey].Fill(resL,pos[0])
2992 h['biasResYL_'+hkey].Fill(resL,pos[1])
2993# now for each tube
2994 detID = str(hit.GetDetectorID())
2995 h['biasResX_'+detID].Fill(resR,pos[0])
2996 h['biasResY_'+detID].Fill(resR,pos[1])
2997 h['biasResXL_'+detID].Fill(resR,pos[0])
2998 h['biasResYL_'+detID].Fill(resR,pos[1])
2999 h['biasResX_'+detID].Fill(resL,pos[0])
3000 h['biasResY_'+detID].Fill(resL,pos[1])
3001 h['biasResXL_'+detID].Fill(resL,pos[0])
3002 h['biasResYL_'+detID].Fill(resL,pos[1])
3003# make hit and TDC plots for hits matched to tracks, within window suitable for not using TDC
3004 if abs(res) < 4. :
3005 t0 = 0
3006 if MCdata: t0 = sTree.ShipEventHeader.GetEventTime()
3007 rc = h['TDC'+str(nRT)].Fill(hit.GetDigi()-t0)
3008 rc = xLayers[ss][pp][ll][vw].Fill( channelID )
3009 rc = h['T0tmp'].Fill(hit.GetDigi()-t0)
3010 if not hitFound:
3011# fill histogram with closest distance to a wire, find z position of present station s layer l
3012 v = 0
3013 if (s==1 and view==1) or (s==2 and view==0): v=1000000
3014 firstWire = s*10000000+v+2000+(l%2)*10000+(l/2)*100000+1
3015 vbot,vtop = strawPositionsBotTop[firstWire]
3016 z = (vbot[2]+vtop[2])/2.
3017 trackLength = muflux_Reco.extrapolateToPlane(aTrack,z,pos,mom)
3018 minDist = 10000.
3019 for n in range(Nchannels[s]):
3020 vbot,vtop = strawPositionsBotTop[firstWire+n]
3021 normal = mom.Cross(vtop-vbot)
3022 d = normal.Dot(pos-vbot)/normal.Mag()
3023 if abs(d)<minDist: minDist=abs(d)
3024 h['distIfNoHit_'+hkey].Fill(minDist)
3025 t0 = h['T0tmp'].GetMean()
3026 rc = h['T0'].Fill(t0)
3027 timerStats['fillRes']+=timer.RealTime()
3028 timer.Start()
3029 timerStats['analysis']+=timer.RealTime()
3030 for aTrack in trackCandidates: aTrack.Delete()
3031 if not h.has_key('biasedResiduals'):
3032 ut.bookCanvas(h,key='biasedResiduals',title='biasedResiduals',nx=1600,ny=1200,cx=4,cy=6)
3033 ut.bookCanvas(h,key='biasedResidualsX',title='biasedResiduals function of X',nx=1600,ny=1200,cx=4,cy=6)
3034 ut.bookCanvas(h,key='biasedResidualsY',title='biasedResiduals function of Y',nx=1600,ny=1200,cx=4,cy=6)
3035 j=1
3036 for s in range(1,5):
3037 for view in ['_x','_u','_v']:
3038 if s>2 and view != '_x': continue
3039 if s==1 and view == '_v' or s==2 and view == '_u': continue
3040 for l in range(0,4):
3041 if withTDC: hname = 'biasResX_'+str(s)+view+str(l)
3042 else: hname = 'biasResXL_'+str(s)+view+str(l)
3043 hnameProjX = 'biasRes_'+str(s)+view+str(l)
3044 h[hnameProjX] = h[hname].ProjectionX()
3045 tc = h['biasedResiduals'].cd(j)
3046 if h[hname].GetEntries()<10:
3047 h[hnameProjX].Draw()
3048 j+=1
3049 continue
3050 fitResult = h[hnameProjX].Fit('gaus','SQ','',-0.5,0.5)
3051 rc = fitResult.Get()
3052 fitFunction = h[hnameProjX].GetFunction('gauss')
3053 if not fitFunction : fitFunction = myGauss
3054 if not rc:
3055 print "simple gaus fit failed"
3056 fitFunction.SetParameter(0,h[hnameProjX].GetEntries()*h[hnameProjX].GetBinWidth(1))
3057 fitFunction.SetParameter(1,0.)
3058 fitFunction.SetParameter(2,0.1)
3059 fitFunction.SetParameter(3,1.)
3060 else:
3061 fitFunction.SetParameter(0,rc.GetParams()[0]*ROOT.TMath.Sqrt(2*ROOT.TMath.Pi())*rc.GetParams()[2])
3062 fitFunction.SetParameter(1,rc.GetParams()[1])
3063 fitFunction.SetParameter(2,rc.GetParams()[2])
3064 fitFunction.SetParameter(3,0.)
3065 fitResult = h[hnameProjX].Fit(fitFunction,'SQ','',-0.2,0.2)
3066 fitResult = h[hnameProjX].Fit(fitFunction,'SQ','',-0.5,0.5)
3067 rc = fitResult.Get()
3068 if not rc:
3069 print hnameProjX
3070 h[hnameProjX].Draw()
3071 j+=1
3072 continue
3073 tc.Update()
3074 stats = h[hnameProjX].FindObject("stats")
3075 stats.SetX1NDC(0.563258)
3076 stats.SetY1NDC(0.526687)
3077 stats.SetX2NDC(0.938728)
3078 stats.SetY2NDC(0.940086)
3079 stats.SetOptFit(111)
3080 stats.SetOptStat(0)
3081 mean = rc.GetParams()[1]
3082 rms = rc.GetParams()[2]
3083 Emean = rc.GetErrors()[1]
3084 Erms = rc.GetErrors()[2]
3085 print "%i, %s, %i mean=%5.2F+/-%5.2F RMS=%5.2F+/-%5.2F [mm]"%(s,view,l,mean*10,Emean*10,rms*10,Erms*10)
3086 residuals[j-1]= h[hnameProjX].GetMean() # fitresult too unstable, mean
3087 # make plot of mean as function of X,Y
3088 for p in ['X','Y']:
3089 if withTDC: hname = 'biasRes'+p+'_'+str(s)+view+str(l)
3090 else: hname = 'biasRes'+p+'L_'+str(s)+view+str(l)
3091 hmean = hname+'_mean'+p
3092 h[hmean] = h[hname].ProjectionY(hname+'_mean')
3093 h[hmean].Reset()
3094 rc = h['biasedResiduals'+p].cd(j)
3095 for k in range(1,h[hname].GetNbinsY()+1):
3096 sli = hname+'_'+str(k)
3097 h[sli] = h[hname].ProjectionX(sli,k,k)
3098 if h[sli].GetEntries()<10: continue
3099 fitResult = h[sli].Fit('gaus','SQ','',-0.5,0.5)
3100 rc = fitResult.Get()
3101 fitFunction = h[sli].GetFunction('gauss')
3102 if not fitFunction : fitFunction = myGauss
3103 if not rc:
3104 print "simple gaus fit failed"
3105 fitFunction.SetParameter(0,h[sli].GetEntries()*h[sli].GetBinWidth(1))
3106 fitFunction.SetParameter(1,0.)
3107 fitFunction.SetParameter(2,0.1)
3108 fitFunction.SetParameter(3,1.)
3109 else:
3110 fitFunction.SetParameter(0,rc.GetParams()[0]*ROOT.TMath.Sqrt(2*ROOT.TMath.Pi())*rc.GetParams()[2])
3111 fitFunction.SetParameter(1,rc.GetParams()[1])
3112 fitFunction.SetParameter(2,rc.GetParams()[2])
3113 fitFunction.SetParameter(3,0.)
3114 fitResult = h[sli].Fit(fitFunction,'SQ','',-0.3,0.3)
3115 rc = fitResult.Get()
3116 mean,rms = 0,0
3117 if rc:
3118 mean = rc.GetParams()[1]
3119 rms = rc.GetParams()[2]
3120 rc = h[hmean].SetBinContent( k, mean)
3121 rc = h[hmean].SetBinError(k, rms)
3122 amin,amax,nmin,nmax = ut.findMaximumAndMinimum(h[hmean])
3123 if amax<3. and amin>-3.:
3124 h[hmean].SetMaximum(0.2)
3125 h[hmean].SetMinimum(-0.2)
3126 else:
3127 h[hmean].SetLineColor(ROOT.kRed)
3128 h[hmean].SetMaximum(0.2)
3129 h[hmean].SetMinimum(-0.2)
3130 h[hmean].Draw()
3131 j+=1
3132 myPrint(h['biasedResiduals'], 'biasedResiduals')
3133 myPrint(h['biasedResidualsX'],'biasedResidualsX')
3134 momDisplay()
3135 print "timing:",timerStats

◆ plotDTPoints()

conditionsDatabase.demo.drifttubeMonitoring.plotDTPoints (   onlyPlotting = False)

Definition at line 5546 of file drifttubeMonitoring.py.

5546def plotDTPoints(onlyPlotting=False):
5547 views = ['_u1','_v2','_x1','_x2','_x3','_x4']
5548 if not onlyPlotting:
5549 for view in views:
5550 ut.bookHist(h,'points'+view,'points'+view,100,0,400,10,-0.5,9.5)
5551 ut.bookHist(h,'Fitpoints'+view,'points'+view,100,0,400,10,-0.5,9.5)
5552 for n in range(sTree.GetEntries()):
5553 rc = sTree.GetEvent(n)
5554 hitsPerTrack = {}
5555 mom = {}
5556 for p in sTree.MufluxSpectrometerPoint:
5557 t = p.GetTrackID()
5558 if not hitsPerTrack.has_key(t):
5559 if abs(p.PdgCode())!=13:continue
5560 P = ROOT.TVector3(p.GetPx(),p.GetPy(),p.GetPz())
5561 if P.Mag() < 10: continue
5562 if abs(p.GetX())>10 or abs(p.GetY())>10 : continue
5563 hitsPerTrack[t] = {'_u1':0,'_v2':0,'_x1':0,'_x2':0,'_x3':0,'_x4':0}
5564 mom[t] = P.Mag()
5565 test = ROOT.MufluxSpectrometerHit(p.GetDetectorID(),0.)
5566 statnb,vnb,pnb,lnb,view,channelID,tdcId,nRT = stationInfo(test)
5567 key = view+str(statnb)
5568 hitsPerTrack[t][key]+=1
5569 for view in views:
5570 for t in hitsPerTrack:
5571 rc = h['points'+view].Fill(mom[t],hitsPerTrack[t][view])
5572 n = 0
5573 for aTrack in sTree.FitTracks:
5574 fst = aTrack.getFitStatus()
5575 if not fst.isFitConverged(): continue
5576 fstate = aTrack.getFittedState(0)
5577 mom = fstate.getMom()
5578 mStatistics = countMeasurements(n,PR=1)
5579 for view in views:
5580 v = view.replace('_','')
5581 if v=='u1': v='u'
5582 if v=='v2': v='v'
5583 rc = h['Fitpoints'+view].Fill(mom.Mag(),len(mStatistics[v]))
5584 ut.writeHists(h,'histos-DTPoints-'+rname)
5585 cases = {'FitPoints':'Fitpoints'}
5586 if MCdata: cases['MC-DTPoints']='points'
5587 for t in cases:
5588 if not h.has_key(t):
5589 ut.bookCanvas(h,key=t,title=t,nx=1200,ny=600,cx=3,cy=2)
5590 ut.bookCanvas(h,key=t+'proj',title=t,nx=1200,ny=600,cx=3,cy=2)
5591 n = 1
5592 for view in views:
5593 mean = 'mean'+cases[t]+view
5594 oneHit234 = 'oneHit234'+cases[t]+view
5595 twoHit34 = 'twoHit34'+cases[t]+view
5596 h[mean] = h[cases[t]+view].ProjectionX().Clone(mean)
5597 h[oneHit234]= h[cases[t]+view].ProjectionX().Clone(oneHit234)
5598 h[twoHit34]= h[cases[t]+view].ProjectionX().Clone(twoHit34)
5599 h[cases[t]+view+'proj']= h[cases[t]+view].ProjectionY().Clone(cases[t]+view+'proj')
5600 h[oneHit234].SetMaximum(-1111)
5601 h[oneHit234].SetMinimum(-1111)
5602 h[twoHit34].SetMaximum(-1111)
5603 h[twoHit34].SetMinimum(-1111)
5604 for k in range(1,h[mean].GetNbinsX()):
5605 test = h[cases[t]+view].ProjectionY('test',k,k)
5606 h[mean].SetBinContent(k,test.GetMean())
5607 h[mean].SetBinError(k,0)
5608 ratio = float(test.GetBinContent(2))/(test.GetBinContent(3)+test.GetBinContent(4)+test.GetBinContent(5)+1E-6)
5609 h[oneHit234].SetBinContent(k,ratio)
5610 h[oneHit234].SetBinError(k,0)
5611 ratio = float(test.GetBinContent(3))/(test.GetBinContent(4)+test.GetBinContent(5)+1E-6)
5612 h[twoHit34].SetBinContent(k,ratio)
5613 h[twoHit34].SetBinError(k,0)
5614 tc = h[t].cd(n)
5615 h[mean].SetMinimum(2.)
5616 h[mean].SetMaximum(4.)
5617 h[mean].Fit('pol1','PL','',50,300)
5618 h[mean].SetStats(0)
5619 h[mean].Draw('hist')
5620 h[mean].GetFunction('pol1').Draw('same')
5621 tc = h[t+'proj'].cd(n)
5622 tc.SetLogy()
5623 h[cases[t]+view+'proj'].GetXaxis().SetRangeUser(-0.5,6.5)
5624 h[cases[t]+view+'proj'].Draw('hist')
5625 n+=1
5626 myPrint(h[t],t+'meanFunP')
5627 myPrint(h[t+'proj'],t+'distribution')

◆ plotEffMethod2Example()

conditionsDatabase.demo.drifttubeMonitoring.plotEffMethod2Example ( )

Definition at line 7261 of file drifttubeMonitoring.py.

7261def plotEffMethod2Example():
7262 efficiencyEstimates(method=2)
7263 ut.bookCanvas(h,'Residualsexample',' ',1200,600,1,1)
7264 h['Residualsexample'].SetLogy(1)
7265 for l in range(0,4):
7266 for z in ['x','u','v']:
7267 for s in range(1,5):
7268 if z=='u' and s!=1: continue
7269 if z=='v' and s!=2: continue
7270 hname = 'biasResXL_'+str(s)+'_'+z+str(l)+'_projx'
7271 h[hname].SetTitle(h[hname].GetTitle()+'; [cm]')
7272 h[hname].Draw()
7273 h['Residualsexample'].Update()
7274 stats = h[hname].FindObject("stats")
7275 stats.SetX1NDC(0.60)
7276 stats.SetY1NDC(0.60)
7277 stats.SetX2NDC(0.97)
7278 stats.SetY2NDC(0.93)
7279 stats.SetOptFit(111)
7280 h['Residualsexample'].Update()
7281 myPrint(h['Residualsexample'],hname)

◆ plotEnergyLoss()

conditionsDatabase.demo.drifttubeMonitoring.plotEnergyLoss ( )

Definition at line 5693 of file drifttubeMonitoring.py.

5693def plotEnergyLoss():
5694 f=ROOT.TFile('PinPout.root')
5695 PinPout = f.PinPout
5696 PinPout.SetStats(0)
5697 PinPout.SetTitle('incoming vs. outgoing momentum;#it{p} [GeV/c];#it{p} [GeV/c]; ')
5698 PinPout.Draw('box')
5699 lx = ROOT.TLine(0.,1.,10.,1.)
5700 lx.DrawClone()
5701 ly = ROOT.TLine(5.,0.,5.,10.)
5702 ly.DrawClone()
5703

◆ plotEvent()

conditionsDatabase.demo.drifttubeMonitoring.plotEvent (   n = -1)

Definition at line 908 of file drifttubeMonitoring.py.

908def plotEvent(n=-1):
909 h['dispTrack']=[]
910 h['dispTrack3D']=[]
911 h['dispTrackY']=[]
912 if not n<0: rc = sTree.GetEvent(n)
913 h['hitCollection']= {'upstream':[0,ROOT.TGraph()],'downstream':[0,ROOT.TGraph()],'muonTaggerX':[0,ROOT.TGraph()],'muonTaggerY':[0,ROOT.TGraph()]}
914 h['stereoHits'] = []
915 for c in h['hitCollection']: rc=h['hitCollection'][c][1].SetName(c)
916 for c in h['hitCollection']: rc=h['hitCollection'][c][1].Set(0)
917 ut.bookHist(h,'xz','x (y) vs z; Z [cm]; X(Y) [cm]',500,0.,1200.,100,-100.,100.)
918 if not h.has_key('simpleDisplay'): ut.bookCanvas(h,key='simpleDisplay',title='simple event display',nx=1200,ny=800,cx=1,cy=0)
919 rc = h[ 'simpleDisplay'].cd(1)
920 h['xz'].SetMarkerStyle(30)
921 h['xz'].SetStats(0)
922 h['xz'].Draw('b')
923 for hit in sTree.Digi_MufluxSpectrometerHits:
924 if not hit.hasTimeOverThreshold(): continue # 16% of the hits, isn't it a bit too much?
925 statnb,vnb,pnb,lnb,view,channelID,tdcId,nRT = stationInfo(hit)
926 # print statnb,vnb,pnb,lnb,view,hit.GetDetectorID()
927 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
928 if view != '_x':
929 stereoHit = ROOT.TGraph()
930 stereoHit.SetPoint(0,vbot[2],vbot[0])
931 stereoHit.SetPoint(1,vtop[2],vtop[0])
932 h['stereoHits'].append(stereoHit)
933 continue
934 if statnb<3:
935 c = h['hitCollection']['upstream']
936 rc = c[1].SetPoint(c[0],vbot[2],vbot[0])
937 c[0]+=1
938 else:
939 c = h['hitCollection']['downstream']
940 rc = c[1].SetPoint(c[0],vbot[2],vbot[0])
941 c[0]+=1
942 c = h['hitCollection']['muonTaggerX']
943 cy = h['hitCollection']['muonTaggerY']
944 if sTree.GetBranch("Digi_MuonTaggerHits"):
945 for hit in sTree.Digi_MuonTaggerHits:
946 channelID = hit.GetDetectorID()
947 statnb = channelID/10000
948 view = (channelID-10000*statnb)/1000
949 channel = channelID%1000
950 vbot,vtop = RPCPositionsBotTop[channelID]
951 if view == 1:
952 x,z = (vtop[0]+vbot[0])/2.,(vtop[2]+vbot[2])/2.
953 rc = c[1].SetPoint(c[0],z,x)
954 c[0]+=1
955 if view == 0:
956 y,z = (vtop[1]+vbot[1])/2.,(vtop[2]+vbot[2])/2.
957 rc = cy[1].SetPoint(cy[0],z,y)
958 cy[0]+=1
959 h['hitCollection']['downstream'][1].SetMarkerColor(ROOT.kRed)
960 h['hitCollection']['upstream'][1].SetMarkerColor(ROOT.kBlue)
961 h['hitCollection']['muonTaggerX'][1].SetMarkerColor(ROOT.kGreen)
962 h['hitCollection']['muonTaggerY'][1].SetMarkerColor(ROOT.kCyan)
963 for c in h['hitCollection']: rc=h['hitCollection'][c][1].SetMarkerStyle(30)
964 for c in h['hitCollection']:
965 if h['hitCollection'][c][1].GetN()<1: continue
966 rc=h['hitCollection'][c][1].Draw('sameP')
967 h['display:'+c]=h['hitCollection'][c][1]
968 for g in h['stereoHits']:
969 g.SetLineWidth(2)
970 g.Draw('same')
971 h[ 'simpleDisplay'].Update()
972

◆ plotFitPoints()

conditionsDatabase.demo.drifttubeMonitoring.plotFitPoints ( )

Definition at line 5628 of file drifttubeMonitoring.py.

5628def plotFitPoints():
5629 t = 'Fitpoints'
5630 views = ['_u1','_v2','_x1','_x2','_x3','_x4']
5631 interestingHistos=[]
5632 for view in views: interestingHistos.append(t+view)
5633 ut.readHists(hMC,'../DTPoints-mbias.root',interestingHistos)
5634 ut.readHists(h,'momDistributions.root',interestingHistos)
5635 if not h.has_key(t):
5636 ut.bookCanvas(h,key=t,title=t,nx=1200,ny=600,cx=3,cy=2)
5637 ut.bookCanvas(h,key=t+'proj',title=t,nx=1200,ny=600,cx=3,cy=2)
5638 histos = {'data':h,'MC':hMC}
5639 for data in ['data','MC']:
5640 hx = histos[data]
5641 for view in views:
5642 mean = data+'mean'+t+view
5643 oneHit234 = data+'oneHit234'+t+view
5644 twoHit34 = data+'twoHit34'+t+view
5645 h[mean] = hx[t+view].ProjectionX().Clone(mean)
5646 h[oneHit234]= hx[t+view].ProjectionX().Clone(oneHit234)
5647 h[twoHit34] = hx[t+view].ProjectionX().Clone(twoHit34)
5648 h[data+t+view+'proj']= hx[t+view].ProjectionY().Clone(data+t+view+'proj')
5649 h[oneHit234].SetMaximum(-1111)
5650 h[oneHit234].SetMinimum(-1111)
5651 h[twoHit34].SetMaximum(-1111)
5652 h[twoHit34].SetMinimum(-1111)
5653 for k in range(1,h[mean].GetNbinsX()):
5654 test = hx[t+view].ProjectionY('test',k,k)
5655 h[mean].SetBinContent(k,test.GetMean())
5656 h[mean].SetBinError(k,0)
5657 ratio = float(test.GetBinContent(2))/(test.GetBinContent(3)+test.GetBinContent(4)+test.GetBinContent(5)+1E-6)
5658 h[oneHit234].SetBinContent(k,ratio)
5659 h[oneHit234].SetBinError(k,0)
5660 ratio = float(test.GetBinContent(3))/(test.GetBinContent(4)+test.GetBinContent(5)+1E-6)
5661 h[twoHit34].SetBinContent(k,ratio)
5662 h[twoHit34].SetBinError(k,0)
5663 h[mean].SetMinimum(2.)
5664 h[mean].SetMaximum(4.)
5665 h[mean].Fit('pol1','PL','',50,300)
5666 h[mean].SetStats(0)
5667 for data in ['data','MC']:
5668 hx = histos[data]
5669 n = 1
5670 for view in views:
5671 tc = h[t].cd(n)
5672 mean = data+'mean'+t+view
5673 if data == 'MC':
5674 h[mean].SetLineColor(ROOT.kGreen)
5675 h[mean].Draw('histsame')
5676 else:
5677 h[mean].SetLineColor(ROOT.kBlue)
5678 h[mean].Draw('hist')
5679 h[mean].GetFunction('pol1').Draw('same')
5680 tc = h[t+'proj'].cd(n)
5681 tc.SetLogy()
5682 hname = data+t+view+'proj'
5683 h[hname].GetXaxis().SetRangeUser(-0.5,6.5)
5684 if data == 'MC':
5685 h[hname].SetLineColor(ROOT.kGreen)
5686 h[hname].Draw('histsame')
5687 else:
5688 h[hname].SetLineColor(ROOT.kBlue)
5689 h[hname].Draw('hist')
5690 n+=1
5691 myPrint(h[t],t+'meanFunP')
5692 myPrint(h[t+'proj'],t+'distribution')

◆ plotHitMaps()

conditionsDatabase.demo.drifttubeMonitoring.plotHitMaps (   onlyPlotting = False)

Definition at line 1164 of file drifttubeMonitoring.py.

1164def plotHitMaps(onlyPlotting=False):
1165 if not onlyPlotting: muflux_Reco.fillHitMaps()
1166 plotHitMapsOld(onlyPlotting=True)
1167

◆ plotHitMapsOld()

conditionsDatabase.demo.drifttubeMonitoring.plotHitMapsOld (   onlyPlotting = False)

Definition at line 1191 of file drifttubeMonitoring.py.

1191def plotHitMapsOld(onlyPlotting=False):
1192 noisyChannels = []
1193 deadThreshold = 1.E-4 # ~1% typical occupancy
1194 deadChannels = []
1195 if sTree.GetBranch("FitTracks"):
1196 FitTracksBrStatus = sTree.GetBranchStatus("FitTracks")
1197 sTree.SetBranchStatus("FitTracks",0)
1198 if not onlyPlotting:
1199 for event in sTree:
1200 for hit in event.Digi_MufluxSpectrometerHits:
1201 s,v,p,l,view,channelNr,tdcId,nRT = stationInfo(hit)
1202 tot = ''
1203 if not hit.hasTimeOverThreshold(): tot='_noToT'
1204 try:
1205 rc = xLayers[s][p][l][view].Fill(channelNr)
1206 except:
1207 print "plotHitMaps error",hit.GetDetectorID(),s,v,p,l,view,channelNr,tdcId
1208 continue
1209 if hit.GetDetectorID() not in noisyChannels:
1210 t0 = 0
1211 if MCdata: t0 = sTree.ShipEventHeader.GetEventTime()
1212 rc = h['TDC'+str(nRT)+tot].Fill(hit.GetDigi()-t0)
1213 channel = 'TDC'+str(hit.GetDetectorID())
1214 if not h.has_key(channel+tot): h[channel+tot]=h['TDC'+str(nRT)+tot].Clone(channel)
1215 rc = h[channel+tot].Fill(hit.GetDigi()-t0)
1216 if not h.has_key('hitMapsX'): ut.bookCanvas(h,key='hitMapsX',title='Hit Maps All Layers',nx=1600,ny=1200,cx=4,cy=6)
1217 if not h.has_key('TDCMapsX'): ut.bookCanvas(h,key='TDCMapsX',title='TDC Maps All Layers',nx=1600,ny=1200,cx=5,cy=10)
1218 if not h.has_key('TDCMapsX_noToT'): ut.bookCanvas(h,key='TDCMapsX_noToT',title='TDC Maps All Layers noToT',nx=1600,ny=1200,cx=5,cy=10)
1219 j = 0
1220 jt = 0
1221 for s in range(1,5):
1222 for view in ['_x','_u','_v']:
1223 for p in range(2):
1224 for l in range(2):
1225 if not xLayers[s][p][l].has_key(view):continue
1226 if s>2 and view != '_x': continue
1227 if s==1 and view == '_v'or s==2 and view == '_u': continue
1228 j+=1
1229 rc = h['hitMapsX'].cd(j)
1230 xLayers[s][p][l][view].Draw()
1231 mean = xLayers[s][p][l][view].GetEntries()/channels[s][p][l][view]
1232 v = 0
1233 if s==2 and view == "_x": v = 1
1234 if s==1 and view == "_u": v = 1
1235 myDetID = s * 10000000 + v * 1000000 + p * 100000 + l*10000
1236 for i in range(2,int(xLayers[s][p][l][view].GetEntries())+1):
1237 if i+1>Nchannels[s]: continue
1238 channel = myDetID+i-1 + 2000
1239 if xLayers[s][p][l][view].GetBinContent(i) > noiseThreshold * mean:
1240 print "noisy channel:",s,p,l,view,xLayers[s][p][l][view].GetBinContent(i) , noiseThreshold , mean
1241 if not channel in noisyChannels: noisyChannels.append(myDetID+i-1)
1242 if xLayers[s][p][l][view].GetBinContent(i) < max(1,deadThreshold * mean):
1243 print "dead channel:",s,p,l,view,i,xLayers[s][p][l][view].GetBinContent(i) , deadThreshold , mean
1244 deadChannels.append(channel)
1245#
1246 for nRT in range(1,576/cuts['RTsegmentation']+1):
1247 jt+=1
1248 tp = h['TDCMapsX'].cd(jt)
1249 tp.SetLogy(1)
1250 h['TDC'+str(nRT-1)].Draw()
1251 tp = h['TDCMapsX_noToT'].cd(jt)
1252 tp.SetLogy(1)
1253 h['TDC'+str(nRT-1)+'_noToT'].Draw()
1254
1255 print "list of noisy channels"
1256 for n in noisyChannels: print n
1257 print "list of dead channels"
1258 for n in deadChannels: print n
1259 if sTree.GetBranch("FitTracks"): sTree.SetBranchStatus("FitTracks",FitTracksBrStatus)
1260

◆ plotLinearResiduals()

conditionsDatabase.demo.drifttubeMonitoring.plotLinearResiduals ( )

Definition at line 3937 of file drifttubeMonitoring.py.

3937def plotLinearResiduals():
3938 if not h.has_key('linearResiduals2dX'):
3939 plotRPCExtrap(0,-1)
3940 ut.bookCanvas(h,key='linearResiduals2dX',title='linear track model, residuals function of X',nx=1600,ny=1200,cx=4,cy=4)
3941 ut.bookCanvas(h,key='linearResidualsX',title='linear track model, residuals',nx=1600,ny=1200,cx=4,cy=4)
3942 for s in range(1,5):
3943 for view in ['_x']:
3944 for l in range(0,4):
3945 hname = 'linearRes'+str(s)+view+str(l)
3946 h[hname].Reset()
3947 for Nr in range(sTree.GetEntries()):
3948 sTree.GetEvent(Nr)
3949 if Nr%10000==0: print "now at event",Nr,' of ',sTree.GetEntries(),sTree.GetCurrentFile().GetName()
3950 if not findSimpleEvent(sTree): continue
3951 trackCandidates = findTracks(PR = 3,linearTrackModel = True)
3952 j=1
3953 for s in range(1,5):
3954 for view in ['_x']:
3955 for l in range(0,4):
3956 hname = 'linearRes'+str(s)+view+str(l)
3957 rc = h['linearResiduals2dX'].cd(j)
3958 h[hname].Draw('box')
3959 rc = h['linearResidualsX'].cd(j)
3960 proj = h[hname].ProjectionX(hname+'_projx')
3961 proj.Draw()
3962 print "%s: %7.3F"%(hname, proj.GetMean())
3963 j+=1
3964 j=1
3965 for s in range(1,5):
3966 h['RPCResiduals'].cd(j*2-1)
3967 h['RPCResX_'+str(s)+'1'].Draw('colz')
3968 h['RPCResiduals'].cd(j*2)
3969 h['RPCResX_'+str(s)+'1'].ProjectionX().Draw()
3970 j+=1
3971

◆ plotMuonTaggerTrack()

conditionsDatabase.demo.drifttubeMonitoring.plotMuonTaggerTrack (   muTracks)

Definition at line 1831 of file drifttubeMonitoring.py.

1831def plotMuonTaggerTrack(muTracks):
1832 for view in ['X','Y']:
1833 for muTrack in muTracks[view]:
1834 h['simpleDisplay'].cd(1)
1835 nt = len(h['dispTrack'])
1836 h['dispTrack'].append( ROOT.TGraph(2) )
1837 h['dispTrackY'].append( ROOT.TGraph(2) ) # tricky, framework expects equal number of x and y projections
1838 zStart = 850.
1839 x = muTrack[0]*zStart+muTrack[1]
1840 h['dispTrack'][nt].SetPoint(0,zStart,x)
1841 zEnd = 1180.
1842 x = muTrack[0]*zEnd+muTrack[1]
1843 h['dispTrack'][nt].SetPoint(1,zEnd,x)
1844 if view == 'X': h['dispTrack'][nt].SetLineColor(ROOT.kRed)
1845 else:
1846 h['dispTrack'][nt].SetLineColor(ROOT.kBlue)
1847 h['dispTrack'][nt].SetLineStyle(10)
1848 h['dispTrack'][nt].SetLineWidth(3)
1849 h['dispTrack'][nt].Draw('same')
1850 h[ 'simpleDisplay'].Update()
1851

◆ plotResidualExample()

conditionsDatabase.demo.drifttubeMonitoring.plotResidualExample ( )

Definition at line 7172 of file drifttubeMonitoring.py.

7172def plotResidualExample():
7173 if not h.has_key('biasedResiduals'):
7174 ut.readHists(h,'residuals_refit.root')
7175 plotBiasedResiduals(onlyPlotting=True)
7176 ut.bookCanvas(h,'Residualsexample',' ',1200,600,1,1)
7177 h['Residualsexample'].cd()
7178 h['theResidualPlot']=h['biasRes_1_x1'].Clone('theResidualPlot')
7179 h['theResidualPlot'].Reset()
7180 for l in range(0,4):
7181 for z in ['x','u','v']:
7182 for s in range(1,5):
7183 if z=='u' and s!=1: continue
7184 if z=='v' and s!=2: continue
7185 hname = 'biasRes_'+str(s)+'_'+z+str(l)
7186 h[hname].SetTitle(h[hname].GetTitle()+';[cm]')
7187 h[hname].Draw()
7188 h['theResidualPlot'].Add(h[hname])
7189 myPrint(h['Residualsexample'],hname)
7190 hname = 'theResidualPlot'
7191 h[hname].SetTitle(';[cm]')
7192 fitFunction = h['biasRes_1_x0'].GetFunction('gauss').Clone()
7193 fitResult = h[hname].Fit(fitFunction,'S','',-0.5,0.5)
7194 h[hname].Draw()
7195 h['Residualsexample'].Update()
7196 stats = h['Residualsexample'].GetPrimitive('stats')
7197 stats.SetOptFit(10111)
7198 stats.SetFitFormat('5.4g')
7199 stats.SetX1NDC(0.6)
7200 stats.SetY1NDC(0.5)
7201 stats.SetX2NDC(0.98)
7202 stats.SetY2NDC(0.94)
7203 h['Residualsexample'].Update()
7204 myPrint(h['Residualsexample'],hname)
7205 hname = 'biasResDist_projy'
7206 h['biasResDist_projy'].GetXaxis().SetRangeUser(-0.5,0.5)
7207 h['biasResDist_projy'].Draw()
7208 h[hname].SetTitle(';[cm]')
7209 fitFunction = h['biasRes_1_x1'].GetFunction('gauss')
7210 fitFunction.ReleaseParameter(3)
7211 rc = h[hname].Fit(fitFunction,'SQ','',-0.3,0.3)
7212 fitResult=rc.Get()
7213 for n in range(4):
7214 myGauss2.SetParameter(n,fitResult.Parameter(n))
7215 myGauss2.FixParameter(4,0)
7216 myGauss2.FixParameter(5,0.04)
7217 rc = h[hname].Fit(myGauss2,'S','',-0.3,0.3)
7218 myGauss2.ReleaseParameter(4)
7219 rc = h[hname].Fit(myGauss2,'S','',-0.3,0.3)
7220 myGauss2.ReleaseParameter(5)
7221 rc = h[hname].Fit(myGauss2,'S','',-0.3,0.3)
7222 fitResult=rc.Get()
7223 n1 = fitResult.Parameter(0)
7224 n2 = fitResult.Parameter(4)
7225 s1 = fitResult.Parameter(2)
7226 s2 = fitResult.Parameter(5)
7227 a = (s1*n1+s2*n2)/(n1+n2)
7228 txt = ROOT.TLatex(-0.45,h[hname].GetMaximum()*0.8,"#sigma_{mean} = %5.0F#mum"%(a*10*1000))
7229 h[hname].SetTitle('')
7230 h[hname].Draw()
7231 txt.Draw()
7232 h['Residualsexample'].Update()
7233 stats = h['Residualsexample'].GetPrimitive('stats')
7234 stats.SetOptFit(10111)
7235 stats.SetFitFormat('5.4g')
7236 stats.SetX1NDC(0.6)
7237 stats.SetY1NDC(0.5)
7238 stats.SetX2NDC(0.98)
7239 stats.SetY2NDC(0.94)
7240 myPrint(h['Residualsexample'],'biasResDistAll')
7241#

◆ plotRPC3Example()

conditionsDatabase.demo.drifttubeMonitoring.plotRPC3Example ( )

Definition at line 7311 of file drifttubeMonitoring.py.

7311def plotRPC3Example():
7312 ut.bookCanvas(h,'Residualsexample',' ',1200,600,1,1)
7313 h['RPCextTrack_21-70-100GeV'] = h['RPCextTrack_21'].ProjectionY('RPCextTrack_21-70-100GeV',70,100)
7314 h['RPCextTrack_31-70-100GeV'] = h['RPCextTrack_31'].ProjectionY('RPCextTrack_31-70-100GeV',70,100)
7315 h['RPCextTrack_21-5-10GeV'] = h['RPCextTrack_21'].ProjectionY('RPCextTrack_21-5-10GeV',5,10)
7316 h['RPCextTrack_31-5-10GeV'] = h['RPCextTrack_31'].ProjectionY('RPCextTrack_31-5-10GeV',5,10)
7317 h['RPCextTrack_21-70-100GeV'].SetLineColor(ROOT.kRed)
7318 h['RPCextTrack_21-5-10GeV'].SetLineColor(ROOT.kRed)
7319 h['Residualsexample'].cd()
7320 h['RPCextTrack_21-5-10GeV'].SetTitle('track with 5<P<10GeV position X at station 3 close to hit ; x [cm]')
7321 h['RPCextTrack_21-5-10GeV'].Draw()
7322 h['RPCextTrack_31-5-10GeV'].Draw('same')
7323 myPrint(h['Residualsexample'],"XRPClowMom")
7324 h['RPCextTrack_21-70-100GeV'].SetTitle('track with 70<P<100GeV position X at station 3 close to hit ; x [cm]')
7325 h['RPCextTrack_21-70-100GeV'].Draw()
7326 h['RPCextTrack_31-70-100GeV'].Draw('same')
7327 myPrint(h['Residualsexample'],"XRPChighMom")
7328
7329

◆ plotRPCExample()

conditionsDatabase.demo.drifttubeMonitoring.plotRPCExample ( )

Definition at line 1319 of file drifttubeMonitoring.py.

1319def plotRPCExample():
1320 h['X'] = ROOT.TFile('RPCHitMap.root')
1321 ROOT.gROOT.cd()
1322 h['rpcPlot']=h['X'].Get('rpcPlot').Clone('rpcPlot')
1323 for pad in h['rpcPlot'].GetListOfPrimitives():
1324 if pad.GetListOfPrimitives().GetSize()==0: continue
1325 hist = pad.GetListOfPrimitives()[1]
1326 hist.SetStats(0)
1327 s = hist.GetName()[9:10]
1328 if hist.GetTitle().find('layer 1')>0:
1329 hist.SetTitle('RPC hitmap station '+s+'X readout; channel number N')
1330 elif hist.GetTitle().find('layer 0')>0:
1331 hist.SetTitle('RPC hitmap station '+s+'Y readout; channel number N')
1332 hist.GetXaxis().SetRangeUser(0,120)
1333 else:
1334 hist.SetTitle('Number of hits per station ; station number ')
1335 pad.Update()
1336 h['rpcPlot'].Update()
1337 h['rpcPlot'].Draw()
1338 myPrint(h['rpcPlot'],'RPCHitMap')
1339

◆ plotRPCExtrap()

conditionsDatabase.demo.drifttubeMonitoring.plotRPCExtrap (   nEvent = -1,
  nTot = 1000,
  PR = 1,
  onlyPlotting = False 
)

Definition at line 4198 of file drifttubeMonitoring.py.

4198def plotRPCExtrap(nEvent=-1,nTot=1000,PR=1,onlyPlotting=False):
4199 if not onlyPlotting:
4200 eventRange = [0,sTree.GetEntries()]
4201 if not nEvent<0: eventRange = [nEvent,nEvent+nTot]
4202 for s in range(1,6):
4203 for v in range(2):
4204 if v==1: dx=20
4205 if v==0: dx=20
4206 ut.bookHist(h,'RPCResX_'+str(s)+str(v),'RPC residual for '+str(s)+' '+ str(v),100,-dx,dx,20,-140.,140.)
4207 ut.bookHist(h,'RPCResY_'+str(s)+str(v),'RPC residual for '+str(s)+' '+ str(v),100,-dx,dx,20,-140.,140.)
4208 ut.bookHist(h,'RPCextTrack_'+str(s)+str(v),'mom of tracks extr to RPC k with RPC k+1 matched',100,0.,100.,100,-140.,140.)
4209 ut.bookHist(h,'RPCfired_'+str(s)+str(v),'mom of tracks extr to RPC k and matched with RPC k+1 matched',100,0.,100.)
4210 ut.bookHist(h,'RPCfired_or_'+str(s),'mom of tracks extr to RPC k and matched with RPC k+1 or of 0 and 1',100,0.,100.)
4211 ut.bookHist(h,'RPCResX'+str(s)+'_p','RPC residual for station '+str(s)+' as function of track momentum',100,-dx,dx,100,0.,100.)
4212 ut.bookHist(h,'RPCMatchedHits','matched RPC hits as function of track momentum',10,0.5,10.5,20,-0.5,19.5,100,0.,100.)
4213 ut.bookHist(h,'RPCMeanMatchedHits','mean matched RPC hits as function of track momentum',100,0.,100.)
4214 ut.bookHist(h,'RPC>1','fraction of tracks with > 1 RPC hits',100,0.,100.)
4215 ut.bookHist(h,'RPC<2XY','position of tracks with < 2 RPC hits and p>30GeV',50,-100.,100.,50,-100.,100.)
4216 ut.bookHist(h,'RPC_p', 'momentum of tracks pointing to RPC',100,0.,100.)
4217 for k in range(2,20):
4218 ut.bookHist(h, 'RPC<'+str(k)+'_p', ' < '+str(k)+' RPC hits p',100,0.,100.)
4219 if PR==1 or PR==3:
4220 muflux_Reco.RPCextrap()
4221 return
4222 for Nr in range(eventRange[0],eventRange[1]):
4223 getEvent(Nr)
4224 if Nr%10000==0: print "now at event",Nr,' of ',sTree.GetEntries(),sTree.GetCurrentFile().GetName(),time.ctime()
4225 if not sTree.Digi_MuonTaggerHits.GetEntries()>0: continue
4226 if not findSimpleEvent(sTree): continue
4227 trackCandidates = findTracks(PR)
4228 first = True
4229 for aTrack in trackCandidates:
4230 matchedHits={1:{0:[],1:[]},2:{0:[],1:[]},3:{0:[],1:[]},4:{0:[],1:[]},5:{0:[],1:[]}}
4231 trackPos = {}
4232 st = aTrack.getFitStatus()
4233 if not st.isFitConverged(): continue
4234 if not aTrack.getNumPointsWithMeasurement()>0: continue
4235 sta = aTrack.getFittedState(0)
4236 if sta.getMomMag() < 1.: continue
4237 nHit = -1
4238 rc,pos1,mom = extrapolateToPlane(aTrack,cuts['zRPC1'])
4239 if not rc: continue
4240 inAcc=False
4241 if pos1[0]>cuts['xLRPC1'] and pos1[0]<cuts['xRRPC1'] and pos1[1]>cuts['yBRPC1'] and pos1[1]<cuts['yTRPC1']:
4242 inAcc=True
4243 for hit in sTree.Digi_MuonTaggerHits:
4244 if hit.GetDetectorID() in deadChannelsRPC4MC: continue
4245 nHit+=1
4246 channelID = hit.GetDetectorID()
4247 s = channelID/10000
4248 v = (channelID-10000*s)/1000
4249 if first:
4250 layer = channelID/1000
4251 rc = h['rpcHitmap'].Fill(layer)
4252 channel = channelID%1000
4253 rc = h['rpcHitmap'+str(layer)].Fill(channel)
4254 vtop,vbot = RPCPositionsBotTop[channelID]
4255 z = (vtop[2]+vbot[2])/2.
4256 rc,pos,mom = extrapolateToPlane(aTrack,z)
4257 if not rc:
4258 error = "RPCextrap: plotRPCExtrap failed"
4259 ut.reportError(error)
4260 if Debug: print error
4261 continue
4262 # closest distance from point to line
4263 # res = vbot[0]*pos[1] - vtop[0]*pos[1] - vbot[1]*pos[0]+ vtop[0]*vbot[1] + pos[0]*vtop[1]-vbot[0]*vtop[1]
4264 # res = -res/ROOT.TMath.Sqrt( (vtop[0]-vbot[0])**2+(vtop[1]-vbot[1])**2)
4265 if v==0:
4266 Y = (vtop[1]+vbot[1])/2.
4267 res = pos[1] - Y
4268 h['RPCResY_'+str(s)+str(v)].Fill(res,Y)
4269 trackPos[s*10+v]=pos[1]
4270 else:
4271 X = (vtop[0]+vbot[0])/2.
4272 res = pos[0] - X
4273 h['RPCResX_'+str(s)+str(v)].Fill(res,X)
4274 h['RPCResX'+str(s)+'_p'].Fill(res,sta.getMomMag())
4275 trackPos[s*10+v]=pos[0]
4276 if abs(res)<cuts["RPCmaxDistance"]:
4277 matchedHits[s][v].append(nHit)
4278 # record number of hits per station and view and track momentum
4279 # but only for tracks in acceptance
4280 first = True
4281 if inAcc:
4282 Nmatched = 0
4283 p = min(99.9,sta.getMomMag())
4284# try the following:
4285# require matched hit in station k+1
4286# record how often hit matched in station k
4287 for k in range(1,5):
4288 if len(matchedHits[k+1][0])==0 or len(matchedHits[k+1][1])==0: continue # suppress noise TR 30Sept
4289 rc = h['RPCextTrack_'+str(k)+str(v)].Fill(p,trackPos[(k+1)*10+v])
4290 if p<8 and abs(trackPos[(k+1)*10+v]) <1: print Nr
4291 for v in range(0,2):
4292 if len(matchedHits[k][v])>0: rc = h['RPCfired_'+str(k)+str(v)].Fill(p)
4293 if v==0:
4294 if len(matchedHits[k][v])>0 or len(matchedHits[k][v+1])>0: rc = h['RPCfired_or_'+str(k)].Fill(p)
4295 for s in matchedHits:
4296 for v in matchedHits[s]:
4297 rc = h['RPCMatchedHits'].Fill(2*s-1+v,len(matchedHits[s][v]),p)
4298 Nmatched+=len(matchedHits[s][v])
4299 if Nmatched <2 and p>30: rc = h['RPC<2XY'].Fill(pos1[0],pos1[1])
4300 rc = h['RPC_p'].Fill(p)
4301 for k in range(2,20):
4302 if Nmatched<k: rc = h['RPC<'+str(k)+'_p'].Fill(p)
4303 if not h.has_key('RPCResiduals'):
4304 ut.bookCanvas(h,key='RPCResiduals',title='RPCResiduals',nx=1600,ny=1200,cx=2,cy=5)
4305 ut.bookCanvas(h,key='RPCResidualsXY',title='RPCResiduals function of Y/X',nx=1600,ny=1200,cx=2,cy=5)
4306 ut.bookCanvas(h,key='RPCResidualsP',title='RPCResiduals function of muon momentum',nx=900,ny=900,cx=1,cy=1)
4307 j=1
4308 T = ROOT.TLatex()
4309 T.SetTextSize(0.1)
4310 for s in range(1,6):
4311 for v in range(0,2): # 1 = x layer vertical strip, 0 = y layer horizontal strips
4312 if v==1:
4313 hname = 'RPCResX_'+str(s)+str(v)
4314 p='X'
4315 jk = 2*j
4316 elif v==0:
4317 hname = 'RPCResY_'+str(s)+str(v)
4318 p='Y'
4319 jk = 2*j-1
4320 hnameProjX = 'RPCRes_'+str(s)+str(v)
4321 if h[hname].GetEntries()==0: continue
4322 h[hnameProjX] = h[hname].ProjectionX()
4323 h[hnameProjX].GetXaxis().SetTitle('#Delta [cm]')
4324 myGauss.SetParameter(0,h[hnameProjX].GetMaximum())
4325 myGauss.SetParameter(1,0.)
4326 myGauss.SetParameter(2,4.)
4327 myGauss.SetParameter(3,1.)
4328 rc = h['RPCResiduals'].cd(jk)
4329 if v==0: fitResult = h[hnameProjX].Fit(myGauss,'SQ','',-40.,40.)
4330 else: fitResult = h[hnameProjX].Fit(myGauss,'SQ','',-10.,10.)
4331 rc = fitResult.Get()
4332 if not rc: continue
4333 myGauss2.SetParameter(0,rc.GetParams()[0])
4334 myGauss2.SetParameter(1,rc.GetParams()[1])
4335 myGauss2.SetParameter(2,abs(rc.GetParams()[2]))
4336 myGauss2.SetParameter(3,rc.GetParams()[3])
4337 myGauss2.SetParameter(4,0.)
4338 myGauss2.SetParameter(5,10.)
4339 if v==0: fitResult = h[hnameProjX].Fit(myGauss2,'SQ','',-40.,40.)
4340 else: fitResult = h[hnameProjX].Fit(myGauss2,'SQ','',-10.,10.)
4341 rc = fitResult.Get()
4342 if rc.GetParams()[3]<0: myGauss2.SetParameter(3,abs(rc.GetParams()[3]))
4343 if v==0: fitResult = h[hnameProjX].Fit(myGauss2,'SQ','',-40.,40.)
4344 else: fitResult = h[hnameProjX].Fit(myGauss2,'SQ','',-10.,10.)
4345 rc = fitResult.Get()
4346 mean = rc.GetParams()[1]
4347 rms1 = rc.GetParams()[2]
4348 rms2 = rc.GetParams()[5]
4349 N1 = rc.GetParams()[0]
4350 N2 = rc.GetParams()[4]
4351 avRMS = (rms1*N1+rms2*N2)/(N1+N2)
4352 print "%i, %i, mean=%5.2F RMS=%5.2F"%(s,v,mean,avRMS)
4353 t = "#sigma_{av}=%5.2Fcm"%(avRMS)
4354 rc = T.DrawLatexNDC(0.13,0.7,t)
4355 # make plot of mean as function of X,Y
4356 rc = h['RPCResidualsXY'].cd(jk)
4357 hname = 'RPCRes'+p+'_'+str(s)+str(v)
4358 hmean = hname+'_mean'+p
4359 h[hmean] = h[hname].ProjectionY(hname+'_mean')
4360 h[hmean].Reset()
4361 for k in range(1,h[hname].GetNbinsY()+1):
4362 sli = hname+'_'+str(k)
4363 h[sli] = h[hname].ProjectionX(sli,k,k)
4364 if h[sli].GetEntries()<10: continue
4365 myGauss.SetParameter(0,h[sli].GetMaximum())
4366 myGauss.SetParameter(1,0.)
4367 myGauss.SetParameter(2,4.)
4368 myGauss.SetParameter(3,1.)
4369 if v==0: fitResult = h[sli].Fit(myGauss,'SQ','',-40.,40.)
4370 else: fitResult = h[sli].Fit(myGauss,'SQ','',-10.,10.)
4371 rc = fitResult.Get()
4372 if not rc: continue
4373 params = rc.GetParams()
4374 if not params: continue
4375 mean = rc.GetParams()[1]
4376 rms = abs(rc.GetParams()[2])
4377 rc = h[hmean].SetBinContent(k,mean)
4378 rc = h[hmean].SetBinError(k,rms)
4379 h[hmean].Draw()
4380 j+=1
4381 if not h.has_key('RPCResiduals2dXY'):
4382 ut.bookCanvas(h,key='RPCResiduals2dXY',title='muon tagger Residuals function of X/Y',nx=1600,ny=1200,cx=2,cy=5)
4383 j=1
4384 for s in range(1,6):
4385 for v in range(0,2): # 1 = x layer vertical strip, 0 = y layer horizontal strips
4386 if v==0:
4387 p = 'Y'
4388 jk = j*2-1
4389 if v==1:
4390 p = 'X'
4391 jk = j*2
4392 rc = h['RPCResiduals2dXY'].cd(jk)
4393 hname = 'RPCRes'+p+'_'+str(s)+str(v)
4394 h[hname].Draw('box')
4395 j+=1
4396 h['RPCResidualsP'].cd(1)
4397 h['RPCResX1_p'].Draw('colz')
4398# rc = h['RPCMatchedHits'].Fill(2*s-1+v,len(matchedHits[s][v]),mom.Mag())
4399 zax = h['RPCMatchedHits'].GetZaxis() # 100 momentum
4400 xax = h['RPCMatchedHits'].GetXaxis() # 10 bins station and view
4401 yax = h['RPCMatchedHits'].GetYaxis() # 20 multiplicity
4402 for ip in range(1,zax.GetNbins()+1):
4403 Nmean = 0
4404 Nentries = 0
4405 Ntracks1 = 0
4406 for ks in range(1,xax.GetNbins()+1):
4407 Ntracks1=h['RPCMatchedHits'].GetBinContent(ks,1,ip)+h['RPCMatchedHits'].GetBinContent(ks,2,ip)
4408 for n in range(1,yax.GetNbins()+1):
4409 Nmean += h['RPCMatchedHits'].GetBinContent(ks,n,ip)*yax.GetBinCenter(n)
4410 Nentries+=h['RPCMatchedHits'].GetBinContent(ks,n,ip)
4411 Nmean = Nmean / float(Nentries+1E-10)
4412 rc = h['RPCMeanMatchedHits'].SetBinContent(ip,Nmean)
4413 fraction = (Nentries-Ntracks1)/(Nentries+1E-10)
4414 rc = h['RPC>1'].SetBinContent(ip,fraction)
4415 for k in range(2,20):
4416 h['RPCeff_'+str(k)]=h['RPC<'+str(k)+'_p'].Clone('RPCeff_'+str(k))
4417 h['RPCeff_'+str(k)].Divide(h['RPC_p'])
4418 ut.bookCanvas(h,key='RPCEff',title='RPC efficiencies',nx=1600,ny=1200,cx=3,cy=4)
4419 const = ROOT.TF1('const','pol0',10,100)
4420 l=1
4421 T=ROOT.TLatex()
4422 for s in range(1,5):
4423 for v in range(3):
4424 if v==2:
4425 hname = 'RPCfired_or_'+str(s)
4426 h['Eff'+hname]=ROOT.TEfficiency(h[hname],h['RPCextTrack_'+str(s)+str(0)+'_projx'])
4427 else:
4428 hname = 'RPCfired_'+str(s)+str(v)
4429 h['Eff'+hname]=ROOT.TEfficiency(h[hname],h['RPCextTrack_'+str(s)+str(v)+'_projx'])
4430 pad = h['RPCEff'].cd(l)
4431 l+=1
4432 rc = h['Eff'+hname].Fit(const)
4433 h['Eff'+hname].Draw('AP')
4434 pad.Update()
4435 graph = h['Eff'+hname].GetPaintedGraph()
4436 graph.SetMinimum(0.9)
4437 graph.SetMaximum(1.01)
4438 pad.Update()
4439 fun = h['Eff'+hname].GetListOfFunctions()[0]
4440 eff = fun.GetParameter(0)
4441 err = fun.GetParError(0)
4442 T.SetTextSize(0.1)
4443 rc = T.DrawLatexNDC(0.3,0.2,'eff = (%5.2F\pm%5.2F)%s'%(eff*100,err*100,'%'))
4444 txt = "station "+str(s)+" X"
4445 if v==0: txt = "station "+str(s)+" Y"
4446 if v==2: txt = "station "+str(s)+" X or Y"
4447 T.SetTextSize(0.08)
4448 rc = T.DrawLatexNDC(0.2,0.8,txt)
4449 myPrint(h['RPCEff'],"rpchiteff")
4450 h['RPCResiduals'].Draw()
4451 for x in h['RPCResiduals'].GetListOfPrimitives():
4452 for xx in x.GetListOfPrimitives():
4453 if xx.ClassName()=='TH1D':
4454 stats = xx.GetListOfFunctions().FindObject("stats")
4455 stats.SetOptStat(1000000001)
4456 stats.SetOptFit(10001)
4457 stats.SetX1NDC(0.70)
4458 stats.SetY1NDC(0.23)
4459 stats.SetX2NDC(0.97)
4460 stats.SetY2NDC(0.94)
4461 h['RPCResiduals'].Update()
4462 myPrint(h['RPCResiduals'],'RPCResiduals')
4463 print "do not forget there were runs without one RPC station"
4464

◆ plotRPCHitmap()

conditionsDatabase.demo.drifttubeMonitoring.plotRPCHitmap ( )

Definition at line 1301 of file drifttubeMonitoring.py.

1301def plotRPCHitmap():
1302 if not h.has_key('rpcPlot'): ut.bookCanvas(h,key='rpcPlot',title='RPC Hitmaps',nx=1200,ny=600,cx=4,cy=3)
1303 j=0
1304 for n in range(1,6):
1305 for l in range(2):
1306 j+=1
1307 rc = h['rpcPlot'].cd(j)
1308 h['rpcHitmap'+str(n)+str(l)].SetStats(0)
1309 if l==0:
1310 h['rpcHitmap'+str(n)+str(l)].SetTitle('RPC hitmap station '+str(n)+'Y readout; channel number N')
1311 h['rpcHitmap'+str(n)+str(l)].GetXaxis().SetRangeUser(0,120)
1312 else:
1313 h['rpcHitmap'+str(n)+str(l)].SetTitle('RPC hitmap station '+str(n)+'X readout; channel number N')
1314 h['rpcHitmap'+str(n)+str(l)].Draw()
1315 rc = h['rpcPlot'].cd(j)
1316 h['rpcHitmap'].SetTitle('Number of hits per station ; station number ')
1317 h['rpcHitmap'].Draw()
1318 myPrint(h['rpcPlot'],'RPCHitMap')

◆ plotRPCResidualsExample()

conditionsDatabase.demo.drifttubeMonitoring.plotRPCResidualsExample ( )

Definition at line 7292 of file drifttubeMonitoring.py.

7292def plotRPCResidualsExample():
7293 ut.bookCanvas(h,'Residualsexample',' ',1200,600,1,1)
7294 t='RPCResiduals'
7295 h['Residualsexample'].cd()
7296 for p in h[t].GetListOfPrimitives():
7297 hist = p.GetListOfPrimitives()[1]
7298 hist.Draw()
7299 p.GetListOfPrimitives()[2].Draw()
7300 myPrint(h['Residualsexample'],hist.GetName())
7301 t='RPCEff'
7302 for p in h[t].GetListOfPrimitives():
7303 hist = p.GetListOfPrimitives()[1]
7304 hist.SetTitle(';track momentum [GeV/c]')
7305 hist.Draw()
7306 txt1 = p.GetListOfPrimitives()[2].Clone('1')
7307 txt1.Draw()
7308 txt2 = p.GetListOfPrimitives()[3].Clone('2')
7309 txt2.Draw()
7310 myPrint(h['Residualsexample'],hist.GetName())

◆ plotSigmaRes()

conditionsDatabase.demo.drifttubeMonitoring.plotSigmaRes ( )

Definition at line 3146 of file drifttubeMonitoring.py.

3146def plotSigmaRes():
3147 ut.bookHist(h,'resDistr','residuals',50,0.,0.1)
3148 for tc in h['biasedResiduals'].GetListOfPrimitives():
3149 for p in tc.GetListOfPrimitives():
3150 if p.InheritsFrom('TH1'):
3151 fitFun = p.GetFunction('gauss')
3152 h['resDistr'].Fill(fitFun.GetParameter(2))
3153 ROOT.gROOT.FindObject('c1').cd()
3154 h['resDistr'].Draw()

◆ plotTDCExample()

conditionsDatabase.demo.drifttubeMonitoring.plotTDCExample ( )

Definition at line 7078 of file drifttubeMonitoring.py.

7078def plotTDCExample():
7079 h['f']=ROOT.TFile.Open(os.environ['EOSSHIP']+'/eos/experiment/ship/user/odurhan/muflux-recodata/RUN_8000_2278/SPILLDATA_8000_0517453245_20180719_082409_RT.root')
7080 upkl = Unpickler(h['f'])
7081 h['tMinAndTmax'] = upkl.load('tMinAndTmax')
7082 ROOT.gROOT.cd()
7083 h['TDCMapsX'] = h['f'].histos.Get('TDCMapsX').Clone('TDCMapsX')
7084 h['TDCMapsX'].Draw()
7085 h['TDCMapsX'].Update()
7086 for p in h['TDCMapsX'].GetListOfPrimitives():
7087 t = p.GetTitle()
7088 if t.find("TDCMapsX")<0: continue
7089 h['Pad'+t] = p.Clone('Pad'+t)
7090 if len(h['Pad'+t].GetListOfPrimitives())<2: continue
7091 n = h['Pad'+t].GetListOfPrimitives()[1].GetName()
7092 h['x'+n] = h['Pad'+t].GetListOfPrimitives()[1].Clone('x'+n)
7093 h['x'+n].SetTitle("Group "+str(n)+'; TDC [ns]')
7094 # h['x'+n].SetTitleSize(0.1,'x')
7095 ut.bookCanvas(h,'TDC1example',' ',1200,600,1,1)
7096 ut.bookCanvas(h,key='TDCMaps',title='TDC Maps All Layers',nx=3*1600,ny=3*1200,cx=5,cy=9)
7097 n = 1
7098 for x in range(50):
7099 if x in [16 ,17, 30, 31]: continue
7100 h['TDCMaps'].cd(n)
7101 if not h.has_key('xTDC'+str(x)): continue
7102 z = 'xTDC'+str(x)
7103 h[z].Draw()
7104 tmin = h['tMinAndTmax']['TDC'+str(x)][0]
7105 tmax = h['tMinAndTmax']['TDC'+str(x)][1]
7106 h[z+'tMin'] = ROOT.TArrow(tmin,-5.,tmin,0.8,0.05,">")
7107 h[z+'tMax'] = ROOT.TArrow(tmax,-5.,tmax,0.8,0.05,">")
7108 h[z+'tMin'].SetLineColor(ROOT.kRed)
7109 h[z+'tMax'].SetLineColor(ROOT.kRed)
7110 h[z+'tMin'].Draw()
7111 h[z+'tMax'].Draw()
7112 h['TDC1example'].cd()
7113 h[z].Draw()
7114 h[z+'tMin'].Draw()
7115 h[z+'tMax'].Draw()
7116 myPrint(h['TDC1example'],'xTDC'+str(x))
7117 n+=1
7118 h['TDCMaps'].Update()
7119 myPrint(h['TDCMaps'],'TDCMaps')
7120#
7121 ut.bookCanvas(h,key='RTrelations',title='RT relations',nx=1600,ny=1200,cx=1,cy=1)
7122 h['RTrelations'].cd(1)
7123 x = h['TDC0']
7124 h['emptyHist'] = ROOT.TH2F('empty',' ;[ns];[cm] ',100,x.GetBinCenter(1),x.GetBinCenter(x.GetNbinsX()),100,0.,2.)
7125 h['emptyHist'].SetStats(0)
7126 h['emptyHist'].Draw()
7127 h['legRT'] = ROOT.TLegend(0.69,0.10,0.99,0.98)
7128 for x in range(48):
7129 if x in [16 ,17, 30, 31]: continue
7130 g = 'rtTDC'+str(x)
7131 h['g'+g]=h['f'].RT.Get(g).Clone('g'+g)
7132 if not g.find('TDC1')<0: h['g'+g].SetLineColor(ROOT.kBlue)
7133 elif not g.find('TDC2')<0: h['g'+g].SetLineColor(ROOT.kCyan)
7134 elif not g.find('TDC3')<0: h['g'+g].SetLineColor(ROOT.kGreen)
7135 elif not g.find('TDC4')<0: h['g'+g].SetLineColor(ROOT.kGreen+2)
7136 h['g'+g].Draw()
7137 h['legRT'].AddEntry(h['g'+g],h['g'+g].GetTitle(),'PL')
7138 h['legRT'].Draw()
7139 myPrint(h['RTrelations'],'RTRelations')

◆ plotTimeOverThreshold()

conditionsDatabase.demo.drifttubeMonitoring.plotTimeOverThreshold (   N,
  Debug = False 
)

Definition at line 1340 of file drifttubeMonitoring.py.

1340def plotTimeOverThreshold(N,Debug=False):
1341 ut.bookHist(h,'ToverT','Time over threshold',3000,-1000.,2000.)
1342 ut.bookHist(h,'endTime','End Time',100,0.,2000.)
1343 ut.bookHist(h,'tdc','tdc',100,-200.,2000.)
1344 for n in range(N):
1345 rc = sTree.GetEvent(n)
1346 flag = False
1347 for aHit in sTree.Digi_MufluxSpectrometerHits:
1348 detID=hit.GetDetectorID()
1349 if detID<0: continue # feature for converted data in February'19
1350 if not aHit.hasTimeOverThreshold():
1351 rc=h['ToverT'].Fill( -999. )
1352 continue
1353 rc=h['ToverT'].Fill( aHit.GetTimeOverThreshold() )
1354 rc=h['tdc'].Fill( aHit.GetDigi())
1355 rc=h['endTime'].Fill( aHit.GetDigi()+aHit.GetTimeOverThreshold() )
1356 if aHit.GetTimeOverThreshold() < 10: flag = True
1357 if flag and Debug:
1358 print n
1359 spectrHitsSorted = ROOT.nestedList()
1360 muflux_Reco.sortHits(sTree.Digi_MufluxSpectrometerHits,spectrHitsSorted,True)
1361 for s in range(1,5):
1362 for view in viewsI[s]:
1363 for l in range(4):
1364 for hit in spectrHitsSorted[view][s][l]:
1365 print s,viewC[view],l,hit.GetDetectorID()%1000,hit.GetTimeOverThreshold()
1366

◆ plotTracklets()

conditionsDatabase.demo.drifttubeMonitoring.plotTracklets (   track_hits)

Definition at line 2239 of file drifttubeMonitoring.py.

2239def plotTracklets(track_hits):
2240 for nTrack in track_hits:
2241 upStream = True
2242 for x in [track_hits[nTrack]['y12'],track_hits[nTrack]['34']]:
2243 clus = {1:[],2:[]}
2244 for hits in x:
2245 detID = hits['detID']/10000000
2246 if detID>2: detID-=2
2247 clus[detID].append([0,(hits['xtop']+hits['xbot'])/2.,hits['z']])
2248 slopeA,bA = getSlopes(clus[1],clus[2])
2249 x1 = zgoliath*slopeA+bA
2250 nt = len(h['dispTrackSeg'])
2251 h['dispTrackSeg'].append( ROOT.TGraph(2) )
2252 if upStream:
2253 h['dispTrackSeg'][nt].SetPoint(0,0.,bA)
2254 h['dispTrackSeg'][nt].SetPoint(1,400.,slopeA*400+bA)
2255 h['dispTrackSeg'][nt].SetLineColor(ROOT.kRed)
2256 upStream=False
2257 else:
2258 h['dispTrackSeg'][nt].SetPoint(0,300.,slopeA*300+bA)
2259 h['dispTrackSeg'][nt].SetPoint(1,900.,slopeA*900+bA)
2260 h['dispTrackSeg'][nt].SetLineColor(ROOT.kBlue)
2261 h['dispTrackSeg'][nt].SetLineWidth(2)
2262 h['simpleDisplay'].cd(1)
2263 h['dispTrackSeg'][nt].Draw('same')
2264 h['simpleDisplay'].Update()
2265

◆ plotWithRPCTrackEffExample()

conditionsDatabase.demo.drifttubeMonitoring.plotWithRPCTrackEffExample ( )

Definition at line 7282 of file drifttubeMonitoring.py.

7282def plotWithRPCTrackEffExample():
7283 DTeffWithRPCTracks(Nevents=0,onlyPlotting=True)
7284 t = 'tagstation'+str(1)
7285 ut.bookCanvas(h,'Residualsexample',' ',1200,600,1,1)
7286 h['Residualsexample'].cd()
7287 for p in h[t].GetListOfPrimitives():
7288 hist = p.GetListOfPrimitives()[1]
7289 hist.GetXaxis().SetTitle('[cm]')
7290 hist.Draw('hist')
7291 myPrint(h['Residualsexample'],hist.GetName())

◆ printClustersPerStation()

conditionsDatabase.demo.drifttubeMonitoring.printClustersPerStation (   clusters,
  s,
  view 
)

Definition at line 2266 of file drifttubeMonitoring.py.

2266def printClustersPerStation(clusters,s,view):
2267 k=0
2268 if MCdata:
2269 keysToDThits=MakeKeysToDThits(cuts['lateArrivalsToT'])
2270 for n in clusters[s][view]:
2271 print '--------'
2272 for x in n:
2273 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(x[0])
2274 if MCdata:
2275 detID = x[0].GetDetectorID()
2276 MCTrackID = sTree.MufluxSpectrometerPoint[keysToDThits[detID][0]].GetTrackID()
2277 print k,':',s,view,2*p+l,x[2],x[3],':',MCTrackID
2278 else: print k,':',s,view,2*p+l,x[2],x[3]
2279 k+=1

◆ printResiduals()

conditionsDatabase.demo.drifttubeMonitoring.printResiduals (   aTrack)

Definition at line 2837 of file drifttubeMonitoring.py.

2837def printResiduals(aTrack):
2838 if not aTrack.getNumPointsWithMeasurement()>0: return
2839 sta = aTrack.getFittedState(0)
2840 txt = {}
2841 tmpList={}
2842 k=0
2843 for hit in sTree.Digi_MufluxSpectrometerHits:
2844 if not hit.hasTimeOverThreshold(): continue
2845 if hit.GetDetectorID() in noisyChannels: continue
2846 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
2847 vbot,vtop = strawPositionsBotTop[hit.GetDetectorID()]
2848 z = (vbot[2]+vtop[2])/2.
2849 rc,pos,mom = extrapolateToPlane(aTrack,z)
2850 if not rc:
2851 error = "printResiduals: plotBiasedResiduals extrap failed"
2852 ut.reportError(error)
2853 continue
2854 distance = 0
2855 if RTrelations.has_key(rname) or MCdata:
2856 distance = RT(hit,hit.GetDigi())
2857 tmp = (vbot[0] - vtop[0])*pos[1] - (vbot[1] - vtop[1])*pos[0] + vtop[0]*vbot[1] - vbot[0]*vtop[1]
2858 tmp = -tmp/ROOT.TMath.Sqrt( (vtop[0]-vbot[0])**2+(vtop[1]-vbot[1])**2) # to have same sign as difference in X
2859 xL = tmp -distance
2860 xR = tmp +distance
2861 if abs(xL)<abs(xR):res = xL
2862 else: res = xR
2863 tmpList[k]=pos[2]
2864 txt[k]="%i %s %i %5.3F %5.3F %5.3F %5.3F "%( s,view,2*p+l,pos[0],pos[1],pos[2],res)
2865 k+=1
2866 sorted_z = sorted(tmpList.items(), key=operator.itemgetter(1))
2867 for k in sorted_z:
2868 print txt[k[0]]
2869
2870# make TDC plots for hits matched to tracks)

◆ printScalers()

conditionsDatabase.demo.drifttubeMonitoring.printScalers ( )

Definition at line 1261 of file drifttubeMonitoring.py.

1261def printScalers():
1262 ut.bookHist(h,'integratedrate','rate integrated',100,-0.5,99.5)
1263 ut.bookHist(h,'rate','rate',100,-0.5,99.5)
1264 ut.bookHist(h,'scalers','rate',100,-0.5,99.5)
1265 if not h.has_key('rates'): ut.bookCanvas(h,key='rates',title='Rates',nx=800,ny=400,cx=2,cy=1)
1266 rc = h['rates'].cd(1)
1267 scalers = sTree.GetCurrentFile().Get('scalers')
1268 if not scalers:
1269 print "no scalers in this file"
1270 return
1271 scalers.GetEntry(0)
1272 ns = 0
1273 for x in scalers.GetListOfBranches():
1274 name = x.GetName()
1275 s = eval('scalers.'+name)
1276 if name!='slices':
1277 print "%20s :%8i"%(name,s)
1278 rc=h['scalers'].Fill(ns,s)
1279 ns+=1
1280 else:
1281 r0 = 0
1282 for n in range(s.size()):
1283 r0 = s[n] - r0
1284 if r0<0: r0 = s[n]
1285 rc=h['rate'].Fill(n,r0)
1286 rc=h['integratedrate'].Fill(n,s[n])
1287 r0 = s[n]
1288 h['rate'].Draw('hist')
1289 rc = h['rates'].cd(2)
1290 h['integratedrate'].Draw('hist')
1291

◆ printSources()

conditionsDatabase.demo.drifttubeMonitoring.printSources ( )

Definition at line 6861 of file drifttubeMonitoring.py.

6861def printSources():
6862 charmNorm = {1:0.176,10:0.424}
6863 beautyNorm = {1:0., 10:0.01218}
6864 sources = {"":1.,"Hadronic inelastic":100.,"Lepton pair":100.,"Positron annihilation":100.,"charm":1./charmNorm[10],"beauty":1./beautyNorm[10],"Di-muon P8":100.}
6865 print " source P>5GeV/c P>20GeV/c"
6866 for xx in sources:
6867 i='MC'
6868 d='I-'
6869 hname = d+i+'p/pt'+xx+'_x'
6870 hname10 = d+i+'10p/pt'+xx+'_x'
6871 if not h.has_key(hname):continue
6872 ratio = h[hname].GetBinContent(1)/h[d+i+'p/pt_x'].GetBinContent(1)*100
6873 ratio10 = h[hname10].GetBinContent(21)/h[d+i+'10p/pt_x'].GetBinContent(21)*100
6874 print " %25s %4.2F%% %4.2F%% "%(xx,ratio,ratio10)

◆ printTrackMeasurements()

conditionsDatabase.demo.drifttubeMonitoring.printTrackMeasurements (   atrack,
  PR = 1 
)

Definition at line 3816 of file drifttubeMonitoring.py.

3816def printTrackMeasurements(atrack,PR=1):
3817 mult = {'_x':0,'_u':0,'_v':0}
3818 rej = {'_x':0,'_u':0,'_v':0}
3819 if PR==1 and sTree.GetBranch("TrackInfos"):
3820 trInfo = sTree.TrackInfos[atrack]
3821 for n in range(trInfo.N()):
3822 detID = trInfo.detId(n)
3823 hit = ROOT.MufluxSpectrometerHit(detID,0)
3824 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
3825 print "%3i %3i %3i %3i %3s %3i %3i %4.2F %4.2F "%(\
3826 s,v,p,l,view,channelID,tdcId,trInfo.wL(n),trInfo.wR(n))
3827 if trInfo.wL(n)<0.1 and trInfo.wR(n) < 0.1: rej[view]+=1
3828 else: mult[view]+=1
3829 else:
3830 for p in atrack.getPointsWithMeasurement():
3831 rawM = p.getRawMeasurement()
3832 info = p.getFitterInfo()
3833 if not info: continue
3834 detID = rawM.getDetId()
3835 hit = ROOT.MufluxSpectrometerHit(detID,0)
3836 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
3837 coords = rawM.getRawHitCoords()
3838 print "%3i %3i %3i %3i %3s %3i %3i %4.2F %4.2F %5.2F %5.2F %5.2F "%(
3839 s,v,p,l,view,channelID,tdcId,info.getWeights()[0],info.getWeights()[1],coords[0],coords[1],coords[2])
3840 if info.getWeights()[0]<0.1 and info.getWeights()[1] < 0.1: rej[view]+=1
3841 else: mult[view]+=1
3842 print "views used",mult
3843 print "views rejected",rej

◆ pyExit()

conditionsDatabase.demo.drifttubeMonitoring.pyExit ( )

Definition at line 68 of file drifttubeMonitoring.py.

68def pyExit():
69 ut.errorSummary()
70# atexit.register(pyExit)
71

◆ recoMuonTaggerTracks()

conditionsDatabase.demo.drifttubeMonitoring.recoMuonTaggerTracks ( )

Definition at line 7589 of file drifttubeMonitoring.py.

7589def recoMuonTaggerTracks():
7590 global MCdata
7591 global sTree
7592 if sTree.GetBranch('MCTrack'): MCdata = True
7593 fname = sTree.GetCurrentFile().GetName()
7594 if sTree.GetBranch("RPCTrackX"):
7595 print "remove RECO branch and rerun muonTagger reconstruction"
7596 os.system('cp '+fname+' '+fname.replace('.root','orig.root')) # make backup
7597 for br in ['RPCTrackX','RPCTrackY']:
7598 b = sTree.GetBranch(br)
7599 sTree.GetListOfBranches().Remove(b)
7600 l = sTree.GetLeaf(br)
7601 sTree.GetListOfLeaves().Remove(l)
7602 sTree.Write()
7603 fn = sTree.GetCurrentFile().GetName()
7604 f = ROOT.TFile(fn,'update')
7605 sTree = f.cbmsim
7606 fRPCTrackArray = {'X':ROOT.TClonesArray("RPCTrack"),'Y':ROOT.TClonesArray("RPCTrack")}
7607 RPCTrackbranch = {}
7608 for x in fRPCTrackArray:
7609 fRPCTrackArray[x].BypassStreamer(ROOT.kTRUE)
7610 RPCTrackbranch[x] = sTree.Branch("RPCTrack"+x, fRPCTrackArray[x],32000,-1)
7611 for n in range(sTree.GetEntries()):
7612 if n%10000==0: print "Now at event",n,"of",sTree.GetEntries(),sTree.GetCurrentFile().GetName(),time.ctime()
7613 rc = sTree.GetEvent(n)
7614 for x in ['X','Y']: fRPCTrackArray[x].Clear()
7615 if MCdata:
7616 if sTree.FitTracks.GetEntries()==0:
7617 for x in ['X','Y']: RPCTrackbranch[x].Fill()
7618 continue
7619 RPCclusters, RPCtracks = muonTaggerClustering(PR=11)
7620 for x in ['X','Y']:
7621 for aTrack in RPCtracks[x]:
7622 nTrack = fRPCTrackArray[x].GetEntries()
7623 try:
7624 fRPCTrackArray[x][nTrack] = ROOT.RPCTrack(aTrack[0],aTrack[1])
7625 except:
7626 print nTrack,x,aTrack
7627 RPCTrackbranch[x].Fill()
7628 sTree.Write()
7629 ftemp = sTree.GetCurrentFile()
7630 ftemp.Write("",ROOT.TFile.kOverwrite)
7631 ftemp.Close()
7632 ftest = ROOT.TFile(fname)
7633 OK = False
7634 if ftest.GetKey('cbmsim'):
7635 sTree = ftest.cbmsim
7636 check = sTree.GetBranch('RPCTrackY').GetZipBytes()
7637 check += sTree.GetBranch('RPCTrackY').GetZipBytes()
7638 if check/float(sTree.GetBranch('FitTracks').GetZipBytes())>0.003: OK = True
7639 if not OK:
7640 print "muon track reco failed, reinstall original file"
7641 os.system('mv '+fname.replace('.root','orig.root')+' '+fname)
7642 else:
7643 os.system('rm '+fname.replace('.root','orig.root'))
7644 print "finished adding muonTagger tracks",options.listOfFiles
7645 print "make suicid"
7646 os.system('kill '+str(os.getpid()))

◆ recoStep0()

conditionsDatabase.demo.drifttubeMonitoring.recoStep0 ( )

Definition at line 7488 of file drifttubeMonitoring.py.

7488def recoStep0():
7489 global withTDC
7490 withTDC = False
7491 disableBranches()
7492 withMaterial = False
7493 materialEffects(False)
7494 plotBiasedResiduals(PR=1)
7495 makeRTrelations()
7496 RTrelations = {'tMinAndTmax':h['tMinAndTmax']}
7497 for s in h['tMinAndTmax']: RTrelations['rt'+s] = h['rt'+s]
7498 makeRTrelPersistent(RTrelations)

◆ recoStep1()

conditionsDatabase.demo.drifttubeMonitoring.recoStep1 (   PR = 11)

Definition at line 7499 of file drifttubeMonitoring.py.

7499def recoStep1(PR=11):
7500# make fitted tracks
7501 #disableBranches()
7502 global MCdata
7503 fGenFitArray = ROOT.TClonesArray("genfit::Track")
7504 fGenFitArray.BypassStreamer(ROOT.kTRUE)
7505 fitTracks = sTree.Branch("FitTracks", fGenFitArray,32000,-1)
7506 fTrackInfoArray = ROOT.TClonesArray("TrackInfo")
7507 fTrackInfoArray.BypassStreamer(ROOT.kTRUE)
7508 TrackInfos = sTree.Branch("TrackInfos", fTrackInfoArray,32000,-1)
7509 fRPCTrackArray = {'X':ROOT.TClonesArray("RPCTrack"),'Y':ROOT.TClonesArray("RPCTrack")}
7510 RPCTrackbranch = {}
7511 for x in fRPCTrackArray:
7512 fRPCTrackArray[x].BypassStreamer(ROOT.kTRUE)
7513 RPCTrackbranch[x] = sTree.Branch("RPCTrack"+x, fRPCTrackArray[x],32000,-1)
7514 if sTree.GetBranch('MCTrack'): MCdata = True
7515
7516 for n in range(sTree.GetEntries()):
7517 if n%10000==0: print "Now at event",n,"of",sTree.GetEntries(),sTree.GetCurrentFile().GetName(),time.ctime()
7518 rc = sTree.GetEvent(n)
7519 fGenFitArray.Clear()
7520 fTrackInfoArray.Clear()
7521 for x in ['X','Y']: fRPCTrackArray[x].Clear()
7522 theTracks = findTracks(PR)
7523 for aTrack in theTracks:
7524 nTrack = fGenFitArray.GetEntries()
7525 fTrackInfoArray[nTrack] = ROOT.TrackInfo(aTrack)
7526 aTrack.prune("CFL") # aTrack.prune("CURM") # FL keep first and last point only, C deleteTrackRep, W deleteRawMeasurements, I U R M
7527 fGenFitArray[nTrack] = aTrack
7528 RPCclusters, RPCtracks = muonTaggerClustering(PR=11)
7529 for x in ['X','Y']:
7530 for aTrack in RPCtracks[x]:
7531 nTrack = fRPCTrackArray[x].GetEntries()
7532 try:
7533 fRPCTrackArray[x][nTrack] = ROOT.RPCTrack(aTrack[0],aTrack[1])
7534 except:
7535 print nTrack,x,aTrack
7536 RPCTrackbranch[x].Fill()
7537 fitTracks.Fill()
7538 TrackInfos.Fill()
7539 for aTrack in theTracks: aTrack.Delete()
7540 sTree.Write()
7541 makeAlignmentConstantsPersistent()
7542 ftemp=sTree.GetCurrentFile()
7543 ftemp.Write("",ROOT.TFile.kOverwrite)
7544 ftemp.Close()
7545 print "finished adding fitted tracks",options.listOfFiles
7546 print "make suicid"
7547 os.system('kill '+str(os.getpid()))

◆ recoStep2()

conditionsDatabase.demo.drifttubeMonitoring.recoStep2 ( )

Definition at line 7558 of file drifttubeMonitoring.py.

7558def recoStep2():
7559# refit tracks with improved RT relation
7560 global MCdata
7561 fGenFitArray = ROOT.TClonesArray("genfit::Track")
7562 fGenFitArray.BypassStreamer(ROOT.kTRUE)
7563 fitTracks = sTree.Branch("FitTracks_refitted", fGenFitArray,32000,-1)
7564 fTrackInfoArray = ROOT.TClonesArray("TrackInfo")
7565 fTrackInfoArray.BypassStreamer(ROOT.kTRUE)
7566 TrackInfos = sTree.Branch("TrackInfos_refitted", fTrackInfoArray,32000,-1)
7567 if sTree.GetBranch('MCTrack'): MCdata = True
7568 for n in range(sTree.GetEntries()):
7569 if n%10000==0: print "Now at event",n,"of",sTree.GetEntries(),sTree.GetCurrentFile().GetName(),time.ctime()
7570 rc = sTree.GetEvent(n)
7571 fGenFitArray.Clear()
7572 fTrackInfoArray.Clear()
7573 theTracks = findTracks(PR = 13)
7574 for aTrack in theTracks:
7575 nTrack = fGenFitArray.GetEntries()
7576 fTrackInfoArray[nTrack] = ROOT.TrackInfo(aTrack)
7577 aTrack.prune("CFL") # aTrack.prune("CURM") # FL keep first and last point only, C deleteTrackRep, W deleteRawMeasurements, I U R M
7578 fGenFitArray[nTrack] = aTrack
7579 fitTracks.Fill()
7580 TrackInfos.Fill()
7581 for aTrack in theTracks: aTrack.Delete()
7582 sTree.Write()
7583 ftemp=sTree.GetCurrentFile()
7584 ftemp.Write("",ROOT.TFile.kOverwrite)
7585 ftemp.Close()
7586 print "finished adding fitted tracks",options.listOfFiles
7587 print "make suicid"
7588 os.system('kill '+str(os.getpid()))

◆ residualLoop()

conditionsDatabase.demo.drifttubeMonitoring.residualLoop (   nstart = 0,
  nend = 50000 
)

Definition at line 4706 of file drifttubeMonitoring.py.

4706def residualLoop(nstart=0,nend=50000):
4707 for l in range(4):
4708 global exclude_layer
4709 exclude_layer = l
4710 plotBiasedResiduals(nstart,nend,2)
4711 for s in ['1_x','1_u','2_x','2_u','3_x','4_x']:
4712 name = 'biasResX_'+s+str(2*p+l)
4713 h['un'+name] = h[name].Clone('un'+name)
4714 name = 'biasResY_'+s+str(2*p+l)
4715 h['un'+name] = h[name].Clone('un'+name)
4716 exclude_layer = None
4717 if not h.has_key('unbiasedResiduals'):
4718 ut.bookCanvas(h,key='unbiasedResiduals',title='unbiasedResiduals',nx=1600,ny=1200,cx=4,cy=6)
4719 ut.bookCanvas(h,key='unbiasedResidualsX',title='unbiasedResiduals function of X',nx=1600,ny=1200,cx=4,cy=6)
4720 ut.bookCanvas(h,key='unbiasedResidualsY',title='unbiasedResiduals function of Y',nx=1600,ny=1200,cx=4,cy=6)
4721 j=1
4722 for s in range(1,5):
4723 for view in ['_x','_u','_v']:
4724 if s>2 and view != '_x': continue
4725 if s==1 and view == '_v' or s==2 and view == '_u': continue
4726 for l in range(0,4):
4727 hname = 'biasResX_'+str(s)+view+str(l)
4728 hnameProjX = 'biasRes_'+str(s)+view+str(l)
4729 if h[hname].GetEntries()<10:
4730 h[hnameProjX].Draw()
4731 j+=1
4732 continue
4733 h[hnameProjX] = h[hname].ProjectionX()
4734 tc = h['unbiasedResiduals'].cd(j)
4735 fitResult = h[hnameProjX].Fit('gaus','SQ','',-0.5,0.5)
4736 rc = fitResult.Get()
4737 if not rc:
4738 # print "simple gaus fit failed"
4739 myGauss.SetParameter(0,h[hnameProjX].GetEntries())
4740 myGauss.SetParameter(1,0.)
4741 myGauss.SetParameter(2,0.1)
4742 myGauss.SetParameter(3,1.)
4743 else:
4744 myGauss.SetParameter(0,rc.GetParams()[0])
4745 myGauss.SetParameter(1,rc.GetParams()[1])
4746 myGauss.SetParameter(2,rc.GetParams()[2])
4747 myGauss.SetParameter(3,0.)
4748 fitResult = h[hnameProjX].Fit(myGauss,'SQ','',-0.2,0.2)
4749 fitResult = h[hnameProjX].Fit(myGauss,'SQ','',-0.5,0.5)
4750 rc = fitResult.Get()
4751 if not rc:
4752 print hnameProjX
4753 h[hnameProjX].Draw()
4754 j+=1
4755 continue
4756 tc.Update()
4757 stats = h[hnameProjX].FindObject("stats")
4758 stats.SetX1NDC(0.563258)
4759 stats.SetY1NDC(0.526687)
4760 stats.SetX2NDC(0.938728)
4761 stats.SetY2NDC(0.940086)
4762 stats.SetOptFit(111)
4763 stats.SetOptStat(0)
4764 mean = rc.GetParams()[1]
4765 rms = rc.GetParams()[2]
4766 Emean = rc.GetErrors()[1]
4767 Erms = rc.GetErrors()[2]
4768 print "%i, %s, %i mean=%5.2F+/-%5.2F RMS=%5.2F+/-%5.2F [mm]"%(s,view,l,mean*10,Emean*10,rms*10,Erms*10)
4769 residuals[j-1]= h[hnameProjX].GetMean() # fitresult too unstable, mean
4770 # make plot of mean as function of X,Y
4771 for p in ['X','Y']:
4772 hname = 'biasRes'+p+'_'+str(s)+view+str(l)
4773 hmean = hname+'_mean'+p
4774 h[hmean] = h[hname].ProjectionY(hname+'_mean')
4775 h[hmean].Reset()
4776 rc = h['unbiasedResiduals'+p].cd(j)
4777 for k in range(1,h[hname].GetNbinsY()+1):
4778 sli = hname+'_'+str(k)
4779 h[sli] = h[hname].ProjectionX(sli,k,k)
4780 if h[sli].GetEntries()<10: continue
4781 myGauss.SetParameter(0,h[sli].GetMaximum())
4782 myGauss.SetParameter(1,0.)
4783 myGauss.SetParameter(2,0.1)
4784 myGauss.SetParameter(3,1.)
4785 fitResult = h[sli].Fit(myGauss,'SQ','',-5.,5.)
4786 rc = fitResult.Get()
4787 mean,rms = 0,0
4788 if rc:
4789 mean = rc.GetParams()[1]
4790 rms = rc.GetParams()[2]
4791 rc = h[hmean].Fill( h[hmean].GetBinCenter(k), mean)
4792 amin,amax,nmin,nmax = ut.findMaximumAndMinimum(h[hmean])
4793 if amax<3. and amin>-3.:
4794 h[hmean].SetMaximum(2.)
4795 h[hmean].SetMinimum(-2.)
4796 else:
4797 h[hmean].SetLineColor(ROOT.kRed)
4798 h[hmean].SetMaximum(10.)
4799 h[hmean].SetMinimum(-10.)
4800 h[hmean].Draw()
4801 j+=1
4802

◆ residualsExamples()

conditionsDatabase.demo.drifttubeMonitoring.residualsExamples ( )

Definition at line 7242 of file drifttubeMonitoring.py.

7242def residualsExamples():
7243 h['example'] = h['biasResDist_4_x2'].ProjectionY('example',40,60)
7244 h['example'].GetXaxis().SetRangeUser(-0.5,0.5)
7245 fitFunction = h['biasResX_1_x1_px'].GetFunction('gauss')
7246 fitResult = h['example'].Fit(fitFunction,'S','',-0.2,0.2)
7247 fitFunction.ReleaseParameter(3)
7248 fitResult = h['example'].Fit(fitFunction,'S','',-0.2,0.2)
7249 stats = h['Residualsexample'].GetPrimitive('stats')
7250 stats.SetOptFit(10111)
7251 stats.SetFitFormat('5.4g')
7252 stats.SetX1NDC(0.6)
7253 stats.SetY1NDC(0.5)
7254 stats.SetX2NDC(0.98)
7255 stats.SetY2NDC(0.94)
7256
7257 h['example2'] = h['biasResDistLR_4_x2'].ProjectionY('example',40,60)
7258 fitResult = h['example'].Fit(fitFunction,'S','',-0.2,0.2)
7259
7260

◆ RPCPosition()

conditionsDatabase.demo.drifttubeMonitoring.RPCPosition ( )

Definition at line 4532 of file drifttubeMonitoring.py.

4532def RPCPosition():
4533 for s in range(1,6):
4534 for v in range(2):
4535 for c in range(1,185):
4536 if v==0 and c>116: continue
4537 detID = s*10000+v*1000+c
4538 hit = ROOT.MuonTaggerHit(detID,0)
4539 a,b = correctAlignmentRPC(hit,v)
4540 RPCPositionsBotTop[detID] = [a.Clone(),b.Clone()]
4541 x = (a[0]+b[0])/2.
4542 y = (a[1]+b[1])/2.
4543 z = (a[2]+b[2])/2.
4544 muflux_Reco.setRPCPositions(detID,x,y,z)
4545

◆ RPCResolution()

conditionsDatabase.demo.drifttubeMonitoring.RPCResolution ( )

Definition at line 4169 of file drifttubeMonitoring.py.

4169def RPCResolution():
4170 vtop = ROOT.TVector3()
4171 vbot = ROOT.TVector3()
4172 for s in range(1,6):
4173 for v in range(2):
4174 ut.bookHist(h,'RPC'+str(s)+str(v),'hit resolution',100,-10.,10.)
4175 for n in range(sTree.GetEntries()):
4176 rc = sTree.GetEvent(n)
4177# check for MCTrack
4178 track={}
4179 for m in sTree.MuonTaggerPoint:
4180 t = m.GetTrackID()
4181 if not track.has_key(t): track[t]=[]
4182 track[t].append([m.GetDetectorID(),m.GetX(),m.GetY()])
4183 if len(track)!=1: continue
4184 for t in track:
4185 for d in track[t]:
4186 plane = d[0]/10000
4187 truex,truey = d[1],d[2]
4188 for hit in sTree.Digi_MuonTaggerHits:
4189 channelID = hit.GetDetectorID()
4190 s = channelID/10000
4191 v = (channelID-10000*s)/1000
4192 vtop,vbot = RPCPositionsBotTop[channelID]
4193 if plane == s:
4194 if v==0: delpos = (vtop[1]+vbot[1])/2. - truey
4195 if v==1: delpos = (vtop[0]+vbot[0])/2. - truex
4196 h['RPC'+str(s)+str(v)].Fill(delpos)
4197

◆ RT()

conditionsDatabase.demo.drifttubeMonitoring.RT (   hit,
  t 
)

Definition at line 1467 of file drifttubeMonitoring.py.

1467def RT(hit,t):
1468# rt relation, drift time to distance
1469 R = ShipGeo.MufluxSpectrometer.InnerTubeDiameter/2. # = 3.63*u.cm
1470 t0 = 0
1471 if MCdata:
1472 t0 = t-sTree.ShipEventHeader.GetEventTime()
1473 r = t0*ShipGeo.MufluxSpectrometer.v_drift
1474 if MCsmearing:
1475 r+=rnr.Gaus(0,MCsmearing)
1476 r=abs(r)
1477 else:
1478 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
1479 if nRT in [16,17]: nRT = 18
1480 if nRT in [30,31]: nRT = 32 # not enough statistics for left and right of T3
1481 name = 'TDC'+str(nRT)
1482 if t==0: t=0.1
1483 if t > h['tMinAndTmax'][name][1]: r = R
1484 elif t< h['tMinAndTmax'][name][0]: r = 0
1485 else:
1486 r = h['rt'+name].Eval(t)
1487 if h.has_key('RTcorr'): r+=h['RTcorrFun_'+str(s)+view+str(2*p+l)].Eval(r)
1488 h['TDC2R'].Fill(t-t0,r)
1489 return r
1490

◆ singlePtSlices()

conditionsDatabase.demo.drifttubeMonitoring.singlePtSlices ( )

Definition at line 6842 of file drifttubeMonitoring.py.

6842def singlePtSlices():
6843 t='MC-Comparison Pt'
6844 tx = h['dummy'].cd()
6845 tx.SetLogy(0)
6846 for c in h[t].GetListOfPrimitives():
6847 histos = {}
6848 k = 2
6849 for p in c.GetListOfPrimitives():
6850 if p.GetName().find('p/pt')==0: histos[1]=p
6851 elif p.GetName().find('MCp/pt')==0:
6852 histos[k]=p
6853 k+=1
6854 elif p.GetTitle().find('Legend')==0:histos[0]=p
6855 histos[1].Draw()
6856 histos[1].Draw('histsame')
6857 for i in range(k): histos[i].Draw('same')
6858 histos[0].Draw()
6859 myPrint(h['dummy'],c.GetName().replace(' ',''))
6860

◆ splitOffBoostedEvents()

conditionsDatabase.demo.drifttubeMonitoring.splitOffBoostedEvents ( )

Definition at line 5511 of file drifttubeMonitoring.py.

5511def splitOffBoostedEvents():
5512 curFile = sTree.GetCurrentFile().GetName()
5513 newFile1 = curFile.replace(".root","_dimuon99.root")
5514 newFile2 = curFile.replace(".root","_dimuon1.root")
5515 os.system('cp '+curFile+' '+newFile1)
5516 os.system('cp '+curFile+' '+newFile2)
5517 # make new files without reco branches
5518 sTree.SetBranchStatus("FitTracks",0)
5519 sTree.SetBranchStatus("RPCTrackX",0)
5520 sTree.SetBranchStatus("RPCTrackY",0)
5521 sTree.SetBranchStatus("TrackInfos",0)
5522 newf1 = ROOT.TFile(newFile1,"recreate")
5523 newTree1 = sTree.CloneTree(0)
5524 newf2 = ROOT.TFile(newFile2,"recreate")
5525 newTree2 = sTree.CloneTree(0)
5526 for n in range(sTree.GetEntries()):
5527 rc = sTree.GetEntry(n)
5528 if checkForDiMuon() and rnr.Uniform(0.,1.)<0.99: rc = newTree1.Fill() # dimuon99
5529 else: rc = newTree2.Fill() # dimuon1
5530 sTree.Clear()
5531 newTree1.AutoSave()
5532 newf1.Close()
5533 newTree2.AutoSave()
5534 newf2.Close()
5535 newf1 = ROOT.TFile(newFile1)
5536 newf2 = ROOT.TFile(newFile2)
5537 n12 = newf1.cbmsim.GetEntries() + newf2.cbmsim.GetEntries()
5538 N = sTree.GetEntries()
5539 newf1.Close()
5540 newf2.Close()
5541 sTree.GetCurrentFile().Close()
5542 if n12 == N:
5543 print "check OK"
5544 os.system('mv '+newFile2+' '+curFile)
5545 else: print "unitarity violated",f,n1,n2,sTree.GetEntries()

◆ stationInfo()

conditionsDatabase.demo.drifttubeMonitoring.stationInfo (   hit)

Definition at line 974 of file drifttubeMonitoring.py.

974def stationInfo(hit):
975 info = hit.StationInfo()
976 return info[0],info[1],info[2],info[3],viewDict[info[4]],info[5],info[6],info[7]/cuts['RTsegmentation']
977 # statnb, vnb, pnb, lnb, view, channelID,tdcId, nRT
978

◆ strawPosition()

conditionsDatabase.demo.drifttubeMonitoring.strawPosition ( )

Definition at line 4524 of file drifttubeMonitoring.py.

4524def strawPosition():
4525 for detID in alignConstants['strawPositions']:
4526 b = alignConstants['strawPositions'][detID]['bot']
4527 t = alignConstants['strawPositions'][detID]['top']
4528 strawPositionsBotTop[detID]=[ROOT.TVector3(b[0],b[1],b[2]),ROOT.TVector3(t[0],t[1],t[2])]
4529 muflux_Reco.setDTPositions(int(detID),t[0],t[1],t[2],b[0],b[1],b[2])
4530

◆ studyDeltaRays()

conditionsDatabase.demo.drifttubeMonitoring.studyDeltaRays (   onlyPlots = False)

Definition at line 4989 of file drifttubeMonitoring.py.

4989def studyDeltaRays(onlyPlots=False):
4990 if onlyPlots:
4991 interestingHistos=['station1Occ','station1OccX','deltaRay','deltaRayN','deltaRayNvsE']
4992 ut.readHists(hMC,"deltaRaysMC.root",interestingHistos)
4993 ut.readHists(h,"deltaRays.root",interestingHistos)
4994 ut.bookCanvas(h,"s1Occ","station 1 occupancy",1200,900,1,1)
4995 tc = h["s1Occ"].cd(1)
4996 tc.SetLogy()
4997 h['MCstation1Occ']=hMC['station1Occ'].Clone('MCstation1Occ')
4998 A = h['station1Occ'].GetBinContent(4)+h['station1Occ'].GetBinContent(5)
4999 B = hMC['station1Occ'].GetBinContent(4)+hMC['station1Occ'].GetBinContent(5)
5000 h['MCstation1Occ'].Scale(A/B)
5001 h['station1Occ'].Draw()
5002 h['MCstation1Occ'].SetLineColor(ROOT.kRed)
5003 h['MCstation1Occ'].Draw("same")
5004 return
5005 #MC
5006 ut.bookHist(h,'station1Occ','station1 Occupancy',50,0.0,50.)
5007 ut.bookHist(h,'station1OccX','station1 Occupancy deltaRay present',50,0.0,50.)
5008 ut.bookHist(h,'deltaRay','E vs z',100,-1.0,1.0,100,0.0,10.)
5009 ut.bookHist(h,'deltaRayN','hits vs z',100,-1.0,1.0,50,0.0,50.)
5010 ut.bookHist(h,'deltaRayNvsE','hits vs E',100,0.0,10.0,50,0.0,50.)
5011 for n in range(sTree.GetEntries()):
5012 rc=sTree.GetEvent(n)
5013 if not (sTree.RPCTrackX.GetEntries()==1) or not (sTree.RPCTrackY.GetEntries()==1) : continue
5014 N=0
5015 spectrHitsSorted = ROOT.nestedList()
5016 muflux_Reco.sortHits(sTree.Digi_MufluxSpectrometerHits,spectrHitsSorted,True)
5017 for l in range(4): N+= len(spectrHitsSorted[0][1][l])
5018 rc = h['station1Occ'].Fill(N)
5019 if MCdata:
5020 found = False
5021 for m in sTree.MCTrack:
5022 pName = m.GetProcName().Data()
5023 if not pName.find('Delta ray')<0:
5024 if m.GetStartZ()/100. < 0.05 and m.GetStartZ()/100. > -0.3:
5025 rc = h['deltaRayNvsE'].Fill(m.GetP(),N)
5026 if m.GetP()>0.01:
5027 rc = h['station1OccX'].Fill(N)
5028 found = True
5029 rc = h['deltaRay'].Fill(m.GetStartZ()/100.,m.GetP())
5030 rc = h['deltaRayN'].Fill(m.GetStartZ()/100.,N)
5031 # if not found and N>8: sTree.MCTrack.Dump()
5032 tmp = sTree.GetCurrentFile().GetName()
5033 k = tmp.find('SPILLDATA')
5034 if k<0: outFile = 'deltaRays-'+tmp
5035 else: outFile = 'deltaRays-'+tmp[k:]
5036 ut.writeHists(h,outFile)
5037

◆ studyGhosts()

conditionsDatabase.demo.drifttubeMonitoring.studyGhosts ( )

Definition at line 5058 of file drifttubeMonitoring.py.

5058def studyGhosts():
5059 ut.readHists(h,'ghostStudy.root')
5060 ut.bookCanvas(h,'ghosts','ghosts',1600,700,1,1)
5061 h['gf_perfect'].SetTitle(' ;#it{p} [GeV/c];N/5GeV')
5062 h['gf_perfect'].SetLineColor(ROOT.kGreen)
5063 h['gf_ghosts'].SetTitle('ghost > 33;#it{p}[GeV/c];N/5GeV')
5064 h['ghosts'].cd(1).SetLogy(1)
5065 h['gf_perfect'].Draw()
5066 for x in ['gf_perfect','gf_ghosts','P','Ptrue']:
5067 h[x].SetLineWidth(2)
5068 h[x].SetStats(0)
5069 h[x].Draw('same')
5070 h[x].Draw('hist same')
5071 #h[x].Rebin(5)
5072 myPrint(h['ghosts'],'ghostStudy')
5073 h['gf_perfect'].GetXaxis().SetRangeUser(250.,500.)
5074 h['ghosts'].Update()
5075 myPrint(h['ghosts'],'ghostStudy_zoom')
5076# back ground subtraction
5077 badTracks = h['P'].GetBinContent(h['P'].GetNbinsX())
5078 h['P_backsubtr']= h['P'].Clone('P_backsubtr')
5079 h['P_backsubtr'].SetLineColor(ROOT.kCyan)
5080 for n in range(1,h['P'].GetNbinsX()):
5081 h['P_backsubtr'].SetBinContent(n,h['P'].GetBinContent(n)-badTracks)
5082 h['P_backsubtr'].Draw()
5083 h['P'].Draw('same')
5084 h['gf_perfect'].Draw('same')
5085 h['ghosts'].Update()
5086 myPrint(h['ghosts'],'ghostStudy_backsubtr')
5087#
5088 for x in ['gfDiff']:
5089 h[x+'_perfect'] =h[x].ProjectionY(x+'_perfect',1,1)
5090 h[x+'_ghosts'] =h[x].ProjectionY(x+'_ghosts',33,100)
5091 h[x+'_ghosts'].SetLineColor(ROOT.kRed)
5092 h[x+'_perfect'].SetLineColor(ROOT.kGreen)
5093 h[x+'_perfect'].SetTitle('perfect;#it{p} [GeV/c];N/5GeV')
5094 h[x+'_ghosts'].SetTitle('ghost > 33;#it{p} [GeV/c];N/5GeV')
5095 for x in ['gfDiff_perfect','gfDiff_ghosts']:
5096 h[x].Rebin(5)
5097 ut.makeIntegralDistrib(h,x)
5098 h['I-'+x].Scale(1./h['I-'+x].GetBinContent(1))
5099 h['I-'+x].SetLineWidth(2)
5100 h['I-'+x].SetStats(0)
5101 if x.find('perfect')>0:
5102 h['I-'+x].SetMinimum(0.001)
5103 h['I-'+x].Draw()
5104 h['I-'+x].Draw('hist same')
5105 h['I-'+x].Draw('hist same')
5106 h['ghosts'].Update()
5107 myPrint(h['ghosts'],'ghostStudy_tails')
5108

◆ studyGhostTracks()

conditionsDatabase.demo.drifttubeMonitoring.studyGhostTracks (   nStart = 0,
  nEnd = 0,
  chi2UL = 3,
  pxLow = 5. 
)

Definition at line 5109 of file drifttubeMonitoring.py.

5109def studyGhostTracks(nStart = 0, nEnd=0, chi2UL=3,pxLow=5.):
5110 if nEnd == 0: nEnd = sTree.GetEntries()
5111 for n in range(nStart,nEnd):
5112 rc = sTree.GetEvent(n)
5113 N = -1
5114 for aTrack in sTree.FitTracks:
5115 N+=1
5116 fitStatus = aTrack.getFitStatus()
5117 if not fitStatus.isFitConverged(): continue
5118# track quality
5119 hitsPerStation = countMeasurements(N,1)
5120 if len(hitsPerStation['x1'])<2: continue
5121 if len(hitsPerStation['x2'])<2: continue
5122 if len(hitsPerStation['x3'])<2: continue
5123 if len(hitsPerStation['x4'])<2: continue
5124 chi2 = fitStatus.getChi2()/fitStatus.getNdf()
5125 fittedState = aTrack.getFittedState()
5126 P = fittedState.getMomMag()
5127 Px,Py,Pz = fittedState.getMom().x(),fittedState.getMom().y(),fittedState.getMom().z()
5128 if chi2 > chi2UL: continue
5129 if Px<pxLow: continue
5130# check for muon tag
5131 rc,posRPC,momRPC = extrapolateToPlane(aTrack,zRPC1)
5132 if rc:
5133 tagged = {'X':False,'Y':False}
5134 for proj in ['X','Y']:
5135 if proj=='X':
5136 for mu in sTree.RPCTrackX:
5137 if abs(posRPC[0]-mu.m()*zRPC1+mu.b() ) < cuts['muTrackMatch'+proj]: tagged[proj]=True
5138 if proj=='Y':
5139 for mu in sTree.RPCTrackY:
5140 if abs(posRPC[0]-mu.m()*zRPC1+mu.b() )< cuts['muTrackMatch'+proj]: tagged[proj]=True
5141 if not tagged['X'] or not tagged['Y'] : # not within ~3sigma of any mutrack
5142 print n
5143

◆ studyLateDTHits()

conditionsDatabase.demo.drifttubeMonitoring.studyLateDTHits (   nevents = 1000,
  nStart = 0 
)

Definition at line 1110 of file drifttubeMonitoring.py.

1110def studyLateDTHits(nevents=1000,nStart=0):
1111 ut.bookHist(h,'multLateDTHits','multiplicity of late DT hits',11,-1.5,9.5)
1112 ut.bookHist(h,'ToverTvsTDC','Time over threshold vs tdc',300,-1000.,2000.,300,-1000.,2000.)
1113 nHits=0
1114 for n in range(nStart,nevents):
1115 rc=sTree.GetEvent(n)
1116 keysToDThits=MakeKeysToDThits()
1117 for channel in keysToDThits:
1118 if keysToDThits[channel][0]<0: rc=h['multLateDTHits'].Fill(-1)
1119 else:
1120 nHits+=1
1121 rc=h['multLateDTHits'].Fill(len(keysToDThits[channel])-1)
1122 for n in range(1,len(keysToDThits[channel])):
1123 key = keysToDThits[channel][n]
1124 aHit = sTree.Digi_LateMufluxSpectrometerHits[key]
1125 rc=h['ToverTvsTDC'].Fill( aHit.GetTimeOverThreshold() ,aHit.GetDigi())
1126 ROOT.gROOT.FindObject('c1').cd()
1127 h['multLateDTHits'].Draw()
1128 print "nHits",nHits

◆ studyScintillator()

conditionsDatabase.demo.drifttubeMonitoring.studyScintillator ( )

Definition at line 5144 of file drifttubeMonitoring.py.

5144def studyScintillator():
5145 ut.bookHist(h,'sc','sc',1000,-500.,2000.)
5146 ut.bookHist(h,'sc6','sc',1000,-500.,2000.)
5147 ut.bookHist(h,'sc7','sc',1000,-500.,2000.)
5148 ut.bookHist(h,'scmult','sc multiplicity',10,-0.5,9.5)
5149 for n in range(sTree.GetEntries()):
5150 rc=sTree.GetEvent(n)
5151 rc=h['scmult'].Fill(sTree.Digi_ScintillatorHits.GetEntries())
5152 for sc in sTree.Digi_ScintillatorHits:
5153 rc=h['sc'].Fill(sc.GetDigi())
5154 rc=h['sc'+str(sc.GetDetectorID())].Fill(sc.GetDigi())
5155

◆ surveyVSfairship()

conditionsDatabase.demo.drifttubeMonitoring.surveyVSfairship ( )

Definition at line 752 of file drifttubeMonitoring.py.

752def surveyVSfairship():
753 print "z-positions relative to station 1"
754 test = ROOT.MufluxSpectrometerHit(10002012,0.)
755 test.MufluxSpectrometerEndPoints(vbot,vtop)
756 z1 = (surveyXYZ['T1_MA_01'][2]+surveyXYZ['T1_MA_04'][2])/2.+3.03
757 z1F = vtop[2]
758 print " X topY botY Z"
759 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T1_MA_01/04 survey corrected",(surveyXYZ['T1_MA_01'][0]+surveyXYZ['T1_MA_04'][0])/2.,surveyXYZ['T1_MA_01'][1],surveyXYZ['T1_MA_04'][1],z1-z1)
760 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T1_MA_01/04 Daniel ",(daniel['T1_MA_01'][0]+daniel['T1_MA_04'][0])/2.,daniel['T1_MA_01'][1],daniel['T1_MA_04'][1],(daniel['T1_MA_01'][2]+daniel['T1_MA_04'][2])/2.+3.03-z1)
761 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("tube 10002012 ",vtop[0],vbot[1],vtop[1],vtop[2]-z1F)
762# same station
763 vtop2,vbot2 = ROOT.TVector3(),ROOT.TVector3()
764 test2 = ROOT.MufluxSpectrometerHit(10102001,0.)
765 test2.MufluxSpectrometerEndPoints(vbot2,vtop2)
766 delx = (daniel['T1_MA_01'][0]+daniel['T1_MA_04'][0])/2.-(daniel['T1_MA_02'][0]+daniel['T1_MA_03'][0])/2.
767 dely = [daniel['T1_MA_01'][1]-daniel['T1_MA_02'][1],daniel['T1_MA_04'][1]-daniel['T1_MA_03'][1]]
768 delz = ((daniel['T1_MA_01'][2]+daniel['T1_MA_04'][2])/2.+3.03) - ((daniel['T1_MA_02'][2]+daniel['T1_MA_03'][2])/2.+3.03+3.64+4.06)
769 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T1_MA_01/04 - T1_MA_02/03 ",delx,dely[0],dely[1],delz)
770 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("tube 10002012 - 10102001 ",vtop[0]-vtop2[0],vtop[1]-vtop2[1],vbot[1]-vbot2[1],vtop[2]-vtop2[2])
771 test = ROOT.MufluxSpectrometerHit(21112001,0.)
772 test.MufluxSpectrometerEndPoints(vbot,vtop)
773 z2 = (surveyXYZ['T2_MD_02'][2]+surveyXYZ['T2_MD_03'][2])/2.-3.03
774 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T2_MD_02/03 survey corrected",(surveyXYZ['T2_MD_02'][0]+surveyXYZ['T2_MD_03'][0])/2.,surveyXYZ['T2_MD_02'][1],surveyXYZ['T2_MD_03'][1],z2-z1)
775 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T2_MD_02/03 Daniel ",(daniel['T2_MD_02'][0]+daniel['T2_MD_03'][0])/2.,daniel['T2_MD_02'][1],daniel['T2_MD_03'][1],(daniel['T2_MD_02'][2]+daniel['T2_MD_03'][2])/2.-3.03-z1)
776 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("tube 21112001 ",vtop[0],vbot[1],vtop[1],vtop[2]-z1F)
777 test = ROOT.MufluxSpectrometerHit(11002012,0.)
778 test.MufluxSpectrometerEndPoints(vbot,vtop)
779 z1b = (surveyXYZ['T1_MB_01'][2]+surveyXYZ['T1_MB_04'][2])/2.-3.03-3.64-4.06-3.64
780 z1bF = vtop[2]
781 m = (surveyXYZ['T1_MB_01'][1]-surveyXYZ['T1_MB_04'][1])/(surveyXYZ['T1_MB_01'][0]-surveyXYZ['T1_MB_04'][0])
782 b = surveyXYZ['T1_MB_01'][1] - m*surveyXYZ['T1_MB_01'][0]
783 xposAty0 = -b/m
784 m = (daniel['T1_MB_01'][1]-daniel['T1_MB_04'][1])/(daniel['T1_MB_01'][0]-daniel['T1_MB_04'][0])
785 b = daniel['T1_MB_01'][1] - m*daniel['T1_MB_01'][0]
786 xposAty0D = -b/m
787 m = (vbot[1]-vtop[1])/(vbot[0]-vtop[0])
788 b = vbot[1] - m*vbot[0]
789 xposAty0F = -b/m
790 print " X@Y=0 topY botY Z"
791 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T1_MB_01/04 survey corrected",xposAty0,surveyXYZ['T1_MB_01'][1],surveyXYZ['T1_MB_04'][1],z1b-z1)
792 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T1_MB_01/04 Daniel ",xposAty0D,daniel['T1_MB_01'][1],daniel['T1_MB_04'][1],(daniel['T1_MB_01'][2]+daniel['T1_MB_04'][2])/2.-3.03-3.64-4.06-3.64-z1)
793 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("tube 11002012 ",xposAty0F,vbot[1],vtop[1],vtop[2]-z1F)
794 test = ROOT.MufluxSpectrometerHit(20012012,0.)
795 test.MufluxSpectrometerEndPoints(vbot,vtop)
796 z2b = (surveyXYZ['T2_MC_01'][2]+surveyXYZ['T2_MC_04'][2])/2.+3.03+3.64
797 m = (surveyXYZ['T2_MC_01'][1]-surveyXYZ['T2_MC_04'][1])/(surveyXYZ['T2_MC_01'][0]-surveyXYZ['T2_MC_04'][0])
798 b = surveyXYZ['T2_MC_01'][1] - m*surveyXYZ['T2_MC_01'][0]
799 xposAty0 = -b/m
800 m = (daniel['T2_MC_01'][1]-daniel['T2_MC_04'][1])/(daniel['T2_MC_01'][0]-daniel['T2_MC_04'][0])
801 b = daniel['T2_MC_01'][1] - m*daniel['T2_MC_01'][0]
802 xposAty0D = -b/m
803 m = (vbot[1]-vtop[1])/(vbot[0]-vtop[0])
804 b = vbot[1] - m*vbot[0]
805 xposAty0F = -b/m
806 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T2_MC_01/04 survey corrected",xposAty0,surveyXYZ['T2_MC_01'][1],surveyXYZ['T2_MC_04'][1],z2b-z1)
807 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T2_MC_01/04 Daniel ",xposAty0D,daniel['T2_MC_01'][1],daniel['T2_MC_04'][1],(daniel['T2_MC_01'][2]+daniel['T2_MC_04'][2])/2.+3.03+3.64-z1)
808 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("tube 20012012 ",xposAty0F,vbot[1],vtop[1],vtop[2]-z1F)
809 test = ROOT.MufluxSpectrometerHit(30012046,0.)
810 test.MufluxSpectrometerEndPoints(vbot,vtop)
811 # For T3 it is placed 7cm in front and for T4 7cm behind the endplate
812 z3 = (surveyXYZ['T3_T01'][2]+surveyXYZ['T3_B01'][2])/2.+4.33+3.64 + 7.0
813 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T3_T01/B01 survey corrected",(surveyXYZ['T3_T01'][0]+surveyXYZ['T3_B01'][0])/2.,surveyXYZ['T3_T01'][1],surveyXYZ['T3_B01'][1],z3-z1)
814 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T3_T01/B01 Daniel ",(daniel['T3_T01'][0]+daniel['T3_B01'][0])/2.,daniel['T3_T01'][1],daniel['T3_B01'][1],(daniel['T3_T01'][2]+daniel['T3_B01'][2])/2.+4.33+3.64-z1)
815 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("tube 30012046 ",vtop[0],vbot[1],vtop[1],vtop[2]-z1F)
816 test = ROOT.MufluxSpectrometerHit(40102046,0.)
817 test.MufluxSpectrometerEndPoints(vbot,vtop)
818 z4 = (surveyXYZ['T4_T01'][2]+surveyXYZ['T4_B01'][2])/2.-4.33-3.64 - 7.0
819 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T4_T01/B01 survey corrected",(surveyXYZ['T4_T01'][0]+surveyXYZ['T4_B01'][0])/2.,surveyXYZ['T4_T01'][1],surveyXYZ['T4_B01'][1],z4-z1)
820 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("T4_T01/B01 Daniel ",(daniel['T4_T01'][0]+daniel['T4_B01'][0])/2.,daniel['T4_T01'][1],daniel['T4_B01'][1],(daniel['T4_T01'][2]+daniel['T4_B01'][2])/2.-4.33-3.64-z1)
821 print "%s, %7.3F,%7.3F,%7.3F,%7.3F"%("tube 40102046 ",vtop[0],vbot[1],vtop[1],vtop[2]-z1F)
822

◆ synchFigures()

conditionsDatabase.demo.drifttubeMonitoring.synchFigures ( )

Definition at line 6838 of file drifttubeMonitoring.py.

6838def synchFigures():
6839 for x in ['MC-ComparisonChi2mu_*P*.pdf','MC-ComparisonPt_*.pdf','True-RecoP*.pdf','MC-ComparisonChi2Ratios2Dppt.pdf','MC-ComparisonChi2DatapPt.pdf']:
6840 os.system('cp '+x+' /mnt/hgfs/Images/VMgate/muflux/ ')
6841

◆ testClusters()

conditionsDatabase.demo.drifttubeMonitoring.testClusters (   nEvent = -1,
  nTot = 1000 
)

Definition at line 2823 of file drifttubeMonitoring.py.

2823def testClusters(nEvent=-1,nTot=1000):
2824 eventRange = [0,sTree.GetEntries()]
2825 if not nEvent<0: eventRange = [nEvent,nEvent+nTot]
2826 for Nr in range(eventRange[0],eventRange[1]):
2827 sTree.GetEvent(Nr)
2828 print "===== New Event =====",Nr
2829 plotEvent(Nr)
2830 trackCandidates = findTracks()
2831 print "tracks found",len(trackCandidates)
2832 for aTrack in trackCandidates:
2833 displayTrack(aTrack)
2834 next = raw_input("Next (Ret/Quit): ")
2835 if next<>'': break
2836

◆ testConvOfGausses()

conditionsDatabase.demo.drifttubeMonitoring.testConvOfGausses ( )

Definition at line 3224 of file drifttubeMonitoring.py.

3224def testConvOfGausses():
3225 h['biasResX_all']=h['biasResX_1_x1_projx'].Clone('biasResX_all')
3226 h['biasResX_all'].Reset()
3227 for s in xLayers:
3228 for p in xLayers[s]:
3229 for l in xLayers[s][p]:
3230 for view in xLayers[s][p][l]:
3231 h['biasResX_all'].Add(h['biasResX_'+str(s)+view+str(2*p+l)+'_projx'])
3232 dr = 0.1
3233 r = 0
3234 h['test'] = h['biasResDist_projy'].Clone('test')
3235 h['test'].Reset()
3236 h['test0'] = h['test'].Clone('test0')
3237 for k in range( int(1.8/dr)):
3238 r+=dr
3239 offset = h['RTcorr'].Eval(r)
3240 sigma = 0.04
3241 for n in range(10000):
3242 rr = rnr.Gaus(offset,sigma)
3243 rc = h['test'].Fill(rr)
3244 rr = rnr.Gaus(0.,sigma)
3245 rc = h['test0'].Fill(rr)
3246
3247

◆ testForSameDetID()

conditionsDatabase.demo.drifttubeMonitoring.testForSameDetID (   nEvent = -1,
  nTot = 1000 
)

Definition at line 4914 of file drifttubeMonitoring.py.

4914def testForSameDetID(nEvent=-1,nTot=1000):
4915 ut.bookHist(h,'multHits','DT hits multiplicity',10,-0.5,9.5)
4916 ut.bookHist(h,'multHits_deltaT','DT multiple hits delta T',100,0.,2000.)
4917 ut.bookHist(h,'multHits_deltaTz','DT multiple hits delta T',400,-200.,200.)
4918 eventRange = [0,sTree.GetEntries()]
4919 if not nEvent<0: eventRange = [nEvent,nEvent+nTot]
4920 listOfTDCs = {}
4921 for Nr in range(eventRange[0],eventRange[1]):
4922 rc = sTree.GetEvent(Nr)
4923 listOfDigits={}
4924 for hit in sTree.Digi_MufluxSpectrometerHits:
4925 detID = hit.GetDetectorID()
4926 if detID<0: continue # feature for converted data in February'19
4927 if not listOfDigits.has_key(detID):
4928 listOfDigits[detID]=[0,[]]
4929 listOfTDCs[detID]={}
4930 tdcModule = hit.GetTDC()
4931 if not listOfTDCs[detID].has_key(tdcModule):
4932 listOfTDCs[detID][tdcModule] = 0
4933 listOfTDCs[detID][tdcModule] +=1
4934 listOfDigits[detID][0]+=1
4935 listOfDigits[detID][1].append(hit.GetDigi())
4936 for x in listOfDigits:
4937 rc=h['multHits'].Fill(listOfDigits[x][0])
4938 if listOfDigits[x][0]>1:
4939 print x
4940 listOfDigits[x][1].sort()
4941 for t in range(1,len(listOfDigits[x][1])):
4942 rc=h['multHits_deltaT'].Fill(abs(t-listOfDigits[x][1][0]))
4943 rc=h['multHits_deltaTz'].Fill(abs(t-listOfDigits[x][1][0]))
4944 if not MCdata:
4945 for detID in listOfTDCs:
4946 test = ROOT.MufluxSpectrometerHit(detID,0.)
4947 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(test)
4948 if tdcId not in listOfTDCs[detID].keys():
4949 print "not matching TDC id",detID,tdcId,listOfTDCs[detID]
4950 if len(listOfTDCs[detID])>1:
4951 print detID,listOfTDCs[detID]
4952

◆ testPR()

conditionsDatabase.demo.drifttubeMonitoring.testPR (   onlyHits = False)

Definition at line 2194 of file drifttubeMonitoring.py.

2194def testPR(onlyHits=False):
2195 global exclude_layer
2196 trackCandidates = []
2197 TaggerHits = []
2198 withNTaggerHits = 0
2199 withTDCPR = False
2200 DTHits = []
2201 key = -1
2202 for hit in sTree.Digi_MufluxSpectrometerHits:
2203 key+=1
2204 # if not hit.isValid(): continue
2205 if not hit.hasTimeOverThreshold(): continue
2206 if hit.GetDetectorID() in noisyChannels: continue
2207 detID = hit.GetDetectorID()
2208 s,v,p,l,view,channelID,tdcId,nRT = stationInfo(hit)
2209 if exclude_layer != None and view != '_x':
2210 if (2*p+l)==exclude_layer: continue
2211 vbot,vtop = strawPositionsBotTop[detID]
2212 tdc = hit.GetDigi()
2213 distance = 0
2214 if withTDCPR: distance = RT(hit,tdc)
2215 DTHits.append( {'digiHit':key,'xtop':vtop.x(),'ytop':vtop.y(),'z':vtop.z(),'xbot':vbot.x(),'ybot':vbot.y(),'dist':distance, 'detID':detID} )
2216 track_hits = MufluxPatRec.execute(DTHits, TaggerHits, withNTaggerHits, withTDCPR)
2217 hitlist = {}
2218 k = 0
2219 if Debug:
2220 print "PR returned %i track candidates"%(len(track_hits))
2221 plotTracklets(track_hits)
2222 for nTrack in track_hits:
2223 h['magPos'].Fill(track_hits[nTrack]['x_in_magnet'],track_hits[nTrack]['y_in_magnet'])
2224 # node = sGeo.FindNode(track_hits[nTrack]['x_in_magnet'],track_hits[nTrack]['y_in_magnet'],zgoliath)
2225 # if node.GetName() != "volGoliath_1": continue
2226 hitlist[k]=[]
2227 # if len(track_hits[nTrack]['34'])<5 or len(track_hits[nTrack]['y12'])<5: continue
2228 for dets in ['34','stereo12','y12']:
2229 rc = h['tracklets'+dets].Fill(len(track_hits[nTrack][dets]))
2230 for aHit in track_hits[nTrack][dets]:
2231 hitlist[k].append( aHit['digiHit'])
2232 aTrack = fitTrack(hitlist[k],abs(track_hits[nTrack]['p']))
2233 if type(aTrack) != type(1):
2234 trackCandidates.append(aTrack)
2235 k+=1
2236 if onlyHits: return hitlist
2237 return trackCandidates
2238
execute(SmearedHits, TaggerHits, withNTaggerHits, withDist2Wire, debug=0)

◆ tuneMCefficiency()

conditionsDatabase.demo.drifttubeMonitoring.tuneMCefficiency (   tkey)

Definition at line 2670 of file drifttubeMonitoring.py.

2670def tuneMCefficiency(tkey):
2671 effFudgeFac = {'u': 0.84, 'v': 0.82, 'x2': 0.91, 'x3': 0.89, 'x1': 0.94, 'x4': 0.96}
2672 measurements = countMeasurements(tkey)
2673 detectors = {'x1':0,'x2':0,'x3':0,'x4':0,'u':0,'v':0}
2674 for d in detectors:
2675 for m in measurements[d]:
2676 if rnr.Uniform() < effFudgeFac[d]: detectors[d]+=1
2677 passed = True
2678 for d in detectors:
2679 if detectors[d]<2:
2680 passed = False
2681 break
2682 return passed
2683

◆ yBeam()

conditionsDatabase.demo.drifttubeMonitoring.yBeam ( )

Definition at line 1595 of file drifttubeMonitoring.py.

1595def yBeam():
1596 Mproton = 0.938272081
1597 pbeam = 400.
1598 Ebeam = ROOT.TMath.Sqrt(400.**2+Mproton**2)
1599 beta = 400./Ebeam # p/E
1600 sqrtS = ROOT.TMath.Sqrt(2*Mproton**2+2*Ebeam*Mproton)
1601 y_beam = ROOT.TMath.Log(sqrtS/Mproton) # Carlos Lourenco, private communication
1602 return y_beam

Variable Documentation

◆ a

conditionsDatabase.demo.drifttubeMonitoring.a

Definition at line 213 of file drifttubeMonitoring.py.

◆ alignConstants

dict conditionsDatabase.demo.drifttubeMonitoring.alignConstants = {}

Definition at line 55 of file drifttubeMonitoring.py.

◆ alignCorrection

dict conditionsDatabase.demo.drifttubeMonitoring.alignCorrection = {}

Definition at line 4503 of file drifttubeMonitoring.py.

◆ alignCorrectionTMP

tuple conditionsDatabase.demo.drifttubeMonitoring.alignCorrectionTMP = (conditionsDB.get_condition_by_name_and_tag("muflux/driftTubes", "alignCorrection", "muflux/driftTubes_align_2020-03-23"))["values"]

Definition at line 4513 of file drifttubeMonitoring.py.

◆ angle

int conditionsDatabase.demo.drifttubeMonitoring.angle = -angleu

Definition at line 286 of file drifttubeMonitoring.py.

◆ angleu

tuple conditionsDatabase.demo.drifttubeMonitoring.angleu = (angleu1+angleu2)/2.

Definition at line 284 of file drifttubeMonitoring.py.

◆ angleu1

conditionsDatabase.demo.drifttubeMonitoring.angleu1 = ROOT.TMath.ATan2((daniel['T1_MB_01'][0]-daniel['T1_MB_04'][0]),(daniel['T1_MB_01'][1]-daniel['T1_MB_04'][1]))

Definition at line 282 of file drifttubeMonitoring.py.

◆ angleu2

conditionsDatabase.demo.drifttubeMonitoring.angleu2 = ROOT.TMath.ATan2((daniel['T1_MB_02'][0]-daniel['T1_MB_03'][0]),(daniel['T1_MB_02'][1]-daniel['T1_MB_03'][1]))

Definition at line 283 of file drifttubeMonitoring.py.

◆ anglev

tuple conditionsDatabase.demo.drifttubeMonitoring.anglev = (anglev1+anglev2)/2.

Definition at line 380 of file drifttubeMonitoring.py.

◆ anglev1

conditionsDatabase.demo.drifttubeMonitoring.anglev1 = ROOT.TMath.ATan2((daniel['T2_MC_02'][0]-daniel['T2_MC_03'][0]),(daniel['T2_MC_02'][1]-daniel['T2_MC_03'][1]))

Definition at line 378 of file drifttubeMonitoring.py.

◆ anglev2

conditionsDatabase.demo.drifttubeMonitoring.anglev2 = ROOT.TMath.ATan2((daniel['T2_MC_01'][0]-daniel['T2_MC_04'][0]),(daniel['T2_MC_01'][1]-daniel['T2_MC_04'][1]))

Definition at line 379 of file drifttubeMonitoring.py.

◆ api_factory

conditionsDatabase.demo.drifttubeMonitoring.api_factory = APIFactory()

Definition at line 174 of file drifttubeMonitoring.py.

◆ bfield

conditionsDatabase.demo.drifttubeMonitoring.bfield = ROOT.genfit.FairShipFields()

Definition at line 1372 of file drifttubeMonitoring.py.

◆ botA

conditionsDatabase.demo.drifttubeMonitoring.botA

Definition at line 2142 of file drifttubeMonitoring.py.

◆ botB

conditionsDatabase.demo.drifttubeMonitoring.botB

Definition at line 2143 of file drifttubeMonitoring.py.

◆ Bx

conditionsDatabase.demo.drifttubeMonitoring.Bx

Definition at line 1777 of file drifttubeMonitoring.py.

◆ By

conditionsDatabase.demo.drifttubeMonitoring.By

Definition at line 1777 of file drifttubeMonitoring.py.

◆ Bz

conditionsDatabase.demo.drifttubeMonitoring.Bz

Definition at line 1777 of file drifttubeMonitoring.py.

◆ channels

dict conditionsDatabase.demo.drifttubeMonitoring.channels = {}

Definition at line 987 of file drifttubeMonitoring.py.

◆ clusters

dict conditionsDatabase.demo.drifttubeMonitoring.clusters = {}

Definition at line 2144 of file drifttubeMonitoring.py.

◆ conditionsDB

conditionsDatabase.demo.drifttubeMonitoring.conditionsDB = api_factory.construct_DB_API()

Definition at line 175 of file drifttubeMonitoring.py.

◆ cuts

dict conditionsDatabase.demo.drifttubeMonitoring.cuts = {}

Definition at line 33 of file drifttubeMonitoring.py.

◆ DAFfitter

bool conditionsDatabase.demo.drifttubeMonitoring.DAFfitter = True

Definition at line 26 of file drifttubeMonitoring.py.

◆ daniel

tuple conditionsDatabase.demo.drifttubeMonitoring.daniel = {}

Definition at line 170 of file drifttubeMonitoring.py.

◆ database

str conditionsDatabase.demo.drifttubeMonitoring.database = 'muflux_RTrelations.pkl'

Definition at line 7680 of file drifttubeMonitoring.py.

◆ deadChannels4MC

conditionsDatabase.demo.drifttubeMonitoring.deadChannels4MC = ROOT.std.vector('int')()

Definition at line 1020 of file drifttubeMonitoring.py.

◆ deadChannelsRPC4MC

conditionsDatabase.demo.drifttubeMonitoring.deadChannelsRPC4MC = ROOT.std.vector('int')()

Definition at line 1022 of file drifttubeMonitoring.py.

◆ debug

bool conditionsDatabase.demo.drifttubeMonitoring.debug = False

Definition at line 58 of file drifttubeMonitoring.py.

◆ Debug

bool conditionsDatabase.demo.drifttubeMonitoring.Debug = False

Definition at line 2139 of file drifttubeMonitoring.py.

◆ default

conditionsDatabase.demo.drifttubeMonitoring.default

Definition at line 74 of file drifttubeMonitoring.py.

◆ delta

float conditionsDatabase.demo.drifttubeMonitoring.delta = daniel[s+'1'][0]-daniel[s+'2'][0]

Definition at line 224 of file drifttubeMonitoring.py.

◆ deltaZ

dict conditionsDatabase.demo.drifttubeMonitoring.deltaZ = zpos['T1X']-(vbot[2]+vtop[2])/2.

Definition at line 252 of file drifttubeMonitoring.py.

◆ delx

dict conditionsDatabase.demo.drifttubeMonitoring.delx = surveyXYZ[s+'01'][0]-surveyXYZ[s+'04'][0]

Definition at line 205 of file drifttubeMonitoring.py.

◆ dely

dict conditionsDatabase.demo.drifttubeMonitoring.dely = surveyXYZ[s+'01'][1]-surveyXYZ[s+'04'][1]

Definition at line 206 of file drifttubeMonitoring.py.

◆ dest

conditionsDatabase.demo.drifttubeMonitoring.dest

Definition at line 73 of file drifttubeMonitoring.py.

◆ DT

dict conditionsDatabase.demo.drifttubeMonitoring.DT = {}

Definition at line 684 of file drifttubeMonitoring.py.

◆ dx

dict conditionsDatabase.demo.drifttubeMonitoring.dx = node.GetVolume().GetShape().GetDX()

Definition at line 1049 of file drifttubeMonitoring.py.

◆ dy

dict conditionsDatabase.demo.drifttubeMonitoring.dy = node.GetVolume().GetShape().GetDY()

Definition at line 1050 of file drifttubeMonitoring.py.

◆ exclude_layer

conditionsDatabase.demo.drifttubeMonitoring.exclude_layer = None

Definition at line 2192 of file drifttubeMonitoring.py.

◆ f

conditionsDatabase.demo.drifttubeMonitoring.f = ROOT.TFile.Open(fname)

Definition at line 91 of file drifttubeMonitoring.py.

◆ fgeo

conditionsDatabase.demo.drifttubeMonitoring.fgeo = ROOT.TFile.Open(options.geoFile)

Definition at line 129 of file drifttubeMonitoring.py.

◆ fitter

conditionsDatabase.demo.drifttubeMonitoring.fitter = ROOT.genfit.DAF()

Definition at line 1379 of file drifttubeMonitoring.py.

◆ fM

conditionsDatabase.demo.drifttubeMonitoring.fM = ROOT.genfit.FieldManager.getInstance()

Definition at line 1374 of file drifttubeMonitoring.py.

◆ fname

list conditionsDatabase.demo.drifttubeMonitoring.fname = x.replace('\n','')

Definition at line 89 of file drifttubeMonitoring.py.

◆ fnames

conditionsDatabase.demo.drifttubeMonitoring.fnames = []

Definition at line 85 of file drifttubeMonitoring.py.

◆ geoMat

conditionsDatabase.demo.drifttubeMonitoring.geoMat = ROOT.genfit.TGeoMaterialInterface()

Definition at line 1370 of file drifttubeMonitoring.py.

◆ gErrorIgnoreLevel

conditionsDatabase.demo.drifttubeMonitoring.gErrorIgnoreLevel

Definition at line 12 of file drifttubeMonitoring.py.

◆ glob

conditionsDatabase.demo.drifttubeMonitoring.glob = array('d',[0,0,0])

Definition at line 1044 of file drifttubeMonitoring.py.

◆ globOrigin

conditionsDatabase.demo.drifttubeMonitoring.globOrigin = array('d',[0,0,0])

Definition at line 1038 of file drifttubeMonitoring.py.

◆ gMan

conditionsDatabase.demo.drifttubeMonitoring.gMan = ROOT.gGeoManager

Definition at line 1369 of file drifttubeMonitoring.py.

◆ gol

conditionsDatabase.demo.drifttubeMonitoring.gol = sGeo.GetTopVolume().GetNode("volGoliath_1")

Definition at line 1025 of file drifttubeMonitoring.py.

◆ h

dict conditionsDatabase.demo.drifttubeMonitoring.h = {}

Definition at line 56 of file drifttubeMonitoring.py.

◆ hCharm

dict conditionsDatabase.demo.drifttubeMonitoring.hCharm = {}

Definition at line 5705 of file drifttubeMonitoring.py.

◆ hCharm0

dict conditionsDatabase.demo.drifttubeMonitoring.hCharm0 = {}

Definition at line 5713 of file drifttubeMonitoring.py.

◆ hCharm2

dict conditionsDatabase.demo.drifttubeMonitoring.hCharm2 = {}

Definition at line 5714 of file drifttubeMonitoring.py.

◆ hCharmD

dict conditionsDatabase.demo.drifttubeMonitoring.hCharmD = {}

Definition at line 5715 of file drifttubeMonitoring.py.

◆ hCharmrec0

dict conditionsDatabase.demo.drifttubeMonitoring.hCharmrec0 = {}

Definition at line 5716 of file drifttubeMonitoring.py.

◆ hCharmrec2

dict conditionsDatabase.demo.drifttubeMonitoring.hCharmrec2 = {}

Definition at line 5717 of file drifttubeMonitoring.py.

◆ help

conditionsDatabase.demo.drifttubeMonitoring.help

Definition at line 73 of file drifttubeMonitoring.py.

◆ hMC

dict conditionsDatabase.demo.drifttubeMonitoring.hMC = {}

Definition at line 5704 of file drifttubeMonitoring.py.

◆ hMC0

dict conditionsDatabase.demo.drifttubeMonitoring.hMC0 = {}

Definition at line 5708 of file drifttubeMonitoring.py.

◆ hMC10GeV

dict conditionsDatabase.demo.drifttubeMonitoring.hMC10GeV = {}

Definition at line 5706 of file drifttubeMonitoring.py.

◆ hMC10GeV0

dict conditionsDatabase.demo.drifttubeMonitoring.hMC10GeV0 = {}

Definition at line 5718 of file drifttubeMonitoring.py.

◆ hMC10GeV2

dict conditionsDatabase.demo.drifttubeMonitoring.hMC10GeV2 = {}

Definition at line 5719 of file drifttubeMonitoring.py.

◆ hMC10GeVD

dict conditionsDatabase.demo.drifttubeMonitoring.hMC10GeVD = {}

Definition at line 5722 of file drifttubeMonitoring.py.

◆ hMC10GeVrec0

dict conditionsDatabase.demo.drifttubeMonitoring.hMC10GeVrec0 = {}

Definition at line 5720 of file drifttubeMonitoring.py.

◆ hMC10GeVrec2

dict conditionsDatabase.demo.drifttubeMonitoring.hMC10GeVrec2 = {}

Definition at line 5721 of file drifttubeMonitoring.py.

◆ hMC2

dict conditionsDatabase.demo.drifttubeMonitoring.hMC2 = {}

Definition at line 5709 of file drifttubeMonitoring.py.

◆ hMCD

dict conditionsDatabase.demo.drifttubeMonitoring.hMCD = {}

Definition at line 5710 of file drifttubeMonitoring.py.

◆ hMCrec0

dict conditionsDatabase.demo.drifttubeMonitoring.hMCrec0 = {}

Definition at line 5711 of file drifttubeMonitoring.py.

◆ hMCrec2

dict conditionsDatabase.demo.drifttubeMonitoring.hMCrec2 = {}

Definition at line 5712 of file drifttubeMonitoring.py.

◆ hruns

dict conditionsDatabase.demo.drifttubeMonitoring.hruns = {}

Definition at line 6968 of file drifttubeMonitoring.py.

◆ L

int conditionsDatabase.demo.drifttubeMonitoring.L = 110.

Definition at line 297 of file drifttubeMonitoring.py.

◆ Langle

dict conditionsDatabase.demo.drifttubeMonitoring.Langle = {}

Definition at line 203 of file drifttubeMonitoring.py.

◆ Lcorrection

dict conditionsDatabase.demo.drifttubeMonitoring.Lcorrection = {}

Definition at line 179 of file drifttubeMonitoring.py.

◆ listOfTracks

dict conditionsDatabase.demo.drifttubeMonitoring.listOfTracks = {}

Definition at line 4640 of file drifttubeMonitoring.py.

◆ loc

conditionsDatabase.demo.drifttubeMonitoring.loc = array('d',[0,0,0])

Definition at line 1043 of file drifttubeMonitoring.py.

◆ local

conditionsDatabase.demo.drifttubeMonitoring.local = array('d',[0,0,0])

Definition at line 1037 of file drifttubeMonitoring.py.

◆ log

dict conditionsDatabase.demo.drifttubeMonitoring.log = {}

Definition at line 57 of file drifttubeMonitoring.py.

◆ maxHitsPerCluster

conditionsDatabase.demo.drifttubeMonitoring.maxHitsPerCluster

Definition at line 2141 of file drifttubeMonitoring.py.

◆ MCdata

bool conditionsDatabase.demo.drifttubeMonitoring.MCdata = False

Definition at line 28 of file drifttubeMonitoring.py.

◆ MCsmearing

float conditionsDatabase.demo.drifttubeMonitoring.MCsmearing = 0.022

before RT correction: MCsmearing=0.04 # + 0.027**2 -> 0.05

Definition at line 31 of file drifttubeMonitoring.py.

◆ method

conditionsDatabase.demo.drifttubeMonitoring.method

Definition at line 1076 of file drifttubeMonitoring.py.

◆ minHitsPerCluster

conditionsDatabase.demo.drifttubeMonitoring.minHitsPerCluster

Definition at line 2141 of file drifttubeMonitoring.py.

◆ minP

conditionsDatabase.demo.drifttubeMonitoring.minP

Definition at line 7758 of file drifttubeMonitoring.py.

◆ modules

conditionsDatabase.demo.drifttubeMonitoring.modules = charmDet_conf.configure(run,ShipGeo)

Definition at line 139 of file drifttubeMonitoring.py.

◆ muflux_Reco

conditionsDatabase.demo.drifttubeMonitoring.muflux_Reco = ROOT.MufluxReco(xSHiP)

Definition at line 1074 of file drifttubeMonitoring.py.

◆ muSources

dict conditionsDatabase.demo.drifttubeMonitoring.muSources = {'eta':221,'omega':223,'phi':333,'rho0':113,'eta_prime':331}

Definition at line 64 of file drifttubeMonitoring.py.

◆ muSourcesIDs

dict conditionsDatabase.demo.drifttubeMonitoring.muSourcesIDs = muSources.values()

Definition at line 65 of file drifttubeMonitoring.py.

◆ myDetID

int conditionsDatabase.demo.drifttubeMonitoring.myDetID = s * 1000 + v * 100 + p * 10 + l

Definition at line 1003 of file drifttubeMonitoring.py.

◆ myGauss

conditionsDatabase.demo.drifttubeMonitoring.myGauss = ROOT.TF1('gauss','abs([0])/(abs([2])*sqrt(2*pi))*exp(-0.5*((x-[1])/[2])**2)+abs([3])',4)

Definition at line 2186 of file drifttubeMonitoring.py.

◆ myGauss2

conditionsDatabase.demo.drifttubeMonitoring.myGauss2 = ROOT.TF1('test','abs([0])/(abs([2])*sqrt(2*pi))*exp(-0.5*((x-[1])/[2])**2)+abs( [3]+[6]*x+[7]*x**2 )+abs([4])/(abs([5])*sqrt(2*pi))*exp(-0.5*((x-[1])/[5])**2)',8)

Definition at line 3300 of file drifttubeMonitoring.py.

◆ n

int conditionsDatabase.demo.drifttubeMonitoring.n = 10002012

Definition at line 253 of file drifttubeMonitoring.py.

◆ nav

conditionsDatabase.demo.drifttubeMonitoring.nav = sGeo.GetCurrentNavigator()

Definition at line 143 of file drifttubeMonitoring.py.

◆ Nchannels

dict conditionsDatabase.demo.drifttubeMonitoring.Nchannels = {1:12,2:12,3:48,4:48}

Definition at line 166 of file drifttubeMonitoring.py.

◆ node

conditionsDatabase.demo.drifttubeMonitoring.node = nav.GetCurrentNode()

Definition at line 1048 of file drifttubeMonitoring.py.

◆ noiseThreshold

int conditionsDatabase.demo.drifttubeMonitoring.noiseThreshold = 10

Definition at line 1018 of file drifttubeMonitoring.py.

◆ noisyChannels

list conditionsDatabase.demo.drifttubeMonitoring.noisyChannels = []

Definition at line 1019 of file drifttubeMonitoring.py.

◆ onlyPlotting

conditionsDatabase.demo.drifttubeMonitoring.onlyPlotting

Definition at line 7764 of file drifttubeMonitoring.py.

◆ options

conditionsDatabase.demo.drifttubeMonitoring.options = parser.parse_args()

Definition at line 83 of file drifttubeMonitoring.py.

◆ p

str conditionsDatabase.demo.drifttubeMonitoring.p = 'T1_MB_0'+str(i)

Definition at line 289 of file drifttubeMonitoring.py.

◆ parallelToZ

conditionsDatabase.demo.drifttubeMonitoring.parallelToZ = ROOT.TVector3(0., 0., 1.)

Definition at line 1677 of file drifttubeMonitoring.py.

◆ parser

conditionsDatabase.demo.drifttubeMonitoring.parser = ArgumentParser()

Definition at line 72 of file drifttubeMonitoring.py.

◆ PDG

conditionsDatabase.demo.drifttubeMonitoring.PDG = ROOT.TDatabasePDG.Instance()

Definition at line 8 of file drifttubeMonitoring.py.

◆ pl

dict conditionsDatabase.demo.drifttubeMonitoring.pl = {0:'00',1:'01',2:'10',3:'11'}

Definition at line 2145 of file drifttubeMonitoring.py.

◆ PR

conditionsDatabase.demo.drifttubeMonitoring.PR

Definition at line 7716 of file drifttubeMonitoring.py.

◆ r

conditionsDatabase.demo.drifttubeMonitoring.r = ROOT.TMath.Sqrt(delx**2+dely**2)

Definition at line 678 of file drifttubeMonitoring.py.

◆ rc

dict conditionsDatabase.demo.drifttubeMonitoring.rc = h['lengthCalibration'].Fill(delta-45.2)

Definition at line 226 of file drifttubeMonitoring.py.

◆ required

conditionsDatabase.demo.drifttubeMonitoring.required

Definition at line 73 of file drifttubeMonitoring.py.

◆ residuals

list conditionsDatabase.demo.drifttubeMonitoring.residuals = [0.]*24

Definition at line 163 of file drifttubeMonitoring.py.

◆ rn

dict conditionsDatabase.demo.drifttubeMonitoring.rn = {}

Definition at line 236 of file drifttubeMonitoring.py.

◆ rname

list conditionsDatabase.demo.drifttubeMonitoring.rname = rnames[0]

Definition at line 119 of file drifttubeMonitoring.py.

◆ rnames

list conditionsDatabase.demo.drifttubeMonitoring.rnames = []

Definition at line 116 of file drifttubeMonitoring.py.

◆ rnr

conditionsDatabase.demo.drifttubeMonitoring.rnr = ROOT.TRandom()

Definition at line 66 of file drifttubeMonitoring.py.

◆ rpc

dict conditionsDatabase.demo.drifttubeMonitoring.rpc = {}

Definition at line 683 of file drifttubeMonitoring.py.

◆ RPCPositionsBotTop

dict conditionsDatabase.demo.drifttubeMonitoring.RPCPositionsBotTop = {}

Definition at line 4531 of file drifttubeMonitoring.py.

◆ rtdb

conditionsDatabase.demo.drifttubeMonitoring.rtdb = run.GetRuntimeDb()

Definition at line 138 of file drifttubeMonitoring.py.

◆ RTrelations

conditionsDatabase.demo.drifttubeMonitoring.RTrelations = {}

Definition at line 5376 of file drifttubeMonitoring.py.

◆ run

conditionsDatabase.demo.drifttubeMonitoring.run = ROOT.FairRunSim()

Definition at line 134 of file drifttubeMonitoring.py.

◆ saveGeofile

bool conditionsDatabase.demo.drifttubeMonitoring.saveGeofile = False

Definition at line 150 of file drifttubeMonitoring.py.

◆ sGeo

conditionsDatabase.demo.drifttubeMonitoring.sGeo = ROOT.gGeoManager

Definition at line 142 of file drifttubeMonitoring.py.

◆ shape

conditionsDatabase.demo.drifttubeMonitoring.shape = vol.GetVolume().GetShape()

Definition at line 1036 of file drifttubeMonitoring.py.

◆ ShipGeo

conditionsDatabase.demo.drifttubeMonitoring.ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py")

Definition at line 124 of file drifttubeMonitoring.py.

◆ sigma_spatial

float conditionsDatabase.demo.drifttubeMonitoring.sigma_spatial = 0.25

Definition at line 2010 of file drifttubeMonitoring.py.

◆ slopeX

dict conditionsDatabase.demo.drifttubeMonitoring.slopeX
Initial value:
1= {3:[0,0,0,0],
2 2:[0,0,0,0]}

Definition at line 4505 of file drifttubeMonitoring.py.

◆ slopeY

dict conditionsDatabase.demo.drifttubeMonitoring.slopeY = {2:[0,0,0,0]}

Definition at line 4507 of file drifttubeMonitoring.py.

◆ start

tuple conditionsDatabase.demo.drifttubeMonitoring.start = daniel['T1_MA_01'][0]

Definition at line 254 of file drifttubeMonitoring.py.

◆ strawPositionsBotTop

dict conditionsDatabase.demo.drifttubeMonitoring.strawPositionsBotTop = {}

Definition at line 4523 of file drifttubeMonitoring.py.

◆ sTree

conditionsDatabase.demo.drifttubeMonitoring.sTree = f.cbmsim

Definition at line 92 of file drifttubeMonitoring.py.

◆ survey

tuple conditionsDatabase.demo.drifttubeMonitoring.survey = {}

Definition at line 169 of file drifttubeMonitoring.py.

◆ surveyXYZ

dict conditionsDatabase.demo.drifttubeMonitoring.surveyXYZ = {}

Definition at line 198 of file drifttubeMonitoring.py.

◆ tdcIds

dict conditionsDatabase.demo.drifttubeMonitoring.tdcIds
Initial value:
1= {'1000_x':[0],'1001_x':[0],'1010_x':[0],'1011_x':[0],
2 '1100_u':[0],'1101_u':[0],'1110_u':[0],'1111_u':[0],
3 '2000_v':[0],'2001_v':[0],'2010_v':[1],'2011_v':[1],
4 '2100_x':[1],'2101_x':[1],'2110_x':[1],'2111_x':[1],
5 '3000_x':[3,4], '3001_x':[3,4], '3010_x':[3,4],'3011_x':[3,4],
6 '4000_x':[3,2,1],'4001_x':[3,2,1],'4010_x':[2,1],'4011_x':[2,1]}

Definition at line 979 of file drifttubeMonitoring.py.

◆ test

conditionsDatabase.demo.drifttubeMonitoring.test = ROOT.MufluxSpectrometerHit(10002012,0.)

Definition at line 250 of file drifttubeMonitoring.py.

◆ timer

conditionsDatabase.demo.drifttubeMonitoring.timer = ROOT.TStopwatch()

Definition at line 10 of file drifttubeMonitoring.py.

◆ tmp

conditionsDatabase.demo.drifttubeMonitoring.tmp = open(options.listOfFiles)

Definition at line 87 of file drifttubeMonitoring.py.

◆ top

conditionsDatabase.demo.drifttubeMonitoring.top = sGeo.GetTopVolume()

Definition at line 144 of file drifttubeMonitoring.py.

◆ topA

conditionsDatabase.demo.drifttubeMonitoring.topA

Definition at line 2142 of file drifttubeMonitoring.py.

◆ topB

conditionsDatabase.demo.drifttubeMonitoring.topB

Definition at line 2143 of file drifttubeMonitoring.py.

◆ tx

int conditionsDatabase.demo.drifttubeMonitoring.tx = tx/4.

Definition at line 287 of file drifttubeMonitoring.py.

◆ ty

int conditionsDatabase.demo.drifttubeMonitoring.ty = ty/4.

Definition at line 287 of file drifttubeMonitoring.py.

◆ upkl

conditionsDatabase.demo.drifttubeMonitoring.upkl = Unpickler(options.geoFile)

Definition at line 130 of file drifttubeMonitoring.py.

◆ v

conditionsDatabase.demo.drifttubeMonitoring.v = 0

Definition at line 1000 of file drifttubeMonitoring.py.

◆ vbot

conditionsDatabase.demo.drifttubeMonitoring.vbot = ROOT.TVector3()

Definition at line 53 of file drifttubeMonitoring.py.

◆ vetoLayer

list conditionsDatabase.demo.drifttubeMonitoring.vetoLayer = []

Definition at line 7679 of file drifttubeMonitoring.py.

◆ viewC

dict conditionsDatabase.demo.drifttubeMonitoring.viewC = {0:"_x",1:"_u",2:"_v"}

Definition at line 62 of file drifttubeMonitoring.py.

◆ viewDict

dict conditionsDatabase.demo.drifttubeMonitoring.viewDict = {0:'_x',1:'_u',2:'_v'}

Definition at line 973 of file drifttubeMonitoring.py.

◆ views

dict conditionsDatabase.demo.drifttubeMonitoring.views = {1:['_x','_u'],2:['_x','_v'],3:['_x'],4:['_x']}

Definition at line 60 of file drifttubeMonitoring.py.

◆ viewsI

dict conditionsDatabase.demo.drifttubeMonitoring.viewsI = {1:[0,1],2:[0,2],3:[0],4:[0]}

Definition at line 61 of file drifttubeMonitoring.py.

◆ vol

conditionsDatabase.demo.drifttubeMonitoring.vol = nav.GetCurrentNode()

Definition at line 1035 of file drifttubeMonitoring.py.

◆ vtop

conditionsDatabase.demo.drifttubeMonitoring.vtop = ROOT.TVector3()

Definition at line 54 of file drifttubeMonitoring.py.

◆ withCorrections

bool conditionsDatabase.demo.drifttubeMonitoring.withCorrections = True

Definition at line 4510 of file drifttubeMonitoring.py.

◆ withDefaultAlignment

bool conditionsDatabase.demo.drifttubeMonitoring.withDefaultAlignment = True

Definition at line 858 of file drifttubeMonitoring.py.

◆ withMaterial

bool conditionsDatabase.demo.drifttubeMonitoring.withMaterial = True

Definition at line 27 of file drifttubeMonitoring.py.

◆ withTDC

bool conditionsDatabase.demo.drifttubeMonitoring.withTDC = True

Definition at line 857 of file drifttubeMonitoring.py.

◆ xLayers

dict conditionsDatabase.demo.drifttubeMonitoring.xLayers = {}

Definition at line 986 of file drifttubeMonitoring.py.

◆ xnom

dict conditionsDatabase.demo.drifttubeMonitoring.xnom = start - delta * i

Definition at line 304 of file drifttubeMonitoring.py.

◆ xpos

dict conditionsDatabase.demo.drifttubeMonitoring.xpos = {}

Definition at line 158 of file drifttubeMonitoring.py.

◆ xposb

dict conditionsDatabase.demo.drifttubeMonitoring.xposb = {}

Definition at line 159 of file drifttubeMonitoring.py.

◆ xSHiP

conditionsDatabase.demo.drifttubeMonitoring.xSHiP = ROOT.TTreeReader(sTree)

Definition at line 1073 of file drifttubeMonitoring.py.

◆ ynom

int conditionsDatabase.demo.drifttubeMonitoring.ynom = L/2.

Definition at line 305 of file drifttubeMonitoring.py.

◆ ypos

dict conditionsDatabase.demo.drifttubeMonitoring.ypos = {}

Definition at line 160 of file drifttubeMonitoring.py.

◆ yposb

dict conditionsDatabase.demo.drifttubeMonitoring.yposb = {}

Definition at line 161 of file drifttubeMonitoring.py.

◆ zeroField

bool conditionsDatabase.demo.drifttubeMonitoring.zeroField = False

Definition at line 25 of file drifttubeMonitoring.py.

◆ zeroFieldData

list conditionsDatabase.demo.drifttubeMonitoring.zeroFieldData = ['SPILLDATA_8000_0515970150_20180715_220030.root']

Definition at line 5377 of file drifttubeMonitoring.py.

◆ zgoliath

conditionsDatabase.demo.drifttubeMonitoring.zgoliath = gol.GetMatrix().GetTranslation()[2]

Definition at line 1026 of file drifttubeMonitoring.py.

◆ zpos

dict conditionsDatabase.demo.drifttubeMonitoring.zpos = {}

Definition at line 162 of file drifttubeMonitoring.py.

◆ zRPC1

conditionsDatabase.demo.drifttubeMonitoring.zRPC1 = glob[2]

Definition at line 1046 of file drifttubeMonitoring.py.