StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructSupport.h
1 /**********************************************************************
2  *
3  * $Id: StEStructSupport.h,v 1.19 2011/08/02 20:42:24 prindle Exp $
4  *
5  * Author: Jeff Porter
6  *
7  **********************************************************************
8  *
9  * Description: Simple helper class for calculating
10  * delta-rho, delta-rho/rho, and delta-rho/sqrt(rho)
11  * plus some other goodies
12  *
13  ***********************************************************************/
14 #ifndef __STESTRUCTSUPPORT__H
15 #define __STESTRUCTSUPPORT__H
16 
17 #include "TROOT.h"
18 
19 class TH1;
20 class TH2;
21 class TH1D;
22 class TH2D;
23 class TFile;
24 
25 class StEStructSupport : public TObject {
26 
27 public:
28 
29  TFile* mtf;
30  float* mnpairs;
31  int mbgMode;
32  int mNumZBins;
33  char* mtmpString;
34  bool mapplyDEtaFix;
35  bool msilent;
36  bool mDoSymmetrize;
37  bool mPairNormalization;
38  bool mPairWeighting;
39  bool mIdenticalPair;
40  bool mYtYtNormalization;
41  bool mYtYtVolumeNormalization;
42 
43  bool goodName(const char* name); // test if name is one of ours
44  bool goodName_zBuf(const char* name, int zBin); // test if name is one of ours with zBuffer.
45  char* getFrontName(int itype);
46  const char* getTypeName(int itype);
47  const char* getChargeSignName(int ics);
48  char* prepend(const char* name, const char* s1);
49  char* swapIn(const char* name, const char* s1, const char* s2);
50  void rescale(TH2D** hists);
51  void rescale(TH2D** hists, int zBin);
52  void rescalePt(TH2D** hists, int zBin);
53  void setSymmetrizeUS(bool symm);
54  void symmetrizeUS(const char *name, TH2D** histos);
55  void symmetrizePtUS(const char *name, TH2D** histos);
56 
57  StEStructSupport() {};
58 
59  StEStructSupport(TFile* tf, int bgmode, float* npairs=0);
60  virtual ~StEStructSupport();
61  void setTFile(TFile* tf);
62  void setBGMode( int mode);
63  void setApplyDEtaFix();
64  void unsetApplyDEtaFix(); // default
65  bool applyDEtaFix();
66  void setSilent();
67  void unsetSilent();
68  bool silent();
69 
70  int getNZBins();
71  float *getCommonNumber(int zBin);
72  float *getCommonPairs(int zBin);
73  float *getChargeNumber(int zBin);
74  float *getChargePairs(int zBin);
75 
76  double getCIdNdEtadPhi();
77  double *getd2NdEtadPhi(int zBin, bool include2s=true);
78  double *getScaleFactors();
79  double *getScaleFactors(int zBin);
80  double *getptHat();
81  double *getptHat(int zBin);
82  int histogramExists(const char* name, int zBin);
83  TH2D** getHists(const char* name, int zBin);
84  TH2D** getLocalClones(const char* name, int zBin);
85  TH2D** getPtHists(const char* name, int zBin);
86  TH2D** getPtClones(const char* name, int zBin);
87  float* getNorms(TH2D** histArray);
88  double getRatio(int iCombo, int zBin);
89 
90  // ++, +-, -+, --
91  TH2D** buildCommonRatios(const char* name, float* sf=0);
92  TH2D** buildCommonRatios(const char* name, float* sf, int zBin);
93  TH2D** buildCommonCFunctions(const char* name, float* sf=0);
94  TH2D** buildCommonCFunctions(const char* name, float* sf, int zBin);
95  TH2D** buildCommonRFunctions(const char* name, float* sf=0);
96  TH2D** buildCommonRFunctions(const char* name, float* sf, int zBin);
97  TH2D** buildCommon(const char* name, int opt=2, float* sf=0);
98  TH2D** buildCommon(const char* name, int opt, float* sf, int zBin);
99  TH2D** buildPtCommon(const char* name, int opt=2, int subtract=1);
100  TH2D** buildPtCommon(const char* name, int opt, int subtract, int zBin);
101 
102  // LS, US, CD, CI
103  TH2D** buildChargeTypeRatios(const char* name, float* sf=0);
104  TH2D** buildChargeTypeRatios(const char* name, float* sf, int zBin);
105  TH2D** buildChargeTypeCFunctions(const char* name, float* sf=0);
106  TH2D** buildChargeTypeCFunctions(const char* name, float* sf, int zBin);
107  TH2D** buildChargeTypeRFunctions(const char* name, float* sf=0);
108  TH2D** buildChargeTypeRFunctions(const char* name, float* sf, int zBin);
109  TH2D** buildChargeTypes(const char* name, int opt=2, float* sf=0);
110  TH2D** buildChargeTypes(const char* name, int opt, float* sf, int zBin);
111  TH2D** buildPtChargeTypes(const char* name, int opt=2, int subtract=1);
112  TH2D** buildPtChargeTypes(const char* name, int opt, int subtract, int zBin);
113 
114  TH2D** buildChargeTypesSumOfRatios(const char* name, int opt, float* sf=0);
115  TH2D** buildChargeTypesSumOfRatios(const char* name, int opt, float* sf, int zBin);
116 
117  void scaleBackGround(TH2D* sib, TH2D* mix, float sf=0);
118  void fixDEtaGeometric(TH2** h, int numHists); // correct triangle in hists with DEta
119  void fixDEta(TH2** h, int numHists); // tries to do an acceptance correction
120 
121  // helper for writing ascii dump of set a of histograms to file=fname
122  void writeAscii(TH2D** h, int numHists, const char* fname, int optErrors);
123 
124  ClassDef(StEStructSupport,1)
125 };
126 
127 inline void StEStructSupport::setTFile(TFile* tf){
128  mtf=tf;
129  getNZBins();
130 };
131 inline void StEStructSupport::setBGMode(int mode){ mbgMode=mode; };
132 inline void StEStructSupport::setApplyDEtaFix() { mapplyDEtaFix=true; };
133 inline void StEStructSupport::unsetApplyDEtaFix(){ mapplyDEtaFix=false; };
134 inline bool StEStructSupport::applyDEtaFix() { return mapplyDEtaFix; };
135 inline void StEStructSupport::setSilent() { msilent=true; };
136 inline void StEStructSupport::unsetSilent(){ msilent=false; };
137 inline bool StEStructSupport::silent() { return msilent; };
138 
139 #endif
140 
141 /***********************************************************************
142  *
143  * $Log: StEStructSupport.h,v $
144  * Revision 1.19 2011/08/02 20:42:24 prindle
145  * Added YtYtVolumeNormalization.
146  * Fixed calculation of error for YtYt \Delta\rho/sqrt(\rho_{ref})
147  * Added error calculation for p_t histograms
148  * Added warning when either \rho_{sib} or \rho_{ref} has an empty bin. Set ratio
149  * bin to 0 instead of -1.
150  *
151  * Revision 1.18 2010/09/02 21:31:14 prindle
152  * Support: Can't find evidence that YtYt correlation depends on z vertex.
153  * Add numerators and denominators then take ratio. Need a new
154  * rescale method independent of z bin. Looks like we can normalize
155  * mixed so \int{sib/mix} = number of bins (what we have recently been
156  * doing) or \int{sib} = \int{mix} and the former is more snesitive
157  * to bins with very few counts. That isn't important for angular
158  * histograms but is for (yt,yt). I am calling the \int{sib} = \int(mix}
159  * Yt normalization (even though it is what we did long ago).
160  *
161  * Revision 1.17 2010/06/23 22:33:56 prindle
162  * In HAdd we distinguish between the parent distributions of the
163  * two particles.
164  * In Support I fixed a number of problems in the Pt correlation section.
165  *
166  * Revision 1.16 2010/03/02 21:48:30 prindle
167  * Fix addDensities (for checking pair cuts)
168  * Lots of small changes
169  *
170  * Revision 1.15 2009/07/29 21:47:47 dkettler
171  * New weighting for z bins
172  *
173  * Revision 1.14 2009/05/08 00:21:42 prindle
174  * In StEStructHadd remove support for old style of histogram names, do a better job calculating
175  * errors (at least for number (\eta_\Delta,\phi_\Delta) histograms), double bins which
176  * have an edge in the center (purely cosmetic when looking at intermediate histograms).
177  * In StEStructSupport check for existance of histograms and return gracefully.
178  * Code in buildChargeTypes and buildPtChargeTypes was essentially duplicate of code
179  * in buildCommon and buildPtCommon so I refactored to reduce redundancy.
180  *
181  * Revision 1.13 2008/12/02 23:52:53 prindle
182  * Get information about histogram XX being symmetrized from CutBin.
183  * Changed TH1* to TH2D* in many places hoping to be able to plot DEtaDPhi
184  * as colz (doesn't work yet).
185  * Added direct calculation of \Delta\rho/\rho_{ref} (and similar) which is
186  * needed for YtYt correlations.
187  *
188  * Revision 1.12 2008/03/19 22:08:39 prindle
189  * Use GetObject instead of Get for type safety. Stop deleting objects we didn't create.
190  * Treat \Delta\rho = d^2n/dEtadphi (rho - rho_ref)/rho_ref as basic unit when combining
191  * centralities and z bins.
192  *
193  * This code should be check in more detail before being completely relied upon.
194  *
195  * Revision 1.11 2007/11/26 20:07:20 prindle
196  * Modified to average \Delta\rho/sqrt(\rho) over z-bins (if more than one z-bin
197  * present for given centrality. Note: I weight by number of tracks, not number of
198  * pairs. This is important when we are also combining different centralities (which
199  * I do by combining centrality tag with z-bin tag in macro/addCentralities.)
200  *
201  * Scale mixed histograms by number of events. Integral of \Delta\rho need not be 0.
202  *
203  * delete items that are created and valgrind complained were lost. (Not a big deal
204  * since macro is run once)
205  *
206  * [Still need to commit StEStructHAdd.cxx which cvs complained that check-update failed.]
207  *
208  * Revision 1.10 2007/05/27 22:46:02 msd
209  * Added buildChargeTypes mode 3 which takes rho_ref from track counts.
210  * Added buildChargeTypeSumOfRatios.
211  *
212  * Revision 1.9 2007/01/26 17:20:59 msd
213  * Updated HAdd for new binning scheme.
214  * Improved Support::buildChargeTypes.
215  *
216  * Revision 1.8 2006/12/14 20:07:15 prindle
217  * I was calculating \Delta\rho/sqrt(rho) for ++, +-, -+ and --
218  * and then combining those into LS, US, CD and CI. The was wrong
219  * and now I am doing it correctly. For CI this makes only a slight
220  * change, it seems the amplitude is decreased a little. For CD
221  * this is a bigger change. I left the old versions (with _Old appended)
222  * for now.
223  *
224  * Revision 1.7 2006/10/02 22:26:53 prindle
225  * Hadd now symmetrizes histograms while adding them, so output is usable
226  * in Support as before. Need to load library for Correlation so we know
227  * how many bins there are.
228  * Added alternative versions of methods to calculate Delta\sigma^2.
229  * Important for pt correlations where we need proper normalization before
230  * subtracting mixed reference.
231  *
232  * Revision 1.6 2006/04/06 01:09:50 prindle
233  * Calculating pt for each cut bin caused changes in HAdd.
234  * The splitting of +- into +- and -+ caused changes in Support.
235  *
236  * Revision 1.5 2006/04/04 22:14:10 porter
237  * fixdeta is now NOT default but included in StEStruct2ptCorrelations
238  *
239  * Revision 1.4 2005/09/07 20:26:18 prindle
240  *
241  *
242  * Support: Fixed some meory leaks.
243  *
244  * Revision 1.3 2005/03/08 21:56:42 porter
245  * fixed bug in StEStructHAdd.cxx and added diagnostic option in ptcorrelations to
246  * view individual terms separately
247  *
248  * Revision 1.2 2005/03/03 01:33:05 porter
249  * Added pt-correlations method to support and included
250  * these histograms to the HAdd routine
251  *
252  * Revision 1.1 2004/07/01 00:37:17 porter
253  * new code previously my StEStructHelper. Takes hists from correltation
254  * pass and builds final ressults. Also the StEStructHAdd.h is a simple
255  * replacemnt for my sumyt.C macro which could be expanded later as needed.
256  *
257  *
258  *
259  *********************************************************************/
260 
261 
262 
int mbgMode
for normalization comparing different cuts