Hi All,
I’m trying to get my code to make a 1d histogram for each of the individual particles for which it currently prints a histogram of their momenta against each other. however I currently get a stream of errors. I found a code that this approach worked for, but can’t seem to get it to work.
This is the code:
void test7(UInt_t NrOfEvents = 1000000) {
if (!gROOT->GetClass(“TGenPhaseSpace”)) gSystem->Load(“libPhysics”);
TLorentzVector target(0.0, 0.0, 0.0, 1.879);
TLorentzVector beam(0.0, 0.0, 2.2, 2.2);
TLorentzVector W = beam + target;
// cout << “W=”<< W << endl;
//(Momentum, Energy units are Gev/C, GeV)
Double_t masses[4] = {0.938, 0.493, 0.493, 0.938} ;
int c=0;
TRandom3 p(-1);
for (UInt_t iEvent = 0; iEvent < NrOfEvents; ++iEvent) {
Double_t num = p.Uniform(0,360);
if (num > 0.05){
c=c+1;
}
}
cout << “c=”<< c << endl;
//int detectn = 10000; //detect n will eventually be an output based on detector efficiency and angle p
TGenPhaseSpace event;
event.SetDecay(W, 4, masses);
TH2F *h2 = new TH2F(“h2”,“h2”, 1000,0,10, 1000,0,10);
TH1 *h1 = new TH1(“h1”,“h1”, 1000,0,10,1000,0,10);
for (Int_t n=0; n<c; n++) { //instead of being 100000 events this will be 100000 runs where each event is ‘tested’ to see if it is detected
Double_t weight = event.Generate();
TLorentzVector *pNeutron = event.GetDecay(0);
TLorentzVector *pKp = event.GetDecay(1);
TLorentzVector *pKm = event.GetDecay(2);
TLorentzVector *pProton = event.GetDecay(3);
TLorentzVector pNKp = *pNeutron + *pKp;
TLorentzVector pKmP = *pKm + *pProton;
TLorentzVector pKms = *pKm;
h2->Fill(pNKp.M2() ,pKmP.M2() ,weight); //histogram of momentum for the two pairs of particles
h1->Fill(pKms.M2()); //1D histogram of individual particle momentum
}
h2->Draw();
h1->Draw();
}
and these are the errors:
root [0]
Processing test7.C…
c=999857
Error: Can’t call TH1::TH1(“h1”,“h1”,1000,0,10,1000,0,10) in current scope test7.C:28:
Possible candidates are…
(in TH1)
/mnt/share/cern_FC21/root/v5.34.24/lib/libHist.so -1:-1 0 protected: TH1 TH1::TH1(void);
/mnt/share/cern_FC21/root/v5.34.24/lib/libHist.so -1:-1 0 protected: TH1 TH1::TH1(const char* name,const char* title,Int_t nbinsx,Double_t xlow,Double_t xup);
/mnt/share/cern_FC21/root/v5.34.24/lib/libHist.so -1:-1 0 protected: TH1 TH1::TH1(const char* name,const char* title,Int_t nbinsx,const Float_t* xbins);
/mnt/share/cern_FC21/root/v5.34.24/lib/libHist.so -1:-1 0 protected: TH1 TH1::TH1(const char* name,const char* title,Int_t nbinsx,const Double_t* xbins);
/mnt/share/cern_FC21/root/v5.34.24/lib/libHist.so -1:-1 0 public: TH1 TH1::TH1(const TH1&);
*** Interpreter error recovered ***
Thanks in advance!