diff --git a/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h b/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h index 95ed75ea70912f146181e5a0f03c2b291bcadbd1..72cb65f304fc7cb70f0ca900815c6f80ae53b416 100644 --- a/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h +++ b/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h @@ -140,6 +140,7 @@ namespace dqutils { static void fitMergedFile_IDAlignMonResiduals(TFile* f, std::string run_dir, std::string TriggerName); static void fitMergedFile_IDAlignMonTrackSegments(TFile* file, std::string run_dir, std::string tracksName); static void fitMergedFile_IDAlignMonGenericTracks(TFile* file, std::string run_dir, std::string tracksName); + static void fitMergedFile_IDAlignMonPVbiases(TFile* file, std::string run_dir, std::string tracksName); static void fitMergedFile_IDPerfMonKshort(TFile* f, std::string run_dir, std::string TriggerName); static void fitMergedFile_IDPerfMonJpsi(TFile* f, std::string run_dir, std::string TriggerName); @@ -155,7 +156,7 @@ namespace dqutils { static void fitZmumuHistograms(TH1F* hmass, TH1F* hwidth, std::vector<TH1F*> hvec); static void processModule(TFile* f, std::string run_dir, TKey* key_module, std::string moduleName); static void fitMergedFile_DiMuMonAll(TFile* f, std::string run_dir, std::string resonName, std::string triggerName); - static void fitHistos(TH2D* hin, std::vector<TH1D*> hout, int mode, std::string triggerName, std::string resonName, TH1D* m_chi2); + static void fitHistos(TH2F* hin, std::vector<TH1F*> hout, int mode, std::string triggerName, std::string resonName, TH1F* m_chi2); static void fillGaussianMeanOrWidth(TH2F* h2d, TH1F* h, float fitMin, float fitMax, int iopt); static void fillMeanOrWidth(TH2F* h2d, TH1F* h, int iopt); static void fillDetPaperMeanRMS(TH2F* h2d, TH1F* h, int iopt); @@ -168,6 +169,9 @@ namespace dqutils { static void setMinWindow(TH1* h1, float min, float max); static float getMedian(TH1* h1); static void ProcessAsymHistograms(TH1F* m_neg, TH1F* m_pos, TH1F* m_asym); + static void Make1DProfile(TH1* output, TH2* histo); + static void MakeMap(TH2* outputhist, TH3* hist); + static int IterativeGaussFit(TH1* hist, double &mu, double &mu_err, double &sigma, double &sigma_err); // Muon CSC static void CSCPostProcess(std::string inFilename, bool isIncremental = false); diff --git a/DataQuality/DataQualityUtils/DataQualityUtils/RootLinkDef.h b/DataQuality/DataQualityUtils/DataQualityUtils/RootLinkDef.h index 49a4e496a0ab21b156862431d60574adbf8c4c6f..eb6f66a609191c840f6e4589b7c3293c0f57d5b3 100644 --- a/DataQuality/DataQualityUtils/DataQualityUtils/RootLinkDef.h +++ b/DataQuality/DataQualityUtils/DataQualityUtils/RootLinkDef.h @@ -20,4 +20,6 @@ #pragma link C++ class dqutils::CoolMdt ; #pragma link C++ class dqutils::CoolTgc ; +#pragma link C++ class map<TString,TString> ; + #endif diff --git a/DataQuality/DataQualityUtils/python/DQWebDisplayConfig.py b/DataQuality/DataQualityUtils/python/DQWebDisplayConfig.py index 3275ac781ade847d1558ad79421851c0238f8d60..af54923445d34c750bb92d814c2ef44c6aa5eb9a 100644 --- a/DataQuality/DataQualityUtils/python/DQWebDisplayConfig.py +++ b/DataQuality/DataQualityUtils/python/DQWebDisplayConfig.py @@ -10,6 +10,7 @@ class DQWebDisplayConfig: server = [] histogramCache = "" hanResultsDir = "" + eosResultsDir = "" htmlDir = "" htmlWeb = "" runlist = "" diff --git a/DataQuality/DataQualityUtils/python/DQWebDisplayMod.py b/DataQuality/DataQualityUtils/python/DQWebDisplayMod.py index 5a4e11717938110f35564ed528e3360e2bf40a63..8cfd4f8dcde9e21f111e3f888bd3d2bc402e20ad 100755 --- a/DataQuality/DataQualityUtils/python/DQWebDisplayMod.py +++ b/DataQuality/DataQualityUtils/python/DQWebDisplayMod.py @@ -14,6 +14,7 @@ import time from time import sleep from multiprocessing import Process, Queue, Manager from DataQualityUtils.dqu_subprocess import apply as _local_apply +import re ## Needed to correct ROOT behavior; see below CWD = os.getcwd() @@ -162,7 +163,7 @@ def DQWebDisplay( inputFilePath, runAccumulating, c ): outputHanResultsDir = c.hanResultsDir + stream + '/run_' + `runid` outputHtmlDir = c.htmlDir + stream + "/" - if c.server != [] or c.webHandoffDir != "": + if c.server != [] or c.webHandoffDir != "" or c.eosResultsDir: print "Writing all output to \'./\'; will copy at the end to", if c.webHandoffDir != "": print "a handoff directory:", c.webHandoffDir @@ -202,7 +203,7 @@ def DQWebDisplay( inputFilePath, runAccumulating, c ): failures = 0 for server in c.server: print "Transfering han files to server: ", server - success = transferFilesToServer( xferFileList, "./han_results/", c.hanResultsDir, server ) + success = transferFilesToServer( xferFileList[:], "./han_results/", c.hanResultsDir, server ) if success: print "Done." print "" @@ -228,6 +229,26 @@ def DQWebDisplay( inputFilePath, runAccumulating, c ): print "These are:", ', '.join(c.server) print "Will die so as to alert Tier-0 shifter" raise IOError('tarfile ssh transfer failed') + if c.eosResultsDir != "": + print "Transfering han files to EOS" + success_EOS = transferFilesToEOS( xferFileList[:], "./han_results/", c.eosResultsDir ) + if success_EOS: + print "Done." + print "" + else: + print "FAILED!", + if c.emailWarnings: + email('The transfer of han files\n\n' + + ''.join(xferFileList) + + '\nto EOS failed.\n' + 'Please investigate as soon as possible!', + 'WARNING! File transfer from Tier-0 failed', + FROMEMAIL, + 'hn-atlas-data-quality-operations@cern.ch' + ) + print "Email sent..." + else: + print "" runNumber = runfile[1] @@ -670,6 +691,7 @@ def transferFilesToServer( fileList, localDir, targetDir, server ): os.system( "chmod 664 " + xferFile ) xferFile = xferFile.replace(localDir,"") t.write(xferFile) + t.close() cmd = "" @@ -684,6 +706,19 @@ def transferFilesToServer( fileList, localDir, targetDir, server ): # raise IOError('tarfile ssh transfer failed') return rv == 0 +def transferFilesToEOS(fileList, localDir, eosResultsDir): + os.system('export XRD_REQUESTTIMEOUT=10') + for xferFile in fileList: + xferFile = xferFile.rstrip() + os.system( "chmod 664 " + xferFile ) + file_name = xferFile.replace(localDir,"") + + eos = "xrdcp --force --path --silent " + xferFile + " "+ os.path.join(eosResultsDir, file_name) + + print eos + run_eos += os.system( eos ) + + return run_eos == 0 def retrieveFileFromServer( filePath, localDir, remoteDir, server ): username = "atlasdqm" diff --git a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py index 71f0b0acfb8ed67a49b8b5db924f8a005d5acb29..c48205135ed8de31f1ae7c11c068b22775473f7a 100644 --- a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py +++ b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py @@ -59,14 +59,12 @@ parser.add_argument('-ul','--upperlb',type=int,dest='upperLB',default='999999',h parser.add_argument('-s','--stream',dest='stream',default='express',help="Stream without prefix: express, CosmicCalo, Egamma...",action='store') parser.add_argument('-t','--tag',dest='tag',default='data16_13TeV',help="DAQ tag: data12_8TeV, data12_calocomm...",action='store') parser.add_argument('-a','--amiTag',dest='amiTag',default='x',help="First letter of AMI tag: x->express / f->bulk",action='store') -parser.add_argument('-e','--eta',type=float,dest='etaSpot',default='0',help='Eta of hot spot',action='store') -parser.add_argument('-p','--phi',type=float,dest='phiSpot',default='0.',help='Phi of hot spot (or MET bump)',action='store') +parser.add_argument('-e','--eta',type=float,dest='etaSpot',default='-999.',help='Eta of hot spot',action='store') +parser.add_argument('-p','--phi',type=float,dest='phiSpot',default='-999.',help='Phi of hot spot (or MET bump)',action='store') +parser.add_argument('-lb','--lowerBound',type=float,dest='lowerBound',default='-999.',help='Lower bound of upper band',action='store') parser.add_argument('-d','--delta',type=float,dest='deltaSpot',default='0.1',help='Distance to look around hot spot (or MET bump)',action='store') parser.add_argument('-o','--object',dest='objectType',default='TopoClusters',help='TopoClusters,EMTopoClusters,EMTopoJets',action='store') -#parser.add_argument('-c','--cut',type=int,dest='upperLB',default='999999',help="Upper lb",action='store') parser.add_argument('-m','--min',type=int,dest='minInLB',default='5',help='Min number of object in a LB',action='store') -parser.add_argument('-n','--noplot',dest='noplot',help='Do not plot LB map',action='store_true') - args = parser.parse_args() @@ -81,6 +79,7 @@ amiTag = args.amiTag etaSpot = args.etaSpot phiSpot = args.phiSpot deltaSpot = args.deltaSpot +lowerBound = args.lowerBound objectType = args.objectType minInLB = args.minInLB @@ -98,8 +97,8 @@ if (objectType == "TopoClusters"): histoKeys = ["Et10GeV", "Et25GeV", "Et50GeV"] - b_2dHisto = True # Draw with "COLZ" - + histoType = "2d_hotSpot" + histoName = "TopoClusters" if (objectType == "EMTopoClusters"): histoPath = {"Et4GeV":"run_%d/CaloMonitoring/ClusterMon/LArClusterEMNoTrigSel/2d_Rates/m_clus_etaphi_Et_thresh1"%(run), "Et10GeV":"run_%d/CaloMonitoring/ClusterMon/LArClusterEMNoTrigSel/2d_Rates/m_clus_etaphi_Et_thresh2"%(run), @@ -113,8 +112,8 @@ if (objectType == "EMTopoClusters"): histoKeys = ["Et4GeV", "Et10GeV", "Et25GeV"] - b_2dHisto = True # Draw with "COLZ" - + histoType = "2d_hotSpot" + histoName = "EMTopoClusters" if (objectType == "EMTopoJets"): histoPath = {"noCut":"run_%d/Jets/AntiKt4EMTopoJets/OccupancyEtaPhi"%(run), "cut1":"run_%d/Jets/AntiKt4EMTopoJets/OccupancyEtaPhisel_20000_inf_pt_inf_500000"%(run), @@ -136,7 +135,74 @@ if (objectType == "EMTopoJets"): "cut2", "cut3", "cut4"] - b_2dHisto = True # Draw with "COLZ" + histoType = "2d_hotSpot" + histoName = "EMTopoJots" +if (objectType == "EMTopoJets_eta"): + histoPath = {"cut1":"run_%d/Jets/AntiKt4EMTopoJets/etasel_20000_inf_pt_inf_500000"%(run), + "cut2":"run_%d/Jets/AntiKt4EMTopoJets/etasel_500000_inf_pt_inf_1000000"%(run), + "cut3":"run_%d/Jets/AntiKt4EMTopoJets/etasel_1000000_inf_pt_inf_2000000"%(run), + "cut4":"run_%d/Jets/AntiKt4EMTopoJets/etasel_2000000_inf_pt_inf_8000000"%(run)} + histoLegend = {"cut1":"20GeV-500GeV", + "cut2":"500GeV-1TeV", + "cut3":"1TeV-2TeV", + "cut4":"2TeV-8TeV"} + histoColor = {"cut1":kRed, + "cut2":kBlue, + "cut3":kGreen, + "cut4":kPink} + histoKeys = ["cut1", + "cut2", + "cut3", + "cut4"] + histoType = "1d_etaHotSpot" + histoName = "EMTopoJots" +if (objectType == "NumberTau"): + histoPath = {"cut1":"run_%d/Tau/nTauCandidates"%(run), + "cut2":"run_%d/Tau/nHighPtTauCandidates"%(run)} + histoLegend = {"cut1":"All candidates", + "cut2":"High Pt (>100GeV) candidates"} + histoColor = {"cut1":kRed, + "cut2":kBlue} + histoKeys = ["cut1", + "cut2"] + histoType = "1d_upperBand" + histoName = "Number of Tau candidates" +if (objectType == "TightFwdElectrons"): + histoPath = {"cut1":"run_%d/egamma/forwardElectrons/forwardElectronTightEtaPhi"%(run)} + histoLegend = {"cut1":"10GeV"} + histoColor = {"cut1":kRed} + histoKeys = ["cut1"] + histoType = "2d_hotSpot" + histoName = "Tight electrons" +if (objectType == "NumberTightElectrons"): + histoPath = {"cut1":"run_%d/egamma/forwardElectrons/forwardElectronTightN"%(run)} + histoLegend = {"cut1":"All candidates"} + histoColor = {"cut1":kRed} + histoKeys = ["cut1"] + histoType = "1d_upperBand" + histoName = "Number of tight electrons" + + +# Depending of the histo/check type, define the summary title and +# check that the position of the "hot spot" (or lower bound of the band) is defined +if histoType == "2d_hotSpot": + summaryTitle = "Nb of hits in a region of %.2f around the position (%.2f,%.2f) - %s"%(deltaSpot,etaSpot,phiSpot,histoName) + statement = "I have looked for LBs with at least %d entries at position (%.2f,%.2f) in %s histogram"%(minInLB,etaSpot,phiSpot,histoName) + if (etaSpot==-999. or phiSpot==-999.): + print "You must define eta/phi of hot spot" + sys.exit() +elif histoType == "1d_etaHotSpot": + summaryTitle = "Nb of hits in a region of %.2f around the eta position %.2f - %s"%(deltaSpot,etaSpot,histoName) + statement = "I have looked for LBs with at least %d entries at eta position %.2f in %s histogram"%(minInLB,etaSpot,histoName) + if (etaSpot==-999.): + print "You must define eta of hot spot" + sys.exit() +elif histoType == "1d_upperBand": + summaryTitle = "Nb of hits in the band above %.2f - %s"%(lowerBound,histoName) + statement = "I have looked for LBs with at least %d entries in band above %.2f in %s histogram"%(minInLB,lowerBound,histoName) + if (lowerBound==-999.): + print "You must define the lower bound of your band" + sys.exit() # Look for the final merged HIST file # and plot the histogram @@ -150,7 +216,7 @@ histo = {} for iHisto in histoKeys: histo[iHisto] = f.Get(histoPath[iHisto]) -if (b_2dHisto): +if ("2d" in histoType):# Definition of drawOption gStyle.SetPalette(1) gStyle.SetOptStat("") drawOption="COLZ" @@ -162,23 +228,37 @@ for iHisto in histoKeys: c[iHisto] = TCanvas(histoLegend[iHisto]) histo[iHisto].Draw(drawOption) -# Extract the bin number of the noisy region. the position should be precisely defined (facility of -# using a delta around the position not yet implemented) -# Assume that eta is on x axis -#hotSpotBin = histo[iHisto].FindBin(etaSpot,phiSpot) +# Extract the bin region where to count. # Scans the window to find all bins that fall in the window -regionBins = [] -nSteps = 1000 -subStep = 2*deltaSpot/nSteps -for ix in range(nSteps): - iEta = etaSpot - deltaSpot + ix * subStep - for iy in range (nSteps): - iPhi = phiSpot - deltaSpot + iy * subStep - tmpBin = histo[iHisto].FindBin(iEta,iPhi) - if (tmpBin not in regionBins): - regionBins.append(tmpBin) - -# Extract all the unmerged files available withthe LB range +# The regionBins is defined for ech histogram allowing different binning +regionBins = {} +for iHisto in histoKeys: + if (histoType == "2d_hotSpot"): + nSteps = 1000 + subStep = 2*deltaSpot/nSteps + regionBins[iHisto] = [] + for ix in range(nSteps):# Assume that eta is on x axis + iEta = etaSpot - deltaSpot + ix * subStep + for iy in range (nSteps): + iPhi = phiSpot - deltaSpot + iy * subStep + tmpBin = histo[iHisto].FindBin(iEta,iPhi) + if (tmpBin not in regionBins[iHisto]): + regionBins[iHisto].append(tmpBin) + elif (histoType == "1d_etaHotSpot"): + nSteps = 1000 + subStep = 2*deltaSpot/nSteps + regionBins[iHisto] = [] + for ix in range(nSteps): + iEta = etaSpot - deltaSpot + ix * subStep + tmpBin = histo[iHisto].FindBin(iEta) + if (tmpBin not in regionBins[iHisto]): + regionBins[iHisto].append(tmpBin) + elif (histoType == "1d_upperBand"): + regionBins[iHisto] = [] + for iBin in range(histo[iHisto].FindBin(lowerBound),histo[iHisto].GetNbinsX()): + regionBins[iHisto].append(iBin) + +# Extract all the unmerged files available with the LB range lbFilePathList = pathExtract.returnEosHistPathLB(args.runNumber,lowerLumiBlock,upperLumiBlock,args.stream,args.amiTag,args.tag) nbHitInHot = [] @@ -201,14 +281,14 @@ sys.stdout.write("Start scanning the LBs:") # Loop on all unmerged files for lbFile in lbFilePathList: lbFilePath = "root://eosatlas.cern.ch/%s"%(lbFile).rstrip() - ilb = int((lbFile.split("_lb")[1]).split("._SFO")[0]) + ilb = int((lbFile.split("_lb")[1]).split("._")[0]) sys.stdout.write("%d "%(ilb)) sys.stdout.flush() fLB[lbFile] = TFile.Open(lbFilePath) histoLB = {} for iHisto in histoKeys: histoLB[iHisto] = fLB[lbFile].Get(histoPath[iHisto]) - for iBin in regionBins: + for iBin in regionBins[iHisto]: nbHitInHot[iHisto][ilb] = nbHitInHot[iHisto][ilb] + histoLB[iHisto].GetBinContent(iBin) # sys.stdout.write("->%d "%(nbHitInHot[ilb])) @@ -221,7 +301,7 @@ for iHisto in histoKeys: if ilb>upperLB : upperLB = ilb print "" -print "I have looked for LBs with at least %d entries at position (%.2f,%.2f) in %s histogram"%(minInLB,etaSpot,phiSpot,objectType) +print statement maxNbInHot = 0 totalInRegionRecomp = {} @@ -233,7 +313,7 @@ for iHisto in histoKeys: for iHisto in histoKeys: print "======= ",histoLegend[iHisto] - for iBin in regionBins: + for iBin in regionBins[iHisto]: totalInRegion[iHisto] = totalInRegion[iHisto] + histo[iHisto].GetBinContent(iBin) for i in range(nLB): totalInRegionRecomp[iHisto] = totalInRegionRecomp[iHisto] + nbHitInHot[iHisto][i] @@ -260,7 +340,7 @@ if (upperLB>=lowerLB): # check that at least one noisy LB was found h0Evol = {} first = True for iHisto in histoKeys: - h0Evol[iHisto] = TH1I("h0Evol%s"%(iHisto),"Nb of hits in a region of %.2f around the position (%.2f,%.2f) - %s"%(deltaSpot,etaSpot,phiSpot,objectType),upperLB-lowerLB+1,lowerLB-0.5,upperLB+0.5) + h0Evol[iHisto] = TH1I("h0Evol%s"%(iHisto),summaryTitle,upperLB-lowerLB+1,lowerLB-0.5,upperLB+0.5) h0Evol[iHisto].SetXTitle("LumiBlock (Only LB with >= %d entries)"%(minInLB)) h0Evol[iHisto].SetLineColor(histoColor[iHisto]) leg.AddEntry(h0Evol[iHisto],"%s (%d entries in the run)"%(histoLegend[iHisto],totalInRegion[iHisto])) @@ -269,7 +349,7 @@ if (upperLB>=lowerLB): # check that at least one noisy LB was found if first: h0Evol[iHisto].Draw() h0Evol[iHisto].SetMinimum(minInLB-1) - h0Evol[iHisto].SetMaximum(maxNbInHot*1.25) + h0Evol[iHisto].SetMaximum(maxNbInHot*1.5) first = False else: h0Evol[iHisto].Draw("SAME") diff --git a/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py b/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py index 55a53392fad8cfef82625690f625854a72bec9e4..1765bb368b697ab9233811a2684c6380c0a7b90f 100755 --- a/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py +++ b/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py @@ -59,15 +59,15 @@ def mergeFolder(path) : hname = hpath[hpath.find(":")+2:]+"/"+obj.GetName() print "Path: "+hname for tup in files: - if tup!=file: - nextfile = ROOT.TFile(tup) - h2 = nextfile.Get(hname) - if not h2: - error = "ERROR: Cannot find " + hname + " in file " + tup + ". Omitting." - print error - errors.append(error) - continue - h1.Add(h2) + if tup==files[1]: continue + nextfile = ROOT.TFile(tup) + h2 = nextfile.Get(hname) + if not h2: + error = "ERROR: Cannot find " + hname + " in file " + tup + ". Omitting." + print error + errors.append(error) + continue + h1.Add(h2) subfolder = f.Get(hpath[hpath.find(":")+2:]) subfolder.cd() h1.Write() diff --git a/DataQuality/DataQualityUtils/scripts/pathExtract.py b/DataQuality/DataQualityUtils/scripts/pathExtract.py index d7e64077d9a7e2b9d9e2ea74ef2e92f415c6f813..c0ba82fb897b16edd44bcb718f5d7c9e4ba3b037 100644 --- a/DataQuality/DataQualityUtils/scripts/pathExtract.py +++ b/DataQuality/DataQualityUtils/scripts/pathExtract.py @@ -11,7 +11,7 @@ from ROOT import * # Return the path of the output of tier0 monitoring def returnEosHistPath(run,stream,amiTag,tag="data16_13TeV"): - prefix = {'express':'express_','Egamma':'physics_','CosmicCalo':'physics_','JetTauEtmiss':'physics_','Main':'physics_','ZeroBias':'physics_'} + prefix = {'express':'express_','Egamma':'physics_','CosmicCalo':'physics_','JetTauEtmiss':'physics_','Main':'physics_','ZeroBias':'physics_','MinBias':'physics_'} path = '/eos/atlas/atlastier0/rucio/'+tag+'/'+prefix[stream]+stream+'/00'+str(run)+'/' P = sp.Popen(['/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select','ls',path],stdout=sp.PIPE,stderr=sp.PIPE) p = P.communicate() @@ -67,7 +67,8 @@ def returnEosHistPathLB(run,lb0,lb1,stream,amiTag,tag="data16_13TeV"): listOfFiles2 = p[0].split('\n') for iFile2 in listOfFiles2: if ("data" in iFile2): - ilb = int((iFile2.split("_lb")[1]).split("._SFO")[0]) + ilb = int((iFile2.split("_lb")[1]).split("._")[0]) +# print iFile2,ilb if (lb0<=ilb and ilb<=lb1): path = '/eos/atlas/atlastier0/tzero/prod/'+tag+'/'+prefix[stream]+stream+'/00'+str(run)+'/'+iFile+'/'+iFile2 pathList.append(path) diff --git a/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py b/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py index d4dfee16c6cad74f068325ffa67d5224a410b549..edb9d261d4941ae536d199d127460b9cdb812815 100755 --- a/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py +++ b/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py @@ -28,7 +28,7 @@ algorithmparameters = [DQAlgorithmParameter('AuxAlgName--Chi2Test_Chi2_per_NDF', # Edit this to change thresholds thresh = make_thresholds('Chi2_per_NDF', 1.0, 1.50, 'Chi2Thresholds') -def recurse(rdir, dqregion, ignorepath, refs=None, displaystring='Draw=PE', regex=None, startpath=None, hists=None): +def recurse(rdir, dqregion, ignorepath, refs=None, displaystring='Draw=PE', displaystring2D='Draw=COLZ', regex=None, startpath=None, hists=None): import re for key in rdir.GetListOfKeys(): cl = key.GetClassName(); rcl = ROOT.TClass.GetClass(cl) @@ -65,15 +65,22 @@ def recurse(rdir, dqregion, ignorepath, refs=None, displaystring='Draw=PE', rege dqpar = dqregion.newDQParameter( **dqpargs) drawstrs = [] if not options.normalize: drawstrs.append('NoNorm') - if options.logy: drawstrs.append('LogY') + if options.logy and (cl.startswith('TH1') or cl.startswith('TProfile')): drawstrs.append('LogY') + if options.logy and cl.startswith('TH2'): drawstrs.append('LogZ') if cl.startswith('TH1'): drawstrs.append(displaystring) + if cl.startswith('TProfile'): drawstrs.append(displaystring) + if cl.startswith('TH2'): drawstrs.append(displaystring2D) if options.scaleref != 1: drawstrs.append('ScaleRef=%f' % options.scaleref) + if options.ratio: drawstrs.append('RatioPad') + #if options.ratio: drawstrs.append('Ref2DSignif') + if options.ratio2D: drawstrs.append('Ref2DRatio') + drawstrs.append('DataName=%s' % options.title) dqpar.addAnnotation('display', ','.join(drawstrs)) elif rcl.InheritsFrom('TDirectory'): newregion = dqregion.newDQRegion( key.GetName(), algorithm=worst ) - recurse(key.ReadObj(), newregion, ignorepath, refs, displaystring, regex, startpath, hists) + recurse(key.ReadObj(), newregion, ignorepath, refs, displaystring, displaystring2D, regex, startpath, hists) def prune(dqregion): """ @@ -131,6 +138,10 @@ def process(infname, confname, options, refs=None): displaystring = options.drawopt if options.refdrawopt: displaystring += ',' + (','.join('DrawRef=%s' % _ for _ in options.refdrawopt.split(','))) + displaystring2D = options.drawopt2D + if options.drawrefopt2D: + displaystring2D += ',' + (','.join('DrawRef2D=%s' % _ for _ in options.drawrefopt2D.split(','))) + if options.startpath: topindir = f.Get(options.startpath) if not topindir: @@ -145,7 +156,7 @@ def process(infname, confname, options, refs=None): if options.histlistfile: hists = [re.compile(line.rstrip('\n')) for line in open(options.histlistfile)] if options.pathregex: print "histlistfile given, pathregex is ignored" - recurse(topindir, top_level, topindirname, dqrs, displaystring, + recurse(topindir, top_level, topindirname, dqrs, displaystring, displaystring2D, re.compile(options.pathregex), startpath, hists) print 'Pruning dead branches...' prune(top_level) @@ -256,10 +267,14 @@ if __name__=="__main__": help='Normalize reference histograms for display') parser.add_option('--title', default='Summary', help='Title for histograms being tested') - parser.add_option('--refdrawopt', - help='ROOT Draw option for reference histograms (e.g. HIST)') parser.add_option('--drawopt', default='Draw=PE', help='Draw options for tested histograms (only use if you know what you are doing)') + parser.add_option('--refdrawopt', + help='ROOT Draw option for reference histograms (e.g. HIST)') + parser.add_option('--drawopt2D', default='Draw=COLZ', + help='Draw options for tested TH2 histograms (only use if you know what you are doing)') + parser.add_option('--drawrefopt2D', default=None, + help='Draw options for reference TH2 histograms. If nothing is specified, no 2D reference histograms are drawn. If you want to draw both test and reference histo, recommended settings are --drawopt2D="Draw=BOX" --drawrefopt2D="COLZ"') parser.add_option('--logy', action='store_true', help='Display on log Y scale') parser.add_option('--pathregex', default='.*', @@ -272,6 +287,10 @@ if __name__=="__main__": help='Scale references by this value') parser.add_option('--Kolmogorov', default=False, action='store_true', help='Run Kolmogorov test instead of Chi2 test') + parser.add_option('--ratio', default=False, action='store_true', + help='Draw histograms with ratio plots') + parser.add_option('--ratio2D', default=False, action='store_true', + help='Draw 2D histograms with ratio plots') options, args = parser.parse_args() diff --git a/DataQuality/DataQualityUtils/src/HanOutputFile.cxx b/DataQuality/DataQualityUtils/src/HanOutputFile.cxx index febddb48827846e16fb92e53587d504915335907..5aae411a8f92ebef6f95197535a3fdab5b9a1919 100644 --- a/DataQuality/DataQualityUtils/src/HanOutputFile.cxx +++ b/DataQuality/DataQualityUtils/src/HanOutputFile.cxx @@ -794,7 +794,7 @@ saveAllHistograms( std::string location, bool drawRefs, std::string run_min_LB ) << "No input file is open\n"; return 0; } - + if( m_indirMap.size() == 0 ) { getAllGroupDirs( m_indirMap, m_file, "" ); } @@ -838,7 +838,8 @@ HanOutputFile:: saveHistogramToFile( std::string nameHis, std::string location, TDirectory* groupDir, bool drawRefs,std::string run_min_LB, std::string pathName){ dqi::DisableMustClean disabled; groupDir->cd(); - + + int iMarkerStyle = 20; gStyle->SetFrameBorderMode(0); gStyle->SetFrameFillColor(0); gStyle->SetCanvasBorderMode(0); @@ -851,7 +852,7 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou gStyle->SetPalette(1,0); gStyle->SetTitleFontSize(0.06); gStyle->SetTitleH(0.06); - gStyle->SetMarkerStyle(20); + gStyle->SetMarkerStyle(iMarkerStyle); gStyle->SetOptStat(111100); gStyle->SetStatBorderSize(0); gStyle->SetStatX(0.99); @@ -868,6 +869,7 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou if(LookForDisplay) { display = getStringName(pathname + "/"+ nameHis + "_/Config/annotations/display" ); } + // Plot overflows? bool PlotOverflows = (display.find("PlotUnderOverflow") != std::string::npos); // Look for Draw Options @@ -883,7 +885,7 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou } found=display.find("Draw=",found+1); } - // Look for Draw Options + // Look for DrawRef Options found = display.find("DrawRef="); std::string drawrefopt =""; while (found!=std::string::npos){ @@ -898,6 +900,20 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou } if (drawrefopt=="") { drawrefopt = drawopt; } + // Look for DrawRef2D Options + found = display.find("DrawRef2D="); + std::string drawrefopt2D =""; + while (found!=std::string::npos){ + std::size_t found1 = display.find_first_of(",",found+1); + if (found1!=std::string::npos){ + drawrefopt2D +=boost::algorithm::to_lower_copy(display.substr(found+10,found1-found-10)); + } + else { + drawrefopt2D +=boost::algorithm::to_lower_copy(display.substr(found+10,display.size())); + } + found=display.find("DrawRef2D=",found+1); + } + // should we rename "Data" ? found = display.find("DataName"); std::string datatitle; @@ -1126,16 +1142,16 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou if( h2 != 0 ) { + formatTH2( myC, h2 ); myC->cd(); if( h2->GetMinimum() >= 0 && h2->GetMaximum()>0.) { - gPad->SetLogy(display.find("LogY")!=std::string::npos ); + gPad->SetLogy(display.find("LogY")!=std::string::npos ); gPad->SetLogz(display.find("LogZ")!=std::string::npos ); } if( BINLOEDGE(h2,1) > 0) { gPad->SetLogx(display.find("LogX")!=std::string::npos ); } - - formatTH2( myC, h2 ); + if( h->GetXaxis()->GetXmin() >= h->GetXaxis()->GetXmax() ) { std::cerr << "HanOutputFile::saveHistogramToFile(): " << "Inconsistent x-axis settings: min=" << h->GetXaxis()->GetXmin() << ", " @@ -1154,19 +1170,27 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou if (drawopt =="") { drawopt = "COLZ"; } - h2->Draw(drawopt.c_str() ); + + if(drawRefs){ + groupDir->cd((nameHis+"_/Results").c_str()); + gDirectory->GetObject("Reference;1",ref); + h2Ref = dynamic_cast<TH2*>(ref); + TCollection* colln = dynamic_cast<TCollection*>(ref); + if(colln){ + h2Ref = dynamic_cast<TH2*>(colln->MakeIterator()->Next()); + } + if (h2Ref && (drawrefopt2D!="")){ + formatTH2( myC, h2Ref ); + h2Ref->Draw(drawrefopt2D.c_str()); + } + } + + h2->Draw(("SAME"+drawopt).c_str()); displayExtra(myC,display); if (drawopt.find("lego") == std::string::npos) { myC->RedrawAxis(); } - - if(drawRefs){ - groupDir->cd((nameHis+"_/Results").c_str()); - gDirectory->GetObject("Reference;1",ref); - h2Ref = (TH2*)(ref); - if (h2Ref) - ratioplot2D(myC, h2, h2Ref, display); - } + if (h2Ref) ratioplot2D(myC, h2, h2Ref, display); polynomial(myC,display,h2); TLatex t; @@ -1180,8 +1204,7 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou myC->SaveAs( name.c_str() ); - } - else if( h != 0 ){ + } else if( h != 0 ){ formatTH1( myC, h ); if(display.find("StatBox")!=std::string::npos){ h->SetStats(kTRUE); @@ -1195,6 +1218,8 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou } h->SetLineColor(kBlack); h->SetMarkerColor(1); + // h->SetMarkerStyle(iMarkerStyle); + // h->SetMarkerSize(0.8); h->SetFillStyle(0); h->SetLineWidth(2); myC->cd(); @@ -1234,8 +1259,10 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou TProfile* pRef = dynamic_cast<TProfile*>( hRef ); if( pRef != 0 ) { hRef->SetMarkerColor(local_color); + // hRef->SetMarkerStyle(iMarkerStyle); + // hRef->SetMarkerSize(0.8); hRef->SetLineColor(local_color); - hRef->SetLineWidth(local_color); + hRef->SetLineWidth(2); double ymin = ( hRef->GetMinimum() < h->GetMinimum() )? hRef->GetMinimum(): h->GetMinimum(); double ymax = ( hRef->GetMaximum() > h->GetMaximum() )? hRef->GetMaximum(): h->GetMaximum(); double xmin, xmax; @@ -1271,7 +1298,7 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou if( h->GetMinimum()>= 0. && hRef->GetMinimum()>= 0. && h->GetMaximum()> 0. && hRef->GetMaximum()> 0.) { gPad->SetLogy(display.find("LogY")!=std::string::npos ); } - if( BINLOEDGE(h, 1)>0 && BINLOEDGE(hRef, 1) > 0) { + if( BINLOEDGE(h, 1)>0 && BINLOEDGE(hRef, 1) > 0) { gPad->SetLogx(display.find("LogX")!=std::string::npos ); } if (!hasPlotted) { @@ -1287,6 +1314,8 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou scale = h->Integral("width")/hRef->Integral("width"); } hRef->Scale( scale ); + // hRef->SetMarkerStyle(iMarkerStyle); + // hRef->SetMarkerSize(0.8); hRef->SetMarkerColor(local_color); //hRef->SetFillColor(local_color); hRef->SetLineColor(local_color); @@ -1327,7 +1356,7 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou if( h->GetMinimum()>= 0 && hRef->GetMinimum()>= 0 && h->GetMaximum()> 0. && hRef->GetMaximum()> 0.) { gPad->SetLogy(display.find("LogY")!=std::string::npos ); } - if( BINLOEDGE(h, 1)>0 && BINLOEDGE(hRef, 1) > 0) { + if( BINLOEDGE(h, 1)>0 && BINLOEDGE(hRef, 1) > 0) { gPad->SetLogx(display.find("LogX")!=std::string::npos ); } axisOption(display,h); @@ -1346,7 +1375,7 @@ saveHistogramToFile( std::string nameHis, std::string location, TDirectory* grou if( h->GetMinimum() >= 0) { gPad->SetLogy(display.find("LogY")!=std::string::npos ); } - if( BINLOEDGE(h, 1) > 0) { + if( BINLOEDGE(h, 1) > 0) { gPad->SetLogx(display.find("LogX")!=std::string::npos ); } axisOption(display,h); @@ -1434,7 +1463,7 @@ bool HanOutputFile::saveHistogramToFileSuperimposed( std::string nameHis, std::s gStyle->SetStatY(0.99); gStyle->SetStatW(0.2); gStyle->SetStatH(0.1); - + gROOT->SetBatch(); std::string pathname( groupDir1->GetPath() ); @@ -1838,7 +1867,7 @@ bool HanOutputFile::drawH1(TCanvas* myC,TH1* h,TH1* hRef,std::string &drawopt,st }else{ gPad->SetLogy(false); } - if( BINLOEDGE(h, 1) > 0) { + if( BINLOEDGE(h, 1) > 0) { gPad->SetLogx(display.find("LogX")!=std::string::npos ); }else{ gPad->SetLogx(false ); @@ -1860,7 +1889,7 @@ bool HanOutputFile::drawReference(TCanvas* myC,TH1* hRef,TH1* h,std::string &dra hRef->SetLineColor(2); hRef->SetLineWidth(2); double ymin = ( hRef->GetMinimum() < h->GetMinimum() )? hRef->GetMinimum(): h->GetMinimum(); - double ymax = ( hRef->GetMaximum() > h->GetMaximum() )? hRef->GetMaximum(): h->GetMaximum(); + double ymax = ( hRef->GetMaximum() > h->GetMaximum() )? hRef->GetMaximum(): h->GetMaximum(); //double xmin = ( BINLOEDGE(hRef, 1) < BINLOEDGE(h, 1)) ? BINLOEDGE(hRef, 1)-BINWIDTH(hRef, 1) : BINLOEDGE(h, 1)-BINWIDTH(h, 1); //double xmax = ( BINLOEDGE(hRef, hRef->GetNbinsX()) + BINWIDTH(hRef, hRef->GetNbinsX()) > BINLOEDGE(h, h->GetNbinsX()) + BINWIDTH(h, h->GetNbinsX()) ) ? // BINLOEDGE(hRef, hRef->GetNbinsX()) + 2.0*BINWIDTH(hRef, hRef->GetNbinsX()): BINLOEDGE(h, h->GetNbinsX()) + 2.0*BINWIDTH(h, h->GetNbinsX()) ; @@ -1908,7 +1937,7 @@ bool HanOutputFile::drawReference(TCanvas* myC,TH1* hRef,TH1* h,std::string &dra hRef->SetFillColor(15); hRef->SetLineColor(15); double ymin = ( hRef->GetMinimum() < h->GetMinimum() )? hRef->GetMinimum(): h->GetMinimum(); - double ymax = ( hRef->GetMaximum() > h->GetMaximum() )? hRef->GetMaximum(): h->GetMaximum(); + double ymax = ( hRef->GetMaximum() > h->GetMaximum() )? hRef->GetMaximum(): h->GetMaximum(); //double xmin = ( BINLOEDGE(hRef, 1) < BINLOEDGE(h, 1)) ? BINLOEDGE(hRef, 1)-BINWIDTH(hRef, 1) : BINLOEDGE(h, 1)-BINWIDTH(h, 1); //double xmax = ( BINLOEDGE(hRef, hRef->GetNbinsX()) + BINWIDTH(hRef, hRef->GetNbinsX()) > BINLOEDGE(h, h->GetNbinsX()) + BINWIDTH(h, h->GetNbinsX()) ) ? BINLOEDGE(hRef, hRef->GetNbinsX()) + 2.0*BINWIDTH(hRef, hRef->GetNbinsX()): BINLOEDGE(h, h->GetNbinsX()) + 2.0*BINWIDTH(h, h->GetNbinsX()) ; double xmin = ( BINLOEDGE(hRef, 1) < BINLOEDGE(h, 1)) ? BINLOEDGE(hRef, 1) : BINLOEDGE(h, 1); @@ -2037,12 +2066,12 @@ axisOption( std::string str, TH1* h ) if(txt[1]=='M'){ if (txt=="XMax") { - double xmin = BINLOEDGE(h, 1); + double xmin = BINLOEDGE(h, 1); h->GetXaxis()->SetRangeUser(xmin,x1); } if (txt=="XMin") { - double xmax = BINLOEDGE(h, h->GetNbinsX()) + BINWIDTH(h, h->GetNbinsX()) ; + double xmax = BINLOEDGE(h, h->GetNbinsX()) + BINWIDTH(h, h->GetNbinsX()) ; h->GetXaxis()->SetRangeUser(x1,xmax); } if (txt=="YMax") @@ -2085,8 +2114,10 @@ void HanOutputFile::ratioplot (TCanvas* myC_upperpad ,TH1* h,TH1* hRef,std::stri clonehist->Divide(hRef); formatTH1( myC_ratiopad, clonehist); clonehist->SetTitle(""); - clonehist->SetAxisRange(0,2,"Y"); - clonehist->Draw("HIST"); + clonehist->SetAxisRange(0.25,1.75,"Y"); + clonehist->GetYaxis()->SetNdivisions(3, true); + clonehist->SetMarkerStyle(1); + clonehist->Draw("E"); clonehist->GetXaxis()->SetTitleSize(0.11); clonehist->GetXaxis()->SetLabelSize(0.11); clonehist->GetYaxis()->SetTitleSize(0.11); @@ -2127,7 +2158,6 @@ void HanOutputFile::ratioplot (TCanvas* myC_upperpad ,TH1* h,TH1* hRef,std::stri } void HanOutputFile::ratioplot2D (TCanvas* canvas_top, TH2* h2, TH2* h2Ref, std::string display) { - if (display.find("Ref2DRatio") == std::string::npos && display.find("Ref2DSignif") == std::string::npos ) @@ -2176,7 +2206,7 @@ void HanOutputFile::ratioplot2D (TCanvas* canvas_top, TH2* h2, TH2* h2Ref, std:: else signif = (value_a - value_b) / sqrt((sigma_a*sigma_a + sigma_b*sigma_b)); - comparison->SetBinContent(binx, biny, signif); + comparison->SetBinContent(binx, biny, signif); } } } @@ -2211,6 +2241,7 @@ void HanOutputFile::ratioplot2D (TCanvas* canvas_top, TH2* h2, TH2* h2Ref, std:: canvas_all->DrawClonePad(); } + //----------------------------- void HanOutputFile::polynomial( TCanvas* c, std::string str,TH1* h ) { double xmin=h->GetXaxis()->GetXmin(); @@ -2449,6 +2480,8 @@ formatTH1( TCanvas* c, TH1* h ) const h->GetXaxis()->SetTitleSize(0.04); h->GetYaxis()->SetTitleFont(62); h->GetYaxis()->SetTitleSize(0.04); + h->SetMarkerStyle(20); + h->SetMarkerSize(0.8); h->SetTitleOffset(1.5,"y"); h->SetTitleOffset(0.9,"x"); diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_DiMuPostProcess.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_DiMuPostProcess.cxx index efd4e4387ee26d7abe687dd61303c0fff8a532ee..45cffcee22e0b430b83c2fa38da1bc77072c16e6 100644 --- a/DataQuality/DataQualityUtils/src/MonitoringFile_DiMuPostProcess.cxx +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_DiMuPostProcess.cxx @@ -166,32 +166,32 @@ fitMergedFile_DiMuMonAll( TFile* f, std::string run_dir, std::string resonName, vars.push_back("phiSumm"); vars.push_back("crtDiff"); - std::map< std::string, TH1D* > m_invmass; - std::map< std::string, std::map< std::string, TH2D*> > m_2DinvmassVSx; - std::map< std::string, std::map< std::string, TH1D*> > m_invmassVSx; - std::map< std::string, std::map< std::string, TH1D*> > m_widthVSx; - TH1D* m_chi2; + std::map< std::string, TH1F* > m_invmass; + std::map< std::string, std::map< std::string, TH2F*> > m_2DinvmassVSx; + std::map< std::string, std::map< std::string, TH1F*> > m_invmassVSx; + std::map< std::string, std::map< std::string, TH1F*> > m_widthVSx; + TH1F* m_chi2; //loop over all possible 2D histos //check if 2D histo has been filled //if found the 2D histo, then see whether the mean or width or both 1D histos were also made.-->Decide what to refit ` if (CheckHistogram(f,(path+"_detail/chi2").c_str())) { - m_chi2 = (TH1D*)(f->Get((path+"_detail/chi2").c_str())->Clone()); + m_chi2 = (TH1F*)(f->Get((path+"_detail/chi2").c_str())->Clone()); std::vector<std::string> ::iterator ivar = vars.begin(); std::vector<std::string> ::iterator ireg = regions.begin(); for (ireg=regions.begin(); ireg!=regions.end(); ireg++) { for (ivar=vars.begin(); ivar!=vars.end(); ivar++) { std::string hname2D = resonName + "_2DinvmassVS" + *ivar + "_" + *ireg; if (CheckHistogram(f,(path+"/"+hname2D).c_str())) { - m_2DinvmassVSx[*ireg][*ivar] = (TH2D*)(f->Get((path+"/"+hname2D).c_str())->Clone()); + m_2DinvmassVSx[*ireg][*ivar] = (TH2F*)(f->Get((path+"/"+hname2D).c_str())->Clone()); std::string hnameMean = resonName + "_invmassVS" + *ivar + "_" + *ireg; std::string hnameWidth = resonName + "_widthVS" + *ivar + "_" + *ireg; - std::vector<TH1D*> hfitted; + std::vector<TH1F*> hfitted; if (CheckHistogram(f,(path+"/"+hnameMean).c_str())) { - m_invmassVSx[*ireg][*ivar] = (TH1D*)(f->Get((path+"/"+hnameMean).c_str())->Clone()); + m_invmassVSx[*ireg][*ivar] = (TH1F*)(f->Get((path+"/"+hnameMean).c_str())->Clone()); hfitted.push_back(m_invmassVSx[*ireg][*ivar] ); if (CheckHistogram(f,(path+"_detail/"+hnameWidth).c_str())) { - m_widthVSx[*ireg][*ivar] = (TH1D*)(f->Get((path+"_detail/"+hnameWidth).c_str())->Clone()); + m_widthVSx[*ireg][*ivar] = (TH1F*)(f->Get((path+"_detail/"+hnameWidth).c_str())->Clone()); hfitted.push_back(m_widthVSx[*ireg][*ivar] ); fitHistos(m_2DinvmassVSx[*ireg][*ivar], hfitted, 0, triggerName, resonName, m_chi2);// 0 means to fill both mean and width results from the fit f->cd((path+"/").c_str()); @@ -205,7 +205,7 @@ fitMergedFile_DiMuMonAll( TFile* f, std::string run_dir, std::string resonName, } } else { if (CheckHistogram(f,(path+"_detail/"+hnameWidth).c_str())) { - m_widthVSx[*ireg][*ivar] = (TH1D*)(f->Get((path+"_detail/"+hnameWidth).c_str())->Clone()); + m_widthVSx[*ireg][*ivar] = (TH1F*)(f->Get((path+"_detail/"+hnameWidth).c_str())->Clone()); hfitted.push_back(m_widthVSx[*ireg][*ivar] ); fitHistos(m_2DinvmassVSx[*ireg][*ivar], hfitted, 2, triggerName, resonName, m_chi2);// 2 means to fill only width results from the fit f->cd((path+"_detail/").c_str()); @@ -223,7 +223,7 @@ fitMergedFile_DiMuMonAll( TFile* f, std::string run_dir, std::string resonName, f->Write(); } -void MonitoringFile::fitHistos (TH2D* hin, std::vector<TH1D*> hout, int mode, std::string triggerName, std::string resonName, TH1D* m_chi2){ +void MonitoringFile::fitHistos (TH2F* hin, std::vector<TH1F*> hout, int mode, std::string triggerName, std::string resonName, TH1F* m_chi2){ bool saveHistos = false; // a canvas may be needed when implmenting this into the post-processing file //std::cout<<"The fitHistos method is called"<<endl; @@ -233,7 +233,7 @@ void MonitoringFile::fitHistos (TH2D* hin, std::vector<TH1D*> hout, int mode, st int nbins=hin->GetNbinsX(); for (int i=0; i<nbins;i++){ snprintf(num2str,50,"%s_%i",(hname).c_str(),i); - TH1D* htemp = (TH1D*) (hin->ProjectionY(num2str,i+1,i+1)); + TH1F* htemp = (TH1F*) (hin->ProjectionY(num2str,i+1,i+1)); //htemp->SetTitle(projName); htemp->Sumw2(); if (htemp->GetEntries()>50){ diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_HLTMuonHistogramDivision.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_HLTMuonHistogramDivision.cxx index bd9fe913832574768e46747b0a175dc3a419791e..6c6de28ed99de8f679b0dae43f2edd209bd87bbb 100644 --- a/DataQuality/DataQualityUtils/src/MonitoringFile_HLTMuonHistogramDivision.cxx +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_HLTMuonHistogramDivision.cxx @@ -101,7 +101,7 @@ namespace dqutils { }else{ //std::cout<<"HI_PP_Flag :found "<<std::endl; //std::cout<<"bin content "<<hHI_PP_Flag->GetBinContent(0)<<"/"<<hHI_PP_Flag->GetBinContent(1)<<"/"<<hHI_PP_Flag->GetBinContent(2)<<std::endl; - if(hHI_PP_Flag->GetBinContent(1)==0){ + if(hHI_PP_Flag->GetBinContent(1) > 0){ m_HI_pp_key = true; }else{ m_HI_pp_key = false; diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_IDAlignPostProcess.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_IDAlignPostProcess.cxx index 4a0f5d9556826360604ecb35ee2c94383eb56a59..5911b07433ade2466853c23833a2e4ad0a9907cc 100644 --- a/DataQuality/DataQualityUtils/src/MonitoringFile_IDAlignPostProcess.cxx +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_IDAlignPostProcess.cxx @@ -79,7 +79,7 @@ fitMergedFile_IDAlignMonManager( std::string inFilename, bool /* isIncremental * while ((key_tracks=dynamic_cast<TKey*>(next_tracks() )) !=0) { std::string tracks_name(key_tracks->GetName()); //std::cout<<"looking at tracks dir: "<<tracks_name<<std::endl; - if (tracks_name.find("Tracks")!=std::string::npos) { + if (tracks_name.find("Track")!=std::string::npos) { //std::cout<<"Found tracks name: "<<tracks_name<<std::endl; TObject *obj = key_tracks->ReadObj(); TDirectory *tdir = dynamic_cast<TDirectory*>(obj); @@ -98,6 +98,9 @@ fitMergedFile_IDAlignMonManager( std::string inFilename, bool /* isIncremental * //std::cout<<"Find Module: "<<module_name<<std::endl; fitMergedFile_IDAlignMonTrackSegments( f,run_dir,tracks_name ); } + if (module_name.find("GenericTracks")!=std::string::npos) { + fitMergedFile_IDAlignMonPVbiases( f,run_dir,tracks_name ); + } //This is not needed. The plots are already in the monitoring file //if (module_name.find("GenericTracks")!=std::string::npos) { //std::cout<<"Find Module: "<<module_name<<std::endl; @@ -133,7 +136,7 @@ fitMergedFile_IDAlignMonManager( std::string inFilename, bool /* isIncremental * while ((key_tracks=dynamic_cast<TKey*>(next_tracks() )) !=0) { std::string tracks_name(key_tracks->GetName()); //std::cout<<"looking at tracks dir: "<<tracks_name<<std::endl; - if (tracks_name.find("AlignTracks")!=std::string::npos) { + if (tracks_name.find("Tracks")!=std::string::npos) { //std::cout<<"Found tracks name: "<<tracks_name<<std::endl; TObject *obj = key_tracks->ReadObj(); TDirectory *tdir = dynamic_cast<TDirectory*>(obj); @@ -1105,7 +1108,7 @@ fitMergedFile_IDAlignMonResiduals( TFile* f, std::string run_dir, std::string tr TH2F* m_pix_b1_xresvsmodetaphi_mean = new TH2F("pix_b1_xresvsmodetaphi_mean","X Residual Mean vs Module Eta-Phi-ID Pixel Barrel L1",13,-6.5,6.5,22,-0.5,21.5); m_pix_b1_xresvsmodetaphi_mean->GetXaxis()->SetTitle("Module Eta-ID"); m_pix_b1_xresvsmodetaphi_mean->GetYaxis()->SetTitle("Module Phi-ID"); - TH2F* m_pix_b2_xresvsmodetaphi_mean = new TH2F("pix_b1_xresvsmodetaphi_mean","X Residual Mean vs Module Eta-Phi-ID Pixel Barrel L2",13,-6.5,6.5,38,-0.5,37.5); + TH2F* m_pix_b2_xresvsmodetaphi_mean = new TH2F("pix_b2_xresvsmodetaphi_mean","X Residual Mean vs Module Eta-Phi-ID Pixel Barrel L2",13,-6.5,6.5,38,-0.5,37.5); m_pix_b2_xresvsmodetaphi_mean->GetXaxis()->SetTitle("Module Eta-ID"); m_pix_b2_xresvsmodetaphi_mean->GetYaxis()->SetTitle("Module Phi-ID"); TH2F* m_pix_b3_xresvsmodetaphi_mean = new TH2F("pix_b3_xresvsmodetaphi_mean","X Residual Mean vs Module Eta-Phi-ID Pixel Barrel L3",13,-6.5,6.5,52,-0.5,51.5); @@ -2170,6 +2173,440 @@ fitMergedFile_IDAlignMonGenericTracks (TFile* file, std::string run_dir, std::st } +void +MonitoringFile:: +fitMergedFile_IDAlignMonPVbiases (TFile* file, std::string run_dir, std::string tracksName) +{ + std::string path; + path= run_dir + "IDAlignMon/" + tracksName + "/GenericTracks"; + //path= run_dir + "IDAlignMon/InDetTrackParticles_all/GenericTracks"; + if( file->cd(path.c_str())==0 ) { + //std::cerr << "MonitoringFile::fitMergedFile_IDAlignMonGenericTracks(): " + // << "No such directory \"" << path << "\"\n"; + return; + } + + + //Maps vs phi_vs_eta vs eta + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_negative").c_str()) ) { + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_positive=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_positive").c_str())->Clone()); + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_negative=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_negative").c_str())->Clone()); + + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_positive = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_positive", "map d0 vs phi_vs_eta 400MeV-600MeV positive; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_negative = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_negative", "map d0 vs phi_vs_eta 400MeV-600MeV negative; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_positive,m_trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_positive); + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_negative,m_trk_d0_wrtPV_vs_phi_vs_eta_400MeV_600MeV_negative); + + m_trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_map_vs_phi_vs_eta_400MeV_600MeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_negative").c_str()) ) { + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_positive=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_positive").c_str())->Clone()); + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_negative=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_negative").c_str())->Clone()); + + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_positive = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_positive", "map d0 vs phi_vs_eta 600MeV-1GeV positive; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_negative = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_negative", "map d0 vs phi_vs_eta 600MeV-1GeV negative; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_positive,m_trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_positive); + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_negative,m_trk_d0_wrtPV_vs_phi_vs_eta_600MeV_1GeV_negative); + + m_trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_map_vs_phi_vs_eta_600MeV_1GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_negative").c_str()) ) { + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_positive=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_positive").c_str())->Clone()); + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_negative=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_negative").c_str())->Clone()); + + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_positive = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_positive", "map d0 vs phi_vs_eta 1GeV-2GeV positive; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_negative = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_negative", "map d0 vs phi_vs_eta 1GeV-2GeV negative; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_positive,m_trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_positive); + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_negative,m_trk_d0_wrtPV_vs_phi_vs_eta_1GeV_2GeV_negative); + + m_trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_map_vs_phi_vs_eta_1GeV_2GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_negative").c_str()) ) { + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_positive=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_positive").c_str())->Clone()); + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_negative=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_negative").c_str())->Clone()); + + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_positive = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_positive", "map d0 vs phi_vs_eta 2GeV-5GeV positive; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_negative = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_negative", "map d0 vs phi_vs_eta 2GeV-5GeV negative; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_positive,m_trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_positive); + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_negative,m_trk_d0_wrtPV_vs_phi_vs_eta_2GeV_5GeV_negative); + + m_trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_map_vs_phi_vs_eta_2GeV_5GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_negative").c_str()) ) { + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_positive=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_positive").c_str())->Clone()); + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_negative=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_negative").c_str())->Clone()); + + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_positive = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_positive", "map d0 vs phi_vs_eta 5GeV-10GeV positive; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_negative = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_negative", "map d0 vs phi_vs_eta 5GeV-10GeV negative; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_positive,m_trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_positive); + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_negative,m_trk_d0_wrtPV_vs_phi_vs_eta_5GeV_10GeV_negative); + + m_trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_map_vs_phi_vs_eta_5GeV_10GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_10GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_vs_eta_10GeV_negative").c_str()) ) { + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_10GeV_positive=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_10GeV_positive").c_str())->Clone()); + TH3F* m_trk_d0_wrtPV_vs_phi_vs_eta_10GeV_negative=(TH3F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_vs_eta_10GeV_negative").c_str())->Clone()); + + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_positive = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_positive", "map d0 vs phi_vs_eta >10GeV positive; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + TH2F* m_trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_negative = new TH2F("trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_negative", "map d0 vs phi_vs_eta >10GeV negative; #phi; #eta" , 20, -3.1, 3.1, 20, -2.5, 2.5 ); + + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_positive,m_trk_d0_wrtPV_vs_phi_vs_eta_10GeV_positive); + MakeMap(m_trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_negative,m_trk_d0_wrtPV_vs_phi_vs_eta_10GeV_negative); + + m_trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_map_vs_phi_vs_eta_10GeV_negative->Write("",TObject::kOverwrite); + } + + //Profiles vs phi + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_400MeV_600MeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_400MeV_600MeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_phi_400MeV_600MeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_400MeV_600MeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_phi_400MeV_600MeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_400MeV_600MeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_positive", "profile d0 vs phi 400MeV-600MeV positive; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + TH1F* m_trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_negative", "profile d0 vs phi 400MeV-600MeV negative; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_positive,m_trk_d0_wrtPV_vs_phi_400MeV_600MeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_negative,m_trk_d0_wrtPV_vs_phi_400MeV_600MeV_negative); + + m_trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_phi_400MeV_600MeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_600MeV_1GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_600MeV_1GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_phi_600MeV_1GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_600MeV_1GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_phi_600MeV_1GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_600MeV_1GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_positive", "profile d0 vs phi 600MeV-1GeV positive; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + TH1F* m_trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_negative", "profile d0 vs phi 600MeV-1GeV negative; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_positive,m_trk_d0_wrtPV_vs_phi_600MeV_1GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_negative,m_trk_d0_wrtPV_vs_phi_600MeV_1GeV_negative); + + m_trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_phi_600MeV_1GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_1GeV_2GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_1GeV_2GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_phi_1GeV_2GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_1GeV_2GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_phi_1GeV_2GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_1GeV_2GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_positive", "profile d0 vs phi 1GeV-2GeV positive; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + TH1F* m_trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_negative", "profile d0 vs phi 1GeV-2GeV negative; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_positive,m_trk_d0_wrtPV_vs_phi_1GeV_2GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_negative,m_trk_d0_wrtPV_vs_phi_1GeV_2GeV_negative); + + m_trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_phi_1GeV_2GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_2GeV_5GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_2GeV_5GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_phi_2GeV_5GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_2GeV_5GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_phi_2GeV_5GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_2GeV_5GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_positive", "profile d0 vs phi 2GeV-5GeV positive; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + TH1F* m_trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_negative", "profile d0 vs phi 2GeV-5GeV negative; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_positive,m_trk_d0_wrtPV_vs_phi_2GeV_5GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_negative,m_trk_d0_wrtPV_vs_phi_2GeV_5GeV_negative); + + m_trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_phi_2GeV_5GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_5GeV_10GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_5GeV_10GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_phi_5GeV_10GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_5GeV_10GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_phi_5GeV_10GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_5GeV_10GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_positive", "profile d0 vs phi 5GeV-10GeV positive; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + TH1F* m_trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_negative", "profile d0 vs phi 5GeV-10GeV negative; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_positive,m_trk_d0_wrtPV_vs_phi_5GeV_10GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_negative,m_trk_d0_wrtPV_vs_phi_5GeV_10GeV_negative); + + m_trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_phi_5GeV_10GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_10GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_phi_10GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_phi_10GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_10GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_phi_10GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_phi_10GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_phi_10GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_phi_10GeV_positive", "profile d0 vs phi >10GeV positive; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + TH1F* m_trk_d0_wrtPV_profile_vs_phi_10GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_phi_10GeV_negative", "profile d0 vs phi >10GeV negative; #phi; d0 [mm]" , 50, -3.1, 3.1 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_10GeV_positive,m_trk_d0_wrtPV_vs_phi_10GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_phi_10GeV_negative,m_trk_d0_wrtPV_vs_phi_10GeV_negative); + + m_trk_d0_wrtPV_profile_vs_phi_10GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_phi_10GeV_negative->Write("",TObject::kOverwrite); + } + + //Profiles vs eta + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_400MeV_600MeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_400MeV_600MeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_eta_400MeV_600MeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_400MeV_600MeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_eta_400MeV_600MeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_400MeV_600MeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_positive", "profile d0 vs eta 400MeV-600MeV positive; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + TH1F* m_trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_negative", "profile d0 vs eta 400MeV-600MeV negative; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_positive,m_trk_d0_wrtPV_vs_eta_400MeV_600MeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_negative,m_trk_d0_wrtPV_vs_eta_400MeV_600MeV_negative); + + m_trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_eta_400MeV_600MeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_600MeV_1GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_600MeV_1GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_eta_600MeV_1GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_600MeV_1GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_eta_600MeV_1GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_600MeV_1GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_positive", "profile d0 vs eta 600MeV-1GeV positive; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + TH1F* m_trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_negative", "profile d0 vs eta 600MeV-1GeV negative; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_positive,m_trk_d0_wrtPV_vs_eta_600MeV_1GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_negative,m_trk_d0_wrtPV_vs_eta_600MeV_1GeV_negative); + + m_trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_eta_600MeV_1GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_1GeV_2GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_1GeV_2GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_eta_1GeV_2GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_1GeV_2GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_eta_1GeV_2GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_1GeV_2GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_positive", "profile d0 vs eta 1GeV-2GeV positive; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + TH1F* m_trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_negative", "profile d0 vs eta 1GeV-2GeV negative; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_positive,m_trk_d0_wrtPV_vs_eta_1GeV_2GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_negative,m_trk_d0_wrtPV_vs_eta_1GeV_2GeV_negative); + + m_trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_eta_1GeV_2GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_2GeV_5GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_2GeV_5GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_eta_2GeV_5GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_2GeV_5GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_eta_2GeV_5GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_2GeV_5GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_positive", "profile d0 vs eta 2GeV-5GeV positive; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + TH1F* m_trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_negative", "profile d0 vs eta 2GeV-5GeV negative; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_positive,m_trk_d0_wrtPV_vs_eta_2GeV_5GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_negative,m_trk_d0_wrtPV_vs_eta_2GeV_5GeV_negative); + + m_trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_eta_2GeV_5GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_5GeV_10GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_5GeV_10GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_eta_5GeV_10GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_5GeV_10GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_eta_5GeV_10GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_5GeV_10GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_positive", "profile d0 vs eta 5GeV-10GeV positive; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + TH1F* m_trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_negative", "profile d0 vs eta 5GeV-10GeV negative; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_positive,m_trk_d0_wrtPV_vs_eta_5GeV_10GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_negative,m_trk_d0_wrtPV_vs_eta_5GeV_10GeV_negative); + + m_trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_eta_5GeV_10GeV_negative->Write("",TObject::kOverwrite); + } + + if(CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_10GeV_positive").c_str()) && CheckHistogram(file,(path+"/trk_d0_wrtPV_vs_eta_10GeV_negative").c_str()) ) { + TH2F* m_trk_d0_wrtPV_vs_eta_10GeV_positive=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_10GeV_positive").c_str())->Clone()); + TH2F* m_trk_d0_wrtPV_vs_eta_10GeV_negative=(TH2F*)(file->Get((path+"/trk_d0_wrtPV_vs_eta_10GeV_negative").c_str())->Clone()); + + TH1F* m_trk_d0_wrtPV_profile_vs_eta_10GeV_positive = new TH1F("trk_d0_wrtPV_profile_vs_eta_10GeV_positive", "profile d0 vs eta >10GeV positive; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + TH1F* m_trk_d0_wrtPV_profile_vs_eta_10GeV_negative = new TH1F("trk_d0_wrtPV_profile_vs_eta_10GeV_negative", "profile d0 vs eta >10GeV negative; #eta; d0 [mm]" , 50, -2.5, 2.5 ); + + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_10GeV_positive,m_trk_d0_wrtPV_vs_eta_10GeV_positive); + Make1DProfile(m_trk_d0_wrtPV_profile_vs_eta_10GeV_negative,m_trk_d0_wrtPV_vs_eta_10GeV_negative); + + m_trk_d0_wrtPV_profile_vs_eta_10GeV_positive->Write("",TObject::kOverwrite); + m_trk_d0_wrtPV_profile_vs_eta_10GeV_negative->Write("",TObject::kOverwrite); + } + + file->Write(); +} + +void +MonitoringFile:: +Make1DProfile(TH1* output, TH2* histo) +{ + int nXbins = histo->GetXaxis()->GetNbins(); //NEED TO CHANGE THIS + + double current_mu[nXbins]; + double current_err_mu[nXbins]; + double current_sigma[nXbins]; + double current_err_sigma[nXbins]; + + for(int i=0;i<nXbins;i++) { + TH1D * projection = histo->ProjectionY("projection",i+1,i+1); + IterativeGaussFit(projection, current_mu[i], current_err_mu[i], current_sigma[i], current_err_sigma[i]); + + output->SetBinContent(i,current_mu[i]); + output->SetBinError(i,current_err_mu[i]); + } +} + +void +MonitoringFile:: +MakeMap(TH2* outputhist, TH3* hist) +{ + int num_bins=1; //WHAT IS THIS AGAIN + + int num_bins_x = hist->GetXaxis()->GetNbins(); + int num_bins_y = hist->GetYaxis()->GetNbins(); + + TH1D* current_proj; + + for (int i = 1; i < num_bins_x+(num_bins==1); i+=num_bins) { + for (int j = 1; j < num_bins_y+(num_bins==1); j+=num_bins) { + + int index = i/num_bins; + int index_y = j/num_bins; + + current_proj = hist->ProjectionZ(Form("%s_GaussProjection_%i_%i",hist->GetName(),index, index_y),i,i+num_bins-1,j,j+num_bins-1); + current_proj->SetTitle(Form("%s - Bin %i x %i",hist->GetName(), index,index_y)); + + //Fit the gauss + double current_mu,current_err_mu, current_sigma, current_err_sigma; + IterativeGaussFit(current_proj, current_mu, current_err_mu, current_sigma, current_err_sigma); + + //Fill the maps + float x_coord = (hist->GetXaxis()->GetBinLowEdge(i) + hist->GetXaxis()->GetBinUpEdge(i+num_bins-1))/2; + float y_coord = (hist->GetYaxis()->GetBinLowEdge(j) + hist->GetYaxis()->GetBinUpEdge(j+num_bins-1))/2; + + outputhist->Fill(x_coord,y_coord,current_mu); + + delete current_proj; + + } //end loop on j (y) + } //end loop on i (x) +} + +int +MonitoringFile:: +IterativeGaussFit(TH1* hist, double &mu, double &mu_err, double &sigma, double &sigma_err) +{ + //constants for fitting algorithm + const int iteration_limit = 20; + const float percent_limit = 0.01; + const float fit_range_multiplier = 1.5; + const int fDebug = 0; + + double last_mu; + double last_sigma; + double current_mu; + double current_sigma; + double mu_percent_diff; + double sigma_percent_diff; + + if (!hist) { + if (fDebug) std::cout<< "Error in Anp::IterativeGaussFit(): Histogram to be fit is missing" <<std::endl; + return 1; + } + + TF1* fit_func = new TF1("fit_func","gaus"); + + int bad_fit = hist->Fit(fit_func,"QN"); + + if (fDebug && bad_fit) std::cout <<"BAD INITIAL FIT: "<< hist->GetTitle() << std::endl; + + last_mu = fit_func->GetParameter(1); + last_sigma = fit_func->GetParameter(2); + + if (bad_fit) last_mu = hist->GetMean(); + + // check as well that the last_mu is reasonable + if (fabs(last_mu - hist->GetMean()) > 5*hist->GetBinWidth(1)) last_mu = hist->GetMean(); + + fit_func->SetRange(last_mu-fit_range_multiplier*last_sigma,last_mu+fit_range_multiplier*last_sigma); + + int iteration = 0; + + while ( iteration < iteration_limit ) { + + iteration++; + + double FitRangeLower = last_mu-fit_range_multiplier*last_sigma; + double FitRangeUpper = last_mu+fit_range_multiplier*last_sigma; + + // if range is to narrow --> broaden it + if ((FitRangeUpper-FitRangeLower)/hist->GetBinWidth(1) < 4) { + FitRangeLower -= hist->GetBinWidth(1); + FitRangeUpper += hist->GetBinWidth(1); + } + + fit_func->SetRange(FitRangeLower, FitRangeUpper); + + bad_fit = hist->Fit(fit_func, "RQN"); + + if (fDebug && bad_fit) std::cout<<" ** BAD FIT ** : bin "<< hist->GetTitle() <<" iteration "<<iteration<<std::endl; + + current_mu = fit_func->GetParameter(1); + current_sigma = fit_func->GetParameter(2); + + float average_mu = (last_mu+current_mu)/2; + float average_sigma = (last_sigma+current_sigma)/2; + + if (average_mu == 0) { + if ( fDebug ) std::cout<<" Average mu = 0 in bin "<< hist->GetTitle() <<std::endl; + average_mu = current_mu; + } + + if (average_sigma == 0) { + if ( fDebug ) std::cout<<"Average sigma = 0; Fit Problem in "<< hist->GetTitle() <<". "<<last_sigma<<" "<<current_sigma<<std::endl; + average_sigma = current_sigma; + } + + mu_percent_diff = fabs((last_mu-current_mu)/average_mu); + sigma_percent_diff = fabs((last_sigma-current_sigma)/average_sigma); + + if ( mu_percent_diff < percent_limit && sigma_percent_diff < percent_limit ) break; + + if (iteration != iteration_limit) { //necessary? + last_mu = current_mu; + last_sigma = current_sigma; + } + // check as well that the last_mu is reasonable + if (fabs(last_mu - hist->GetMean()) > 5*hist->GetBinWidth(1)) { + last_mu = hist->GetMean(); + } + } + + if (iteration == iteration_limit) { + if (fDebug ) std::cout<<"WARNING: Fit did not converge to < "<<percent_limit*100<<"% in "<< hist->GetTitle() <<" in "<<iteration_limit<<" iterations. Percent Diffs: "<<mu_percent_diff*100<<"% (Mu),"<<" "<<sigma_percent_diff*100<<"% (Sigma)"<<std::endl; + //possibly return a value other than 0 to indicate not converged? + } + + mu = current_mu; + mu_err = fit_func->GetParError(1); + sigma = current_sigma; + sigma_err = fit_func->GetParError(2); + fit_func->SetLineColor(kRed); + + hist->GetListOfFunctions()->Add(fit_func); + + return 0; +} + void MonitoringFile:: ProcessAsymHistograms(TH1F* m_neg, TH1F* m_pos, TH1F* m_asym) diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx index bacf04282c528f077bea55ee3a9d97169ecd8f2b..f0b142cdb3e9b4ed2f30e7793efe09c2e3c095d8 100644 --- a/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx @@ -417,10 +417,6 @@ void MonitoringFile::MDTChamEff( std::string inFilename, std::string _title_, in TH1F* heff = new TH1F(ecap_fullStr_lower+"_TUBE_eff",ecap_fullStr_lower+"_TUBE_eff",100,0,1); TH1F* heffML = new TH1F(ecap_fullStr_lower+"_ML_eff",ecap_fullStr_lower+"_ML_eff",50,0,1); //Histogram To Trivially measure coverage per tube - int totalTube_region = 0; - int totalDead_region = 0; - TH1F* hTubeOcc = new TH1F(ecap_fullStr_lower+"_Occupancy",ecap_fullStr_lower+"_Tube_Occupancy",1,0,1); - mf.setMetaData(dir_Overview_local, heff, heffML, hTubeOcc); if(dir_Overview_local){ mf.get("EffsIn"+ecap_str+"InnerPerMultiLayer_ADCCut",EffInner,dir_Overview_local); @@ -705,10 +701,6 @@ void MonitoringFile::MDTChamEff( std::string inFilename, std::string _title_, in EffMiddle->Write("",TObject::kOverwrite); EffOuter->Write("",TObject::kOverwrite); EffExtra->Write("",TObject::kOverwrite); - hTubeOcc->Fill("%_Tubes_On", totalTube_region > 0 ? 1-totalDead_region*1./totalTube_region : 0); - hTubeOcc->Fill("%_Dead_Frac", totalTube_region > 0 ? totalDead_region*1./totalTube_region : 0); - hTubeOcc->LabelsDeflate("x"); - hTubeOcc->Write("",TObject::kOverwrite); } }//End BA,BC,EA,EC if(EffG){