00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00087 #include <cmath>
00088
00089 #include "TCanvas.h"
00090 #include "TH1D.h"
00091 #include "TF1.h"
00092 #include "TFile.h"
00093 #include "TGraphErrors.h"
00094 #include "TMath.h"
00095
00096 #include <map>
00097 #include "NtupleUtils/NuGeneral.h"
00098 #include "CandNtupleSR/NtpSRTrack.h"
00099 #include "MessageService/MsgService.h"
00100 #include "MinosObjectMap/MomNavigator.h"
00101
00102 #include "NtupleUtils/SRMom.h"
00103 #include "NtupleUtils/MajorityCurvature.h"
00104
00105 ClassImp(MajorityCurvature)
00106
00107 CVSID("$Id: MajorityCurvature.cxx,v 1.14 2009/12/08 18:09:26 ahimmel Exp $");
00108
00109 TH1F* MajorityCurvature::hvariances = new TH1F("hvariances","",200,-5,5);
00110
00111
00112 MajorityCurvature::MajorityCurvature()
00113 {
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 TDirectory* tmpd = gDirectory;
00127 MSG("MajorityCurvature",Msg::kDebug)
00128 <<"TDirectory before opening file is:"<<endl;
00129
00130
00131 const NuGeneral& general=NuGeneral();
00132 TString filename=general.GetReleaseDirToUse("NtupleUtils");
00133 filename += "/NtupleUtils/data/pid_evans_cedar_daikon_LE185.root";
00134 fPDFFile = new
00135 TFile(filename, "READ");
00136
00137 fhMajCBa = dynamic_cast<TH1D*> (fPDFFile->Get("hMajCBa"));
00138 fhMajCBa->SetDirectory(0);
00139 if (!fhMajCBa){
00140 cout << "No MajCBa PDF. Expect a seg fault at any moment!" << endl;
00141 }
00142 fhMajCNC = dynamic_cast<TH1D*> (fPDFFile->Get("hMajCNC"));
00143 fhMajCNC->SetDirectory(0);
00144 if (!fhMajCNC){
00145 cout << "No MajCNC PDF. Expect a seg fault at any moment!" << endl;
00146 }
00147 fhMajCNu = dynamic_cast<TH1D*> (fPDFFile->Get("hMajCNu"));
00148 fhMajCNu->SetDirectory(0);
00149 if (!fhMajCNu){
00150 cout << "No MajCNu PDF. Expect a seg fault at any moment!" << endl;
00151 }
00152 fhQOverPBa = dynamic_cast<TH1D*> (fPDFFile->Get("hQOverPBa"));
00153 fhQOverPBa->SetDirectory(0);
00154 if (!fhQOverPBa){
00155 cout << "No QOverPBa PDF. Expect a seg fault at any moment!" << endl;
00156 }
00157 fhQOverPNC = dynamic_cast<TH1D*> (fPDFFile->Get("hQOverPNC"));
00158 fhQOverPNC->SetDirectory(0);
00159 if (!fhQOverPNC){
00160 cout << "No QOverPNC PDF. Expect a seg fault at any moment!" << endl;
00161 }
00162 fhQOverPNu = dynamic_cast<TH1D*> (fPDFFile->Get("hQOverPNu"));
00163 fhQOverPNu->SetDirectory(0);
00164 if (!fhQOverPNu){
00165 cout << "No QOverPNu PDF. Expect a seg fault at any moment!" << endl;
00166 }
00167 fPDFFile->Close();
00168
00169 MSG("MajorityCurvature",Msg::kDebug)
00170 <<"TDirectory after using file is:"<<endl;
00171
00172 MSG("MajorityCurvature",Msg::kDebug)
00173 <<"After reseting gDirectory its location is:"<<endl;
00174 gDirectory=tmpd;
00175
00176
00177 for (Int_t row=0; row<500; ++row){
00178 for (Int_t column=0; column<500; ++column){
00179 fitLengths[row][column] = 0;
00180 }
00181 }
00182
00183
00184 fitLengths[0][0] = 0;
00185 fitLengths[1][0] = 0;
00186 fitLengths[2][0] = 0;
00187
00188 for(Int_t tl=3; tl<8; ++tl){
00189 Int_t i=0;
00190 for(Int_t fl=tl; fl>1; --fl, ++i){
00191 fitLengths[tl][i] = fl;
00192 if (2==fl){fitLengths[tl][i] = 0;}
00193 }
00194 }
00195
00196 for(Int_t tl=8; tl<11; ++tl){
00197 Int_t i=0;
00198 for(Int_t fl = 7; fl>3; --fl,++i){
00199 fitLengths[tl][i] = fl;
00200 }
00201 for(Int_t fl = 8; fl<=tl; ++fl,++i){
00202 fitLengths[tl][i] = fl;
00203 }
00204 fitLengths[tl][i] = 3;
00205 ++i;
00206 fitLengths[tl][i] = 0;
00207 }
00208
00209 for (Int_t tl=11; tl<500; ++tl){
00210 fitLengths[tl][0] = 7;
00211 fitLengths[tl][1] = 8;
00212 fitLengths[tl][2] = 6;
00213 fitLengths[tl][3] = 5;
00214 fitLengths[tl][4] = 4;
00215 fitLengths[tl][5] = 0;
00216 }
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 }
00246
00247
00248 MajorityCurvature::~MajorityCurvature()
00249 {
00250 if (fhMajCBa) {delete fhMajCBa; fhMajCBa = 0;}
00251 if (fhMajCNu) {delete fhMajCNu; fhMajCNu = 0;}
00252 if (fhMajCNC) {delete fhMajCNC; fhMajCNC = 0;}
00253 if (fhQOverPBa) {delete fhQOverPBa; fhQOverPBa = 0;}
00254 if (fhQOverPNu) {delete fhQOverPNu; fhQOverPNu = 0;}
00255 if (fhQOverPNC) {delete fhQOverPNC; fhQOverPNC = 0;}
00256 fPDFFile->Close();
00257 if (fPDFFile) {delete fPDFFile; fPDFFile = 0;}
00258 }
00259
00260
00261 const Float_t MajorityCurvature::CalcCombCurv(const MomNavigator* mom,
00262 const Int_t event,
00263 const Int_t track,
00264 const Int_t fitLength) const
00265 {
00266
00267 SRMom srMom(mom);
00268 TH1F hCurv("hCurv","",100,-5,5);
00269
00270 const multimap<Float_t, Float_t> mu
00271 = srMom.ArrayUAlongTrack(event,track);
00272 const Int_t sizeu = mu.size();
00273 Float_t* xerr = new Float_t[fitLength];
00274 Float_t* zerr = new Float_t[fitLength];
00275 Bool_t smallu = false;
00276
00277 if (sizeu < fitLength){smallu = true;}
00278 else{
00279 multimap<Float_t,Float_t>::const_iterator itu = mu.begin();
00280 for (Int_t k=0; k<(sizeu-fitLength); ++k){
00281 Float_t* z = new Float_t[fitLength];
00282 Float_t* x = new Float_t[fitLength];
00283 Float_t* absx = new Float_t[fitLength];
00284 Bool_t changesign = false;
00285 Bool_t positive = false;
00286 if (itu->second > 0){positive = true;}
00287 for (Int_t l=0; l<fitLength; ++l)
00288 {
00289 Bool_t thispos = false;
00290 z[l] = itu->first;
00291 zerr[l] = 0.0594;
00292 x[l] = itu->second;
00293 xerr[l] = 0.041;
00294 absx[l] = fabs(itu->second);
00295 if (x[l] > 0){thispos = true;}
00296 if (thispos != positive){changesign = true;}
00297 ++itu;
00298 }
00299 if (!changesign){
00300 TGraphErrors g(fitLength,z,absx,zerr,xerr);
00301
00302 g.Draw("A*");
00303 g.Fit("pol2","Q");
00304
00305 Float_t curviness = 2*(g.GetFunction("pol2")->GetParameter(2));
00306
00307
00308
00309 hCurv.Fill(curviness);
00310 }
00311 for (Int_t l=0; l<fitLength; ++l)
00312 {
00313 --itu;
00314 }
00315 ++itu;
00316 if(z){delete z; z=0;}
00317 if(x){delete x; x=0;}
00318 if(absx){delete absx; absx=0;}
00319 }
00320 }
00321
00322 const multimap<Float_t, Float_t> mv
00323 = srMom.ArrayVAlongTrack(event,track);
00324 const Int_t sizev = mv.size();
00325 if (sizev < fitLength){
00326 if (smallu){return 0.0;}
00327 }
00328 else{
00329 multimap<Float_t,Float_t>::const_iterator itv = mv.begin();
00330 for (Int_t k=0; k<(sizev-fitLength); ++k){
00331 Float_t* z = new Float_t[fitLength];
00332 Float_t* x = new Float_t[fitLength];
00333 Float_t* absx = new Float_t[fitLength];
00334 Bool_t changesign = false;
00335 Bool_t positive = false;
00336 if (itv->second > 0){positive = true;}
00337 for (Int_t l=0; l<fitLength; ++l)
00338 {
00339 Bool_t thispos = false;
00340 z[l] = itv->first;
00341 zerr[l] = 0.0594;
00342 x[l] = itv->second;
00343 xerr[l] = 0.041;
00344 absx[l] = fabs(itv->second);
00345 if (x[l] > 0){thispos = true;}
00346 if (thispos != positive){changesign = true;}
00347 ++itv;
00348 }
00349 if (!changesign){
00350 TGraphErrors g(fitLength,z,absx,zerr,xerr);
00351
00352 g.Draw("A*");
00353 g.Fit("pol2","Q");
00354
00355 Float_t curviness = 2*(g.GetFunction("pol2")->GetParameter(2));
00356
00357
00358
00359 hCurv.Fill(curviness);
00360 }
00361 for (Int_t l=0; l<fitLength; ++l)
00362 {
00363 --itv;
00364 }
00365 ++itv;
00366 if(z){delete z; z=0;}
00367 if(x){delete x; x=0;}
00368 if(absx){delete absx; absx=0;}
00369 }
00370 }
00371 TCanvas cCurv("cCurv","",0,0,500,500);
00372 hCurv.Draw();
00373
00374
00375 Float_t neg = hCurv.Integral(0,50);
00376 Float_t pos = hCurv.Integral(51,101);
00377 if(xerr){delete xerr; xerr = 0;}
00378 if(zerr){delete zerr; zerr = 0;}
00379 if (pos > neg) {if (neg) {return pos/neg;} else {return 10.0;}}
00380 if (neg > pos) {if (pos) {return -1.0*neg/pos;} else {return -10.0;}}
00381 if (neg == pos) {return 0.0;}
00382 return 0.0;
00383 }
00384
00385
00386 const Float_t MajorityCurvature::CalcCurv(const multimap<Float_t,
00387 Float_t> md,
00388 const Int_t fitLength) const
00389 {
00390
00391 const Int_t size = md.size();
00392 Float_t* xerr = new Float_t[fitLength];
00393 Float_t* zerr = new Float_t[fitLength];
00394 if (size<fitLength){return 0.0;}
00395
00396 multimap<Float_t, Float_t> mfits;
00397 multimap<Float_t,Float_t>::const_iterator it = md.begin();
00398
00399 for (Int_t k=0; k<(size-fitLength); ++k){
00400 Float_t* z = new Float_t[fitLength];
00401 Float_t* x = new Float_t[fitLength];
00402 Float_t* absx = new Float_t[fitLength];
00403 Bool_t changesign = false;
00404 Bool_t positive = false;
00405 if (it->second > 0){positive = true;}
00406
00407
00408
00409 for (Int_t l=0; l<fitLength; ++l)
00410 {
00411 Bool_t thispos = false;
00412 z[l] = it->first;
00413 zerr[l] = 0.0594;
00414 x[l] = it->second;
00415 xerr[l] = 0.041;
00416 absx[l] = fabs(it->second);
00417 if (x[l] > 0){thispos = true;}
00418 if (thispos != positive){changesign = true;}
00419 ++it;
00420 }
00421 if (!changesign){
00422 TGraphErrors g(fitLength,z,absx,zerr,xerr);
00423
00424 g.Draw("A*");
00425 g.Fit("pol2","Q");
00426 Float_t curviness = 2*(g.GetFunction("pol2")->GetParameter(2));
00427
00428 mfits.insert(pair<Float_t,Float_t>(fabs(curviness),
00429 curviness));
00430 }
00431 for (Int_t l=0; l<fitLength; ++l)
00432 {
00433 --it;
00434 }
00435 ++it;
00436 if(z){delete z; z=0;}
00437 if(x){delete x; x=0;}
00438 if(absx){delete absx; absx=0;}
00439 }
00440
00441 multimap<Float_t,Float_t>::const_iterator itfits = mfits.end();
00442 Int_t numRemove = 0;
00443 if (((Int_t) mfits.size()) >= numRemove){
00444 for (Int_t rem = 0; rem < numRemove; ++rem){
00445 itfits--;
00446 mfits.erase(itfits->first);
00447 itfits = mfits.end();
00448 }
00449 }
00450 TH1F hCurv("hCurv","",100,-5,5);
00451 for (itfits = mfits.begin();
00452 itfits != mfits.end();
00453 ++itfits){
00454 hCurv.Fill(itfits->second);
00455 }
00456
00457 TCanvas cCurv("cCurv","",0,0,500,500);
00458 hCurv.Draw();
00459
00460
00461 Float_t neg = hCurv.Integral(0,50);
00462 Float_t pos = hCurv.Integral(51,101);
00463 hvariances->Fill(hCurv.GetRMS());
00464
00465 if (pos > neg) {if (neg) {return pos/neg;} else {return 10.0;}}
00466 if (neg > pos) {if (pos) {return -1.0*neg/pos;} else {return -10.0;}}
00467 if (neg == pos) {return 0.0;}
00468 else {return 0.0;}
00469 }
00470
00471
00472 const MajCInfo MajorityCurvature::CalcCurvObject(const multimap<Float_t,
00473 Float_t> md,
00474 const Int_t fitLength)
00475 const
00476 {
00477
00478 MajCInfo majCInfo;
00479
00480
00481 const Int_t size = md.size();
00482
00483
00484 if (size<fitLength){return majCInfo;}
00485
00486 multimap<Float_t, Float_t> mfits;
00487 multimap<Float_t,Float_t>::const_iterator it = md.begin();
00488 Double_t totJitter = 0.0;
00489 Double_t totSqJitter = 0.0;
00490 Double_t prevCurvature = 0.0;
00491 Int_t numSegments = 0;
00492
00493
00494 TGraphErrors gQuick(fitLength);
00495 for (Int_t k=0; k<(size-fitLength); ++k){
00496
00497
00498
00499 Bool_t changesign = false;
00500 Bool_t positive = false;
00501 if (it->second > 0){positive = true;}
00502
00503
00504
00505 for (Int_t l=0; l<fitLength; ++l)
00506 {
00507 Bool_t thispos = false;
00508 gQuick.SetPoint(l,it->first,fabs(it->second));
00509 gQuick.SetPointError(l,0.0594,0.041);
00510
00511
00512
00513
00514
00515 if (it->second > 0){thispos = true;}
00516 if (thispos != positive){changesign = true;}
00517 ++it;
00518 }
00519 if (!changesign){
00520
00521 gQuick.Fit("pol2","Q");
00522 Float_t curviness = 2*(gQuick.GetFunction("pol2")->GetParameter(2));
00523 if ((numSegments)){
00524 totJitter += fabs(curviness - prevCurvature);
00525 totSqJitter +=
00526 (curviness - prevCurvature)*(curviness - prevCurvature);
00527 }
00528 ++numSegments;
00529 prevCurvature = curviness;
00530
00531 mfits.insert(pair<Float_t,Float_t>(fabs(curviness),
00532 curviness));
00533 }
00534 for (Int_t l=0; l<fitLength; ++l)
00535 {
00536 --it;
00537 }
00538 ++it;
00539
00540
00541
00542
00543 majCInfo.jitter = -1.0;
00544 majCInfo.sqJitter = -1.0;
00545
00546
00547
00548
00549 if (numSegments){
00550 majCInfo.jitter = totJitter/((Double_t) (numSegments));
00551 majCInfo.sqJitter = totSqJitter/((Double_t) (numSegments));
00552 }
00553 gQuick.Clear();
00554 }
00555
00556 multimap<Float_t,Float_t>::const_iterator itfits = mfits.end();
00557 Int_t numRemove = 0;
00558 if (((Int_t) mfits.size()) >= numRemove){
00559 for (Int_t rem = 0; rem < numRemove; ++rem){
00560 itfits--;
00561 mfits.erase(itfits->first);
00562 itfits = mfits.end();
00563 }
00564 }
00565 TH1F hCurv("hCurv","",100,-5,5);
00566 Float_t smallestCurv=100.0;
00567 Float_t largestCurv = -100.0;
00568 for (itfits = mfits.begin();
00569 itfits != mfits.end();
00570 ++itfits){
00571 hCurv.Fill(itfits->second);
00572 if (itfits->second<smallestCurv){smallestCurv=itfits->second;}
00573 if (itfits->second>largestCurv){largestCurv=itfits->second;}
00574 }
00575
00576
00577
00578 majCInfo.rms = hCurv.GetRMS();
00579 majCInfo.totWidth = largestCurv-smallestCurv;
00580
00581 Float_t neg = hCurv.Integral(0,50);
00582 Float_t pos = hCurv.Integral(51,101);
00583 hvariances->Fill(hCurv.GetRMS());
00584
00585 majCInfo.simpleMajC = pos-neg;
00586 if (neg){majCInfo.majCRatio = pos/neg;}
00587 else{majCInfo.majCRatio = 10.0;}
00588
00589 if (!pos){
00590 majCInfo.smoothMajC = -10.0;
00591 }
00592 else {
00593 if (!neg) {
00594 majCInfo.smoothMajC = 10.0;
00595 }
00596 else{
00597 majCInfo.smoothMajC = TMath::Log(pos/neg);
00598 }
00599 }
00600
00601 if (pos > neg) {
00602 if (neg) {majCInfo.majC = pos/neg; return majCInfo;}
00603 else {majCInfo.majC = 10.0; return majCInfo;}
00604 }
00605 if (neg > pos) {
00606 if (pos) {majCInfo.majC = -1.0*neg/pos; return majCInfo;}
00607 else {majCInfo.majC = -10.0; return majCInfo;}
00608 }
00609 if (neg == pos) {majCInfo.majC = 0.0; return majCInfo;}
00610 else {majCInfo.majC = 0.0; return majCInfo;}
00611 return majCInfo;
00612 }
00613
00614
00615 const MajCInfo MajorityCurvature::CalcCurvObjectFast(const multimap<Float_t,
00616 Float_t> md,
00617 const Int_t fitLength)
00618 const
00619 {
00620
00621 MajCInfo majCInfo;
00622
00623
00624 const Int_t size = md.size();
00625
00626
00627 if (size<fitLength){return majCInfo;}
00628
00629 multimap<Float_t,Float_t>::const_iterator it = md.begin();
00630 Int_t numPositiveSegments = 0;
00631 Int_t numNegativeSegments = 0;
00632
00633 for (Int_t k=0; k<(size-fitLength); ++k){
00634 Bool_t changesign = false;
00635 Bool_t positive = false;
00636 if (it->second > 0){positive = true;}
00637
00638
00639
00640 ++it;
00641 Int_t numPositiveIncrements = 0;
00642 Int_t numNegativeIncrements = 0;
00643 for (Int_t l=1; l<fitLength-1; ++l)
00644 {
00645 Bool_t thispos = false;
00646 --it;
00647 Double_t prevZ = it->first;
00648 Double_t prevX = it->second;
00649 ++it;
00650 Double_t thisZ = it->first;
00651 Double_t thisX = it->second;
00652 ++it;
00653 Double_t nextZ = it->first;
00654 Double_t nextX = it->second;
00655 if ((nextZ-thisZ) && (thisZ-prevZ)){
00656 Double_t forwardGrad = (nextX-thisX)/(nextZ-thisZ);
00657 Double_t backGrad = (thisX-prevX)/(thisZ-prevZ);
00658 if (positive){
00659 if (forwardGrad>backGrad){
00660 ++numPositiveIncrements;
00661 }
00662 if (backGrad>forwardGrad){
00663 ++numNegativeIncrements;
00664 }
00665 }
00666 else{
00667 if (forwardGrad>backGrad){
00668 ++numNegativeIncrements;
00669 }
00670 if (backGrad>forwardGrad){
00671 ++numPositiveIncrements;
00672 }
00673 }
00674 }
00675 --it;
00676 if (it->second > 0){thispos = true;}
00677 if (thispos != positive){changesign = true;}
00678 ++it;
00679 }
00680 if (!changesign){
00681 if (numPositiveIncrements>numNegativeIncrements){
00682 ++numPositiveSegments;
00683 }
00684 if (numNegativeIncrements>numPositiveIncrements){
00685 ++numNegativeSegments;
00686 }
00687 }
00688 for (Int_t l=1; l<fitLength-1; ++l)
00689 {
00690 --it;
00691 }
00692 ++it;
00693
00694 majCInfo.jitter = -1.0;
00695 majCInfo.sqJitter = -1.0;
00696 }
00697
00698 majCInfo.simpleMajC = numPositiveSegments-numNegativeSegments;
00699 if (numNegativeSegments){majCInfo.majCRatio = numPositiveSegments/numNegativeSegments;}
00700 else{majCInfo.majCRatio = 10.0;}
00701
00702 if (!numPositiveSegments){
00703 majCInfo.smoothMajC = -10.0;
00704 }
00705 else {
00706 if (!numNegativeSegments) {
00707 majCInfo.smoothMajC = 10.0;
00708 }
00709 else{
00710 majCInfo.smoothMajC = TMath::Log(numPositiveSegments/numNegativeSegments);
00711 }
00712 }
00713
00714 if (numPositiveSegments > numNegativeSegments) {
00715 if (numNegativeSegments) {majCInfo.majC = numPositiveSegments/numNegativeSegments; return majCInfo;}
00716 else {majCInfo.majC = 10.0; return majCInfo;}
00717 }
00718 if (numNegativeSegments > numPositiveSegments) {
00719 if (numPositiveSegments) {majCInfo.majC = -1.0*numNegativeSegments/numPositiveSegments; return majCInfo;}
00720 else {majCInfo.majC = -10.0; return majCInfo;}
00721 }
00722 if (numNegativeSegments == numPositiveSegments) {majCInfo.majC = 0.0; return majCInfo;}
00723 else {majCInfo.majC = 0.0; return majCInfo;}
00724 return majCInfo;
00725 }
00726
00727
00728 const Float_t MajorityCurvature::CalcXCurv(const MomNavigator* mom,
00729 const Int_t event,
00730 const Int_t track,
00731 const Int_t fitLength) const
00732 {
00733 SRMom srMom(mom);
00734 const multimap<Float_t, Float_t> md
00735 = srMom.ArrayXAlongTrack(event,track);
00736 return CalcCurv(md, fitLength);
00737 }
00738
00739
00740 const MajCInfo MajorityCurvature::
00741 CalcXCurvObject(const MomNavigator* mom,
00742 const Int_t event,
00743 const Int_t track,
00744 const Int_t fitLength) const
00745 {
00746 SRMom srMom(mom);
00747 const multimap<Float_t, Float_t> md
00748 = srMom.ArrayXAlongTrack(event,track);
00749 return CalcCurvObject(md, fitLength);
00750 }
00751
00752
00753 const MajCInfo MajorityCurvature::
00754 CalcXCurvObject(const NtpSRTrack* track,
00755 const Int_t fitLength) const
00756 {
00757 SRMom srMom;
00758 const multimap<Float_t, Float_t> md
00759 = srMom.ArrayXAlongTrack(track);
00760 return CalcCurvObject(md, fitLength);
00761 }
00762
00763
00764 const Float_t MajorityCurvature::CalcXCurv(const NtpSRTrack* track,
00765 const Int_t fitLength) const
00766 {
00767 SRMom srMom;
00768 const multimap<Float_t, Float_t> md
00769 = srMom.ArrayXAlongTrack(track);
00770 return CalcCurv(md, fitLength);
00771 }
00772
00773
00774 const Float_t MajorityCurvature::CalcYCurv(const MomNavigator* mom,
00775 const Int_t event,
00776 const Int_t track,
00777 const Int_t fitLength) const
00778 {
00779 SRMom srMom(mom);
00780 const multimap<Float_t, Float_t> md
00781 = srMom.ArrayYAlongTrack(event,track);
00782 return CalcCurv(md, fitLength);
00783 }
00784
00785
00786 const MajCInfo MajorityCurvature::
00787 CalcYCurvObject(const MomNavigator* mom,
00788 const Int_t event,
00789 const Int_t track,
00790 const Int_t fitLength) const
00791 {
00792 SRMom srMom(mom);
00793 const multimap<Float_t, Float_t> md
00794 = srMom.ArrayYAlongTrack(event,track);
00795 return CalcCurvObject(md, fitLength);
00796 }
00797
00798
00799 const MajCInfo MajorityCurvature::
00800 CalcYCurvObject(const NtpSRTrack* track,
00801 const Int_t fitLength) const
00802 {
00803 SRMom srMom;
00804 const multimap<Float_t, Float_t> md
00805 = srMom.ArrayYAlongTrack(track);
00806 return CalcCurvObject(md, fitLength);
00807 }
00808
00809
00810 const Float_t MajorityCurvature::CalcYCurv(const NtpSRTrack* track,
00811 const Int_t fitLength) const
00812 {
00813 SRMom srMom;
00814 const multimap<Float_t, Float_t> md
00815 = srMom.ArrayYAlongTrack(track);
00816 return CalcCurv(md, fitLength);
00817 }
00818
00819
00820 const Float_t MajorityCurvature::Curvature(const NtpSRTrack* track) const
00821 {
00822 Float_t xCurv = XCurvature(track);
00823 Float_t yCurv = YCurvature(track);
00824 if (fabs(yCurv) > fabs(xCurv)){return yCurv;}
00825 else {return xCurv;}
00826 }
00827
00828
00829 const MajCInfo MajorityCurvature::
00830 CurvatureImproved(const NtpSRTrack* track) const
00831 {
00832 MajCInfo xCurv = XCurvatureObject(track);
00833 MajCInfo yCurv = YCurvatureObject(track);
00834 MajCInfo* bestCurv;
00835 if (fabs(yCurv.majC) > fabs(xCurv.majC)){bestCurv = &yCurv;}
00836 else {bestCurv = &xCurv;}
00837 SRMom srMom;
00838 Double_t qp = srMom.TrackVtxQOvP(track);
00839 bestCurv->jPID = this->JPID(qp,bestCurv->majC);
00840 return *bestCurv;
00841 }
00842
00843
00844 const MajCInfo MajorityCurvature::
00845 CurvatureImproved(const MomNavigator* mom,
00846 const Int_t event,
00847 const Int_t track) const
00848 {
00849 MajCInfo xCurv = XCurvatureObject(mom,event,track);
00850 MajCInfo yCurv = YCurvatureObject(mom,event,track);
00851 MajCInfo* bestCurv;
00852 if (fabs(yCurv.majC) > fabs(xCurv.majC)){bestCurv = &yCurv;}
00853 else {bestCurv = &xCurv;}
00854 SRMom srMom(mom);
00855 Double_t qp = srMom.TrackVtxQOvP(event,track);
00856 bestCurv->jPID = this->JPID(qp,bestCurv->majC);
00857 return *bestCurv;
00858 }
00859
00860
00861 const Float_t MajorityCurvature::Curvature(const MomNavigator* mom,
00862 const Int_t event,
00863 const Int_t track) const
00864 {
00865 Float_t xCurv = XCurvature(mom,event,track);
00866 Float_t yCurv = YCurvature(mom,event,track);
00867 if (fabs(yCurv) > fabs(xCurv)){return yCurv;}
00868 else {return xCurv;}
00869 }
00870
00871
00872 const Float_t MajorityCurvature::CurvatureComb(const MomNavigator* mom,
00873 const Int_t event,
00874 const Int_t track) const
00875 {
00876 SRMom srMom(mom);
00877 const Int_t trkLthPln = srMom.TrackLengthPlanes(event,track);
00878 Int_t fitLength = FitLength(trkLthPln);
00879 if (!fitLength) {return 0.0;}
00880 Float_t xCurv = CalcCombCurv(mom,event,track,fitLength);
00881 if (xCurv) {return xCurv;}
00882 while (!xCurv){
00883 fitLength = NextFitLength(trkLthPln,fitLength);
00884 if (!fitLength){return 0.0;}
00885 xCurv = CalcCombCurv(mom,event,track,fitLength);
00886 }
00887 return xCurv;
00888 }
00889
00890
00891 const Int_t MajorityCurvature::FitLength(const Int_t trkLthPln) const
00892 {
00893 return fitLengths[trkLthPln][0];
00894 }
00895
00896
00897 const Double_t MajorityCurvature::JPID(const Double_t qOverP,
00898 const Double_t majC) const
00899 {
00900 Double_t pBackMajC =
00901 fhMajCNu->GetBinContent(fhMajCNu->GetXaxis()->FindBin(majC));
00902 pBackMajC +=
00903 fhMajCNC->GetBinContent(fhMajCNC->GetXaxis()->FindBin(majC));
00904 Double_t pSigMajC =
00905 fhMajCBa->GetBinContent(fhMajCBa->GetXaxis()->FindBin(majC));
00906
00907 Double_t pBackqOvp =
00908 fhQOverPNu->GetBinContent(fhQOverPNu->GetXaxis()->FindBin(qOverP));
00909 pBackqOvp +=
00910 fhQOverPNC->GetBinContent(fhQOverPNC->GetXaxis()->FindBin(qOverP));
00911 Double_t pSigqOvp =
00912 fhQOverPBa->GetBinContent(fhQOverPBa->GetXaxis()->FindBin(qOverP));
00913
00914 Float_t numerator =
00915 pBackMajC*pBackqOvp;
00916 if (numerator<0.0001){numerator = 0.0001;}
00917 Float_t denominator =
00918 pSigMajC*pSigqOvp;
00919 if (denominator<0.0001){denominator = 0.0001;}
00920
00921 Double_t jPID = log(numerator/denominator);
00922 return jPID;
00923 }
00924
00925
00926 const Int_t MajorityCurvature::NextFitLength(const Int_t trkLthPln,
00927 const Int_t lastFitLength)
00928 const
00929 {
00930 Int_t i=0;
00931 Int_t fitLength = 0;
00932 for (i=0; fitLength != lastFitLength; ++i){
00933 fitLength = fitLengths[trkLthPln][i];
00934 if (!fitLength){return fitLength;}
00935 }
00936 return fitLengths[trkLthPln][i];
00937 }
00938
00939
00940 const Float_t MajorityCurvature::XCurvature(const MomNavigator* mom,
00941 const Int_t event,
00942 const Int_t track) const
00943 {
00944 SRMom srMom(mom);
00945 const Int_t trkLthPln = srMom.TrackLengthPlanes(event,track);
00946 Int_t fitLength = FitLength(trkLthPln);
00947 if (!fitLength) {return 0.0;}
00948 Float_t xCurv = CalcXCurv(mom,event,track,fitLength);
00949 if (xCurv) {return xCurv;}
00950 while (!xCurv){
00951 fitLength = NextFitLength(trkLthPln,fitLength);
00952 if (!fitLength){return 0.0;}
00953 xCurv = CalcXCurv(mom,event,track,fitLength);
00954 }
00955 return xCurv;
00956 }
00957
00958
00959 const MajCInfo MajorityCurvature::
00960 XCurvatureObject(const MomNavigator* mom,
00961 const Int_t event,
00962 const Int_t track) const
00963 {
00964 SRMom srMom(mom);
00965 const Int_t trkLthPln = srMom.TrackLengthPlanes(event,track);
00966 Int_t fitLength = FitLength(trkLthPln);
00967 if (!fitLength) {MajCInfo empty; return empty;}
00968 MajCInfo xCurv = CalcXCurvObject(mom,event,track,fitLength);
00969 if (xCurv.majC) {return xCurv;}
00970 while (!xCurv.majC){
00971 fitLength = NextFitLength(trkLthPln,fitLength);
00972 if (!fitLength){MajCInfo empty; return empty;}
00973 xCurv = CalcXCurvObject(mom,event,track,fitLength);
00974 }
00975 return xCurv;
00976 }
00977
00978
00979 const MajCInfo MajorityCurvature::
00980 XCurvatureObject(const NtpSRTrack* track) const
00981 {
00982 SRMom srMom;
00983 const Int_t trkLthPln = srMom.TrackLengthPlanes(track);
00984 Int_t fitLength = FitLength(trkLthPln);
00985 if (!fitLength) {MajCInfo empty; return empty;}
00986 MajCInfo xCurv = CalcXCurvObject(track,fitLength);
00987 if (xCurv.majC) {return xCurv;}
00988 while (!xCurv.majC){
00989 fitLength = NextFitLength(trkLthPln,fitLength);
00990 if (!fitLength){MajCInfo empty; return empty;}
00991 xCurv = CalcXCurvObject(track,fitLength);
00992 }
00993 return xCurv;
00994 }
00995
00996
00997 const Float_t MajorityCurvature::XCurvature(const NtpSRTrack* track)
00998 const
00999 {
01000 SRMom srMom;
01001 const Int_t trkLthPln = srMom.TrackLengthPlanes(track);
01002 Int_t fitLength = FitLength(trkLthPln);
01003 if (!fitLength) {return 0.0;}
01004 Float_t xCurv = CalcXCurv(track,fitLength);
01005 if (xCurv) {return xCurv;}
01006 while (!xCurv){
01007 fitLength = NextFitLength(trkLthPln,fitLength);
01008 if (!fitLength){return 0.0;}
01009 xCurv = CalcXCurv(track,fitLength);
01010 }
01011 return xCurv;
01012 }
01013
01014
01015 const Float_t MajorityCurvature::YCurvature(const MomNavigator* mom,
01016 const Int_t event,
01017 const Int_t track) const
01018 {
01019 SRMom srMom(mom);
01020 const Int_t trkLthPln = srMom.TrackLengthPlanes(event,track);
01021 Int_t fitLength = FitLength(trkLthPln);
01022 if (!fitLength) {return 0.0;}
01023 Float_t yCurv = CalcYCurv(mom,event,track,fitLength);
01024 if (yCurv) {return yCurv;}
01025 while (!yCurv){
01026 fitLength = NextFitLength(trkLthPln,fitLength);
01027 if (!fitLength){return 0.0;}
01028 yCurv = CalcYCurv(mom,event,track,fitLength);
01029 }
01030 return yCurv;
01031 }
01032
01033
01034 const MajCInfo MajorityCurvature::
01035 YCurvatureObject(const MomNavigator* mom,
01036 const Int_t event,
01037 const Int_t track) const
01038 {
01039 SRMom srMom(mom);
01040 const Int_t trkLthPln = srMom.TrackLengthPlanes(event,track);
01041 Int_t fitLength = FitLength(trkLthPln);
01042 if (!fitLength) {MajCInfo empty; return empty;}
01043 MajCInfo yCurv = CalcYCurvObject(mom,event,track,fitLength);
01044 if (yCurv.majC) {return yCurv;}
01045 while (!yCurv.majC){
01046 fitLength = NextFitLength(trkLthPln,fitLength);
01047 if (!fitLength){MajCInfo empty; return empty;}
01048 yCurv = CalcYCurvObject(mom,event,track,fitLength);
01049 }
01050 return yCurv;
01051 }
01052
01053
01054 const MajCInfo MajorityCurvature::
01055 YCurvatureObject(const NtpSRTrack* track) const
01056 {
01057 SRMom srMom;
01058 const Int_t trkLthPln = srMom.TrackLengthPlanes(track);
01059 Int_t fitLength = FitLength(trkLthPln);
01060 if (!fitLength) {MajCInfo empty; return empty;}
01061 MajCInfo yCurv = CalcYCurvObject(track,fitLength);
01062 if (yCurv.majC) {return yCurv;}
01063 while (!yCurv.majC){
01064 fitLength = NextFitLength(trkLthPln,fitLength);
01065 if (!fitLength){MajCInfo empty; return empty;}
01066 yCurv = CalcYCurvObject(track,fitLength);
01067 }
01068 return yCurv;
01069 }
01070
01071
01072 const Float_t MajorityCurvature::YCurvature(const NtpSRTrack* track) const
01073 {
01074 SRMom srMom;
01075 const Int_t trkLthPln = srMom.TrackLengthPlanes(track);
01076 Int_t fitLength = FitLength(trkLthPln);
01077 if (!fitLength) {return 0.0;}
01078 Float_t yCurv = CalcYCurv(track,fitLength);
01079 if (yCurv) {return yCurv;}
01080 while (!yCurv){
01081 fitLength = NextFitLength(trkLthPln,fitLength);
01082 if (!fitLength){return 0.0;}
01083 yCurv = CalcYCurv(track,fitLength);
01084 }
01085 return yCurv;
01086 }
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229