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

GnumiTree.cxx

Go to the documentation of this file.
00001 #include "GnumiTree.h"
00002 #include "reweight.h"
00003 
00004 #include <TTree.h>
00005 #include <TH2D.h>
00006 
00007 #include <iostream>
00008 using namespace std;
00009 
00010 
00011 void GnumiTree::SetTree(TTree& the_tree)
00012 {
00013     // Got 'a do it this way because all trees are at top level...
00014     the_tree.SetBranchAddress("run",&run);
00015     the_tree.SetBranchAddress("evtno",&evtno);
00016     the_tree.SetBranchAddress("ndxdz",&ndxdz);
00017     the_tree.SetBranchAddress("ndydz",&ndydz);
00018     the_tree.SetBranchAddress("npz",&npz);
00019     the_tree.SetBranchAddress("nenergy",&nenergy);
00020     the_tree.SetBranchAddress("ndxdznea",&ndxdznea);
00021     the_tree.SetBranchAddress("ndydznea",&ndydznea);
00022     the_tree.SetBranchAddress("nenergyn",&nenergyn);
00023     the_tree.SetBranchAddress("nwtnear",&nwtnear);
00024     the_tree.SetBranchAddress("ndxdzfar",&ndxdzfar);
00025     the_tree.SetBranchAddress("ndydzfar",&ndydzfar);
00026     the_tree.SetBranchAddress("nenergyf",&nenergyf);
00027     the_tree.SetBranchAddress("nwtfar",&nwtfar);
00028     the_tree.SetBranchAddress("norig",&norig);
00029     the_tree.SetBranchAddress("ndecay",&ndecay);
00030     the_tree.SetBranchAddress("ntype",&ntype);
00031     the_tree.SetBranchAddress("vx",&vx);
00032     the_tree.SetBranchAddress("vy",&vy);
00033     the_tree.SetBranchAddress("vz",&vz);
00034     the_tree.SetBranchAddress("pdpx",&pdpx);
00035     the_tree.SetBranchAddress("pdpy",&pdpy);
00036     the_tree.SetBranchAddress("pdpz",&pdpz);
00037     the_tree.SetBranchAddress("ppdxdz",&ppdxdz);
00038     the_tree.SetBranchAddress("ppdydz",&ppdydz);
00039     the_tree.SetBranchAddress("pppz",&pppz);
00040     the_tree.SetBranchAddress("ppenergy",&ppenergy);
00041     the_tree.SetBranchAddress("ppmedium",&ppmedium);
00042     the_tree.SetBranchAddress("ptype",&ptype);
00043     the_tree.SetBranchAddress("ppvx",&ppvx);
00044     the_tree.SetBranchAddress("ppvy",&ppvy);
00045     the_tree.SetBranchAddress("ppvz",&ppvz);
00046     the_tree.SetBranchAddress("muparpx",&muparpx);
00047     the_tree.SetBranchAddress("muparpy",&muparpy);
00048     the_tree.SetBranchAddress("muparpz",&muparpz);
00049     the_tree.SetBranchAddress("mupare",&mupare);
00050     the_tree.SetBranchAddress("necm",&necm);
00051     the_tree.SetBranchAddress("nimpwt",&nimpwt);
00052     the_tree.SetBranchAddress("xpoint",&xpoint);
00053     the_tree.SetBranchAddress("ypoint",&ypoint);
00054     the_tree.SetBranchAddress("zpoint",&zpoint);
00055     the_tree.SetBranchAddress("tvx",&tvx);
00056     the_tree.SetBranchAddress("tvy",&tvy);
00057     the_tree.SetBranchAddress("tvz",&tvz);
00058     the_tree.SetBranchAddress("tpx",&tpx);
00059     the_tree.SetBranchAddress("tpy",&tpy);
00060     the_tree.SetBranchAddress("tpz",&tpz);
00061     the_tree.SetBranchAddress("tptype",&tptype);    
00062 
00063     tree = &the_tree;
00064 }
00065 
00066 
00067 void GnumiTree::paint_flux(TH2D* hist, double npot, double zloc)
00068 {
00069         int nbinsx = hist->GetNbinsX();
00070         int nbinsy = hist->GetNbinsY();
00071 
00072         double xmin = hist->GetXaxis()->GetXmin();
00073         double xmax = hist->GetXaxis()->GetXmax();
00074 
00075         double ymin = hist->GetYaxis()->GetXmin();
00076         double ymax = hist->GetYaxis()->GetXmax();
00077 
00078         double xstep = (xmax-xmin)/nbinsx;
00079         double ystep = (ymax-ymin)/nbinsy;
00080 
00081         int nentries = tree->GetEntries();
00082 
00083         cerr << nentries << " entries " <<
00084             " x:(" << xmin << " -> " << xmax << " += " << xstep << ")"
00085             " y:(" << ymin << " -> " << ymax << " += " << ystep << ")"
00086              << endl;
00087 
00088         for (int ind = 0; ind<nentries; ++ind) {
00089             tree->GetEntry(ind);
00090 
00091             if (ind%10000 == 1) cerr << " " << ind << ", ";
00092 
00093             int neutrino_type = ntype;
00094 
00095             if (neutrino_type != 56) {
00096                 //cerr << "Got " << neutrino_type << " not 56\n";
00097                 continue;
00098             }
00099 
00100             double vertex[3] = 
00101                 { vx, vy, vz };
00102             double neutrino_momentum[3] = 
00103                 { ndxdz*npz, ndydz*npz, npz };
00104             double parent_momentum[3] = 
00105                 { pdpx, pdpy, pdpz };
00106             double muparent_momentum[3] = 
00107                 { muparpx, muparpy, muparpz };
00108 
00109             double standard_weight = nimpwt/3.14159;
00110             int parent_type = ptype;        
00111             // Paint the different reweights
00112             for (double x = xmin; x<xmax; x+=xstep) {
00113                 for (double y = ymin; y<ymax; y+=ystep) {
00114                     double det_pos[] = { x, y, zloc } ;
00115                     double eneu, weight;
00116                     reweight_neutrino(det_pos,
00117                                       vertex,
00118                                       neutrino_type,
00119                                       neutrino_momentum,
00120                                       parent_type,
00121                                       parent_momentum,
00122                                       muparent_momentum,
00123                                       eneu, weight);
00124                     hist->Fill(x,y,standard_weight*weight/npot);
00125                 }
00126             }
00127         }
00128     }

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