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

ANtpTruthInfoBeamAna.cxx

Go to the documentation of this file.
00001 #include "CandNtupleSR/NtpSREvent.h"
00002 #include "StandardNtuple/NtpStRecord.h"
00003 #include "MCNtuple/NtpMCTruth.h"
00004 #include "MCNtuple/NtpMCStdHep.h"
00005 #include "TruthHelperNtuple/NtpTHEvent.h"
00006 #include "TruthHelperNtuple/NtpTHTrack.h"
00007 #include "TruthHelperNtuple/NtpTHShower.h"
00008 #include "TruthHelperNtuple/NtpTHStrip.h"
00009 #include "MessageService/MsgService.h"
00010 #include "NueAna/ANtpTruthInfoBeamAna.h"
00011 #include "AnalysisNtuples/Module/ANtpRecoNtpManipulator.h"
00012 #include "AnalysisNtuples/ANtpDefaultValue.h"
00013 #include "NueAna/NueAnaTools/NueConvention.h"
00014 #include "TVector3.h"
00015 #include "DataUtil/OscCalc.h"
00016 
00017 CVSID("$Id: ANtpTruthInfoBeamAna.cxx,v 1.31 2009/04/28 20:16:50 boehm Exp $");
00018 
00019 ANtpTruthInfoBeamAna::ANtpTruthInfoBeamAna(ANtpTruthInfoBeamNue &antib):
00020    fANtpTruthInfoBeam(antib)
00021 {}
00022 
00023 ANtpTruthInfoBeamAna::~ANtpTruthInfoBeamAna()
00024 {}
00025 
00026 void ANtpTruthInfoBeamAna::Analyze(int event, RecRecordImp<RecCandHeader> *srobj)
00027 {
00028   if(srobj==0){
00029     return;
00030   }
00031   NtpStRecord *st = dynamic_cast<NtpStRecord *>(srobj);
00032   Analyze(event,st);
00033 }
00034 
00035 void ANtpTruthInfoBeamAna::Analyze(int evtn, NtpStRecord *srobj)
00036 {
00037   if(srobj==0){
00038     return;
00039   }
00040 
00041     // This is mostly copied from AnalysisNtuples/Module/CondensedNtpModule.cxx
00042     NtpMCTruth *mctruth = 0;
00043     NtpMCStdHep *mcstdhep = 0;
00044     NtpTHEvent *thevent = 0;
00045     //NtpTHStrip *thstrip = 0;
00046     //NtpTHTrack *thtrack = 0;
00047     //NtpTHShower *thshower = 0;
00048 
00049     //instansiate a NtpHelper object to help you get the info you want
00050     ANtpRecoNtpManipulator ntpManipulator(srobj);
00051     fInfoFiller = new ANtpInfoObjectFillerBeam();
00052     fInfoFiller->SetStripArray(ntpManipulator.GetStripArray());
00053   
00054     thevent = ntpManipulator.GetMCManipulator()->GetNtpTHEvent(evtn);
00055     if(thevent){
00056       mctruth = ntpManipulator.GetMCManipulator()->GetNtpMCTruth(thevent->neumc);
00057       mcstdhep = ntpManipulator.GetMCManipulator()->GetNtpMCStdHep(thevent->neustdhep);
00058     }
00059                                   
00060     // no strip info yet
00061     //if(ntpStrip) ntpTHStrip = ntpManipulator.GetNtpTHStrip(ntpStrip->index);
00062     //if(ntpTHStrip){
00063     //    ntpMCTruth = ntpManipulator.GetNtpMCTruth(ntpTHStrip->neumc);   
00064     //}
00065     
00066     if(mctruth){
00067       // fill the ANtpTruthInfo part
00068       fInfoFiller->FillMCTruthInformation(mctruth, &fANtpTruthInfoBeam);
00069       // fill the ANtpTruthInfoBeam part
00070       fInfoFiller->FillBeamMCTruthInformation(mctruth, ntpManipulator.GetStdHepArray(),&fANtpTruthInfoBeam);
00071 
00072       Int_t inu = fANtpTruthInfoBeam.nuFlavor;
00073       Int_t inunoosc = fANtpTruthInfoBeam.nonOscNuFlavor;
00074       Int_t iaction = fANtpTruthInfoBeam.interactionType;          
00075 
00076       fANtpTruthInfoBeam.fNueClass = GetNueClass(inu, inunoosc, iaction);
00077       fANtpTruthInfoBeam.fNueWeight = GetNueWeight(inu, inunoosc);
00078       if(srobj->GetHeader().GetVldContext().GetDetector() == Detector::kFar)
00079         GetOscProb();
00080       else
00081         fANtpTruthInfoBeam.fOscProb = 1.0;
00082 
00083       fANtpTruthInfoBeam.DirCosNeu = TrueLepDCosNeu(mctruth);
00084       fANtpTruthInfoBeam.DirCosZ_pan = TrueLepDCosZ(mctruth);
00085 
00086       fANtpTruthInfoBeam.istruckq = mctruth->istruckq;
00087       fANtpTruthInfoBeam.iflags = mctruth->iflags;
00088       fANtpTruthInfoBeam.sigmadiff = mctruth->sigmadiff;
00089       fANtpTruthInfoBeam.itg = mctruth->itg;
00090 
00091       fANtpTruthInfoBeam.eventCompleteness = thevent->completeall;
00092     }
00093 
00094     if(fInfoFiller){
00095       delete fInfoFiller;
00096       fInfoFiller=0;
00097     }                                   
00098 }
00099 
00100 void ANtpTruthInfoBeamAna::Analyze(int evtn, NtpSRRecord *srobj, NtpMCRecord * mcobj, NtpTHRecord * thobj)
00101 {
00102 
00103   if(srobj==0){
00104     return;
00105   }
00106   if(mcobj==0){
00107     return;
00108   }
00109   if(thobj==0){
00110     return;
00111   }
00112 
00113     fInfoFiller = new ANtpInfoObjectFillerBeam();
00114     // This is mostly copied from AnalysisNtuples/Module/CondensedNtpModule.cxx
00115     NtpMCTruth *mctruth = 0;
00116     NtpMCStdHep *mcstdhep = 0;
00117     NtpTHEvent *thevent = 0;
00118     //NtpTHStrip *thstrip = 0;
00119     //NtpTHTrack *thtrack = 0;
00120     //NtpTHShower *thshower = 0;
00121 
00122     // Only fill if there is MC or Truth information
00123     if (mcobj && thobj){
00124 
00125         //instansiate a NtpHelper object to help you get the info you want
00126         ANtpRecoNtpManipulator ntpManipulator(srobj,mcobj,thobj);
00127         
00128         thevent = ntpManipulator.GetMCManipulator()->GetNtpTHEvent(evtn);
00129         if(thevent){
00130          mctruth = ntpManipulator.GetMCManipulator()->GetNtpMCTruth(thevent->neumc);
00131          mcstdhep = ntpManipulator.GetMCManipulator()->GetNtpMCStdHep(thevent->neustdhep);
00132         }
00133         
00134         // no strip info yet
00135         //if(ntpStrip) ntpTHStrip = ntpManipulator.GetNtpTHStrip(ntpStrip->index);
00136         //if(ntpTHStrip){
00137         //    ntpMCTruth = ntpManipulator.GetNtpMCTruth(ntpTHStrip->neumc);   
00138         //}
00139 
00140         if(mctruth){
00141           // fill the ANtpTruthInfo part
00142           fInfoFiller->FillMCTruthInformation(mctruth, &fANtpTruthInfoBeam);
00143           // fill the ANtpTruthInfoBeam part
00144           fInfoFiller->FillBeamMCTruthInformation(mctruth, ntpManipulator.GetStdHepArray(),&fANtpTruthInfoBeam);
00145 
00146           Int_t inu = fANtpTruthInfoBeam.nuFlavor;
00147           Int_t inunoosc = fANtpTruthInfoBeam.nonOscNuFlavor;
00148           Int_t iaction = fANtpTruthInfoBeam.interactionType;          
00149 
00150           fANtpTruthInfoBeam.fNueClass = GetNueClass(inu, inunoosc, iaction);
00151           fANtpTruthInfoBeam.fNueWeight = GetNueWeight(inu, inunoosc);
00152           if(srobj->GetHeader().GetVldContext().GetDetector() == Detector::kFar)
00153             GetOscProb();
00154           else
00155             fANtpTruthInfoBeam.fOscProb = 1.0;
00156           
00157           fANtpTruthInfoBeam.DirCosNeu = TrueLepDCosNeu(mctruth);
00158           fANtpTruthInfoBeam.DirCosZ_pan = TrueLepDCosZ(mctruth);
00159         }                               
00160     }   
00161 
00162     if(fInfoFiller){
00163       delete fInfoFiller;
00164       fInfoFiller=0;
00165     }
00166 }
00167 
00168 Int_t ANtpTruthInfoBeamAna::GetNueClass(Int_t inu, Int_t inunoosc, Int_t iaction)
00169 {
00170   Int_t cType=ANtpDefVal::kInt;
00171   cType = ClassType::DetermineClassType(inu, inunoosc, iaction);
00172 
00173   if(ANtpDefVal::IsDefault(cType)){
00174        MSG("ANtpTruthInfoBeamAna",Msg::kWarning)<< " GetNueClass called " 
00175                        << "eith invalid paramters - no class assigned" 
00176                        << endl;            
00177   }
00178 
00179   return cType;
00180 }
00181 
00182 
00183 Float_t ANtpTruthInfoBeamAna::GetNueWeight(Int_t inu, Int_t inunoosc)
00184 {
00185                                                                           
00186   Float_t weight = ANtpDefVal::kFloat;
00187 
00188   if(ReleaseType::IsDaikon(release)) weight = 1.0;
00189 
00190   if(ReleaseType::IsCarrot(release)){
00191     if(abs(inu) == 12 || abs(inu) == 14 || abs(inu) == 16){
00192        if(abs(inunoosc) == 12 || abs(inunoosc) == 14 || abs(inunoosc) == 16){
00193           weight = 1.0;
00194           if(abs(inu) ==12 && abs(inunoosc) == 12)    weight = 0.5;
00195        }
00196     }
00197   }
00198 
00199   if(ANtpDefVal::IsDefault(weight)){
00200     // MSG("ANtpTruthInfoBeamAna",Msg::kWarning)<< " GetNueWeight called " 
00201     //                                           << "with invalid paramters "
00202     //                                   <<inu<<" "<<inunoosc
00203     //                                   <<" - 0 weight assigned" 
00204     //                                   << endl;            
00205         return 0.0;
00206   }
00207                           
00208   return weight;  
00209 }
00210 
00211 Float_t ANtpTruthInfoBeamAna::GetOscProb()
00212 {
00213     fANtpTruthInfoBeam.Baseline = 735;
00214     fANtpTruthInfoBeam.DeltamSquared23 = 0.0024;
00215     double th23 = fANtpTruthInfoBeam.Theta23 = TMath::Pi()/4.0;
00216     fANtpTruthInfoBeam.Ue3Squared = 0.025;
00217     
00218 // CC Results for MDC 
00219 //    dm2 = 0.002175;  // +- 0.15e-3
00220     double th13 = TMath::ASin(TMath::Sqrt(fANtpTruthInfoBeam.Ue3Squared)); 
00221 
00222    fANtpTruthInfoBeam.fOscProb = NueConvention::Oscillate(&fANtpTruthInfoBeam);
00223   
00224    Double_t dm2_12 = 8.7e-5;
00225    double th12 = 0.816;
00226    Double_t dm2_23 = fANtpTruthInfoBeam.DeltamSquared23;
00227 
00228    static OscCalc fOscCalc;   
00229                                                                              
00230    Double_t par[9] = {0};
00231    par[OscPar::kL] = fANtpTruthInfoBeam.Baseline;
00232    par[OscPar::kTh23] = fANtpTruthInfoBeam.Theta23 = th23;
00233    par[OscPar::kTh12] = fANtpTruthInfoBeam.Theta12 = th12;
00234    par[OscPar::kTh13] = fANtpTruthInfoBeam.Theta13 = th13;
00235    par[OscPar::kDeltaM23] = dm2_23;
00236    par[OscPar::kDeltaM12] = fANtpTruthInfoBeam.DeltamSquared12 = dm2_12;
00237    par[OscPar::kDensity] = fANtpTruthInfoBeam.Density = 2.65; 
00238    par[OscPar::kDelta] = fANtpTruthInfoBeam.Delta = 0.0;
00239    par[OscPar::kNuAntiNu] = 1;
00240                                                                                 
00241 //  std::cout<<"About to call "<<dm2<<"  "<<ss13<<"  "<<delta<<std::endl;
00242    fOscCalc.SetOscParam(par);
00243  
00244    int nuFlavor = fANtpTruthInfoBeam.nuFlavor;
00245    int nonOscNuFlavor = fANtpTruthInfoBeam.nonOscNuFlavor;
00246 
00247    if(nonOscNuFlavor > 0) fOscCalc.SetOscParam(OscPar::kNuAntiNu, 1);
00248    if(nonOscNuFlavor < 0) fOscCalc.SetOscParam(OscPar::kNuAntiNu, -1);
00249 
00250    double Energy =  fANtpTruthInfoBeam.nuEnergy;
00251 
00252                                                                                 
00253    fANtpTruthInfoBeam.fOscProbMatterNormal = fOscCalc.Oscillate(nuFlavor, nonOscNuFlavor, Energy);
00254     
00255    fOscCalc.SetOscParam(OscPar::kDeltaM23, -dm2_23);
00256    fANtpTruthInfoBeam.fOscProbMatterInverted = fOscCalc.Oscillate(nuFlavor, nonOscNuFlavor, Energy);
00257 
00258 
00259   return 1; 
00260 }
00261 
00262 
00263 Float_t ANtpTruthInfoBeamAna::TrueLepDCosNeu(NtpMCTruth *ntpTruth)
00264 { //ds_mu/ds_nu
00265   TVector3 *nuvec = new TVector3(ntpTruth->p4neu[0],
00266                                  ntpTruth->p4neu[1],
00267                                  ntpTruth->p4neu[2]);
00268 
00269   Float_t p4_0 = 0;
00270   Float_t p4_1 = 0;
00271   Float_t p4_2 = 0;
00272 
00273   Get3Momenta(ntpTruth, p4_0, p4_1, p4_2);
00274 
00275   TVector3 *muvec = new TVector3(p4_0, p4_1, p4_2);
00276   Float_t MuAng = nuvec->Angle(*muvec); //angle in rads
00277   delete nuvec;
00278   delete muvec;
00279   return TMath::Cos(MuAng);
00280 }
00281 
00282 Float_t ANtpTruthInfoBeamAna::TrueLepDCosZ(NtpMCTruth *ntpTruth){ //dz/ds
00283 
00284   Float_t p4_0 = 0;
00285   Float_t p4_1 = 0;
00286   Float_t p4_2 = 0;
00287 
00288   Float_t mom = Get3Momenta(ntpTruth, p4_0, p4_1, p4_2);
00289 
00290   if(mom==0) return 0;
00291   return p4_2/mom;
00292 }
00293 
00294 Float_t ANtpTruthInfoBeamAna::Get3Momenta(NtpMCTruth *ntpTruth,
00295                            Float_t &p4_0, Float_t &p4_1, Float_t &p4_2)
00296 { 
00297   p4_0 = 0;
00298   p4_1 = 0;
00299   p4_2 = 0;
00300                                                                                 
00301   if(TMath::Abs(ntpTruth->p4mu1[3]) > 0){
00302     p4_0 = ntpTruth->p4mu1[0];
00303     p4_1 = ntpTruth->p4mu1[1];
00304     p4_2 = ntpTruth->p4mu1[2];
00305   }
00306   else if(TMath::Abs(ntpTruth->p4el1[3])>0){
00307     p4_0 = ntpTruth->p4el1[0];
00308     p4_1 = ntpTruth->p4el1[1];
00309     p4_2 = ntpTruth->p4el1[2];
00310   }
00311   else if(TMath::Abs(ntpTruth->p4tau[3])>0){
00312     p4_0 = ntpTruth->p4tau[0];
00313     p4_1 = ntpTruth->p4tau[1];
00314     p4_2 = ntpTruth->p4tau[2];
00315   }
00316   
00317   return (p4_0*p4_0 + p4_1*p4_1 + p4_2*p4_2);
00318 
00319 }

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