Reading LUND files

From New IAC Wiki
Revision as of 13:41, 26 April 2016 by Vanwdani (talk | contribs) (Created page with "#include <math.h> #include <TRandom3.h> void ReadLUND() { struct evt_t { Int_t event; Float_t FnlMom[3], MolMom[3]; …")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  1. include <math.h>
#include <TRandom3.h>

void ReadLUND() {

       struct evt_t
       {
               Int_t event;
               Float_t FnlMom[3], MolMom[3];
               Float_t dontcare[10];
               Float_t stilldontcare[14];
               Float_t Px,Py,Pz,E,M,X,Y,Z;
               Float_t px,py,pz,e,m,x,y,z;
       };
       ifstream in;
       in.open("LUND_spread.LUND");
       evt_t evt;
       Int_t nlines=0;
       TLorentzVector Fnl_e_Lab_4Mom;
       TLorentzVector Fnl_Mol_Lab_4Mom;
       TLorentzVector Fnl_e_CM_4Mom;
       TLorentzVector Mol_CM_4Mom;
       TLorentzVector CMS;


       TFile *f = new TFile("CheckLUND_1.root","RECREATE");
       TTree *tree = new TTree("Moller","Moller data from ascii file");
       while(in.good())
       {
               evt.event=nlines;
               in >> evt.dontcare[0] >> evt.dontcare[1] >> evt.dontcare[2] >> evt.dontcare[3] >> evt.dontcare[4] >> evt.dontcare[5] >> evt.dontcare[6]                        
                       >> evt.dontcare[7] >> evt.dontcare[8] >> evt.dontcare[9] ;


               nlines++;
        
               in >> evt.stilldontcare[0] >> evt.stilldontcare[1] >> evt.stilldontcare[2] >> evt.stilldontcare[3] >> evt.stilldontcare[4]
                       >> evt.stilldontcare[5] >> evt.Px >> evt.Py >> evt.Pz >> evt.E >> evt.M >> evt.X >> evt.Y >> evt.Z;
               
               nlines++;
               
               in >> evt.stilldontcare[6] >> evt.stilldontcare[7] >> evt.stilldontcare[8] >> evt.stilldontcare[9] >> evt.stilldontcare[10]
                       >> evt.stilldontcare[11] >> evt.px >> evt.py >> evt.pz >> evt.e >> evt.m >> evt.x >> evt.y >> evt.z;
               nlines++;
               tree->Fill();
       
               //Define using Final Moller momentum
                       //Define 4 vector
                               Fnl_Mol_Lab_4Mom.SetPxPyPzE(evt.px,evt.py,evt.pz,evt.e);
       
       
               //Find 4 Momentum vector componets for Final Lab frame scattered electron
                       //Define 4vector
                               Fnl_e_Lab_4Mom.SetPxPyPzE(evt.Px,evt.Py,evt.Pz,evt.E);
       
                       //Fill Final Lab Histograms
                                       MolMomLab->Fill(Fnl_Mol_Lab_4Mom.P(),evt.dontcare[5]);
                                       MolThetaLab->Fill(Fnl_Mol_Lab_4Mom.Theta()*180/3.14159265359,evt.dontcare[5]);
       
       
                       //Boost vectors
                               CMS=Fnl_e_Lab_4Mom+Fnl_Mol_Lab_4Mom;
                       //Boost to CM Frame
                               Fnl_e_Lab_4Mom.Boost(-CMS.BoostVector());
                               Fnl_Mol_Lab_4Mom.Boost(-CMS.BoostVector());
       
                       //Write to 1D final CM histograms
                                       MolMomCM->Fill(Fnl_Mol_Lab_4Mom.P(),evt.dontcare[5]);
                                       MolThetaCM->Fill(Fnl_Mol_Lab_4Mom.Theta()*180/3.14159265359,evt.dontcare[5]);
       
       
       
               }//End input loop
       
       in.close();
       tree->Print();
       tree->Write();
       f->Write();        
       delete tree;
       delete f;

}//End main