ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/


//#include "Riostream.h"  //in case one wants to make print statements
#include "TProfile.h"
#include "TString.h" 
#include "TComplex.h" 
#include "TList.h"
#include "AliFlowLYZConstants.h" 
#include "AliFlowLYZHist1.h"
#include "TBrowser.h"

class TH1D; 

// Class to organize the histograms in the first run
// in the Lee Yang Zeros Flow analysis.
// Also contains methods to find the first minimum R0
// of the generating function.
// author: N. van der Kolk (kolk@nikhef.nl)

ClassImp(AliFlowLYZHist1)

//-----------------------------------------------------------------------

  AliFlowLYZHist1::AliFlowLYZHist1():
    TNamed(),
    fHistGtheta(0),
    fHistProReGtheta(0),
    fHistProImGtheta(0),
    fHistList(NULL)
{
  //default constructor
} 

//-----------------------------------------------------------------------

  AliFlowLYZHist1::AliFlowLYZHist1(Int_t theta, const char *anInput, Bool_t useSum):
    TNamed(anInput,anInput),
    fHistGtheta(0),
    fHistProReGtheta(0),
    fHistProImGtheta(0),
    fHistList(NULL)
{

  //constructor creating histograms 
  Int_t iNbins      = AliFlowLYZConstants::GetMaster()->GetNbins();
  Double_t dMaxSUM  = AliFlowLYZConstants::GetMaster()->GetMaxSUM();
  Double_t dMaxPROD = AliFlowLYZConstants::GetMaster()->GetMaxPROD();
  Double_t dMin     = 0.;

  TString name, addlast;
 
  if (useSum) { addlast = "LYZSUM"; }
  else { addlast = "LYZPROD"; }
  
  //fHistGtheta
  name = "First_Flow_Gtheta";
  name +=theta;
  name +=addlast;
  if (useSum) { fHistGtheta = new TH1D(name.Data(),name.Data(),iNbins,dMin,dMaxSUM); }
  else { fHistGtheta = new TH1D(name.Data(),name.Data(),iNbins,dMin,dMaxPROD); } 
  fHistGtheta->SetXTitle("r");
  fHistGtheta->SetYTitle("|G^{#theta}(ir)|^{2}");
  
  //fHistProReGtheta
  name = "First_FlowPro_ReGtheta";
  name +=theta;
  name +=addlast;
  if (useSum) { fHistProReGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxSUM); }
  else { fHistProReGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxPROD); }
  fHistProReGtheta->SetXTitle("r");
  fHistProReGtheta->SetYTitle("Re G^{#theta}(ir)");
  
  //fHistProImGtheta
  name = "First_FlowPro_ImGtheta";
  name +=theta;
  name +=addlast;
  if (useSum) { fHistProImGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxSUM); }
  else { fHistProImGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxPROD); }
  fHistProImGtheta->SetXTitle("r");
  fHistProImGtheta->SetYTitle("Im G^{#theta}(ir)");

  //list of histograms
  fHistList = new TList();
  fHistList-> Add(fHistGtheta);
  fHistList-> Add(fHistProReGtheta);
  fHistList-> Add(fHistProImGtheta);
      
}
  
//----------------------------------------------------------------------- 

AliFlowLYZHist1::~AliFlowLYZHist1()
{
  //deletes histograms
  delete fHistGtheta;
  delete fHistProReGtheta;
  delete fHistProImGtheta;
  delete fHistList;
}

//----------------------------------------------------------------------- 

void AliFlowLYZHist1::Fill(Double_t f, TComplex c)
{
  //fill the histograms

  fHistProReGtheta->Fill(f, c.Re());
  fHistProImGtheta->Fill(f, c.Im());
}

//----------------------------------------------------------------------- 

TH1D* AliFlowLYZHist1::FillGtheta()
{
  //method called in Finish() of AliFlowAnalysisWithLeeYangZeroes
  //fills the fHistGtheta histograms

  Int_t iNbins = fHistGtheta->GetNbinsX();
  for (Int_t bin=1;bin<=iNbins;bin++)
	{
	  //get bincentre of bins in histogram
	  Double_t dRe = fHistProReGtheta->GetBinContent(bin);
	  Double_t dIm = fHistProImGtheta->GetBinContent(bin);
	  TComplex cGtheta(dRe,dIm);
	  //fill fHistGtheta with the modulus squared of cGtheta
	  //to avoid errors when using a merged outputfile use SetBinContent() and not Fill()
	  fHistGtheta->SetBinContent(bin,cGtheta.Rho2());
	  fHistGtheta->SetBinError(bin,0.0);                                             
	}

  return fHistGtheta;
}

//----------------------------------------------------------------------- 

Double_t AliFlowLYZHist1::GetR0()
{
  //find the first minimum of the square of the modulus of Gtheta 

  Int_t iNbins = fHistGtheta->GetNbinsX();
  Double_t dR0 = 0.; 

  for (Int_t b=2;b<iNbins;b++)
    {
      Double_t dG0 = fHistGtheta->GetBinContent(b);
      Double_t dGnext = fHistGtheta->GetBinContent(b+1);
      Double_t dGnextnext = fHistGtheta->GetBinContent(b+2);
      
      if (dGnext > dG0 && dGnextnext > dG0)
	{
	  Double_t dGlast = fHistGtheta->GetBinContent(b-1);
	  Double_t dXlast = fHistGtheta->GetBinCenter(b-1);
	  Double_t dX0 = fHistGtheta->GetBinCenter(b);
	  Double_t dXnext = fHistGtheta->GetBinCenter(b+1);

	  dR0 = dX0 - ((dX0-dXlast)*(dX0-dXlast)*(dG0-dGnext) - (dX0-dXnext)*(dX0-dXnext)*(dG0-dGlast))/
	    (2.*((dX0-dXlast)*(dG0-dGnext) - (dX0-dXnext)*(dG0-dGlast))); //parabolic interpolated minimum
	  
	  break; //stop loop if minimum is found
	} //if

    }//b

      
  return dR0;
}
   
//----------------------------------------------------------------------- 
Double_t AliFlowLYZHist1::GetBinCenter(Int_t i)
{
  //gets bincenter of histogram
  Double_t dR = fHistGtheta->GetBinCenter(i);
  return dR;
}

//----------------------------------------------------------------------- 

Int_t AliFlowLYZHist1::GetNBins()
{
  //gets iNbins
  Int_t iNbins = fHistGtheta->GetNbinsX();
  return iNbins;
}

//----------------------------------------------------------------------- 
 Double_t AliFlowLYZHist1::Merge(TCollection *aList)
{
  //merge fuction
  if (!aList) return 0;
  if (aList->IsEmpty()) return 0; //no merging is needed

  Int_t iCount = 0;
  TIter next(aList); // list is supposed to contain only objects of the same type as this
  AliFlowLYZHist1 *toMerge;
  // make a temporary list
  TList *pTemp = new TList();
  while ((toMerge=(AliFlowLYZHist1*)next())) {
    pTemp->Add(toMerge->GetHistList()); 
    iCount++;
  }
  // Now call merge for fHistList providing temp list
  fHistList->Merge(pTemp);
  // Cleanup
  delete pTemp;
    
  return (double)iCount;
    
}

//----------------------------------------------------------------------- 
void AliFlowLYZHist1::Print(Option_t *option) const
{
  //   -*-*-*-*-*Print some global quantities for this histogram collection class *-*-*-*-*-*-*-*
  //             ===============================================
  //   printf( "TH1.Print Name  = %s, Entries= %d, Total sum= %g\n",GetName(),Int_t(fEntries),GetSumOfWeights());
  printf( "Class.Print Name = %s, Histogram list:\n",GetName());

  if (fHistList) {  
    fHistList->Print(option);
  }
  else
    {
      printf( "Empty histogram list \n");
    }
}

//----------------------------------------------------------------------- 
 void AliFlowLYZHist1::Browse(TBrowser *b)
{

  if (!b) return;
  if (fHistList) b->Add(fHistList,"AliFlowLYZHist1List");
}



 AliFlowLYZHist1.cxx:1
 AliFlowLYZHist1.cxx:2
 AliFlowLYZHist1.cxx:3
 AliFlowLYZHist1.cxx:4
 AliFlowLYZHist1.cxx:5
 AliFlowLYZHist1.cxx:6
 AliFlowLYZHist1.cxx:7
 AliFlowLYZHist1.cxx:8
 AliFlowLYZHist1.cxx:9
 AliFlowLYZHist1.cxx:10
 AliFlowLYZHist1.cxx:11
 AliFlowLYZHist1.cxx:12
 AliFlowLYZHist1.cxx:13
 AliFlowLYZHist1.cxx:14
 AliFlowLYZHist1.cxx:15
 AliFlowLYZHist1.cxx:16
 AliFlowLYZHist1.cxx:17
 AliFlowLYZHist1.cxx:18
 AliFlowLYZHist1.cxx:19
 AliFlowLYZHist1.cxx:20
 AliFlowLYZHist1.cxx:21
 AliFlowLYZHist1.cxx:22
 AliFlowLYZHist1.cxx:23
 AliFlowLYZHist1.cxx:24
 AliFlowLYZHist1.cxx:25
 AliFlowLYZHist1.cxx:26
 AliFlowLYZHist1.cxx:27
 AliFlowLYZHist1.cxx:28
 AliFlowLYZHist1.cxx:29
 AliFlowLYZHist1.cxx:30
 AliFlowLYZHist1.cxx:31
 AliFlowLYZHist1.cxx:32
 AliFlowLYZHist1.cxx:33
 AliFlowLYZHist1.cxx:34
 AliFlowLYZHist1.cxx:35
 AliFlowLYZHist1.cxx:36
 AliFlowLYZHist1.cxx:37
 AliFlowLYZHist1.cxx:38
 AliFlowLYZHist1.cxx:39
 AliFlowLYZHist1.cxx:40
 AliFlowLYZHist1.cxx:41
 AliFlowLYZHist1.cxx:42
 AliFlowLYZHist1.cxx:43
 AliFlowLYZHist1.cxx:44
 AliFlowLYZHist1.cxx:45
 AliFlowLYZHist1.cxx:46
 AliFlowLYZHist1.cxx:47
 AliFlowLYZHist1.cxx:48
 AliFlowLYZHist1.cxx:49
 AliFlowLYZHist1.cxx:50
 AliFlowLYZHist1.cxx:51
 AliFlowLYZHist1.cxx:52
 AliFlowLYZHist1.cxx:53
 AliFlowLYZHist1.cxx:54
 AliFlowLYZHist1.cxx:55
 AliFlowLYZHist1.cxx:56
 AliFlowLYZHist1.cxx:57
 AliFlowLYZHist1.cxx:58
 AliFlowLYZHist1.cxx:59
 AliFlowLYZHist1.cxx:60
 AliFlowLYZHist1.cxx:61
 AliFlowLYZHist1.cxx:62
 AliFlowLYZHist1.cxx:63
 AliFlowLYZHist1.cxx:64
 AliFlowLYZHist1.cxx:65
 AliFlowLYZHist1.cxx:66
 AliFlowLYZHist1.cxx:67
 AliFlowLYZHist1.cxx:68
 AliFlowLYZHist1.cxx:69
 AliFlowLYZHist1.cxx:70
 AliFlowLYZHist1.cxx:71
 AliFlowLYZHist1.cxx:72
 AliFlowLYZHist1.cxx:73
 AliFlowLYZHist1.cxx:74
 AliFlowLYZHist1.cxx:75
 AliFlowLYZHist1.cxx:76
 AliFlowLYZHist1.cxx:77
 AliFlowLYZHist1.cxx:78
 AliFlowLYZHist1.cxx:79
 AliFlowLYZHist1.cxx:80
 AliFlowLYZHist1.cxx:81
 AliFlowLYZHist1.cxx:82
 AliFlowLYZHist1.cxx:83
 AliFlowLYZHist1.cxx:84
 AliFlowLYZHist1.cxx:85
 AliFlowLYZHist1.cxx:86
 AliFlowLYZHist1.cxx:87
 AliFlowLYZHist1.cxx:88
 AliFlowLYZHist1.cxx:89
 AliFlowLYZHist1.cxx:90
 AliFlowLYZHist1.cxx:91
 AliFlowLYZHist1.cxx:92
 AliFlowLYZHist1.cxx:93
 AliFlowLYZHist1.cxx:94
 AliFlowLYZHist1.cxx:95
 AliFlowLYZHist1.cxx:96
 AliFlowLYZHist1.cxx:97
 AliFlowLYZHist1.cxx:98
 AliFlowLYZHist1.cxx:99
 AliFlowLYZHist1.cxx:100
 AliFlowLYZHist1.cxx:101
 AliFlowLYZHist1.cxx:102
 AliFlowLYZHist1.cxx:103
 AliFlowLYZHist1.cxx:104
 AliFlowLYZHist1.cxx:105
 AliFlowLYZHist1.cxx:106
 AliFlowLYZHist1.cxx:107
 AliFlowLYZHist1.cxx:108
 AliFlowLYZHist1.cxx:109
 AliFlowLYZHist1.cxx:110
 AliFlowLYZHist1.cxx:111
 AliFlowLYZHist1.cxx:112
 AliFlowLYZHist1.cxx:113
 AliFlowLYZHist1.cxx:114
 AliFlowLYZHist1.cxx:115
 AliFlowLYZHist1.cxx:116
 AliFlowLYZHist1.cxx:117
 AliFlowLYZHist1.cxx:118
 AliFlowLYZHist1.cxx:119
 AliFlowLYZHist1.cxx:120
 AliFlowLYZHist1.cxx:121
 AliFlowLYZHist1.cxx:122
 AliFlowLYZHist1.cxx:123
 AliFlowLYZHist1.cxx:124
 AliFlowLYZHist1.cxx:125
 AliFlowLYZHist1.cxx:126
 AliFlowLYZHist1.cxx:127
 AliFlowLYZHist1.cxx:128
 AliFlowLYZHist1.cxx:129
 AliFlowLYZHist1.cxx:130
 AliFlowLYZHist1.cxx:131
 AliFlowLYZHist1.cxx:132
 AliFlowLYZHist1.cxx:133
 AliFlowLYZHist1.cxx:134
 AliFlowLYZHist1.cxx:135
 AliFlowLYZHist1.cxx:136
 AliFlowLYZHist1.cxx:137
 AliFlowLYZHist1.cxx:138
 AliFlowLYZHist1.cxx:139
 AliFlowLYZHist1.cxx:140
 AliFlowLYZHist1.cxx:141
 AliFlowLYZHist1.cxx:142
 AliFlowLYZHist1.cxx:143
 AliFlowLYZHist1.cxx:144
 AliFlowLYZHist1.cxx:145
 AliFlowLYZHist1.cxx:146
 AliFlowLYZHist1.cxx:147
 AliFlowLYZHist1.cxx:148
 AliFlowLYZHist1.cxx:149
 AliFlowLYZHist1.cxx:150
 AliFlowLYZHist1.cxx:151
 AliFlowLYZHist1.cxx:152
 AliFlowLYZHist1.cxx:153
 AliFlowLYZHist1.cxx:154
 AliFlowLYZHist1.cxx:155
 AliFlowLYZHist1.cxx:156
 AliFlowLYZHist1.cxx:157
 AliFlowLYZHist1.cxx:158
 AliFlowLYZHist1.cxx:159
 AliFlowLYZHist1.cxx:160
 AliFlowLYZHist1.cxx:161
 AliFlowLYZHist1.cxx:162
 AliFlowLYZHist1.cxx:163
 AliFlowLYZHist1.cxx:164
 AliFlowLYZHist1.cxx:165
 AliFlowLYZHist1.cxx:166
 AliFlowLYZHist1.cxx:167
 AliFlowLYZHist1.cxx:168
 AliFlowLYZHist1.cxx:169
 AliFlowLYZHist1.cxx:170
 AliFlowLYZHist1.cxx:171
 AliFlowLYZHist1.cxx:172
 AliFlowLYZHist1.cxx:173
 AliFlowLYZHist1.cxx:174
 AliFlowLYZHist1.cxx:175
 AliFlowLYZHist1.cxx:176
 AliFlowLYZHist1.cxx:177
 AliFlowLYZHist1.cxx:178
 AliFlowLYZHist1.cxx:179
 AliFlowLYZHist1.cxx:180
 AliFlowLYZHist1.cxx:181
 AliFlowLYZHist1.cxx:182
 AliFlowLYZHist1.cxx:183
 AliFlowLYZHist1.cxx:184
 AliFlowLYZHist1.cxx:185
 AliFlowLYZHist1.cxx:186
 AliFlowLYZHist1.cxx:187
 AliFlowLYZHist1.cxx:188
 AliFlowLYZHist1.cxx:189
 AliFlowLYZHist1.cxx:190
 AliFlowLYZHist1.cxx:191
 AliFlowLYZHist1.cxx:192
 AliFlowLYZHist1.cxx:193
 AliFlowLYZHist1.cxx:194
 AliFlowLYZHist1.cxx:195
 AliFlowLYZHist1.cxx:196
 AliFlowLYZHist1.cxx:197
 AliFlowLYZHist1.cxx:198
 AliFlowLYZHist1.cxx:199
 AliFlowLYZHist1.cxx:200
 AliFlowLYZHist1.cxx:201
 AliFlowLYZHist1.cxx:202
 AliFlowLYZHist1.cxx:203
 AliFlowLYZHist1.cxx:204
 AliFlowLYZHist1.cxx:205
 AliFlowLYZHist1.cxx:206
 AliFlowLYZHist1.cxx:207
 AliFlowLYZHist1.cxx:208
 AliFlowLYZHist1.cxx:209
 AliFlowLYZHist1.cxx:210
 AliFlowLYZHist1.cxx:211
 AliFlowLYZHist1.cxx:212
 AliFlowLYZHist1.cxx:213
 AliFlowLYZHist1.cxx:214
 AliFlowLYZHist1.cxx:215
 AliFlowLYZHist1.cxx:216
 AliFlowLYZHist1.cxx:217
 AliFlowLYZHist1.cxx:218
 AliFlowLYZHist1.cxx:219
 AliFlowLYZHist1.cxx:220
 AliFlowLYZHist1.cxx:221
 AliFlowLYZHist1.cxx:222
 AliFlowLYZHist1.cxx:223
 AliFlowLYZHist1.cxx:224
 AliFlowLYZHist1.cxx:225
 AliFlowLYZHist1.cxx:226
 AliFlowLYZHist1.cxx:227
 AliFlowLYZHist1.cxx:228
 AliFlowLYZHist1.cxx:229
 AliFlowLYZHist1.cxx:230
 AliFlowLYZHist1.cxx:231
 AliFlowLYZHist1.cxx:232
 AliFlowLYZHist1.cxx:233
 AliFlowLYZHist1.cxx:234
 AliFlowLYZHist1.cxx:235
 AliFlowLYZHist1.cxx:236
 AliFlowLYZHist1.cxx:237
 AliFlowLYZHist1.cxx:238
 AliFlowLYZHist1.cxx:239
 AliFlowLYZHist1.cxx:240
 AliFlowLYZHist1.cxx:241
 AliFlowLYZHist1.cxx:242
 AliFlowLYZHist1.cxx:243
 AliFlowLYZHist1.cxx:244
 AliFlowLYZHist1.cxx:245
 AliFlowLYZHist1.cxx:246
 AliFlowLYZHist1.cxx:247
 AliFlowLYZHist1.cxx:248
 AliFlowLYZHist1.cxx:249
 AliFlowLYZHist1.cxx:250