MSTCalcAna Class Reference

#include <MSTCalcAna.h>

Inheritance diagram for MSTCalcAna:
NueAnaBase

List of all members.

Public Member Functions

 MSTCalcAna (MSTCalc &mst)
virtual ~MSTCalcAna ()
void Analyze (int evtn, RecRecordImp< RecCandHeader > *srobj)
void Analyze (UberRecord *ur)
void ComputeGraphQuantities ()
void SetSigTemplate (TProfile2D *e)
void SetBGTemplate (TProfile2D *b)
void SetSigMIPTemplate (TProfile2D *e)
void SetBGMIPTemplate (TProfile2D *b)
void SetMSTParams (float minsc, float maxm, float minfsc, float maxmlowz, float scm)
void FindAllGraphs (set< DCHit > &evenhistset, set< DCHit > &oddhitset)
void FillHitSets (int evtn, RecRecordImp< RecCandHeader > *srobj, set< DCHit > &evenhitset, set< DCHit > &oddhitset)
void FillHitSets (UberRecord *ur, set< DCHit > &evenhitset, set< DCHit > &oddhitset)
void DrawMaxGraph (int view)
DCGraph< DCHit > * GetMaxGraph (int view)
TH1D * FindProjection (TProfile2D *tmplt, int nedges, const char *name)
double ComputeChi2 (TH1 *h1, TH1 *h2, double &chi2, int &ndof)
double ComputeLLike (TH1 *data, TH1 *tmpl, int &ndof)
float FindAlpha (TH1 *data, TH1 *ehist, TH1 *bhist)
void FindLikeAlpha (TH1 *data, TH1 *ehist, TH1 *bhist, double &alpha, double &beta)
void GraphLoop (DCGraph< DCHit > *g, int view)
void Print () const
void Reset ()

Private Attributes

MSTCalcfMSTCalc
float minsig
float maxmetric
float minfarsigcor
float maxmetriclowz
vector< DCGraph< DCHit > * > even
vector< DCGraph< DCHit > * > odd
TProfile2D * etemplate
TProfile2D * btemplate
TProfile2D * emtemplate
TProfile2D * bmtemplate

Detailed Description

Definition at line 21 of file MSTCalcAna.h.


Constructor & Destructor Documentation

MSTCalcAna::MSTCalcAna ( MSTCalc mst  ) 

Definition at line 43 of file MSTCalcAna.cxx.

00043                                   :
00044   fMSTCalc(mst),
00045   minsig(0.),
00046   maxmetric(0.),
00047   minfarsigcor(0.),
00048   maxmetriclowz(0.),
00049   even(),
00050   odd(),
00051   etemplate(0),
00052   btemplate(0),
00053   emtemplate(0),
00054   bmtemplate(0)
00055 {}

MSTCalcAna::~MSTCalcAna (  )  [virtual]

Definition at line 57 of file MSTCalcAna.cxx.

References even, and odd.

00058 {
00059    for(unsigned int i=0;i<even.size();i++){
00060       if(even[i]!=0){
00061          delete even[i];
00062          even[i]=0;
00063       }
00064    }
00065    for(unsigned int i=0;i<odd.size();i++){
00066       if(odd[i]!=0){
00067          delete odd[i];
00068          odd[i]=0;
00069       }
00070    }
00071 }


Member Function Documentation

void MSTCalcAna::Analyze ( UberRecord ur  ) 

Definition at line 86 of file MSTCalcAna.cxx.

References ComputeGraphQuantities(), FillHitSets(), FindAllGraphs(), and Reset().

00087 {
00088   set<DCHit> evenhitset;
00089   set<DCHit> oddhitset;
00090   Reset();
00091   FillHitSets(ur,evenhitset,oddhitset);
00092   FindAllGraphs(evenhitset,oddhitset);
00093   ComputeGraphQuantities();
00094 }

void MSTCalcAna::Analyze ( int  evtn,
RecRecordImp< RecCandHeader > *  srobj 
) [virtual]

Implements NueAnaBase.

Definition at line 75 of file MSTCalcAna.cxx.

References ComputeGraphQuantities(), FillHitSets(), FindAllGraphs(), and Reset().

Referenced by NueRecordAna::Analyze().

00076 {
00077   set<DCHit> evenhitset;
00078   set<DCHit> oddhitset;
00079   Reset();
00080   FillHitSets(evtn,srobj,evenhitset,oddhitset);
00081   FindAllGraphs(evenhitset,oddhitset);
00082   ComputeGraphQuantities();
00083   //  cout<<"done with ana"<<endl;
00084 }

double MSTCalcAna::ComputeChi2 ( TH1 *  h1,
TH1 *  h2,
double &  chi2,
int &  ndof 
)

Definition at line 482 of file MSTCalcAna.cxx.

00484 {
00485    chi2=0.;
00486    double NENTH1=h1->Integral();
00487    double NENTH2=h2->Integral();
00488 
00489    ndof = 0;
00490    if(NENTH2==0||NENTH1==0){
00491       chi2=-1.;
00492       ndof=0;
00493       return -1.;
00494    }
00495    
00496 //   double weight1 = sqrt(NENTH2/NENTH1);
00497 //   double weight2 = sqrt(NENTH1/NENTH2);
00498 
00499 
00500    double weight1 = 1.;
00501    double weight2 = 1.;
00502    for(int i=1;i<=h1->GetNbinsX();i++){
00503       double h1bc=h1->GetBinContent(i);
00504       double h2bc=h2->GetBinContent(i);
00505       double eh1bc=h1->GetBinError(i);
00506       double eh2bc=h2->GetBinError(i);
00507       
00508       double num = pow((weight1*h1bc-weight2*h2bc),2);
00509       double denom = eh1bc*eh1bc+eh2bc*eh2bc;
00510 
00511       if(denom!=0){
00512          chi2+=num/denom;
00513          ndof++;
00514       }
00515    }
00516    ndof--; //one constraint, number of entries must be equal to n
00517    Double_t prob = TMath::Prob(chi2/2.,Int_t(ndof/2.));
00518 
00519    return prob;
00520 }

void MSTCalcAna::ComputeGraphQuantities (  ) 

Definition at line 97 of file MSTCalcAna.cxx.

References btemplate, ComputeLLike(), MSTCalc::e4nn, MSTCalc::e4sm, MSTCalc::e4w, MSTCalc::eallm1, MSTCalc::eallw1, MSTCalc::ealpha, MSTCalc::ebeta, MSTCalc::eeprob, emtemplate, MSTCalc::enmsg, MSTCalc::enn1, MSTCalc::enntot, MSTCalc::esm1, MSTCalc::esmtot, etemplate, even, MSTCalc::ew1, MSTCalc::ewtot, FindLikeAlpha(), FindProjection(), fMSTCalc, DCGraph< T >::GetAllWeights(), DCGraph< T >::GetAllZ(), GetMaxGraph(), DCGraph< T >::GetNVerts(), DCGraph< T >::GetSummedMetric(), DCGraph< T >::GetSummedZ(), GraphLoop(), DCGraph< T >::GraphMaxHits(), Msg::kError, ANtpDefaultValue::kFloat, ANtpDefaultValue::kInt, MSG, NYBINS, NYMBINS, MSTCalc::o4nn, MSTCalc::o4sm, MSTCalc::o4w, MSTCalc::oallm1, MSTCalc::oallw1, MSTCalc::oalpha, MSTCalc::obeta, odd, MSTCalc::oeprob, MSTCalc::onmsg, MSTCalc::onn1, MSTCalc::onntot, MSTCalc::osm1, MSTCalc::osmtot, MSTCalc::ow1, and MSTCalc::owtot.

Referenced by Analyze().

00098 {
00099   //  cout<<"In computegraph"<<endl;
00100   //compute quantities
00101   fMSTCalc.enmsg=even.size();
00102   fMSTCalc.onmsg=odd.size();
00103 
00104   fMSTCalc.esmtot = 0.0;
00105   fMSTCalc.ewtot  = 0.0;
00106   fMSTCalc.enntot = 0;
00107   fMSTCalc.osmtot = 0.0;
00108   fMSTCalc.owtot  = 0.0;
00109   fMSTCalc.onntot = 0;
00110     
00111   const int NYBINS = etemplate->GetNbinsY()+1;
00112 
00113   TH1F ew("ew","ew",NYBINS-1,etemplate->GetYaxis()->GetXbins()->GetArray());
00114   TH1F ow("ow","ow",NYBINS-1,etemplate->GetYaxis()->GetXbins()->GetArray());
00115   
00116   const int NYMBINS = emtemplate->GetNbinsY()+1;
00117   TH1F em("em","em",NYMBINS-1,emtemplate->GetYaxis()->GetXbins()->GetArray());
00118   TH1F om("om","om",NYMBINS-1,emtemplate->GetYaxis()->GetXbins()->GetArray());
00119   
00120   for(unsigned int i=0;i<even.size();i++){
00121     if(even[i]==0){
00122       continue;
00123     }
00124     fMSTCalc.esmtot+=even[i]->GetSummedZ();
00125     fMSTCalc.ewtot+=even[i]->GetSummedMetric();
00126     fMSTCalc.enntot+=even[i]->GetNVerts();
00127   }
00128   for(unsigned int i=0;i<odd.size();i++){
00129     if(odd[i]==0){
00130       continue;
00131     }
00132     fMSTCalc.osmtot+=odd[i]->GetSummedZ();
00133     fMSTCalc.owtot+=odd[i]->GetSummedMetric();
00134     fMSTCalc.onntot+=odd[i]->GetNVerts();
00135   }
00136   
00137   DCGraph<DCHit> *me = GetMaxGraph(0);
00138   if(me!=0){
00139     fMSTCalc.esm1=me->GetSummedZ();
00140     fMSTCalc.ew1=me->GetSummedMetric();
00141     fMSTCalc.enn1=me->GetNVerts();                  
00142       vector<float> eweights = me->GetAllWeights();
00143       int NW=eweights.size();
00144       for(int i=0;i<NW;i++){
00145          if(NW<2880){
00146            fMSTCalc.eallw1[i] = eweights[i];
00147          }
00148          if(eweights[i]!=0){
00149             ew.Fill(eweights[i]);
00150          }
00151       }
00152 
00153       int nabove=0;
00154       float aveph=fMSTCalc.esm1/fMSTCalc.enn1;
00155       vector<float> emips = me->GetAllZ();
00156       int NM=emips.size();
00157       for(int i=0;i<NM;i++){
00158          if(NM<2880){
00159            fMSTCalc.eallm1[i] = emips[i];
00160          }
00161          em.Fill(emips[i]);
00162          if(emips[i]>aveph){
00163             nabove++;
00164          }
00165       }
00166       
00167       if(nabove>0){
00168          DCGraph<DCHit> *emax4 = me->GraphMaxHits(nabove);
00169          fMSTCalc.e4w = emax4->GetSummedMetric();
00170          fMSTCalc.e4sm = emax4->GetSummedZ();
00171          fMSTCalc.e4nn = emax4->GetNVerts();
00172          delete emax4;
00173       }
00174       else{
00175         fMSTCalc.e4w = ANtpDefVal::kFloat;
00176         fMSTCalc.e4sm = ANtpDefVal::kFloat;
00177         fMSTCalc.e4nn = 0;
00178       }  
00179   }
00180   GraphLoop(me,0);
00181   
00182 
00183   DCGraph<DCHit> *mo = GetMaxGraph(1);
00184   if(mo!=0){
00185     fMSTCalc.osm1=mo->GetSummedZ();
00186     fMSTCalc.ow1=mo->GetSummedMetric();
00187     fMSTCalc.onn1=mo->GetNVerts();                  
00188     vector<float> oweights = mo->GetAllWeights();
00189      int NW=oweights.size();
00190      for(int i=0;i<NW;i++){
00191        if(NW<2880){
00192          fMSTCalc.oallw1[i] = oweights[i];
00193        }
00194        if(oweights[i]!=0){
00195          ow.Fill(oweights[i]);
00196        }
00197      }
00198 
00199      int nabove=0;
00200      float aveph=fMSTCalc.osm1/fMSTCalc.onn1;
00201      vector<float> omips = mo->GetAllZ();
00202      int NM=omips.size();
00203      for(int i=0;i<NM;i++){
00204        if(NM<2880){
00205          fMSTCalc.oallm1[i] = omips[i];
00206        }
00207        om.Fill(omips[i]);
00208        if(omips[i]>aveph){
00209          nabove++;
00210        }
00211      }
00212      
00213      if(nabove>0){
00214        DCGraph<DCHit> *omax4 = mo->GraphMaxHits(nabove);
00215        fMSTCalc.o4w = omax4->GetSummedMetric();
00216        fMSTCalc.o4sm = omax4->GetSummedZ();
00217        fMSTCalc.o4nn = omax4->GetNVerts();
00218        delete omax4;
00219      }
00220      else{
00221        fMSTCalc.o4w=ANtpDefVal::kFloat;
00222        fMSTCalc.o4sm=ANtpDefVal::kFloat;
00223        fMSTCalc.o4nn=ANtpDefVal::kInt;
00224      }
00225   }
00226   GraphLoop(mo,1);
00227   
00228   if(etemplate==0||btemplate==0){
00229     MSG("MSTCalcAna",Msg::kError)<<"Template Histograms are not available"
00230                                  <<" can not calculate likelihoods"
00231                                  <<" or alphas"<<endl;
00232     fMSTCalc.eeprob=ANtpDefVal::kFloat;
00233      fMSTCalc.oeprob=ANtpDefVal::kFloat;
00234      fMSTCalc.ealpha=ANtpDefVal::kFloat;
00235      fMSTCalc.oalpha=ANtpDefVal::kFloat;
00236      fMSTCalc.ebeta=ANtpDefVal::kFloat;
00237      fMSTCalc.obeta=ANtpDefVal::kFloat;
00238      ew.Reset();
00239      ow.Reset();
00240      em.Reset();
00241      om.Reset();
00242 
00243      return;
00244    }
00245 
00246    TH1F *esigt = (TH1F *)FindProjection(etemplate,
00247                                         fMSTCalc.enn1,"esigt");
00248    TH1F *osigt = (TH1F *)FindProjection(etemplate,
00249                                         fMSTCalc.onn1,"osigt");
00250    TH1F *ebgt = (TH1F *)FindProjection(btemplate,
00251                                        fMSTCalc.enn1,"ebgt");
00252    TH1F *obgt = (TH1F *)FindProjection(btemplate,
00253                                        fMSTCalc.onn1,"obgt");
00254 
00255    int endof, ondof;
00256    fMSTCalc.eeprob = ComputeLLike(&ew,esigt,endof);
00257    fMSTCalc.oeprob = ComputeLLike(&ow,osigt,ondof);
00258 
00259 
00260    FindLikeAlpha(&ew,esigt,ebgt,fMSTCalc.ealpha,fMSTCalc.ebeta);
00261    FindLikeAlpha(&ow,osigt,obgt,fMSTCalc.oalpha,fMSTCalc.obeta);
00262 
00263    esigt->Reset();
00264    osigt->Reset();
00265    ebgt->Reset();
00266    obgt->Reset();
00267    
00268    ew.Reset();
00269    ow.Reset();
00270    em.Reset();
00271    om.Reset();
00272    //   cout<<"done with compute graph"<<endl;
00273 }

double MSTCalcAna::ComputeLLike ( TH1 *  data,
TH1 *  tmpl,
int &  ndof 
)

Definition at line 522 of file MSTCalcAna.cxx.

References Msg::kError, ANtpDefaultValue::kFloat, and MSG.

Referenced by ComputeGraphQuantities().

00523 {
00524 
00525    if(data==0){
00526       return ANtpDefVal::kFloat;
00527    }
00528    if(tmpl==0){
00529       return ANtpDefVal::kFloat;
00530    }
00531    if(data->Integral()<2){
00532       return ANtpDefVal::kFloat;
00533    }
00534    if(data->GetNbinsX()!=tmpl->GetNbinsX()){
00535      MSG("MSTCalcAna",Msg::kError)<<"Data bins "
00536                                   <<data->GetNbinsX()<<endl
00537                                   <<"Template bins "
00538                                   <<tmpl->GetNbinsX()<<endl
00539                                   <<"Can not do likelihood"<<endl;
00540      return ANtpDefVal::kFloat;
00541    }
00542    
00543    ndof=0;
00544    double llike=0.;
00545 
00546    for(int i=1;i<=tmpl->GetNbinsX();i++){
00547       float x = data->GetBinContent(i);
00548       float mu = tmpl->GetBinContent(i);
00549       double l=0.;
00550       if(x>0&&mu>0){
00551          l=x*(TMath::Log(mu)-TMath::Log(x)+1)-mu;
00552       }
00553       else if(x==0&&mu!=0){
00554          l=-mu;
00555       }
00556       else if(x!=0&&mu==0){
00557          l=0.;
00558       }
00559       else{
00560          l=0.;
00561       }
00562          
00563       if(x!=0){
00564          ndof+=(int)(x);
00565       }
00566       llike+=l;    
00567 
00568    }
00569 
00570    double chi2 = -2*llike;
00571    return chi2;
00572 }

void MSTCalcAna::DrawMaxGraph ( int  view  ) 

Definition at line 420 of file MSTCalcAna.cxx.

References even, Munits::g, and odd.

00421 {
00422    float maxmip=0.;
00423    int index=0;
00424    vector<DCGraph<DCHit> *> *g;
00425    if(view==0){
00426       g=&even;
00427    }
00428    else{
00429       g=&odd;
00430    }
00431    for(unsigned int i=0;i<g->size();i++){
00432       if((*g)[i]->GetSummedZ()>maxmip){
00433          maxmip=(*g)[i]->GetSummedZ();
00434          index=i;
00435       }
00436    }
00437    if(g->size()>0){
00438       (*g)[index]->Draw();
00439    }
00440 }

void MSTCalcAna::FillHitSets ( UberRecord ur,
set< DCHit > &  evenhitset,
set< DCHit > &  oddhitset 
)

Definition at line 376 of file MSTCalcAna.cxx.

References UberRecord::GetHitList(), UberHit::GetNegMIP(), UberHit::GetPlane(), UberHit::GetPosMIP(), minsig, UberRecord::nhitstrips, and DCHit::SetData().

00379 {
00380 
00381   const TClonesArray *hits = ur->GetHitList();
00382   for(int i=0;i<ur->nhitstrips;i++){
00383     UberHit *uh=static_cast<UberHit *>((*hits)[i]);
00384     if(uh->GetPosMIP()+uh->GetNegMIP()<minsig){
00385       continue;
00386     }
00387     DCHit h(uh);
00388     h.SetData("zpos","tpos","pulseheight");
00389     
00390     if(uh->GetPlane()%2==0){
00391       evenhitset.insert(h);
00392     }
00393     else{
00394       oddhitset.insert(h);
00395     }
00396   }
00397 }

void MSTCalcAna::FillHitSets ( int  evtn,
RecRecordImp< RecCandHeader > *  srobj,
set< DCHit > &  evenhitset,
set< DCHit > &  oddhitset 
)

Definition at line 307 of file MSTCalcAna.cxx.

References NueAnaBase::evtstp0mip, NueAnaBase::evtstp1mip, SntpHelpers::GetEvent(), RecRecordImp< T >::GetHeader(), RecPhysicsHeader::GetSnarl(), VHS::GetStrip(), SntpHelpers::GetStripIndex(), Msg::kError, PlaneView::kU, PlaneView::kV, minsig, MSG, NtpSRStrip::planeview, DCHit::SetData(), NtpSRStrip::time0, NtpSRStrip::time1, NtpSRStrip::tpos, and NtpSRStrip::z.

Referenced by Analyze().

00309 {
00310 
00311   //  cout<<"In fill hitsets"<<endl;
00312   if(srobj==0){
00313     return;
00314   }
00315   if(((dynamic_cast<NtpStRecord *>(srobj))==0)&&
00316      ((dynamic_cast<NtpSRRecord *>(srobj))==0)){
00317     return;
00318   }
00319 
00320 
00321   NtpSREvent *event = SntpHelpers::GetEvent(evtn,srobj);
00322   if(!event){
00323     MSG("MSTCalcAna",Msg::kError)<<"Couldn't get event "<<evtn
00324                                  <<" from Snarl "
00325                                  <<srobj->GetHeader().GetSnarl()
00326                                  <<endl;
00327     return;
00328   }
00329   
00330   //  cout<<"gotevent"<<endl;
00331   
00332   int nstrips=event->nstrip;
00333   //  cout<<"nstrips "<<nstrips<<endl;
00334   for(int i=0;i<nstrips;i++){
00335     Int_t index = SntpHelpers::GetStripIndex(i,event);
00336     NtpSRStrip *s = SntpHelpers::GetStrip(index,srobj);
00337     if(!s){
00338       continue;
00339     }
00340     if(!evtstp0mip){
00341        MSG("MSTCalcAna",Msg::kError)<<"No mip strip information"<<endl;
00342        continue;
00343     }
00344 
00345 
00346     float energy = evtstp0mip[index] + evtstp1mip[index];
00347     
00348     if(energy<minsig){
00349       continue;
00350     }
00351     
00352     double time = (evtstp0mip[index]*s->time0+
00353                    evtstp1mip[index]*s->time1);
00354     if(energy!=0){
00355       time/=(energy);
00356     }
00357     else{
00358       time=0.;
00359     }
00360     DCHit h(s->z*100.,s->tpos*100., energy,time);
00361     h.SetData("zpos","tpos","pulseheight");
00362     
00363     if(s->planeview==PlaneView::kU){
00364       evenhitset.insert(h);
00365     }
00366     else if(s->planeview==PlaneView::kV){
00367       oddhitset.insert(h);
00368     }
00369     else{
00370     }
00371   }
00372   //  cout<<"done fil hitsets"<<endl;
00373 }

void MSTCalcAna::FindAllGraphs ( set< DCHit > &  evenhistset,
set< DCHit > &  oddhitset 
)

Definition at line 275 of file MSTCalcAna.cxx.

References DCGraph< T >::AddVertex(), even, DCGraph< T >::FindAllMinSpan(), DCGraph< T >::GetNVerts(), maxmetric, maxmetriclowz, minfarsigcor, odd, and th().

Referenced by Analyze().

00277 {
00278   //  cout<<"In findalagraphs"<<endl;
00279   DCGraph<DCHit> geven;
00280   DCGraph<DCHit> godd;
00281    set<DCHit>::reverse_iterator eit=evenhitset.rbegin();
00282    while(eit!=evenhitset.rend()){
00283      DCHit th=*eit;
00284      geven.AddVertex(&th);
00285      eit++;
00286    }
00287    
00288    set<DCHit>::reverse_iterator oit=oddhitset.rbegin();
00289    while(oit!=oddhitset.rend()){
00290       DCHit th=*oit;
00291       godd.AddVertex(&th);
00292       oit++;
00293    }
00294 
00295   if(geven.GetNVerts()!=0){
00296     even=geven.FindAllMinSpan(maxmetric,minfarsigcor,maxmetriclowz);
00297   }
00298   if(godd.GetNVerts()!=0){
00299     odd=godd.FindAllMinSpan(maxmetric,minfarsigcor,maxmetriclowz);
00300   }
00301   //  cout<<"done with findallgraphs"<<endl;
00302 }

float MSTCalcAna::FindAlpha ( TH1 *  data,
TH1 *  ehist,
TH1 *  bhist 
)

Definition at line 574 of file MSTCalcAna.cxx.

References MuELoss::e, Msg::kError, ANtpDefaultValue::kFloat, MSG, and n.

00575 {
00576 
00577    if(data==0){      
00578       MSG("MSTCalcAna",Msg::kError)<<"data==0"<<endl;
00579       return ANtpDefVal::kFloat;
00580    }
00581    if(ehist==0){
00582       MSG("MSTCalcAna",Msg::kError)<<"ehist==0"<<endl;
00583       return ANtpDefVal::kFloat;
00584    }
00585    if(bhist==0){
00586       MSG("MSTCalcAna",Msg::kError)<<"bhist==0"<<endl;
00587       return ANtpDefVal::kFloat;
00588    }
00589 
00590    double num=0.;
00591    double denom=0.;
00592    double error=0.;
00593    float ea=0.;
00594    if(data->GetNbinsX()==ehist->GetNbinsX()&&
00595       data->GetNbinsX()==bhist->GetNbinsX()){
00596       for(int i=1;i<=data->GetNbinsX();i++){
00597          double n=1.*data->GetBinContent(i);
00598          double c=1.*ehist->GetBinContent(i);
00599          double d=1.*bhist->GetBinContent(i);
00600          double en=1.*data->GetBinError(i);
00601          double ec=1.*ehist->GetBinError(i);
00602          double ed=1.*bhist->GetBinError(i);
00603 
00604          error = en*en+ec*ec+ed*ed;
00605          if(error!=0){
00606             num+=(d-n)*(d-c)/error;
00607             denom+=(d-c)*(d-c)/error;
00608          }
00609       }
00610       if(denom>1.e-10){
00611          ea=num/denom;
00612       }
00613       else{
00614          ea=ANtpDefVal::kFloat;
00615       }
00616    }
00617    return ea;
00618 
00619 }

void MSTCalcAna::FindLikeAlpha ( TH1 *  data,
TH1 *  ehist,
TH1 *  bhist,
double &  alpha,
double &  beta 
)

Definition at line 622 of file MSTCalcAna.cxx.

References AFit(), bth, eth, Msg::kError, ANtpDefaultValue::kFloat, and MSG.

Referenced by ComputeGraphQuantities().

00624 {
00625 
00626    if(data==0){      
00627       MSG("MSTCalcAna",Msg::kError)<<"data==0"<<endl;
00628       alpha=ANtpDefVal::kFloat;
00629       beta=ANtpDefVal::kFloat;
00630       return;
00631    }
00632    if(ehist==0){
00633       MSG("MSTCalcAna",Msg::kError)<<"ehist==0"<<endl;
00634       alpha=ANtpDefVal::kFloat;
00635       beta=ANtpDefVal::kFloat;
00636       return;
00637    }
00638    if(bhist==0){
00639       MSG("MSTCalcAna",Msg::kError)<<"bhist==0"<<endl;
00640       alpha=ANtpDefVal::kFloat;
00641       beta=ANtpDefVal::kFloat;
00642       return;
00643    }
00644 
00645    if(data->GetNbinsX()!=ehist->GetNbinsX()){
00646       MSG("MSTCalcAna",Msg::kError)<<"Data bins: "
00647                                    <<data->GetNbinsX()<<endl
00648                                    <<"etemplate bins: "
00649                                    <<ehist->GetNbinsX()<<endl
00650                                    <<"Cant do like alpha"<<endl;
00651       alpha=ANtpDefVal::kFloat;
00652       beta=ANtpDefVal::kFloat;
00653       return;
00654    }
00655    if(data->GetNbinsX()!=bhist->GetNbinsX()){
00656       MSG("MSTCalcAna",Msg::kError)<<"Data bins: "
00657                                    <<data->GetNbinsX()<<endl
00658                                    <<"btemplate bins: "
00659                                    <<bhist->GetNbinsX()<<endl
00660                                    <<"Cant do like alpha"<<endl;
00661       alpha=ANtpDefVal::kFloat;
00662       beta=ANtpDefVal::kFloat;
00663       return;
00664    }
00665    eth=ehist;
00666    bth=bhist;
00667 
00668    TF1 *histfit = new TF1("histfit",AFit,0,100,1);
00669    histfit->SetParName(0,"alpha");
00670    histfit->SetParameter(0,0.9);
00671    histfit->SetParLimits(0,0.,1.);
00672 
00673    data->Fit(histfit,"RLQNO");
00674 //   data->Fit(histfit,"RIL");
00675    
00676    alpha = histfit->GetParameter(0);
00677    beta = histfit->GetParError(0);
00678       
00679    if(histfit!=0){
00680      delete histfit;
00681      histfit=0;
00682    }
00683    return;
00684 }

TH1D * MSTCalcAna::FindProjection ( TProfile2D *  tmplt,
int  nedges,
const char *  name 
)

Definition at line 471 of file MSTCalcAna.cxx.

Referenced by ComputeGraphQuantities().

00472 {
00473 //   string n2d=(string)(name)+"_2d";
00474 //   TH2D *proj2d = tmplt->ProjectionXY(n2d.c_str(),"E");
00475    int bin = tmplt->GetXaxis()->FindFixBin(n);
00476    TH1D *proj = tmplt->ProjectionY(name,bin,bin,"E,goff");
00477 //   delete proj2d;
00478 //   proj->Sumw2();
00479    return proj;
00480 }

DCGraph< DCHit > * MSTCalcAna::GetMaxGraph ( int  view  ) 

Definition at line 442 of file MSTCalcAna.cxx.

References even, Munits::g, and odd.

Referenced by ComputeGraphQuantities().

00443 {
00444   //  cout<<"in getmaxgraph "<<view<<endl;
00445    float maxmip=0.;
00446    int index=0;
00447    vector<DCGraph<DCHit> *> *g;
00448    if(view==0){
00449       g=&even;
00450    }
00451    else{
00452       g=&odd;
00453    }
00454    if(g->size()==0){
00455       return 0;
00456    }
00457    for(unsigned int i=0;i<g->size();i++){
00458       if((*g)[i]->GetSummedZ()>maxmip){
00459          maxmip=(*g)[i]->GetSummedZ();
00460          index=i;
00461       }
00462    }
00463    return (*g)[index];
00464 }

void MSTCalcAna::GraphLoop ( DCGraph< DCHit > *  g,
int  view 
)

Definition at line 686 of file MSTCalcAna.cxx.

References MuELoss::e, MSTCalc::eb1, MSTCalc::eb25, MSTCalc::enbranch, fMSTCalc, DCVertex< T >::GetData(), DCHit::GetData(), DCEdge< T >::GetEnd(), DCGraph< T >::GetFirst(), DCVertex< T >::GetFirstEdge(), DCEdge< T >::GetMetric(), DCEdge< T >::GetNext(), DCVertex< T >::GetNextVertex(), MSTCalc::ob1, MSTCalc::ob25, and MSTCalc::onbranch.

Referenced by ComputeGraphQuantities().

00687 {
00688   //  cout<<"in graph loop "<<view<<endl;
00689   if(g==0){
00690     return;
00691   }
00692 
00693   float mipsum=0;
00694   float b1mipsum=0;
00695   float b25mipsum=0;
00696   int nbranch=0;
00697   DCVertex<DCHit> *v = g->GetFirst();
00698   while(v!=0){
00699     DCEdge<DCHit> *e = v->GetFirstEdge();
00700     float vx1,vy1,vz1;
00701     v->GetData()->GetData(vx1,vy1,vz1);
00702     int nedge=0;
00703     while(e!=0){
00704       float vx2=0,vy2=0,vz2=0;
00705       e->GetEnd()->GetData()->GetData(vx2,vy2,vz2);
00706       if(e->GetMetric()<5){
00707         b1mipsum+=vz1+vz2;
00708       }
00709       if(e->GetMetric()>25){
00710         b25mipsum+=vz1+vz2;
00711       }
00712       mipsum+=vz1+vz2;
00713       nedge++;
00714       e=e->GetNext();
00715     }
00716     if(nedge>1){ nbranch++; }
00717     v=v->GetNextVertex();
00718   }
00719 
00720 
00721   if(view==0){
00722     if(mipsum>0){
00723       fMSTCalc.eb1=b1mipsum/mipsum;
00724       fMSTCalc.eb25=b25mipsum/mipsum;
00725     }
00726     fMSTCalc.enbranch=nbranch;
00727   }
00728   else if(view==1){
00729     if(mipsum>0){
00730       fMSTCalc.ob1=b1mipsum/mipsum;
00731       fMSTCalc.ob25=b25mipsum/mipsum;
00732     }
00733     fMSTCalc.onbranch=nbranch;
00734   }
00735   //  cout<<"done with graph loop"<<endl;
00736 }

void MSTCalcAna::Print ( void   )  const

Definition at line 466 of file MSTCalcAna.cxx.

References fMSTCalc, and MSTCalc::Print().

00467 {
00468   fMSTCalc.Print();
00469 }

void MSTCalcAna::Reset (  ) 

Definition at line 399 of file MSTCalcAna.cxx.

References even, fMSTCalc, odd, and MSTCalc::Reset().

Referenced by Analyze().

00400 {
00401    for(unsigned int i=0;i<even.size();i++){
00402       if(even[i]!=0){
00403          delete even[i];
00404          even[i]=0;
00405       }
00406    }
00407    for(unsigned int i=0;i<odd.size();i++){
00408       if(odd[i]!=0){
00409          delete odd[i];
00410          odd[i]=0;
00411       }
00412    }
00413    even.clear();
00414    odd.clear();
00415 
00416    fMSTCalc.Reset();
00417 }

void MSTCalcAna::SetBGMIPTemplate ( TProfile2D *  b  )  [inline]

Definition at line 40 of file MSTCalcAna.h.

References bmtemplate.

Referenced by NueModule::Analyze().

00040 {bmtemplate=b;}

void MSTCalcAna::SetBGTemplate ( TProfile2D *  b  )  [inline]

Definition at line 37 of file MSTCalcAna.h.

References btemplate.

Referenced by NueModule::Analyze().

00037 {btemplate=b;}

void MSTCalcAna::SetMSTParams ( float  minsc,
float  maxm,
float  minfsc,
float  maxmlowz,
float  scm 
) [inline]

Definition at line 41 of file MSTCalcAna.h.

References maxmetric, maxmetriclowz, minfarsigcor, minsig, and NueAnaBase::SetParams().

Referenced by NueModule::Analyze().

00042                                                              {
00043      minsig=minsc;
00044      maxmetric=maxm;
00045      minfarsigcor=minfsc;
00046      maxmetriclowz=maxmlowz;
00047      SetParams(scm);
00048    }

void MSTCalcAna::SetSigMIPTemplate ( TProfile2D *  e  )  [inline]

Definition at line 39 of file MSTCalcAna.h.

References emtemplate.

Referenced by NueModule::Analyze().

00039 {emtemplate=e;}

void MSTCalcAna::SetSigTemplate ( TProfile2D *  e  )  [inline]

Definition at line 36 of file MSTCalcAna.h.

References etemplate.

Referenced by NueModule::Analyze().

00036 {etemplate=e;}


Member Data Documentation

TProfile2D* MSTCalcAna::bmtemplate [private]

Definition at line 91 of file MSTCalcAna.h.

Referenced by SetBGMIPTemplate().

TProfile2D* MSTCalcAna::btemplate [private]

Definition at line 89 of file MSTCalcAna.h.

Referenced by ComputeGraphQuantities(), and SetBGTemplate().

TProfile2D* MSTCalcAna::emtemplate [private]

Definition at line 90 of file MSTCalcAna.h.

Referenced by ComputeGraphQuantities(), and SetSigMIPTemplate().

TProfile2D* MSTCalcAna::etemplate [private]

Definition at line 88 of file MSTCalcAna.h.

Referenced by ComputeGraphQuantities(), and SetSigTemplate().

vector<DCGraph<DCHit> *> MSTCalcAna::even [private]

Definition at line 79 of file MSTCalcAna.h.

Referenced by ComputeGraphQuantities(), GraphLoop(), Print(), and Reset().

float MSTCalcAna::maxmetric [private]

Definition at line 81 of file MSTCalcAna.h.

Referenced by FindAllGraphs(), and SetMSTParams().

float MSTCalcAna::maxmetriclowz [private]

Definition at line 83 of file MSTCalcAna.h.

Referenced by FindAllGraphs(), and SetMSTParams().

float MSTCalcAna::minfarsigcor [private]

Definition at line 82 of file MSTCalcAna.h.

Referenced by FindAllGraphs(), and SetMSTParams().

float MSTCalcAna::minsig [private]

Definition at line 80 of file MSTCalcAna.h.

Referenced by FillHitSets(), and SetMSTParams().

vector<DCGraph<DCHit> *> MSTCalcAna::odd [private]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1