# Dividing histograms

Hi all,

I have written a very basic macro trying to demonstrate the equivalence of TComplex and TMath as they relate to Eulers relation.

``````{

#include "TH1F.h"
#include "TComplex.h"
#include "TRandom.h"

TComplex Qn;
Qn=TComplex(0.);
TRandom myRandom(12345);
Double_t theta;

//Complex Terms
TH1F *ComplexSin = new TH1F("ComplexSinValue","ComplexSinValue",100,-1,1);
TH1F *ComplexCos = new TH1F("ComplexCosValue","ComplexCosValue",100,-1,1);

//"Normal" Terms
TH1F *SinPlot = new TH1F("SinValue","SinValue",100,-1,1);
TH1F *CosPlot = new TH1F("CosValue","CosValue",100,-1,1);

for (Int_t i=0;i<100000;i++)
{
//Generate Random Angle
theta=0.;
theta=TMath::TwoPi()*myRandom.Rndm();
//Make Complex Number
Qn=TComplex(0.);
Qn=TComplex::Exp(TComplex::I()*theta);
//Fill Plots
SinPlot->Fill(TMath::Sin(theta));
CosPlot->Fill(TMath::Cos(theta));
ComplexSin->Fill(Qn.Im());
ComplexCos->Fill(Qn.Re());
}

//Ratio Plots
TH1F *SinRatio= ComplexSin->Divide(SinPlot);//THE LINE I AM HAVING TROUBLE WITH

}//End of the whole thing  ``````

However I get an error that says

Any ideas?

J

Im sorry I am confused what you mean.

h1->Divide(h2); is a boolean operator?

Or that I have to change something to return a bool?

Yes, TH1::Divide return a bool which is false in case the operation resulted in an error.
I think in your case you should do:

``````TH1F *SinRatio = new TH1F("SinRatio","SinRatio",100,-1,1);
SinRatio->Divide(ComplexSin,SinPlot);``````

Lorenzo