File indexing completed on 2024-04-06 12:29:10
0001 #define SimpleVertexAnalysis_cxx
0002 #include "SimpleVertexAnalysis.h"
0003 #include "TH2.h"
0004 #include "TF1.h"
0005 #include "TStyle.h"
0006 #include "TPostScript.h"
0007 #include <iostream>
0008 #include <fstream>
0009 #include <iomanip>
0010
0011 using std::cout;
0012 using std::endl;
0013
0014
0015
0016
0017
0018
0019
0020 void SimpleVertexAnalysis::vertexLoop()
0021 {
0022 if (fChain == 0) return;
0023
0024 Int_t nentries = Int_t(fChain->GetEntriesFast());
0025 bookVertexHisto();
0026 Int_t nbytes = 0, nb = 0;
0027 total=0; failure=0;
0028 for (Int_t jentry=0; jentry<nentries;jentry++) {
0029 Int_t ientry = LoadTree(jentry);
0030 if (ientry < 0) break;
0031 nb = fChain->GetEntry(jentry); nbytes += nb;
0032
0033 ++total;
0034 if ((vertex==3)&&(nbrTrk_Rec>0)) {
0035 resX->Fill((simPos_X-recPos_X)*10000.);
0036 resY->Fill((simPos_Y-recPos_Y)*10000.);
0037 resZ->Fill((simPos_Z-recPos_Z)*10000.);
0038 pullX->Fill((simPos_X-recPos_X)/recErr_X);
0039 pullY->Fill((simPos_Y-recPos_Y)/recErr_Y);
0040 pullZ->Fill((simPos_Z-recPos_Z)/recErr_Z);
0041 chiNorm->Fill(chiTot/ndf);
0042 chiProbability->Fill(chiProb);
0043 weight->Fill((ndf+3.)/2.);
0044 int tt = ((recTracks==0) ? nbrTrk_Rec : recTracks);
0045 normWeight->Fill((ndf+3.)/2. / tt);
0046 downWeight->Fill(((ndf+3.)/2.) - tt);
0047 numberUsedRecTracks->Fill(nbrTrk_Rec);
0048 numberRawRecTracks->Fill(recTracks);
0049
0050 sharedTracks->Fill(nbrTrk_Shared);
0051
0052 timing->Fill(time);
0053 } else {
0054 ++failure;
0055
0056 numberSimTracks->Fill(nbrTrk_Sim);
0057 numberRawRecTracks->Fill(recTracks);
0058
0059 }
0060 }
0061
0062 }
0063
0064
0065 void SimpleVertexAnalysis::vertexCoverage(ostream &out)
0066 {
0067 if (fChain == 0) return;
0068
0069 Int_t nentries = Int_t(fChain->GetEntriesFast());
0070 Int_t nbytes = 0, nb = 0;
0071 vector<float> xResiduals, yResiduals, zResiduals;
0072 for (Int_t jentry=0; jentry<nentries;jentry++) {
0073 Int_t ientry = LoadTree(jentry);
0074 if (ientry < 0) break;
0075 nb = fChain->GetEntry(jentry); nbytes += nb;
0076 if (vertex==3) {
0077 xResiduals.push_back(fabs(simPos_X-recPos_X)*10000.);
0078 yResiduals.push_back(fabs(simPos_Y-recPos_Y)*10000.);
0079 zResiduals.push_back(fabs(simPos_Z-recPos_Z)*10000.);
0080 }
0081 }
0082 out << "Coverage: 50% 90% 95% \n";
0083 out.width(10);out << "X-coord.:"; x_coverage = getCoverage(xResiduals, out);
0084 out.width(10);out << "Y-coord.:"; y_coverage = getCoverage(yResiduals, out);
0085 out.width(10);out << "Z-coord.:"; z_coverage = getCoverage(zResiduals, out);
0086 }
0087
0088
0089 float SimpleVertexAnalysis::getCoverage(vector<float> &residuals, ostream &out)
0090 {
0091 float retVal;
0092 sort(residuals.begin(),residuals.end());
0093 out.width(10);out << residuals[(int)(residuals.size()*0.5)];
0094 out.width(10);out << residuals[(int)(residuals.size()*0.9)];
0095 out.width(10);out << (retVal = residuals[(int)(residuals.size()*0.95)]);
0096 out << endl;
0097 return retVal;
0098 }
0099
0100
0101
0102
0103 void SimpleVertexAnalysis::vertexHistoLimits(float aMaxTrans, float aMaxZ,
0104 float aMaxTracks, float aMaxWeights, float aMaxTime)
0105 {
0106 maxTrans = aMaxTrans;
0107 maxZ = aMaxZ;
0108 maxTracks = aMaxTracks;
0109 maxWeights = aMaxWeights;
0110 maxTime = aMaxTime;
0111 }
0112
0113
0114 void SimpleVertexAnalysis::bookVertexHisto()
0115 {
0116 if (bookedVertex) deleteVertexHisto();
0117 bookedVertex=true;
0118 resX = new TH1F("ResX"+theTreeName, "Residual x coordinate: "+theTreeName, 50, -maxTrans, maxTrans);
0119 resY = new TH1F("ResY"+theTreeName, "Residual y coordinate: "+theTreeName, 50, -maxTrans, maxTrans);
0120 resZ = new TH1F("ResZ"+theTreeName, "Residual z coordinate: "+theTreeName, 50, -maxZ, maxZ);
0121 pullX = new TH1F("PullX"+theTreeName, "Pull x coordinate: "+theTreeName, 100, -10., 10.);
0122 pullY = new TH1F("PullY"+theTreeName, "Pull y coordinate: "+theTreeName, 100, -10., 10.);
0123 pullZ = new TH1F("PullZ"+theTreeName, "Pull z coordinate: "+theTreeName, 100, -10., 10.);
0124 chiNorm = new TH1F("ChiNorm"+theTreeName, "Normalized chi-square: " +theTreeName, 100, 0., 10.);
0125 chiProbability = new TH1F("ChiProb"+theTreeName, "Chi-square probability: "+theTreeName, 100, 0., 1.);
0126 weight = new TH1F("weight"+theTreeName, "Sum of track weights: " +theTreeName, 100, 0., maxWeights);
0127 normWeight = new TH1F("normWeight"+theTreeName, "Normalized Sum of track weights: " +theTreeName, 100, -0.1, 1.1);
0128 downWeight = new TH1F("downWeight"+theTreeName, "negative of track weights: " +theTreeName, 100, -20., 0.1);
0129 numberUsedRecTracks = new TH1F("usedRecTrk"+theTreeName, "Number of RecTracks used: " +theTreeName, 21, -0.5, maxTracks);
0130 numberRawRecTracks = new TH1F("rawRecTrk"+theTreeName, "Number of RecTracks given: " +theTreeName, 21, -0.5, maxTracks);
0131 numberSimTracks = new TH1F("SimTrk"+theTreeName, "Number of SimTracks: " +theTreeName, 21, -0.5, maxTracks);
0132 sharedTracks = new TH1F("Shared"+theTreeName, "Number of shared tracks: " +theTreeName, 21, -0.5, maxTracks);
0133 ratioSharedTracks = new TH1F("Ratio"+theTreeName, "Ratio of shared tracks: " +theTreeName, 100, 0., 2.);
0134 timing = new TH1F("Timing"+theTreeName, "Time per fit: " +theTreeName, 100, 0., maxTime);
0135 resX->SetXTitle("Res. x coord. [#mum] ");
0136 resY->SetXTitle("Res. y coord. [#mum] ");
0137 resZ->SetXTitle("Res. z coord. [#mum] ");
0138 pullX->SetXTitle("Pull x coord. ");
0139 pullY->SetXTitle("Pull y coord. ");
0140 pullZ->SetXTitle("Pull z coord. ");
0141 chiNorm->SetXTitle("Normalized chi-square: " );
0142 chiProbability->SetXTitle("Chi-square probability");
0143 weight->SetXTitle("Sum of track weights: " +theTreeName);
0144 normWeight->SetXTitle("Normalized Sum of track weights: " +theTreeName);
0145 numberUsedRecTracks->SetXTitle("Number of RecTracks used: " +theTreeName);
0146 numberRawRecTracks ->SetXTitle("Number of RecTracks given: " +theTreeName);
0147 numberSimTracks->SetXTitle("Number of SimTracks: " +theTreeName);
0148 sharedTracks->SetXTitle("Number of shared tracks: " +theTreeName);
0149 ratioSharedTracks->SetXTitle("Ratio of shared tracks: " +theTreeName);
0150 timing->SetXTitle("Time per fit [#mus] " +theTreeName);
0151 }
0152
0153 void SimpleVertexAnalysis::trackLoop()
0154 {
0155 if (fChain == 0) return;
0156
0157 Int_t nentries = Int_t(fChain->GetEntriesFast());
0158 bookTrackHisto();
0159 Int_t nbytes = 0, nb = 0;
0160 for (Int_t jentry=0; jentry<nentries;jentry++) {
0161
0162
0163 Int_t ientry = LoadTree(jentry);
0164 if (ientry < 0) break;
0165 nb = fChain->GetEntry(jentry); nbytes += nb;
0166 if (recTracks>MAXTRACK) {
0167 cout << "Number of Tracks in event exceeds Maximum."<<endl;
0168 cout << "Increase MAXTRACK to at least " << recTracks<< " (line 12 in SimpleVertexAnalysis.h)."<<endl;
0169 }
0170 for (int iTrack=0; ((iTrack<recTracks) && (iTrack<MAXTRACK)); ++iTrack) {
0171 pTRec->Fill(1/recPar_ptinv[iTrack]);
0172 etaRec->Fill(-log(tan(recPar_theta[iTrack]/2)));
0173
0174
0175 if (recTrack_simIndex[iTrack] != -1) {
0176
0177
0178
0179
0180
0181
0182
0183 resRecPt->Fill(simPar_ptinv[recTrack_simIndex[iTrack]]-recPar_ptinv[iTrack]);
0184 resRecPhi->Fill(simPar_phi[recTrack_simIndex[iTrack]]-recPar_phi[iTrack]);
0185 resRecTheta->Fill(simPar_theta[recTrack_simIndex[iTrack]]-recPar_theta[iTrack]);
0186 resRecTimp->Fill(simPar_timp[recTrack_simIndex[iTrack]]-recPar_timp[iTrack]);
0187 resRecLimp->Fill(simPar_limp[recTrack_simIndex[iTrack]]-recPar_limp[iTrack]);
0188
0189 pullRecPt->Fill((simPar_ptinv[recTrack_simIndex[iTrack]]-recPar_ptinv[iTrack])/recErr_ptinv[iTrack]);
0190 pullRecPhi->Fill((simPar_phi[recTrack_simIndex[iTrack]]-recPar_phi[iTrack])/recErr_phi[iTrack]);
0191 pullRecTheta->Fill((simPar_theta[recTrack_simIndex[iTrack]]-recPar_theta[iTrack])/recErr_theta[iTrack]);
0192 pullRecTimp->Fill((simPar_timp[recTrack_simIndex[iTrack]]-recPar_timp[iTrack])/recErr_timp[iTrack]);
0193 pullRecLimp->Fill((simPar_limp[recTrack_simIndex[iTrack]]-recPar_limp[iTrack])/recErr_limp[iTrack]);
0194
0195 pTSim->Fill(1/simPar_ptinv[recTrack_simIndex[iTrack]]);
0196 etaSim->Fill(-log(tan(simPar_theta[recTrack_simIndex[iTrack]]/2)));
0197
0198 if (refPar_ptinv[iTrack]!=0.) {
0199 resRefPt->Fill(simPar_ptinv[recTrack_simIndex[iTrack]]-refPar_ptinv[iTrack]);
0200 resRefPhi->Fill(simPar_phi[recTrack_simIndex[iTrack]]-refPar_phi[iTrack]);
0201 resRefTheta->Fill(simPar_theta[recTrack_simIndex[iTrack]]-refPar_theta[iTrack]);
0202 resRefTimp->Fill(simPar_timp[recTrack_simIndex[iTrack]]-refPar_timp[iTrack]);
0203 resRefLimp->Fill(simPar_limp[recTrack_simIndex[iTrack]]-refPar_limp[iTrack]);
0204
0205 pullRefPt->Fill((simPar_ptinv[recTrack_simIndex[iTrack]]-refPar_ptinv[iTrack])/refErr_ptinv[iTrack]);
0206 pullRefPhi->Fill((simPar_phi[recTrack_simIndex[iTrack]]-refPar_phi[iTrack])/refErr_phi[iTrack]);
0207 pullRefTheta->Fill((simPar_theta[recTrack_simIndex[iTrack]]-refPar_theta[iTrack])/refErr_theta[iTrack]);
0208 pullRefTimp->Fill((simPar_timp[recTrack_simIndex[iTrack]]-refPar_timp[iTrack])/refErr_timp[iTrack]);
0209 pullRefLimp->Fill((simPar_limp[recTrack_simIndex[iTrack]]-refPar_limp[iTrack])/refErr_limp[iTrack]);
0210 pTRef->Fill(1/refPar_ptinv[iTrack]);
0211 etaRef->Fill(-log(tan(refPar_theta[iTrack]/2)));
0212 }
0213 }
0214 }
0215 }
0216
0217 }
0218
0219 void SimpleVertexAnalysis::bookTrackHisto()
0220 {
0221 if (bookedTrack) deleteTrackHisto();
0222 bookedTrack=true;
0223 resRecPt = new TH1F("ResRecPtInv"+theTreeName, "Residual Reco 1/p_{T}: "+theTreeName, 100, -0.03, 0.03);
0224 resRecPhi = new TH1F("ResRecPhi"+theTreeName, "Residual Reco #phi: "+theTreeName, 100, -0.003, 0.003);
0225 resRecTheta = new TH1F("ResRecTheta"+theTreeName, "Residual Reco #theta: "+theTreeName, 100, -0.003, 0.003);
0226 resRecTimp = new TH1F("ResRecTimp"+theTreeName, "Residual Reco Transverse IP: "+theTreeName, 100, -0.03, 0.03);
0227 resRecLimp = new TH1F("ResRecLimp"+theTreeName, "Residual Reco Longitudinal IP: "+theTreeName, 100, -0.04, 0.04);
0228
0229 pullRecPt = new TH1F("PullRecPtInv"+theTreeName, "Pull Reco 1/p_{T}: "+theTreeName, 100, -5., 5.);
0230 pullRecPhi = new TH1F("PullRecPhi"+theTreeName, "Pull Reco #phi: "+theTreeName, 100, -5., 5.);
0231 pullRecTheta = new TH1F("PullRecTheta"+theTreeName, "Pull Reco #theta: "+theTreeName, 100, -5., 5.);
0232 pullRecTimp = new TH1F("PullRecTimp"+theTreeName, "Pull Reco Transverse IP: "+theTreeName, 100, -5., 5.);
0233 pullRecLimp = new TH1F("PullRecLimp"+theTreeName, "Pull Reco Longitudinal IP: "+theTreeName, 100, -5., 5.);
0234
0235 resRefPt = new TH1F("ResRefPtInv"+theTreeName, "Residual Refitted 1/p_{T}: "+theTreeName, 100, -0.03, 0.03);
0236 resRefPhi = new TH1F("ResRefPhi"+theTreeName, "Residual Refitted #phi: "+theTreeName, 100, -0.003, 0.003);
0237 resRefTheta = new TH1F("ResRefTheta"+theTreeName, "Residual Refitted #theta: "+theTreeName, 100, -0.003, 0.003);
0238 resRefTimp = new TH1F("ResRefTimp"+theTreeName, "Residual Refitted Transverse IP: "+theTreeName, 100, -0.02, 0.02);
0239 resRefLimp = new TH1F("ResRefLimp"+theTreeName, "Residual Refitted Longitudinal IP: "+theTreeName, 100, -0.02, 0.02);
0240
0241 pullRefPt = new TH1F("PullRefPtInv"+theTreeName, "Pull Refitted 1/p_{T}: "+theTreeName, 100, -5., 5.);
0242 pullRefPhi = new TH1F("PullRefPhi"+theTreeName, "Pull Refitted #phi: "+theTreeName, 100, -5., 5.);
0243 pullRefTheta = new TH1F("PullRefTheta"+theTreeName, "Pull Refitted #theta: "+theTreeName, 100, -5., 5.);
0244 pullRefTimp = new TH1F("PullRefTimp"+theTreeName, "Pull Refitted Transverse IP: "+theTreeName, 100, -5., 5.);
0245 pullRefLimp = new TH1F("PullRefLimp"+theTreeName, "Pull Refitted Longitudinal IP: "+theTreeName, 100, -5., 5.);
0246
0247 pTSim = new TH1F("pTSim"+theTreeName, "Simulated p_{T} distribution : "+theTreeName, 100, 0., 50.);
0248 etaSim = new TH1F("etaSim"+theTreeName, "Simulated #eta distribution : "+theTreeName, 100, 0., 3.);
0249 pTRec = new TH1F("pTRec"+theTreeName, "Reconstructed p_{T} distribution : "+theTreeName, 100, 0., 50.);
0250 etaRec = new TH1F("etaRec"+theTreeName, "Reconstructed #eta distribution : "+theTreeName, 100, 0., 2.6);
0251 pTRef = new TH1F("pTRef"+theTreeName, "Refitted p_{T} distribution : "+theTreeName, 100, 0., 50.);
0252 etaRef = new TH1F("etaRef"+theTreeName, "Refitted #eta distribution : "+theTreeName, 100, 0., 3.);
0253 pTRec->SetXTitle("p_{T}[GeV/c]");
0254
0255 }
0256
0257 void SimpleVertexAnalysis::deleteTrackHisto()
0258 {
0259 bookedTrack=false;
0260 delete resRecPt; delete resRecPhi; delete resRecTheta; delete resRecTimp; delete resRecLimp;
0261 delete pullRecPt; delete pullRecPhi; delete pullRecTheta; delete pullRecTimp; delete pullRecLimp;
0262 delete resRefPt; delete resRefPhi; delete resRefTheta; delete resRefTimp; delete resRefLimp;
0263 delete pullRefPt; delete pullRefPhi; delete pullRefTheta; delete pullRefTimp; delete pullRefLimp;
0264 delete pTSim; delete etaSim; delete pTRec; delete etaRec; delete pTRef; delete etaRef;
0265 }
0266
0267 void SimpleVertexAnalysis::deleteVertexHisto()
0268 {
0269 delete resX; delete resY; delete resZ;
0270 delete pullX; delete pullY; delete pullZ;
0271 delete chiNorm; delete chiProbability; delete weight; delete normWeight;delete downWeight;
0272 delete numberUsedRecTracks; delete numberRawRecTracks; delete numberSimTracks; delete sharedTracks; delete ratioSharedTracks;
0273 delete timing;
0274 bookedVertex=false;
0275 };
0276
0277
0278 SimpleVertexAnalysis::SimpleVertexAnalysis(TString filename, TString treeName)
0279 {
0280 bookedVertex=false;bookedTrack=false;
0281 bookedVertexC=false;bookedTrackC=false;
0282 TFile *f = new TFile(filename);
0283 if (f) {
0284 TTree* tree = (TTree*)gDirectory->Get(treeName);
0285 if (tree) {
0286 Init(tree);
0287 nentries = Int_t(fChain->GetEntries());
0288 myChain = 0;
0289 } else {
0290 cout <<"Tree "<< treeName <<" does not exist \n";
0291 }
0292 } else {
0293 cout <<"File "<< filename <<" does not exist \n";
0294 }
0295 theTreeName = treeName;
0296 vertexHistoLimits();
0297 }
0298
0299
0300 SimpleVertexAnalysis::SimpleVertexAnalysis(TString base, int start, int end,
0301 TString treeName)
0302 {
0303 bookedVertex=false;bookedTrack=false;
0304 bookedVertexC=false;bookedTrackC=false;
0305 myChain = new TChain(treeName);
0306 char nr[4];
0307 for (int i = start; i<=end ; i++) {
0308 if (i<10) sprintf(nr,"%1.1d",i);
0309 else if (i<100) sprintf(nr,"%2.2d",i);
0310 else sprintf(nr,"%3.3d",i);
0311 TString name = base+"_"+nr+".root";
0312 myChain->Add(name);
0313 }
0314 Init(myChain);
0315 nentries = Int_t(fChain->GetEntries());
0316 theTreeName = treeName;
0317 vertexHistoLimits();
0318 }
0319
0320 void SimpleVertexAnalysis::psVertexResult(TString name)
0321 {
0322 if (!bookedVertexC) plotVertexResult();
0323 resCanvas->Print(name+".ps[");
0324 resCanvas->Draw();
0325 resCanvas->Print(name+".ps");
0326 statCanvas->Draw();
0327 statCanvas->Print(name+".ps");
0328 statCanvas->Print(name+".ps]");
0329 }
0330
0331 void SimpleVertexAnalysis::singleGaussianVertexResult(ostream &out)
0332 {
0333 resX->Fit("gaus","QO");
0334 resY->Fit("gaus","QO");
0335 resZ->Fit("gaus","QO");
0336 pullX->Fit("gaus","QO");
0337 pullY->Fit("gaus","QO");
0338 pullZ->Fit("gaus","QO");
0339
0340 out << "Main results on "<<resX->GetEntries()<<" Events:\n";
0341 out << "Resolutions, X: "<< resX->GetFunction("gaus")->GetParameter(2)<<endl;
0342 out << "Resolutions, Y: "<< resY->GetFunction("gaus")->GetParameter(2)<<endl;
0343 out << "Resolutions, Z: "<< resZ->GetFunction("gaus")->GetParameter(2)<<endl;
0344 out << "Pull, X: "<< pullX->GetFunction("gaus")->GetParameter(2)<<endl;
0345 out << "Pull, Y: "<< pullY->GetFunction("gaus")->GetParameter(2)<<endl;
0346 out << "Pull, Z: "<< pullZ->GetFunction("gaus")->GetParameter(2)<<endl;
0347 out << "Mean nomalised chi**2: "<<chiNorm->GetMean()<<endl;
0348 out << "Mean chi**2-Probability: "<<chiProbability->GetMean()<<endl;
0349 out << "Mean CPU time: "<<(timing->GetMean())*1000.<<" microseconds\n";
0350 out << "Failure rate: "<<failure<<" - "<<failure/total<<endl;
0351 }
0352 void SimpleVertexAnalysis::statTeXResult(ostream &out)
0353 {
0354 out << theTreeName<< " \t& " ;
0355 out.precision(3); out <<chiNorm->GetMean()<< " \t& " ;
0356 out.precision(3); out <<chiProbability->GetMean()<< " \t& " ;
0357 out.precision(3); out <<normWeight->GetMean()<< " \t& " ;
0358
0359
0360 out.precision(3); out <<(timing->GetMean())*1000.<< " \t& " ;
0361
0362 float rare = (float)failure/(float)total*100.;
0363 out.precision(2); out <<rare<< " \t\\\\ \n" ;
0364 }
0365 void SimpleVertexAnalysis::xTeXResult(ostream &out)
0366 {
0367 out << theTreeName<< " \t& " ;
0368 out.precision(3); out <<resX->GetFunction("gaus")->GetParameter(2)<< " \t& " ;
0369 out.precision(3); out <<resX->GetFunction("gaus")->GetParameter(1)<< " \t& " ;
0370 out.precision(3); out <<x_coverage<< " \t& " ;
0371 out.precision(3); out <<pullX->GetFunction("gaus")->GetParameter(2);
0372 out<< " \t\\\\ \n" ;
0373 }
0374 void SimpleVertexAnalysis::zTeXResult(ostream &out)
0375 {
0376 out << theTreeName<< " \t& " ;
0377 out.precision(3); out <<resZ->GetFunction("gaus")->GetParameter(2)<< " \t& " ;
0378 out.precision(3); out <<resZ->GetFunction("gaus")->GetParameter(1)<< " \t& " ;
0379 out.precision(3); out <<z_coverage<< " \t& " ;
0380 out.precision(3); out <<pullZ->GetFunction("gaus")->GetParameter(2);
0381 out<< " \t\\\\ \n" ;
0382 }
0383 void SimpleVertexAnalysis::resolutionTeXResult(ostream &out)
0384 {
0385 out << theTreeName<< " \t& " ;
0386 out.precision(3); out <<resX->GetFunction("gaus")->GetParameter(2)<< " \t& " ;
0387 out.precision(3); out <<resX->GetFunction("gaus")->GetParameter(1)<< " \t& " ;
0388 out.precision(3); out <<x_coverage<< " \t& " ;
0389 out.precision(3); out <<pullX->GetFunction("gaus")->GetParameter(2)<< " \t& " ;
0390 out.precision(3); out <<resZ->GetFunction("gaus")->GetParameter(2)<< " \t& " ;
0391 out.precision(3); out <<resZ->GetFunction("gaus")->GetParameter(1)<< " \t& " ;
0392 out.precision(3); out <<z_coverage<< " \t& " ;
0393 out.precision(3); out <<pullZ->GetFunction("gaus")->GetParameter(2);
0394 out<< " \t\\\\ \n" ;
0395 }
0396
0397
0398 void SimpleVertexAnalysis::doubleGaussianVertexResult(ostream &out)
0399 {
0400 out << "Main results\n";
0401 out << "Resolutions, X: ";doubleGaussianFit(resX);
0402 out << "Resolutions, Y: ";doubleGaussianFit(resY);
0403 out << "Resolutions, Z: ";doubleGaussianFit(resZ);
0404 out << "Pull, X: ";doubleGaussianFit(pullX);
0405 out << "Pull, Y: ";doubleGaussianFit(pullY);
0406 out << "Pull, Z: ";doubleGaussianFit(pullZ);
0407 out << "Mean nomalised chi**2: "<<chiNorm->GetMean()<<endl;
0408 out << "Mean chi**2-Probability: "<<chiProbability->GetMean()<<endl;
0409 out << "Mean CPU time: "<<(timing->GetMean())*1000.<<" microseconds\n";
0410 out << "Failure rate: "<<failure/total<<endl;
0411 }
0412
0413
0414 void SimpleVertexAnalysis::doubleGaussianFit(TH1F *plot, ostream &out)
0415 {
0416 TF1 *myfit = new TF1("myfit","[0]*exp(-0.5*((x-[1])/[2])^2)+[3]*exp(-0.5*((x-[4])/[5])^2)");
0417 myfit->SetParameter(0, 1);
0418 myfit->SetParameter(1, plot->GetMean());
0419 myfit->SetParameter(2, plot->GetRMS()/2);
0420 myfit->SetParameter(3, 1);
0421 myfit->SetParameter(4, plot->GetMean());
0422 myfit->SetParameter(5, plot->GetRMS()*1.5);
0423
0424 plot->Fit(myfit,"QO");
0425 out << myfit->GetParameter(2)<<" "<<myfit->GetParameter(5)<<endl;
0426 }
0427
0428
0429 void SimpleVertexAnalysis::plotVertexResult()
0430 {
0431 if (bookedTrackC) {
0432 delete resCanvas; delete statCanvas;
0433 }
0434 resCanvas = new TCanvas(theTreeName+"Res",theTreeName+"Res", 600, 800);
0435 resCanvas->Divide(2,3);
0436
0437 resCanvas->cd(1);
0438 resX->Draw();
0439 resCanvas->cd(2);
0440 pullX->Draw();
0441 resCanvas->cd(3);
0442 resY->Draw();
0443 resCanvas->cd(4);
0444 pullY->Draw();
0445 resCanvas->cd(5);
0446 resZ->Draw();
0447 resCanvas->cd(6);
0448 pullZ->Draw();
0449 resCanvas->Update();
0450
0451 statCanvas = new TCanvas(theTreeName+"Stat",theTreeName+"Stat", 600, 800);
0452 statCanvas->Divide(2,3);
0453 statCanvas->cd(1);
0454 chiNorm->Draw();
0455 statCanvas->cd(2);
0456 chiProbability->Draw();
0457 statCanvas->cd(3);
0458 weight->Draw();
0459 statCanvas->cd(4);
0460 numberUsedRecTracks->SetLineColor(2);
0461 numberUsedRecTracks->Draw();
0462 numberRawRecTracks->SetLineColor(3);
0463 numberRawRecTracks->Draw("same");
0464 numberSimTracks->SetLineColor(4);
0465 numberSimTracks->Draw("same");
0466 statCanvas->cd(5);
0467 normWeight->Draw();
0468 statCanvas->cd(6);
0469 timing->Draw();
0470 statCanvas->Update();
0471 bookedTrackC=true;
0472 }
0473
0474
0475 void SimpleVertexAnalysis::epsVertexResult(TString name)
0476 {
0477 epsPlot(resX, name);
0478 epsPlot(pullX, name);
0479 epsPlot(resY, name);
0480 epsPlot(pullY, name);
0481 epsPlot(resZ, name);
0482 epsPlot(pullZ, name);
0483
0484 epsPlot(chiNorm, name);
0485 epsPlot(chiProbability, name);
0486 epsPlot(weight, name);
0487 epsPlot(numberUsedRecTracks, name);
0488 epsPlot(numberRawRecTracks, name);
0489 epsPlot(numberSimTracks, name);
0490 epsPlot(ratioSharedTracks, name);
0491 epsPlot(timing, name);
0492 }
0493
0494
0495 void SimpleVertexAnalysis::epsPlot(TH1F *plot, TString name)
0496 {
0497 TCanvas *tc = new TCanvas();
0498 plot->Draw();
0499 tc->Print(TString(name+plot->GetName())+".eps");
0500 delete tc;
0501 }
0502
0503
0504
0505 void SimpleVertexAnalysis::plotTrackResult()
0506 {
0507 if (bookedVertexC) {
0508 delete resRecCanvas;delete pullRecCanvas; delete resRefCanvas; delete pullRefCanvas; delete distCanvas;
0509 }
0510 resRecCanvas = new TCanvas(theTreeName+"ResRec",theTreeName+" Reconstrcuted Track Parameter Residuals", 900, 600);
0511 resRecCanvas->Divide(3,2);
0512
0513 TStyle *fitStyle = new TStyle("Default","Fit Style");
0514 fitStyle->SetLineWidth(1);
0515 fitStyle->SetFuncColor(2);
0516
0517
0518 resRecCanvas->cd(1);
0519 resRecPt->Fit("gaus");
0520 resRecCanvas->cd(2);
0521 resRecPhi->Fit("gaus");
0522 resRecCanvas->cd(3);
0523 resRecTheta->Fit("gaus");
0524 resRecCanvas->cd(4);
0525 resRecTimp->Fit("gaus");
0526 resRecCanvas->cd(5);
0527 resRecLimp->Fit("gaus");
0528 resRecCanvas->Update();
0529
0530 pullRecCanvas = new TCanvas(theTreeName+"PullRec",theTreeName+" Reconstrcuted Track Parameter Pulls", 900, 600);
0531 pullRecCanvas->Divide(3,2);
0532
0533 pullRecCanvas->cd(1);
0534 pullRecPt->Fit("gaus");
0535 pullRecCanvas->cd(2);
0536 pullRecPhi->Fit("gaus");
0537 pullRecCanvas->cd(3);
0538 pullRecTheta->Fit("gaus");
0539 pullRecCanvas->cd(4);
0540 pullRecTimp->Fit("gaus");
0541 pullRecCanvas->cd(5);
0542 pullRecLimp->Fit("gaus");
0543 pullRecCanvas->Update();
0544
0545 resRefCanvas = new TCanvas(theTreeName+"ResRef",theTreeName+" Refitted Track Parameter Residuals", 900, 600);
0546 resRefCanvas->Divide(3,2);
0547
0548 resRefCanvas->cd(1);
0549 resRefPt->Fit("gaus");
0550 resRefCanvas->cd(2);
0551 resRefPhi->Fit("gaus");
0552 resRefCanvas->cd(3);
0553 resRefTheta->Fit("gaus");
0554 resRefCanvas->cd(4);
0555 resRefTimp->Fit("gaus");
0556 resRefCanvas->cd(5);
0557 resRefLimp->Fit("gaus");
0558 resRefCanvas->Update();
0559
0560 pullRefCanvas = new TCanvas(theTreeName+"PullRef",theTreeName+" Refitted Track Parameter Pulls", 900, 600);
0561 pullRefCanvas->Divide(3,2);
0562
0563 pullRefCanvas->cd(1);
0564 pullRefPt->Fit("gaus");
0565 pullRefCanvas->cd(2);
0566 pullRefPhi->Fit("gaus");
0567 pullRefCanvas->cd(3);
0568 pullRefTheta->Fit("gaus");
0569 pullRefCanvas->cd(4);
0570 pullRefTimp->Fit("gaus");
0571 pullRefCanvas->cd(5);
0572 pullRefLimp->Fit("gaus");
0573 pullRefCanvas->Update();
0574
0575 distCanvas = new TCanvas(theTreeName+"TrkDistr",theTreeName+" Track Distributions", 900, 600);
0576 distCanvas->Divide(3,2);
0577 distCanvas->cd(1);
0578 pTSim->Draw();
0579 distCanvas->cd(2);
0580 etaSim->Draw();
0581 distCanvas->cd(3);
0582 pTRec->Draw();
0583 distCanvas->cd(4);
0584 etaRec->Draw();
0585 distCanvas->cd(5);
0586 pTRef->Draw();
0587 distCanvas->cd(6);
0588 etaRef->Draw();
0589 distCanvas->Update();
0590
0591 bookedVertexC = true;
0592 }
0593
0594
0595 void SimpleVertexAnalysis::psTrackResult(TString name)
0596 {
0597 if (!bookedVertexC) plotTrackResult();
0598 resRecCanvas->Print(name+".ps[");
0599 resRecCanvas->Draw();
0600 resRecCanvas->Print(name+".ps");
0601 pullRecCanvas->Draw();
0602 pullRecCanvas->Print(name+".ps");
0603 resRefCanvas->Draw();
0604 resRefCanvas->Print(name+".ps");
0605 pullRefCanvas->Draw();
0606 pullRefCanvas->Print(name+".ps");
0607 distCanvas->Draw();
0608 distCanvas->Print(name+".ps");
0609 distCanvas->Print(name+".ps]");
0610
0611
0612
0613
0614
0615
0616
0617
0618 }