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

ANtpTrackInfoAna.cxx

Go to the documentation of this file.
00001 #include "StandardNtuple/NtpStRecord.h"
00002 #include "CandNtupleSR/NtpSRRecord.h"
00003 #include "CandNtupleSR/NtpSREvent.h"
00004 #include "CandNtupleSR/NtpSRTrack.h"
00005 #include "CandNtupleSR/NtpSRStrip.h"
00006 #include "MessageService/MsgService.h"
00007 #include "NueAna/NueAnaTools/SntpHelpers.h"
00008 #include "NueAna/ANtpTrackInfoAna.h"
00009 #include "AnalysisNtuples/Module/ANtpRecoNtpManipulator.h"
00010 #include "DataUtil/EnergyCorrections.h"
00011 #include "AnalysisNtuples/ANtpDefaultValue.h"
00012 #include "NueAna/NueAnaTools/NueConvention.h"
00013 #include "VertexFinder/NtpVtxFinder/VertexHelper.h"                                       
00014 //CVSID("$Id: ANtpTrackInfoAna.cxx,v 1.29 2009/07/03 14:45:34 vahle Exp $");
00015 
00016 using namespace EnergyCorrections;
00017 
00018 ANtpTrackInfoAna::ANtpTrackInfoAna(ANtpTrackInfoNue &anti):
00019    fANtpTrackInfo(anti)
00020 {}
00021 
00022 ANtpTrackInfoAna::~ANtpTrackInfoAna()
00023 {
00024 
00025 }
00026 
00027 //void ANtpTrackInfoAna::Analyze(int evtn, NtpSRRecord *srobj, NtpMCRecord * /*mcobj*/, NtpTHRecord * /*thobj*/)
00028 void ANtpTrackInfoAna::Analyze(int evtn, RecRecordImp<RecCandHeader> *srobj)
00029 {
00030   if(srobj==0){
00031     return;
00032   }
00033   if(((dynamic_cast<NtpStRecord *>(srobj))==0)&&
00034      ((dynamic_cast<NtpSRRecord *>(srobj))==0)){
00035     return;
00036   }
00037 
00038   NtpSREvent *event =0;
00039   NtpSRTrack *track = 0;
00040 
00041   const RecCandHeader *ntpHeader = &(srobj->GetHeader());
00042   VldContext vc = ntpHeader->GetVldContext();
00043   fDetectorType = ntpHeader->GetVldContext().GetDetector();
00044   //SimFlag::SimFlag_t s = ntpHeader->GetVldContext().GetSimFlag();
00045 
00046   //and now an ugly bit of code to deal with either NtpStRecord or NtpSRRecord
00047   bool foundst=false;
00048   NtpStRecord *st=dynamic_cast<NtpStRecord *>(srobj);
00049   fInfoFiller = new ANtpInfoObjectFiller();
00050 
00051   ANtpRecoNtpManipulator *ntpManipulator = 0;
00052   NtpSRRecord *sr = 0;
00053                                                                                 
00054   if(st != 0){
00055       foundst = true;
00056       ntpManipulator = new ANtpRecoNtpManipulator(st);
00057   }
00058   else{
00059       sr = dynamic_cast<NtpSRRecord *>(srobj);
00060       ntpManipulator = new ANtpRecoNtpManipulator(sr);
00061   }
00062 
00063   if(ReleaseType::IsDogwood(release))
00064      SetCorrectionVersion(EnergyCorrections::kDogwood);
00065   if(ReleaseType::IsCedar(release))
00066      SetCorrectionVersion(EnergyCorrections::kCedar);
00067   if(ReleaseType::IsBirch(release))
00068      SetCorrectionVersion(EnergyCorrections::kBirch);
00069                                                                                 
00070   fInfoFiller->SetStripArray(ntpManipulator->GetStripArray());
00071   //set up which flags you want to use to determine the primary shower or track
00072   //a value of 0 for a flag means it will not be used
00073   ntpManipulator->SetPrimaryTrackCriteria(0,1,0); // nplanes, length, total pulse height
00074   //get the primary track for the event - if no track is present it
00075   //returns 0
00076   ANtpEventManipulator * ntpEventManipulator =
00077                            ntpManipulator->GetEventManipulator();
00078                                                                                           
00079   ntpEventManipulator->SetEventInSnarl(evtn);
00080   event = ntpEventManipulator->GetEvent();
00081   track = SntpHelpers::GetPrimaryTrack(evtn, st);
00082   
00083   if(track){ 
00084 //          Fill information from the base ANtpTrackInfo  
00085       fInfoFiller->FillTrackInformation(track, &fANtpTrackInfo);
00086 //          Fill information specific to the ANtpTrackInfoNue class
00087 
00088      int ntrklike = track->plane.ntrklike;
00089      if(ReleaseType::IsCedar(release)){
00090        ntrklike = VertexHelper::CalculateNTrkLike(track, st);
00091      }
00092      fANtpTrackInfo.trklikePlanes = ntrklike;
00093                                                                                 
00094      if(event->plane.n){
00095         fANtpTrackInfo.trklikeRatio= static_cast<Float_t>(ntrklike)/static_cast<Float_t>(event->plane.n);
00096      }
00097 
00098       FillNueTrackInformation(track, event, &fANtpTrackInfo);
00099       DetermineSigInOut(track, srobj);
00100   
00101       bool IsCont = (IsFidAll(track) || track->momentum.qp==0);
00102       Int_t Method  = 0;
00103       if(IsCont) Method = 2; //stoppers use range
00104       else Method = 1; //Punch Through -> use curvature
00105       if(track->momentum.qp == 0) Method = 2;
00106       fANtpTrackInfo.muonEnergyMethod = Method;
00107 
00108       fANtpTrackInfo.phCCGeV = RecoMuEnergyNew(vc);
00109   }
00110 
00111   if(fInfoFiller){
00112     delete fInfoFiller;
00113     fInfoFiller=0;
00114   }
00115 
00116   if(ntpManipulator){
00117     delete ntpManipulator;
00118     ntpManipulator=0;
00119   }
00120 
00121 }
00122 
00123 //----------------------------------------------------------------------
00124 void ANtpTrackInfoAna::FillNueTrackInformation(NtpSRTrack *ntpTrack, NtpSREvent *ntpEvent, ANtpTrackInfoNue *trackInfoNue)
00125 {
00126     if(ntpEvent->ph.mip){
00127         trackInfoNue->pulseHeightRatio=ntpTrack->ph.mip/ntpEvent->ph.mip; 
00128     }
00129 
00130     trackInfoNue->phMeu = ntpTrack->ph.mip;
00131     trackInfoNue->phMip = ntpTrack->ph.mip;    
00132     trackInfoNue->phNueGeV = trackInfoNue->phMip/MeuPerGeV;
00133 
00134     trackInfoNue->deltaUVVtx = TMath::Abs(ntpTrack->plane.begu - ntpTrack->plane.begv);
00135     
00136 
00137     return;
00138 }
00139 
00140 void ANtpTrackInfoAna::DetermineSigInOut(NtpSRTrack *ntpTrack, RecRecordImp<RecCandHeader> *srobj){
00141   // compute the amount of signal in the partially instrumented region
00142   // and the amount in the fully instrumented region
00143   //
00144   // this region is defined as:
00145   // v planes: (strip<=4 || strip>=67)
00146   // partial u: (strip==0 || strip=63)
00147   // full u: (strip<=26 || strip>=88)
00148                                                                                 
00149   Float_t sigfull,sigpart;
00150   sigfull=sigpart=0;
00151                                                                                 
00152   // loop over all strips in the event
00153   // and sum the signals in the partial and full regions
00154   if(fDetectorType == Detector::kNear){
00155     for(int i=0; i<ntpTrack->nstrip; i++){
00156       Int_t index = SntpHelpers::GetStripIndex(i,ntpTrack);
00157       NtpSRStrip *ntpStrip = SntpHelpers::GetStrip(index,srobj);
00158       if(ntpStrip==0) continue;
00159       Int_t pr = NueConvention::InPartialRegion(ntpStrip->plane, ntpStrip->strip);
00160       float charge =  ntpTrack->stpph1mip[i] + ntpTrack->stpph0mip[i];
00161       if(pr==1)      {  sigpart += charge; }
00162       else if(pr==-1){  sigfull += charge; }
00163     }
00164   }
00165                                                                                 
00166   if(fDetectorType == Detector::kFar)
00167     sigfull = ntpTrack->ph.mip;
00168 
00169   fANtpTrackInfo.trackSignalFull = sigfull;
00170   fANtpTrackInfo.trackSignalPartial = sigpart;
00171 }
00172 
00173 
00174 Bool_t ANtpTrackInfoAna::IsFidAll(NtpSRTrack *ntpTrack){
00175                                                         
00176   if(ntpTrack == 0) return false;
00177  
00178   float x = ntpTrack->end.x;
00179   float y = ntpTrack->end.y;
00180   float z = ntpTrack->end.z;
00181 
00182  // new definition - coil hole cuts removed for cedar
00183   if(fDetectorType ==Detector::kNear) {//near det
00184     if (!(z<15   &&
00185           x<2.7  && x>-1.65 &&
00186           y<1.65 && y>-1.65 &&
00187           y>(-x)-1.65 && y< x+1.65   &&
00188           y<(-x)+3.55 && y>x-3.55)) 
00189       {return false;}
00190   }
00191   else if(pow(x,2)+pow(y,2)>14 || ntpTrack->end.plane>475 
00192            || ntpTrack->end.plane<5) return false;
00193 
00194   return true;
00195 }
00196 
00197 
00198 Float_t ANtpTrackInfoAna::RecoMuEnergy(SimFlag::SimFlag_t s, const Detector::Detector_t det)
00199 {
00200   const float mumass=0.10566; // GeV
00201 
00202   bool isdata = (s == SimFlag::kData);
00203   int opt = fANtpTrackInfo.muonEnergyMethod;
00204 
00205   if(!ANtpDefVal::IsDefault(fANtpTrackInfo.muonEnergyMethod)){
00206      float mr= fANtpTrackInfo.rangeMomentum;
00207      float mc= fANtpTrackInfo.fitMomentum;
00208 
00209      mr=CorrectMomentumFromRange(mr,isdata,det);
00210      mc=CorrectSignedMomentumFromCurvature(mc,isdata,det);
00211 
00212     if(opt==0){
00213       //return the most appropriate measure of momentum
00214       // assign opt based on our choice
00215     }
00216     else if(opt==1) { //return curvature measurement
00217         if(fANtpTrackInfo.fitMomentum > 10000.0) return 10000.0;
00218         else return sqrt(mc*mc + mumass*mumass);
00219     }
00220     else if(opt==2) //return range measurement
00221       return sqrt(mr*mr + mumass*mumass);
00222     else return 0;
00223   }
00224   return 0.;
00225 }
00226 
00227 Float_t ANtpTrackInfoAna::RecoMuEnergyNew(VldContext cx, EnergyCorrections::WhichCorrection_t corrver) {
00228 
00229   // using the new version of energy corrections developed for Cedar/Daikon
00230   corrver = EnergyCorrections::kDefault;
00231 
00232   const float mumass=0.10566;
00233   int method = fANtpTrackInfo.muonEnergyMethod;
00234 
00235   float mr= fANtpTrackInfo.rangeMomentum;
00236   float mc= fANtpTrackInfo.fitMomentum;
00237 
00238   if(mr>0) mr=FullyCorrectMomentumFromRange(mr,cx,release,corrver);
00239   mc=FullyCorrectSignedMomentumFromCurvature(mc,cx,release,corrver);
00240 
00241   if(method == 2) {
00242      return sqrt(mr*mr+ mumass*mumass);
00243   }
00244   if(method == 1){
00245       if(fANtpTrackInfo.fitMomentum > 10000.0) return 10000.0;
00246       else return sqrt(mc*mc+ mumass*mumass);
00247   }
00248   
00249   return 0.;
00250 }
00251 

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