# Filling a TProfile with complex numbers

Hi all,

Recently I was looking for a number like

Re ( <Q Q*>) which is equal to <Re(Q Q*)> so I could simply make a TProfile to find this average like so

(I have omitted some of the code for brevity)

``````TProfile *myprofile = new TProfile("blah","blah",1,0,1);
TComplex Qn=0.0;
TComplex filler=0.0;
for (Int_t i=0;i<NumberOfEvents;i++)
{
for (Int_t track_iter=0;track_iter<NumberOfTracks;track_iter++)
{
Qn+=TComplex::Exp(TComplex::I() * phi_of_track);
}//end of loop over tracks
filler=Qn*TComplex::Conjugate(Qn);
myprofile->Fill(0.2,filler):
}//end of loop over events``````

So this was fine to get <Re(Q Q*)> but now unfortunately I want to calculate:

Re ( <Q Q*> - <Q*>) which is kind of ok because that can split into <Re(Q Q*)> which I already have and then
Re(<Q*>). This however is tricky because how do I find the average Q and Q* ? I ideally would like to use a TProfile but cannot figure out how to put complex values in a TProfile.

So my question is:
Is it at all possible to make some sort of TProfile that knows how to deal with complex numbers?

thanks,

J

HI,

I think you are over-using here the TProfile. First of all you are relying on the fact of an automatic conversion from a TComplex to its real part when filling a TProfile. In my opinion this automatic conversion should not be there. I would reccomend to make yourself your own class dealing with the complex number, maybe using a profile or a standard histogram filled with the real or imaginary part of a complex number

Best Regards

Lorenzo