ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/PVStudy/src/PVHistograms.cc
Revision: 1.3
Committed: Tue Jan 26 12:05:42 2010 UTC (15 years, 3 months ago) by yygao
Content type: text/plain
Branch: MAIN
CVS Tags: CMSSW_3_3_6_patch3_Dec19thReReco
Changes since 1.2: +36 -28 lines
Log Message:
add a few histograms

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.3 version $Id: PVHistograms.cc,v 1.2 2009/12/04 20:41:58 jengbou 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 == "pixVtx") {
55     // Book histograms about pixelVertices
56     h1["trkdz_pxlpvtxdz"] = new TH1D("trkdz_pxlpvtxdz", "(Track dz - pixelpvtx dz) in cm",300,-0.5,0.5);
57     h1["trkdz_pxlpvtxdz_pxlpvtxdzerr"] = new TH1D("trkdz_pxlpvtxdz_pxlpvtxdzerr", "|Track dz - pixelpvtx dz| / pxlpvtxdzErr",300,0,100);
58     h1["trkdz_pxlpvtxdz_trkdzerr"] = new TH1D("trkdz_pxlpvtxdz_trkdzerr", "|Track dz - pixelpvtx dz| / trkdzErr",300,0,50);
59     h1["trkdzErr_pxlpvtx"] = new TH1D("trkdzErr_pxlpvtxdz", "Track dzErr of leading pixelpvtx ",300,0,0.5);
60     h1["trkdzErr_pvtx"] = new TH1D("trkdzErr_pvtx", "Track dzErr of the leading pvtx ",300,0,0.5);
61     h1["dzErr_pxlpvtx"] = new TH1D("dzErr_pxlpvtx", "zError of the leading pvtx ",300,0,0.5);
62    
63     // Compare offlinePrimaryVertices with pixelVertices
64     h1["nrecPV_minus_nrecPxlPV"] = new TH1D("nrecPV_minus_nrecPxlPV", "nrecPV_minus_nrecPxlPV",21,-10.5,10.5);
65     h1["recxPV_minus_recxPxlPV"] = new TH1D("recxPV_minus_recxPxlPV", "recxPV_minus_recxPxlPV",300,-0.02,0.02);
66     h1["recyPV_minus_recyPxlPV"] = new TH1D("recyPV_minus_recyPxlPV", "recyPV_minus_recyPxlPV",300,-0.02,0.02);
67     h1["reczPV_minus_reczPxlPV"] = new TH1D("reczPV_minus_reczPxlPV", "reczPV_minus_reczPxlPV",300,-0.1,0.1);
68     }
69     else if (type == "generator") {
70     h1["genPart_T"] = new TH1D("genPart_T","t component of gen particles",300,-0.5,0.5);
71     h1["genPart_T"]->GetXaxis()->SetTitle("t (nanosecond)");
72     h1["genPart_cT"] = new TH1D("genPart_cT","ct component of gen particles",300,-150.,150.);
73     h1["genPart_cT"]->GetXaxis()->SetTitle("ct (mm)");
74     h1["nsimPV"] = new TH1D("nsimPV","Num of sim PV",51,-0.5,50.5);
75     }
76     else if (type == "misc") {
77     h1["nrecPVDiff"] = new TH1D("nrecPVDiff","nrecPV1-nRecPV2",21,-10.5,10.5);
78     h1["nTrkPVDiff"] = new TH1D("nTrkPVDiff","nTrkPV1-nTrkPV2",41,-20.5,20.5);
79 yygao 1.3 h1["nTrkPVRelDiff"] = new TH1D("nTrkPVRelDiff","(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2)",100,-1,1);
80     h1["ndofPVDiff"] = new TH1D("ndofPVDiff","ndofPV1-ndofPV2",100,-10,10);
81     h1["ndofPVRelDiff"] = new TH1D("ndofPVRelDiff","(ndofPV1-ndofPV2)/(ndofPV1+ndofPV2)",100,-1,1);
82     h1["twovtxzsign"] = new TH1D("twovtxzsign", "two vtx z signficance",300,-20,20);
83 jengbou 1.1 // Histograms on comparing the multi-vertices
84     // Difference in reconstructed vtx position
85     h1["min_xsep"] = new TH1D("min_xsep", "min x diff of primary and secondary pvtx",300,0,0.1);
86     h1["min_xsep_sign"] = new TH1D("min_xsep_sign", "min x diff in signf of primary and secondary pvtx",300,0,5);
87     h1["min_ysep"] = new TH1D("min_ysep", "min y diff of primary and secondary pvtx",300,0,0.1);
88     h1["min_ysep_sign"] = new TH1D("min_ysep_sign", "min y diff in signf of primary and secondary pvtx",300,0,5);
89     h1["min_zsep"] = new TH1D("min_zsep", "min z diff of primary and secondary pvtx",300,0,5);
90     h1["min_zsep_sign"] = new TH1D("min_zsep_sign", "min z diff in signf of primary and secondary pvtx",300,0,200);
91     // Difference in reconstructed vtx position
92     h1["min_ntrksep"] = new TH1D("min_ntrksep", "min nTrk diff of primary and secondary pvtx",201,-50.5,150.5);
93     h1["min_sumpt2sep"] = new TH1D("min_sumpt2sep", "min sumpt2 diff of primary and secondary pvtx",300,0,10000);
94 yygao 1.3
95 jengbou 1.1 }
96     else if (type == "summary") {
97 yygao 1.3 h1["deltax"+suffix1] = new TH1D("deltax"+suffix1, "x-residual pvtx"+suffix1, 800,-0.1,0.1);
98     h1["deltay"+suffix1] = new TH1D("deltay"+suffix1, "y-residual pvtx"+suffix1, 800,-0.1,0.1);
99     h1["deltaz"+suffix1] = new TH1D("deltaz"+suffix1, "z-residual pvtx"+suffix1, 800,-0.1,0.1);
100     h1["pullx"+suffix1] = new TH1D("pullx"+suffix1, "x-pull pvtx"+suffix1, 800,-5,5);
101     h1["pully"+suffix1] = new TH1D("pully"+suffix1, "y-pull pvtx"+suffix1, 800,-5,5);
102     h1["pullz"+suffix1] = new TH1D("pullz"+suffix1, "z-pull pvtx"+suffix1, 800,-5,5);
103     h1["errPVx"+suffix1] = new TH1D("errPVx"+suffix1, "X"+suffix1+" vertex error", 200,0.,0.1);
104     h1["errPVy"+suffix1] = new TH1D("errPVy"+suffix1, "Y"+suffix1+" vertex error", 200,0.,0.1);
105     h1["errPVz"+suffix1] = new TH1D("errPVz"+suffix1, "Z"+suffix1+" vertex error", 200,0.,0.1);
106 jengbou 1.1 }
107     else if (type == "others") {
108 yygao 1.3 h1["deltax"+suffix1] = new TH1D("deltax"+suffix1, "x-residual of pvtx"+methodName, 200,-0.1,0.1);
109 jengbou 1.1 h1["deltax"+suffix1]->GetXaxis()->SetTitle("cm");
110 yygao 1.3 h1["deltay"+suffix1] = new TH1D("deltay"+suffix1, "y-residual of pvtx"+methodName, 200,-0.1,0.1);
111 jengbou 1.1 h1["deltay"+suffix1]->GetXaxis()->SetTitle("cm");
112 yygao 1.3 h1["deltaz"+suffix1] = new TH1D("deltaz"+suffix1, "z-residual of pvtx"+methodName, 200,-0.1,0.1);
113 jengbou 1.1 h1["deltaz"+suffix1]->GetXaxis()->SetTitle("cm");
114 yygao 1.3 h1["pullx"+suffix1] = new TH1D("pullx"+suffix1, "x-pull of pvtx"+methodName, 200,-5.,5.);
115     h1["pully"+suffix1] = new TH1D("pully"+suffix1, "y-pull of pvtx"+methodName, 200,-5.,5.);
116     h1["pullz"+suffix1] = new TH1D("pullz"+suffix1, "z-pull of pvtx"+methodName, 200,-5.,5.);
117     h1["errPVx"+suffix1] = new TH1D("errPVx"+suffix1, "X"+methodName+" vertex error", 200,0.,0.1);
118     h1["errPVy"+suffix1] = new TH1D("errPVy"+suffix1, "Y"+methodName+" vertex error", 200,0.,0.1);
119     h1["errPVz"+suffix1] = new TH1D("errPVz"+suffix1, "Z"+methodName+" vertex error", 200,0.,0.1);
120 jengbou 1.1 }
121    
122     }
123    
124     void PVHistograms::InitA(TString type, TString suffix1, TString suffix2, int nTrkMin_, int nTrkMax_) {
125    
126     TString methodName = suffix1;
127     if (suffix2 != "") suffix1 += "_" + suffix2;
128    
129     if (type == "analysis") {
130 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);
131 jengbou 1.1 h2["resx"+suffix1]->SetMarkerStyle(21);
132     h2["resx"+suffix1]->SetMarkerColor(4);
133     h2["resx"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
134     h2["resx"+suffix1]->GetYaxis()->SetTitle("#mum");
135 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);
136 jengbou 1.1 h2["resy"+suffix1]->SetMarkerStyle(21);
137     h2["resy"+suffix1]->SetMarkerColor(4);
138     h2["resy"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
139     h2["resy"+suffix1]->GetYaxis()->SetTitle("#mum");
140 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);
141 jengbou 1.1 h2["resz"+suffix1]->SetMarkerStyle(21);
142     h2["resz"+suffix1]->SetMarkerColor(4);
143     h2["resz"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
144     h2["resz"+suffix1]->GetYaxis()->SetTitle("#mum");
145 jengbou 1.2 h2["pullx"+suffix1]= new TH2D("pullx"+suffix1, "x-pull vs number of tracks"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,100,0.,2.);
146 jengbou 1.1 h2["pullx"+suffix1]->SetMarkerStyle(21);
147     h2["pullx"+suffix1]->SetMarkerColor(4);
148     h2["pullx"+suffix1]->SetBit(TH1::kCanRebin);
149     h2["pullx"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
150 jengbou 1.2 h2["pully"+suffix1]= new TH2D("pully"+suffix1, "y-pull vs number of tracks"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,100,0.,2.);
151 jengbou 1.1 h2["pully"+suffix1]->SetMarkerStyle(21);
152     h2["pully"+suffix1]->SetMarkerColor(4);
153     h2["pully"+suffix1]->SetBit(TH1::kCanRebin);
154     h2["pully"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
155 jengbou 1.2 h2["pullz"+suffix1]= new TH2D("pullz"+suffix1, "z-pull vs number of tracks"+methodName, nTrkMax_-nTrkMin_,nTrkMin_,nTrkMax_,100,0.,2.);
156 jengbou 1.1 h2["pullz"+suffix1]->SetMarkerStyle(21);
157     h2["pullz"+suffix1]->SetMarkerColor(4);
158     h2["pullz"+suffix1]->SetBit(TH1::kCanRebin);
159     h2["pullz"+suffix1]->GetXaxis()->SetTitle("Num of tracks");
160    
161     }
162    
163     }
164    
165     //_______________________________________________________________
166     void PVHistograms::Fill1d(TString name, Double_t x, Double_t weight) {
167    
168     h1[name]->Fill(x,weight);
169     }
170    
171     //_______________________________________________________________
172     void PVHistograms::Fill2d(TString name, Double_t x, Double_t y, Double_t weight) {
173    
174     h2[name]->Fill(x,y,weight);
175     }
176    
177     //_______________________________________________________________
178     void PVHistograms::Print(TString extension, TString tag) {
179    
180     if ( tag != "" ) tag = "_"+tag;
181    
182     for(std::map<TString,TCanvas*>::const_iterator icv=cv_map.begin(); icv!=cv_map.end(); ++icv){
183    
184     TString tmpname = icv->first;
185     TCanvas *acv = icv->second;
186     acv->Print(TString(tmpname+tag+"."+extension));
187 jengbou 1.2 }
188 jengbou 1.1
189     }
190 jengbou 1.2
191 jengbou 1.1 //_______________________________________________________________
192     void PVHistograms::Save() {
193    
194     for(std::map<TString,TH1* >::const_iterator ih=h1.begin(); ih!=h1.end(); ++ih){
195     TH1D *htemp = (TH1D*) ih->second;
196     if (htemp->GetEntries() > 0 ) htemp->Write();
197     }
198     for(std::map<TString,TH2* >::const_iterator ih=h2.begin(); ih!=h2.end(); ++ih){
199     TH2D *htemp = (TH2D*) ih->second;
200     if (htemp->GetEntries() > 0 ) htemp->Write();
201     }
202     }
203    
204     //_______________________________________________________________
205     void PVHistograms::SaveToFile(TString filename) {
206    
207     foutfile = new TFile(filename,"RECREATE");
208     for(std::map<TString,TH1* >::const_iterator ih=h1.begin(); ih!=h1.end(); ++ih){
209     TH1D *htemp = (TH1D*) ih->second;
210     htemp->Write();
211     }
212     for(std::map<TString,TH2* >::const_iterator ih=h2.begin(); ih!=h2.end(); ++ih){
213     TH2D *htemp = (TH2D*) ih->second;
214     htemp->Write();
215     }
216 jengbou 1.2
217 jengbou 1.1 foutfile->Write();
218     foutfile->Close();
219 jengbou 1.2
220 jengbou 1.1 }