ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/PVStudy/src/PVHistograms.cc
Revision: 1.4
Committed: Sat Jan 30 18:25:53 2010 UTC (15 years, 3 months ago) by yygao
Content type: text/plain
Branch: MAIN
CVS Tags: CMSSW_3_6_1_patch3_May27thReReco, CMSSW_3_5_8_patch3_May6thReReco, PASPlot_27Feb2010, HEAD
Changes since 1.3: +1 -16 lines
Log Message:
Remove the pixel vertices plots

File Contents

# User Rev Content
1 jengbou 1.1 /**_________________________________________________________________
2     class: PVHistograms.cc
3    
4     author: Geng-yuan Jeng, UC Riverside (Geng-yuan.Jeng@cern.ch)
5 jengbou 1.2 Yanyan Gao, Fermilab (ygao@fnal.gov)
6 jengbou 1.1
7 yygao 1.4 version $Id: PVHistograms.cc,v 1.3 2010/01/26 12:05:42 yygao Exp $
8 jengbou 1.1
9     ________________________________________________________________**/
10    
11    
12     #include "UserCode/PVStudy/interface/PVHistograms.h"
13 jengbou 1.2 #include <iostream>
14 jengbou 1.1
15     //_______________________________________________________________
16     PVHistograms::PVHistograms() {
17    
18     }
19    
20     //_______________________________________________________________
21     PVHistograms::~PVHistograms() {
22    
23     this->DeleteHisto();
24    
25     }
26    
27     //_______________________________________________________________
28     void PVHistograms::Init(TString type, TString suffix1, TString suffix2) {
29    
30     TString methodName = suffix1;
31     if (suffix2 != "") suffix1 += "_" + suffix2;
32    
33     if (type == "pvTrk") {
34     // Histograms of track properties
35     h1["nTrk"+suffix1] = new TH1D("nTrk"+suffix1, "Num of rec tracks"+suffix1, 300,0,300);
36 yygao 1.3 h1["trkPt"+suffix1] = new TH1D("trkPt"+suffix1, "Pt of rec tracks "+suffix1, 800,0,100);
37 jengbou 1.1 h1["trkEta"+suffix1] = new TH1D("trkEta"+suffix1, "#eta of rec tracks "+suffix1, 100,-3,3);
38     h1["trkPhi"+suffix1] = new TH1D("trkPhi"+suffix1, "#phi of rec tracks "+suffix1, 100,-3.2,3.2);
39     h1["trkDxy"+suffix1] = new TH1D("trkDxy"+suffix1, "Dxy of rec tracks "+suffix1, 100,-0.5,0.5);
40 yygao 1.3 h1["trkDxyCorr"+suffix1] = new TH1D("trkDxyCorr"+suffix1, TString("BS Corrected Dxy of rec tracks "+suffix1),100,-0.5,0.5);
41     h1["trkDz"+suffix1] = new TH1D("trkDz"+suffix1, "Dz of rec tracks "+suffix1, 300,-50,50);
42 jengbou 1.1
43     h1["nTrkPV"+suffix1] = new TH1D("nTrkPV"+suffix1, "Num of rec tracks in PV"+suffix1, 300,0,300);
44 yygao 1.3 h1["nHWTrkPV"+suffix1] = new TH1D("nHWTrkPV"+suffix1, "Num of rec tracks with over 0.5 weight in PV"+suffix1, 300,0,300);
45     h1["ndofPV"+suffix1] = new TH1D("ndofPV"+suffix1, "PV ndof"+suffix1, 300,0,100);
46     h1["trkPtPV"+suffix1] = new TH1D("trkPtPV"+suffix1, "Pt of rec tracks in "+suffix1 ,800,0,100);
47 jengbou 1.1 h1["trkEtaPV"+suffix1] = new TH1D("trkEtaPV"+suffix1, "#eta of rec tracks in PV"+suffix1, 100,-3,3);
48     h1["trkPhiPV"+suffix1] = new TH1D("trkPhiPV"+suffix1, "#phi of rec tracks in PV"+suffix1, 100,-3.2,3.2);
49 yygao 1.3 h1["trkDxyPV"+suffix1] = new TH1D("trkDxyPV"+suffix1, "Dxy of rec tracks in PV"+suffix1, 100,-0.5,0.5);
50     h1["trkDxyCorrPV"+suffix1] = new TH1D("trkDxyCorrPV"+suffix1, "BS corrected Dxy of rec tracks in PV"+suffix1, 100,-0.5,0.5);
51     h1["trkDzPV"+suffix1] = new TH1D("trkDzPV"+suffix1, "Dz of rec tracks "+suffix1, 300,-50,50);
52 jengbou 1.1 h1["nrecPV"+suffix1] = new TH1D("nrecPV"+suffix1, "Num of rec pvtx"+suffix1, 50,0,50);
53     }
54     else if (type == "generator") {
55     h1["genPart_T"] = new TH1D("genPart_T","t component of gen particles",300,-0.5,0.5);
56     h1["genPart_T"]->GetXaxis()->SetTitle("t (nanosecond)");
57     h1["genPart_cT"] = new TH1D("genPart_cT","ct component of gen particles",300,-150.,150.);
58     h1["genPart_cT"]->GetXaxis()->SetTitle("ct (mm)");
59     h1["nsimPV"] = new TH1D("nsimPV","Num of sim PV",51,-0.5,50.5);
60     }
61     else if (type == "misc") {
62     h1["nrecPVDiff"] = new TH1D("nrecPVDiff","nrecPV1-nRecPV2",21,-10.5,10.5);
63     h1["nTrkPVDiff"] = new TH1D("nTrkPVDiff","nTrkPV1-nTrkPV2",41,-20.5,20.5);
64 yygao 1.3 h1["nTrkPVRelDiff"] = new TH1D("nTrkPVRelDiff","(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2)",100,-1,1);
65     h1["ndofPVDiff"] = new TH1D("ndofPVDiff","ndofPV1-ndofPV2",100,-10,10);
66     h1["ndofPVRelDiff"] = new TH1D("ndofPVRelDiff","(ndofPV1-ndofPV2)/(ndofPV1+ndofPV2)",100,-1,1);
67     h1["twovtxzsign"] = new TH1D("twovtxzsign", "two vtx z signficance",300,-20,20);
68 jengbou 1.1 // Histograms on comparing the multi-vertices
69     // Difference in reconstructed vtx position
70     h1["min_xsep"] = new TH1D("min_xsep", "min x diff of primary and secondary pvtx",300,0,0.1);
71     h1["min_xsep_sign"] = new TH1D("min_xsep_sign", "min x diff in signf of primary and secondary pvtx",300,0,5);
72     h1["min_ysep"] = new TH1D("min_ysep", "min y diff of primary and secondary pvtx",300,0,0.1);
73     h1["min_ysep_sign"] = new TH1D("min_ysep_sign", "min y diff in signf of primary and secondary pvtx",300,0,5);
74     h1["min_zsep"] = new TH1D("min_zsep", "min z diff of primary and secondary pvtx",300,0,5);
75     h1["min_zsep_sign"] = new TH1D("min_zsep_sign", "min z diff in signf of primary and secondary pvtx",300,0,200);
76     // Difference in reconstructed vtx position
77     h1["min_ntrksep"] = new TH1D("min_ntrksep", "min nTrk diff of primary and secondary pvtx",201,-50.5,150.5);
78     h1["min_sumpt2sep"] = new TH1D("min_sumpt2sep", "min sumpt2 diff of primary and secondary pvtx",300,0,10000);
79 yygao 1.3
80 jengbou 1.1 }
81     else if (type == "summary") {
82 yygao 1.3 h1["deltax"+suffix1] = new TH1D("deltax"+suffix1, "x-residual pvtx"+suffix1, 800,-0.1,0.1);
83     h1["deltay"+suffix1] = new TH1D("deltay"+suffix1, "y-residual pvtx"+suffix1, 800,-0.1,0.1);
84     h1["deltaz"+suffix1] = new TH1D("deltaz"+suffix1, "z-residual pvtx"+suffix1, 800,-0.1,0.1);
85     h1["pullx"+suffix1] = new TH1D("pullx"+suffix1, "x-pull pvtx"+suffix1, 800,-5,5);
86     h1["pully"+suffix1] = new TH1D("pully"+suffix1, "y-pull pvtx"+suffix1, 800,-5,5);
87     h1["pullz"+suffix1] = new TH1D("pullz"+suffix1, "z-pull pvtx"+suffix1, 800,-5,5);
88     h1["errPVx"+suffix1] = new TH1D("errPVx"+suffix1, "X"+suffix1+" vertex error", 200,0.,0.1);
89     h1["errPVy"+suffix1] = new TH1D("errPVy"+suffix1, "Y"+suffix1+" vertex error", 200,0.,0.1);
90     h1["errPVz"+suffix1] = new TH1D("errPVz"+suffix1, "Z"+suffix1+" vertex error", 200,0.,0.1);
91 jengbou 1.1 }
92     else if (type == "others") {
93 yygao 1.3 h1["deltax"+suffix1] = new TH1D("deltax"+suffix1, "x-residual of pvtx"+methodName, 200,-0.1,0.1);
94 jengbou 1.1 h1["deltax"+suffix1]->GetXaxis()->SetTitle("cm");
95 yygao 1.3 h1["deltay"+suffix1] = new TH1D("deltay"+suffix1, "y-residual of pvtx"+methodName, 200,-0.1,0.1);
96 jengbou 1.1 h1["deltay"+suffix1]->GetXaxis()->SetTitle("cm");
97 yygao 1.3 h1["deltaz"+suffix1] = new TH1D("deltaz"+suffix1, "z-residual of pvtx"+methodName, 200,-0.1,0.1);
98 jengbou 1.1 h1["deltaz"+suffix1]->GetXaxis()->SetTitle("cm");
99 yygao 1.3 h1["pullx"+suffix1] = new TH1D("pullx"+suffix1, "x-pull of pvtx"+methodName, 200,-5.,5.);
100     h1["pully"+suffix1] = new TH1D("pully"+suffix1, "y-pull of pvtx"+methodName, 200,-5.,5.);
101     h1["pullz"+suffix1] = new TH1D("pullz"+suffix1, "z-pull of pvtx"+methodName, 200,-5.,5.);
102     h1["errPVx"+suffix1] = new TH1D("errPVx"+suffix1, "X"+methodName+" vertex error", 200,0.,0.1);
103     h1["errPVy"+suffix1] = new TH1D("errPVy"+suffix1, "Y"+methodName+" vertex error", 200,0.,0.1);
104     h1["errPVz"+suffix1] = new TH1D("errPVz"+suffix1, "Z"+methodName+" vertex error", 200,0.,0.1);
105 jengbou 1.1 }
106    
107     }
108    
109     void PVHistograms::InitA(TString type, TString suffix1, TString suffix2, int nTrkMin_, int nTrkMax_) {
110    
111     TString methodName = suffix1;
112     if (suffix2 != "") suffix1 += "_" + suffix2;
113    
114     if (type == "analysis") {
115 yygao 1.3 h2["resx"+suffix1]= new TH2D("resx"+suffix1, "x-resolution vs number of tracks in pvtx"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,400,0.,500);
116 jengbou 1.1 h2["resx"+suffix1]->SetMarkerStyle(21);
117     h2["resx"+suffix1]->SetMarkerColor(4);
118     h2["resx"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
119     h2["resx"+suffix1]->GetYaxis()->SetTitle("#mum");
120 yygao 1.3 h2["resy"+suffix1]= new TH2D("resy"+suffix1, "y-resolution vs number of tracks in pvtx"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,400,0.,500);
121 jengbou 1.1 h2["resy"+suffix1]->SetMarkerStyle(21);
122     h2["resy"+suffix1]->SetMarkerColor(4);
123     h2["resy"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
124     h2["resy"+suffix1]->GetYaxis()->SetTitle("#mum");
125 yygao 1.3 h2["resz"+suffix1]= new TH2D("resz"+suffix1, "z-resolution vs number of tracks in pvtx"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,400,0.,500);
126 jengbou 1.1 h2["resz"+suffix1]->SetMarkerStyle(21);
127     h2["resz"+suffix1]->SetMarkerColor(4);
128     h2["resz"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
129     h2["resz"+suffix1]->GetYaxis()->SetTitle("#mum");
130 jengbou 1.2 h2["pullx"+suffix1]= new TH2D("pullx"+suffix1, "x-pull vs number of tracks"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,100,0.,2.);
131 jengbou 1.1 h2["pullx"+suffix1]->SetMarkerStyle(21);
132     h2["pullx"+suffix1]->SetMarkerColor(4);
133     h2["pullx"+suffix1]->SetBit(TH1::kCanRebin);
134     h2["pullx"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
135 jengbou 1.2 h2["pully"+suffix1]= new TH2D("pully"+suffix1, "y-pull vs number of tracks"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,100,0.,2.);
136 jengbou 1.1 h2["pully"+suffix1]->SetMarkerStyle(21);
137     h2["pully"+suffix1]->SetMarkerColor(4);
138     h2["pully"+suffix1]->SetBit(TH1::kCanRebin);
139     h2["pully"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
140 jengbou 1.2 h2["pullz"+suffix1]= new TH2D("pullz"+suffix1, "z-pull vs number of tracks"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,100,0.,2.);
141 jengbou 1.1 h2["pullz"+suffix1]->SetMarkerStyle(21);
142     h2["pullz"+suffix1]->SetMarkerColor(4);
143     h2["pullz"+suffix1]->SetBit(TH1::kCanRebin);
144     h2["pullz"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
145    
146     }
147    
148     }
149    
150     //_______________________________________________________________
151     void PVHistograms::Fill1d(TString name, Double_t x, Double_t weight) {
152    
153     h1[name]->Fill(x,weight);
154     }
155    
156     //_______________________________________________________________
157     void PVHistograms::Fill2d(TString name, Double_t x, Double_t y, Double_t weight) {
158    
159     h2[name]->Fill(x,y,weight);
160     }
161    
162     //_______________________________________________________________
163     void PVHistograms::Print(TString extension, TString tag) {
164    
165     if ( tag != "" ) tag = "_"+tag;
166    
167     for(std::map<TString,TCanvas*>::const_iterator icv=cv_map.begin(); icv!=cv_map.end(); ++icv){
168    
169     TString tmpname = icv->first;
170     TCanvas *acv = icv->second;
171     acv->Print(TString(tmpname+tag+"."+extension));
172 jengbou 1.2 }
173 jengbou 1.1
174     }
175 jengbou 1.2
176 jengbou 1.1 //_______________________________________________________________
177     void PVHistograms::Save() {
178    
179     for(std::map<TString,TH1* >::const_iterator ih=h1.begin(); ih!=h1.end(); ++ih){
180     TH1D *htemp = (TH1D*) ih->second;
181     if (htemp->GetEntries() > 0 ) htemp->Write();
182     }
183     for(std::map<TString,TH2* >::const_iterator ih=h2.begin(); ih!=h2.end(); ++ih){
184     TH2D *htemp = (TH2D*) ih->second;
185     if (htemp->GetEntries() > 0 ) htemp->Write();
186     }
187     }
188    
189     //_______________________________________________________________
190     void PVHistograms::SaveToFile(TString filename) {
191    
192     foutfile = new TFile(filename,"RECREATE");
193     for(std::map<TString,TH1* >::const_iterator ih=h1.begin(); ih!=h1.end(); ++ih){
194     TH1D *htemp = (TH1D*) ih->second;
195     htemp->Write();
196     }
197     for(std::map<TString,TH2* >::const_iterator ih=h2.begin(); ih!=h2.end(); ++ih){
198     TH2D *htemp = (TH2D*) ih->second;
199     htemp->Write();
200     }
201 jengbou 1.2
202 jengbou 1.1 foutfile->Write();
203     foutfile->Close();
204 jengbou 1.2
205 jengbou 1.1 }