StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEpdEpFinder.h
1 #ifndef _StEpdEpFinder
2 #define _StEpdEpFinder
3 
4 class TVector3;
5 //class TH2D;
6 class TFile;
7 class TProfile;
8 class TProfile2D;
9 class StEpdGeom;
10 class TClonesArray;
11 
12 #include "TH3D.h"
13 #include "TH2D.h"
14 
15 /*************************************
16  * \author Mike Lisa
17  * \date 23 June 2018
18  *
19  * \description:
20  * Finds the Event Plane (EP) and EP-related quantities.
21  * Also creates correction files and applies them.
22  * Also calculates resolution
23  *
24  * There is a lot of EP-related information. Raw, phi-weighted, shifted, etc.
25  * 1st, 2nd, nth order. Q-vector and Psi. Even if the user does not request
26  * all of these things, it is convenient and not so wasteful to simply calculate
27  * them all at once. Therefore, the user is presented with a large object of
28  * type StEpdEpInfo. This avoids "calculate-it-on-the-fly" which can be wasteful
29  * if the user requests more than one thing, as well as "has-it-already-been-calculated?"
30  * ambiguities.
31  *
32  * A word about "EventType": the correction factors and other things about the event
33  * plane can depend on centrality, vertex position, etc. This code will apply the
34  * corrections separately for different "EventTypes". It is up to the user to decide
35  * what this denotes. All I care about is that when you send me an event, you tell
36  * me the EventTypeId, which is just an integer. The rest is up to you (as it should be :).
37  * For many (most?) people, this will just be a centrality index.
38  *
39  * This class will do "phi-weighting" and "shifting" corrections, but it needs
40  * some information to do it. It will generate such information itself, but
41  * here is what you need to do, if you are starting from scratch:
42  * 1) With whatever multiplicity/Vz/whatever event cuts you are going to analyze, and
43  * on whatever dataset, run your code that calls this class. This will produce
44  * a file called StEpdEpFinderCorrectionHistograms_OUTPUT.root in the cwd.
45  * --> mv StEpdEpFinderCorrectionHistograms_OUTPUT.root StEpdEpFinderCorrectionHistos_INPUT.root
46  * That takes care of the Phi-weighting
47  * 2) Repeat the above step (including the rename of the file, overwriting the old one).
48  * That takes care of the shifting weights.
49  * 3) You are good to go.
50  *
51  * Note that, to find the EP, you can weight a hit according to ring (you enter the ring weights)
52  * or by eta (you enter the eta weights) or (default) treat all hits equally.
53  * See SetRingWeights() and SetEtaWeights()
54  *
55  * ------------------------------------------
56  * This class creates some histograms and uses some histograms. Since I use GetBinContent()
57  * to extract values from the histograms, the binning is important. I try to keep things
58  * consistent, but let me explain.
59  *
60  * 1) Phi Weighting. Used by StEpdEpFinder and created by StEpdEpFinder.
61  * This code creates a histogram with the root name
62  * Form("PhiWeightEW%d",ew) where ew=0/1 for east/west.
63  * x-axis is PP, with 12 bins running from 0.5 to 12.5.
64  * y-axis is TT, with 31 bins running from 0.5 to 31.5
65  * So, there really ought to be no confusion. h->GetBinContent(4,16) gets the bin that was filled by h->Fill(4,16)
66  * Anyway, the user has no interaction with this histogram.
67  *
68  * 2) Shifting correction. Used by StEpdEpFinder and created by StEpdEpFinder.
69  * This implements equation (6) of arxiv:nucl-ex/9805001
70  * The histogram names are
71  * - Form("EpdShiftEW%dPsi%d_sin",ew,order) - where ew=0/1 for east/west
72  * - Form("EpdShiftEW%dPsi%d_cos",ew,order) - where ew=0/1 for east/west
73  * - Form("EpdShiftFullEventPsi%d_sin",order)
74  * - Form("EpdShiftFullEventPsi%d_cos",order)
75  * In these histograms, order is "n" (as in n=2 for second-order EP)
76  * x-axis is "i" from equation (6) above. As in <cos(n*i*Psi_n)>
77  * There are _EpTermsMax bins running from 0.5 to _EPtermsMax+0.5, so there should be no confusion with this axis.
78  * y-axis is EventTypeId, the *user-defined* EventType bin number.
79  *--------->>>>>>>>>>>>>>>>>> And at this point I must make a demand of the user <<<<<<<<<<<<<<<<<<<
80  * When the user instantiates an StEpdEpFinder object, he specifies nEventTypeBins, the number of EventType bins he will use.
81  * >>>> The user MUST number these bins 0,1,2,3,4,...(nEventTypeBins-1) when he interacts with this class <<<<
82  * (If he wants to use a different convention in his code, that's fine, but when taling to StEpdEpFinder, use 0..(nEventTypeBins-1)
83  * The y-axis then has nEventTypeBins bins, going from -0.5 to nEventTypeBins-0.5
84  *
85  * 3) Eta weights. Used (optional) by StEpdEpFinder, but not created by it.
86  * It gives the additional "weight" that a hit gets, and depends on EventType, eta (obviously), and the harmonic order ("n")
87  * x-axis is eta; y-axis is EventTypeID
88  *----->>>>>>>> The user MUST use the same EventType numbering (i.e. integers, starting at zero) as mentioned above.
89  *----->>>>>>>> The first (non-underflow) bin on the x-axis MUST be centered at zero, and the last (non-overflow) bin on the x-axis MUST be centered on nEventTypeBins-1
90  *
91  * 4) Resolution-related histograms. Not used by StEpdEpFinder, but produced by StEpdEpFinder for user convenience.
92  * These are just the simple <cos(n\Psi_{n,E}-n\Psi_{n,W})> values, as a function of EventType ID
93  *
94  *************************************/
95 
96 #define _EpTermsMax 6
97 
98 #include "StEpdEpInfo.h"
99 
101  public:
102 
108  StEpdEpFinder(int nEventTypeBins=10, char const* OutFileName="StEpdEpFinderCorrectionHistograms_OUTPUT.root", char const* CorrectionFileName="StEpdEpFinderCorrectionHistograms_INPUT.root");
109  ~StEpdEpFinder(){/* no-op */};
110 
115  void SetEtaWeights(int order, TH2D EtaWeight);
116 
120  void SetRingWeights(int order, double* RingWeights);
121 
125  void SetnMipThreshold(double thresh);
126 
130  void SetMaxTileWeight(double MAX);
131 
134  void SetEpdHitFormat(int format);
135 
138  void Finish();
139 
145  StEpdEpInfo Results(TClonesArray* EpdHits, TVector3 primVertex, int EventTypeID);
146 
151  TString Report();
152 
153 
154  private:
155 
156  bool OrderOutsideRange(int order); // just makes sure order is between 1 and _EpOrderMax
157 
158  double GetPsiInRange(double Qx, double Qy, int order);
159  double RingOrEtaWeight(int ring, double eta, int order, int EventTypeId);
160  StEpdGeom* mEpdGeom;
161 
162  int mNumberOfEventTypeBins; // user-defined. Default is 10. Used for correction histograms
163  int mFormatUsed; // 0=StEvent, 1=StMuDst; 2=StPicoDst. Default is 2
164 
165  // tile weight = (0 if ADC< thresh), (MAX if ADC>MAX); (ADC otherwise).
166  double mThresh; // default is 0.3
167  double mMax; // default is 2.0
168 
169  int mWeightingScheme; // 0=none; 1=eta-based weighting; 2=ring-based weighting
170  TH2D* mEtaWeights[_EpOrderMax]; // used if mWeightingScheme=1;
171  double mRingWeights[16][_EpOrderMax]; // used if mWeightingScheme=2
172 
173  TProfile* mAveCosDeltaPsi[_EpOrderMax]; // average of cos(Psi_{East,n}-Psi_{West,n}) using phi-weighted and shifted EPs
174 
175  TFile* mCorrectionInputFile;
176  TFile* mCorrectionOutputFile;
177  TFile* mResolutionOutputFile;
178 
179  // these are shift correction factors that we MAKE now and write out
180  TProfile2D* mEpdShiftOutput_sin[3][_EpOrderMax]; // [ewFull][order-1]
181  TProfile2D* mEpdShiftOutput_cos[3][_EpOrderMax]; // [ewFull][order-1]
182  // these are shift correction factors that we made before, and USE now
183  TProfile2D* mEpdShiftInput_sin[3][_EpOrderMax]; // [ewFull][order-1]
184  TProfile2D* mEpdShiftInput_cos[3][_EpOrderMax]; // [ewFull][order-1]
185  // these are the phi weights
186  TH3D* mPhiWeightInput[2]; // 12aug2019 - MAL has changed these from TH2D* to TH3D* to include EventType.
187  TH3D* mPhiWeightOutput[2]; // the array index is 0/1 for East/West as usual
188  TH3D* mPhiAveraged[2]; // the bins are (PP,TT,EventType)
189 
190 
191 
192  ClassDef(StEpdEpFinder,0)
193 
194 };
195 
196 inline void StEpdEpFinder::SetnMipThreshold(double t){mThresh=t;}
197 inline void StEpdEpFinder::SetMaxTileWeight(double MAX){mMax=MAX;}
198 inline void StEpdEpFinder::SetEpdHitFormat(int f){mFormatUsed=f;}
199 
200 #endif
void SetMaxTileWeight(double MAX)
TString Report()
void SetEtaWeights(int order, TH2D EtaWeight)
void SetnMipThreshold(double thresh)
void SetEpdHitFormat(int format)
StEpdEpInfo Results(TClonesArray *EpdHits, TVector3 primVertex, int EventTypeID)
void SetRingWeights(int order, double *RingWeights)
StEpdEpFinder(int nEventTypeBins=10, char const *OutFileName="StEpdEpFinderCorrectionHistograms_OUTPUT.root", char const *CorrectionFileName="StEpdEpFinderCorrectionHistograms_INPUT.root")