-
-
Save agenel/695aa9f678314daf4a484703013c837d to your computer and use it in GitHub Desktop.
root example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "TRandom3.h" | |
#include "TH1F.h" //INCLUDE ROOT HEADER FILES | |
#include "TLorentzVector.h" // WE WILL USE | |
#include "TCanvas.h" | |
double v1px, v1e; //DECLARE VECTOR COMPONENTS | |
double v2pz, v2e; | |
void TLV() | |
{ | |
TCanvas* c1 = new TCanvas("table", "TLVs", 800,800 ); | |
TH1F* histoM = new TH1F("masses","Lorentz Vectors' Masses",600,0,20.); | |
TH1F* histoPt = new TH1F("pts","Lorentz PTs", 600,-0.5 , 7.); | |
TRandom3* uret = new TRandom3(); // - RANDOM GENERATOR | |
uret->SetSeed(855); // SEED | |
TLorentzVector v1; // - DECLARING LORENTZ | |
TLorentzVector v2; // VECTORS | |
TPad *pad1 = new TPad("pad1", "pad1", 0, 0.5, 1, 1.0); | |
TPad *pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.5); | |
for (int j=0;j<100;j++){ | |
//MAKING RANDOM VECTORS VARIABLES | |
v1px =abs(uret->Gaus(2,1)); | |
v1e =abs(uret->Gaus(6,1)); | |
//MAKING RANDOM ANOTHER VECTORS VARIABLES | |
v2pz =abs(uret->Gaus(2,1)); | |
v2e =abs(uret->Gaus(6,1)); | |
v1.SetPxPyPzE(v1px,1,1,v1e); //SET THE COMPONENTS VECTOR1 | |
v2.SetPxPyPzE(1,1,v2pz,v2e); //SET THE COMPONENTS VECTOR2 | |
TLorentzVector v3 = v1 + v2; //SUMMATION TWO LORENTZ VECTORS | |
double tb2 = v3.Pt(); //SET THE PT VALUE OF NEW VECTOR | |
double tb1 = v3.M(); //SET THE MASS OF NEW VECTOR | |
histoPt->Fill(tb2); //INSERT VALUES TO HISTOGRAMS | |
histoM->Fill(tb1); | |
}; | |
pad1->Draw(); | |
pad1->cd(); | |
histoPt->Draw(); //DRAWING TWO HISTOGRAM IN | |
c1->cd(); //ONE CANVAR HELPS WITH PAD | |
pad2->Draw(); | |
pad2->cd(); | |
histoM->Draw(); | |
c1->SaveAs("cikti.pdf"); //SAVE THE CANVAS AS PDF FILE | |
} | |
/*------------------------- END OF FUNCTION ----------------------------*/ | |
int main() { TLV(); } //MAIN FUNCTION OF SCRIPT | |
/*------------------------- END OF SCRIPT ------------------------------*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment