Greetings,
Here is a sample of my code:
[code]#include “TROOT.h”
#include “TRint.h”
#include “TH1F.h”
#include “TCanvas.h”
#include “TChain.h”
#include “TVector3.h”
#include “TMath.h”
#include “TFile.h”
#include “TSystem.h”
#include “TGStatusBar.h”
#include “TSystem.h”
#include “TXMLEngine.h”
#include “TTree.h”
#include “TLorentzVector.h”
#include “TNtuple.h”
#include
#include
#include
#include
#include
#include
void shortest_check(){
TChain *chain = new TChain(“Lep”);
chain->Add("/Volumes/Mac_Storage/Work_Data/ANALYSIS_DATA/Lepton_Gamcor.root");
Int_t nEvent = chain->GetEntries();
std::cout <<"Number of events " <<nEvent <<std::endl;
TFile f("/Volumes/Mac_Storage/Work_Data/ANALYSIS_DATA/shortest.root",“recreate”);
//########################################### BEGIN INCOMING DATA ###############################################################
//----------------------------------------------------For Proton-------------------------------------------------------------------
Double_t P_Ptot, P_Px, P_Py, P_Pz, P_vx, P_vy, P_vz;
Int_t NProton;
chain->SetBranchAddress(“NProton”,&NProton);
chain->SetBranchAddress(“P_Ptot”,&P_Ptot);
chain->SetBranchAddress(“P_Px”, &P_Px);
chain->SetBranchAddress(“P_Py”, &P_Py);
chain->SetBranchAddress(“P_Pz”, &P_Pz);
chain->SetBranchAddress(“P_vx”, &P_vx);
chain->SetBranchAddress(“P_vy”, &P_vy);
chain->SetBranchAddress(“P_vz”, &P_vz);
//########################################### BEGIN OUTGOING DATA ###############################################################
TTree *t4 = new TTree(“Lep_Tree”,“Lep_Tree”);
//----------------------------------------------------For Proton -------------------------------------------------------------------
Int_t NProt;
Double_t P_px, P_py, P_pz, P_p;
Double_t P_pxfloat, P_pyfloat, P_pzfloat, P_pfloat;
t4->Branch(“NProt”,&NProt,“NProt/I”);
t4->Branch(“P_p”,&P_p,“P_p/D”);
t4->Branch(“P_px”,&P_px,“P_px/D”);
t4->Branch(“P_py”,&P_py,“P_py/D”);
t4->Branch(“P_pz”,&P_pz,“P_pz/D”);
t4->Branch(“P_pfloat”,&P_pfloat,“P_pfloat/F”);
t4->Branch(“P_pxfloat”,&P_pxfloat,“P_pxfloat/F”);
t4->Branch(“P_pyfloat”,&P_pyfloat,“P_pyfloat/F”);
t4->Branch(“P_pzfloat”,&P_pzfloat,“P_pzfloat/F”);
for( Int_t i = 0; i < nEvent ; i++){
chain->GetEntry(i);
if(!(i%100000)) std::cout << "done " << i << " out of " << nEvent << " ==> " << double(i)*100.0/double(nEvent) << "%" << std::endl;
P_p = P_Ptot;
P_px = P_Px;
P_py = P_Py;
P_pz = P_Pz;
P_pfloat = P_Ptot;
P_pxfloat = P_Px;
P_pyfloat = P_Py;
P_pzfloat = P_Pz;
NProt = NProton;
t4 ->Fill();
}
//########################################### END OUTGOING DATA ###############################################################
t4->Write();
f.Close();
}
[/code]
I have uploaded a plot of the P_pxfloat and P_px varible, the blue is of the float type and the red is of the double type.
Hope this clarifies my problem.
Thanks
Michael