Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MajorityCurvature.cxx

Go to the documentation of this file.
00001 
00002 // $Id: MajorityCurvature.cxx,v 1.14 2009/12/08 18:09:26 ahimmel Exp $
00003 //
00004 // Class to calculate the Majority Curvature of a track.
00005 //
00006 // Justin Evans
00007 // j.evans2@physics.ox.ac.uk
00008 //
00009 // $Log: MajorityCurvature.cxx,v $
00010 // Revision 1.14  2009/12/08 18:09:26  ahimmel
00011 //
00012 //
00013 // Removing dependence on NuBarPID now that it's maintainer has moved on.  Let me know ASAP if you see unexpected problems.
00014 //
00015 // Revision 1.13  2009/09/20 15:20:40  ahimmel
00016 //
00017 //
00018 // Now use a NuGeneral object directly rather than  NuLibrary singleton.  This should avoid the chicken-and-egg problem.  I have tested that it runs normally, however I cannot test the file-handling behavior until this change is picked up by the development build.
00019 //
00020 // Revision 1.12  2009/09/20 12:24:54  nickd
00021 // Reverting to version 1.10 to fix chicken-and-egg bug
00022 //
00023 // MajorityCurvature.cxx instanced NuLibrary in it's constructor - NuLibrary also did the same.
00024 // Rather than fixing this myself now, I am reverting it so that the code 'works'
00025 //
00026 // Revision 1.10  2007/10/17 19:17:09  evans
00027 // Removing an unused variable.
00028 //
00029 // Revision 1.9  2007/10/17 19:12:18  evans
00030 // Discovered Google Perftools and made my majority curvature code at
00031 // least a factor of 5 faster. No change in the user interface or
00032 // results.
00033 //
00034 // Revision 1.8  2007/08/14 12:04:17  evans
00035 // Changing the calulation of the smoothMajC variable to be the most up to
00036 // date.
00037 //
00038 // Revision 1.7  2007/08/13 12:47:31  hartnell
00039 //
00040 // Set the gDirectory back to what it was before opening the PID file.
00041 //
00042 // Revision 1.6  2007/07/26 10:32:14  evans
00043 // Adding an implementation of code to make a beam matrix for extrapolation.
00044 //
00045 // NuFluxHelper makes the beam matrix. It's configurable to make the matrix
00046 // for either numus or numubars, and even to make a non-square beam matrix if
00047 // the mood takes you.
00048 //
00049 // NuFluxChain is a wrapper around a fluka file to give the interface required
00050 // by NuFluxHelper.
00051 //
00052 // macros/MakeMMFluxHelpers.C is an example macro of how to make the beam
00053 // matrix.
00054 //
00055 // Revision 1.5  2007/04/13 14:50:35  evans
00056 // Adding a second version of the track jitter using the square of the
00057 // differences between the curvatures of the successive track segments.
00058 //
00059 // Revision 1.4  2007/03/27 13:31:20  evans
00060 // New code to calculate my charge PID (requires pdfs in /data).
00061 // Also includes code to calculate track jitter given an NtpSRTrack object.
00062 //
00063 // Revision 1.3  2007/03/24 20:28:59  evans
00064 // Slight change to the track jitter variable to make sure it's well-defined
00065 // for all tracks.
00066 //
00067 // Revision 1.2  2007/03/09 18:02:11  evans
00068 // Adding extra functionality to MajorityCurvature to allow me to experiment
00069 // with it's capabilities. This requires the addition of the (very
00070 // lightweight) class MajCInfo.
00071 //
00072 // None of the changes affect the function
00073 // MajorityCurvature::Curvature(NtpSRTrack), so anyone using this function
00074 // will be unaffected.
00075 //
00076 // Revision 1.1  2007/02/05 14:45:51  evans
00077 // Adding the code to calculate the majority curvature for a track.
00078 //
00079 // To calculate the majority curvature for an NtpSRTrack object, pass it to the function MajorityCurvature::Curvature(const NtpSRTrack* track) const.
00080 // The return value is the majority curvature of the track.
00081 //
00082 // The class SRMom is a wrapper to the MomNavigator that has been submitted as MajorityCurvature uses some of its methods.
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 //____________________________________________________________________72
00112 MajorityCurvature::MajorityCurvature()
00113 {
00114 
00115 //     topDir="MCReweight/data";
00116 //     std::string base="";
00117 //     base=getenv("SRT_PRIVATE_CONTEXT");
00118 //     if(base=="" || base==".") base=getenv("SRT_PUBLIC_CONTEXT");
00119 //     if(base=="") {
00120 //       cout<<"No SRT_PUBLIC_CONTEXT set"<<std::endl;
00121 //       assert(false);
00122 //     }
00123 //     topDir = base+ "/" + topDir;
00124 
00125 
00126   TDirectory* tmpd = gDirectory;
00127   MSG("MajorityCurvature",Msg::kDebug)
00128     <<"TDirectory before opening file is:"<<endl;
00129   //tmpd->Print();
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   //gDirectory->Print();
00172   MSG("MajorityCurvature",Msg::kDebug)
00173     <<"After reseting gDirectory its location is:"<<endl;
00174   gDirectory=tmpd;
00175   //gDirectory->Print();
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   //Iteration 1
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   //Iteration 2
00220   fitLengths[0][0] = 0;
00221   fitLengths[1][0] = 0;
00222   fitLengths[2][0] = 0;
00223 
00224   for(Int_t tl=3; tl<8; ++tl){
00225     Int_t i=0;
00226     for(Int_t fl=tl; fl>1; --fl, ++i){
00227       fitLengths[tl][i] = fl;
00228       if (2==fl){fitLengths[tl][i] = 0;}
00229     }
00230   }
00231 
00232   for (Int_t tl = 8; tl < 500; ++tl){
00233     Int_t i=0;
00234     for (Int_t fl = 7; fl <= tl; ++fl, ++i){
00235       fitLengths[tl][i] = fl;
00236     }
00237     ++i;
00238     for (Int_t fl=6; fl > 2; --fl, ++i){
00239       fitLengths[tl][i] = fl;
00240     }
00241     ++i;
00242     fitLengths[tl][i] = 0;
00243   }
00244   */
00245 }
00246 
00247 //____________________________________________________________________72
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 //____________________________________________________________________72
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   //   if (snarl > 11){return JobCResult::kFailed;}
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         //      TCanvas cd("cd","",0,0,500,500);
00302         g.Draw("A*");
00303         g.Fit("pol2","Q");
00304         //   cd.Print(Form("~/public_html/AASnarl%dEvent%dSegment%d.gif",snarl,event,k));
00305         Float_t curviness = 2*(g.GetFunction("pol2")->GetParameter(2));
00306         //       for (Double_t i = -99999999; i < 99999999; i+=0.1){
00307         //      Float_t j = 1; ++j;
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         //      TCanvas cd("cd","",0,0,500,500);
00352         g.Draw("A*");
00353         g.Fit("pol2","Q");
00354         //   cd.Print(Form("~/public_html/AASnarl%dEvent%dSegment%d.gif",snarl,event,k));
00355         Float_t curviness = 2*(g.GetFunction("pol2")->GetParameter(2));
00356         //       for (Double_t i = -99999999; i < 99999999; i+=0.1){
00357         //      Float_t j = 1; ++j;
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   //   width = hCurv.GetRMS();
00374   //   cCurv.Print(Form("~/public_html/ASnarl%dEvent%d.gif",snarl,event));
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 //____________________________________________________________________72
00386 const Float_t MajorityCurvature::CalcCurv(const multimap<Float_t,
00387                                           Float_t> md,
00388                                           const Int_t fitLength) const
00389 {
00390   //Set up some arrays.
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; //<abs(parabolic fit),(parabolic fit)>
00397   multimap<Float_t,Float_t>::const_iterator it = md.begin();
00398   //k loops over the fit segments.
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     //l loops over the strips in each fit segment
00407     //The variable 'positive' says whether the first strip in a
00408     //segment has a positive co-ordinate.
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       //      TCanvas cd("cd","",0,0,500,500);
00424       g.Draw("A*");
00425       g.Fit("pol2","Q");
00426       Float_t curviness = 2*(g.GetFunction("pol2")->GetParameter(2));
00427       //      hCurv.Fill(curviness);
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 //   width = hCurv.GetRMS();
00460 //   cCurv.Print(Form("~/public_html/ASnarl%dEvent%d.gif",snarl,event));
00461   Float_t neg = hCurv.Integral(0,50);
00462   Float_t pos = hCurv.Integral(51,101);
00463   hvariances->Fill(hCurv.GetRMS());
00464   //  flastVariance = hCurv.GetRMS();
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 //____________________________________________________________________72
00472 const MajCInfo MajorityCurvature::CalcCurvObject(const multimap<Float_t,
00473                                                  Float_t> md,
00474                                                  const Int_t fitLength)
00475   const
00476 {
00477   //Object to return:
00478   MajCInfo majCInfo;
00479 
00480   //Set up some arrays.
00481   const Int_t size = md.size();
00482 //   Float_t* xerr = new Float_t[fitLength];
00483 //   Float_t* zerr = new Float_t[fitLength];
00484   if (size<fitLength){return majCInfo;}
00485 
00486   multimap<Float_t, Float_t> mfits; //<abs(parabolic fit),(parabolic fit)>
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   /*  Int_t endChop = 3;*///Don't use the final n segments in jitter
00493   //k loops over the fit segments.
00494   TGraphErrors gQuick(fitLength);
00495   for (Int_t k=0; k<(size-fitLength); ++k){
00496 //     Float_t* z = new Float_t[fitLength];
00497 //     Float_t* x = new Float_t[fitLength];
00498 //     Float_t* absx = new Float_t[fitLength];
00499     Bool_t changesign = false;
00500     Bool_t positive = false;
00501     if (it->second > 0){positive = true;}
00502     //l loops over the strips in each fit segment
00503     //The variable 'positive' says whether the first strip in a
00504     //segment has a positive co-ordinate.
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 //      z[l] = it->first;
00511 //      zerr[l] = 0.0594;
00512 //      x[l] = it->second;
00513 //      xerr[l] = 0.041;
00514 //      absx[l] = fabs(it->second);
00515         if (it->second > 0){thispos = true;}
00516         if (thispos != positive){changesign = true;}
00517         ++it;
00518       }
00519     if (!changesign){
00520 //       gQuick.Draw("A*");
00521       gQuick.Fit("pol2","Q");
00522       Float_t curviness = 2*(gQuick.GetFunction("pol2")->GetParameter(2));
00523       if ((numSegments/*-endChop*/)/* && (k<(size-fitLength-endChop))*/){
00524         totJitter += fabs(curviness - prevCurvature);
00525         totSqJitter +=
00526           (curviness - prevCurvature)*(curviness - prevCurvature);
00527       }
00528       ++numSegments;
00529       prevCurvature = curviness;
00530       //      hCurv.Fill(curviness);
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 //     if(z){delete z; z=0;}
00540 //     if(x){delete x; x=0;}
00541 //     if(absx){delete absx; absx=0;}
00542 
00543     majCInfo.jitter = -1.0;
00544     majCInfo.sqJitter = -1.0;
00545 //     if (numSegments>1){
00546 //       majCInfo.jitter = totJitter/((Double_t) (numSegments-1));
00547 //      majCInfo.sqJitter = totSqJitter/((Double_t) (numSegments-1));
00548 //     }
00549     if (numSegments/*-endChop*/){
00550       majCInfo.jitter = totJitter/((Double_t) (numSegments/*-endChop*/));
00551       majCInfo.sqJitter = totSqJitter/((Double_t) (numSegments/*-endChop*/));
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 //   TCanvas cCurv("cCurv","",0,0,500,500);
00577 //   hCurv.Draw();
00578   majCInfo.rms = hCurv.GetRMS();
00579   majCInfo.totWidth = largestCurv-smallestCurv;
00580 //   cCurv.Print(Form("~/public_html/ASnarl%dEvent%d.gif",snarl,event));
00581   Float_t neg = hCurv.Integral(0,50);
00582   Float_t pos = hCurv.Integral(51,101);
00583   hvariances->Fill(hCurv.GetRMS());
00584   //  flastVariance = hCurv.GetRMS();
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 //____________________________________________________________________72
00615 const MajCInfo MajorityCurvature::CalcCurvObjectFast(const multimap<Float_t,
00616                                                      Float_t> md,
00617                                                      const Int_t fitLength)
00618   const
00619 {
00620   //Object to return:
00621   MajCInfo majCInfo;
00622 
00623   //Set up some arrays.
00624   const Int_t size = md.size();
00625 //   Float_t* xerr = new Float_t[fitLength];
00626 //   Float_t* zerr = new Float_t[fitLength];
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   //k loops over the fit segments.
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     //l loops over the strips in each fit segment
00638     //The variable 'positive' says whether the first strip in a
00639     //segment has a positive co-ordinate.
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
00891 const Int_t MajorityCurvature::FitLength(const Int_t trkLthPln) const
00892 {
00893   return fitLengths[trkLthPln][0];
00894 }
00895 
00896 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 //____________________________________________________________________72
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 // //____________________________________________________________________72
01090 // const MajCInfo MajorityCurvature::CalcCurvObject(const multimap<Float_t,
01091 //                                               Float_t> md,
01092 //                                               const Int_t fitLength)
01093 //   const
01094 // {
01095 //   //Object to return:
01096 //   MajCInfo majCInfo;
01097 
01098 //   //Set up some arrays.
01099 //   const Int_t size = md.size();
01100 //   Float_t* xerr = new Float_t[fitLength];
01101 //   Float_t* zerr = new Float_t[fitLength];
01102 //   if (size<fitLength){return majCInfo;}
01103 
01104 //   multimap<Float_t, Float_t> mfits; //<abs(parabolic fit),(parabolic fit)>
01105 //   multimap<Float_t,Float_t>::const_iterator it = md.begin();
01106 //   Double_t totJitter = 0.0;
01107 //   Double_t totSqJitter = 0.0;
01108 //   Double_t prevCurvature = 0.0;
01109 //   Int_t numSegments = 0;
01110 //   /*  Int_t endChop = 3;*///Don't use the final n segments in jitter
01111 //   //k loops over the fit segments.
01112 //   for (Int_t k=0; k<(size-fitLength); ++k){
01113 //     Float_t* z = new Float_t[fitLength];
01114 //     Float_t* x = new Float_t[fitLength];
01115 //     Float_t* absx = new Float_t[fitLength];
01116 //     Bool_t changesign = false;
01117 //     Bool_t positive = false;
01118 //     if (it->second > 0){positive = true;}
01119 //     //l loops over the strips in each fit segment
01120 //     //The variable 'positive' says whether the first strip in a
01121 //     //segment has a positive co-ordinate.
01122 //     for (Int_t l=0; l<fitLength; ++l)
01123 //       {
01124 //      Bool_t thispos = false;
01125 //      z[l] = it->first;
01126 //      zerr[l] = 0.0594;
01127 //      x[l] = it->second;
01128 //      xerr[l] = 0.041;
01129 //      absx[l] = fabs(it->second);
01130 //      if (x[l] > 0){thispos = true;}
01131 //      if (thispos != positive){changesign = true;}
01132 //      ++it;
01133 //       }
01134 //     if (!changesign){
01135 //       TGraphErrors g(fitLength,z,absx,zerr,xerr);
01136 // //       TCanvas cd("cd","",0,0,500,500);
01137 //       g.Draw("A*");
01138 //       g.Fit("pol2","Q");
01139 //       Float_t curviness = 2*(g.GetFunction("pol2")->GetParameter(2));
01140 //       if ((numSegments/*-endChop*/)/* && (k<(size-fitLength-endChop))*/){
01141 //      totJitter += fabs(curviness - prevCurvature);
01142 //      totSqJitter +=
01143 //        (curviness - prevCurvature)*(curviness - prevCurvature);
01144 //       }
01145 //       ++numSegments;
01146 //       prevCurvature = curviness;
01147 //       //      hCurv.Fill(curviness);
01148 //       mfits.insert(pair<Float_t,Float_t>(fabs(curviness),
01149 //                                       curviness));
01150 //     }
01151 //     for (Int_t l=0; l<fitLength; ++l)
01152 //       {
01153 //      --it;
01154 //       }
01155 //     ++it;
01156 //     if(z){delete z; z=0;}
01157 //     if(x){delete x; x=0;}
01158 //     if(absx){delete absx; absx=0;}
01159 
01160 //     majCInfo.jitter = -1.0;
01161 //     majCInfo.sqJitter = -1.0;
01162 // //     if (numSegments>1){
01163 // //       majCInfo.jitter = totJitter/((Double_t) (numSegments-1));
01164 // //      majCInfo.sqJitter = totSqJitter/((Double_t) (numSegments-1));
01165 // //     }
01166 //     if (numSegments/*-endChop*/){
01167 //       majCInfo.jitter = totJitter/((Double_t) (numSegments/*-endChop*/));
01168 //       majCInfo.sqJitter = totSqJitter/((Double_t) (numSegments/*-endChop*/));
01169 //     }
01170 //   }
01171 
01172 //   multimap<Float_t,Float_t>::const_iterator itfits = mfits.end();
01173 //   Int_t numRemove = 0;
01174 //   if (((Int_t) mfits.size()) >= numRemove){
01175 //     for (Int_t rem = 0; rem < numRemove; ++rem){
01176 //       itfits--;
01177 //       mfits.erase(itfits->first);
01178 //       itfits = mfits.end();
01179 //     }
01180 //   }
01181 //   TH1F hCurv("hCurv","",100,-5,5);
01182 //   Float_t smallestCurv=100.0;
01183 //   Float_t largestCurv = -100.0;
01184 //   for (itfits = mfits.begin();
01185 //        itfits != mfits.end();
01186 //        ++itfits){
01187 //     hCurv.Fill(itfits->second);
01188 //     if (itfits->second<smallestCurv){smallestCurv=itfits->second;}
01189 //     if (itfits->second>largestCurv){largestCurv=itfits->second;}
01190 //   }
01191 
01192 //   TCanvas cCurv("cCurv","",0,0,500,500);
01193 //   hCurv.Draw();
01194 //   majCInfo.rms = hCurv.GetRMS();
01195 //   majCInfo.totWidth = largestCurv-smallestCurv;
01196 // //   cCurv.Print(Form("~/public_html/ASnarl%dEvent%d.gif",snarl,event));
01197 //   Float_t neg = hCurv.Integral(0,50);
01198 //   Float_t pos = hCurv.Integral(51,101);
01199 //   hvariances->Fill(hCurv.GetRMS());
01200 //   //  flastVariance = hCurv.GetRMS();
01201 //   majCInfo.simpleMajC = pos-neg;
01202 //   if (neg){majCInfo.majCRatio = pos/neg;}
01203 //   else{majCInfo.majCRatio = 10.0;}
01204 
01205 //   if (!pos){
01206 //     majCInfo.smoothMajC = -10.0;
01207 //   }
01208 //   else {
01209 //     if (!neg) {
01210 //       majCInfo.smoothMajC = 10.0;
01211 //     }
01212 //     else{
01213 //       majCInfo.smoothMajC = TMath::Log(pos/neg);
01214 //     }
01215 //   }
01216 
01217 //   if (pos > neg) {
01218 //     if (neg) {majCInfo.majC = pos/neg; return majCInfo;}
01219 //     else {majCInfo.majC = 10.0; return majCInfo;}
01220 //   }
01221 //   if (neg > pos) {
01222 //     if (pos) {majCInfo.majC = -1.0*neg/pos; return majCInfo;}
01223 //     else {majCInfo.majC = -10.0; return majCInfo;}
01224 //   }
01225 //   if (neg == pos) {majCInfo.majC = 0.0; return majCInfo;}
01226 //   else {majCInfo.majC = 0.0; return majCInfo;}
01227 //   return majCInfo;
01228 // }
01229 

Generated on Mon Feb 15 11:06:56 2010 for loon by  doxygen 1.3.9.1