Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpFinder.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EpFinder.h
1 #ifndef _EpFinder
2 #define _EpFinder
3 
4 class TVector3;
5 class TFile;
6 class TProfile;
7 class TProfile2D;
8 
9 #include "TH2D.h"
10 #include "TVector3.h"
11 #include "EpInfo.h"
12 #include <vector>
13 #include <utility>
14 
15 /*************************************
16  * \author Mike Lisa
17  * \date 23 June 2018
18  *
19  * adjusted for sPHENIX by J. Lajoie
20  * 24 August 2019
21  *
22  * \description:
23  * Finds the Event Plane (EP) and EP-related quantities.
24  * Also creates correction files and applies them.
25  * Also calculates resolution
26  *
27  * There is a lot of EP-related information. Raw, phi-weighted, shifted, etc.
28  * 1st, 2nd, nth order. Q-vector and Psi. Even if the user does not request
29  * all of these things, it is convenient and not so wasteful to simply calculate
30  * them all at once. Therefore, the user is presented with a large object of
31  * type StEpdEpInfo. This avoids "calculate-it-on-the-fly" which can be wasteful
32  * if the user requests more than one thing, as well as "has-it-already-been-calculated?"
33  * ambiguities.
34  *
35  * A word about "EventType": the correction factors and other things about the event
36  * plane can depend on centrality, vertex position, etc. This code will apply the
37  * corrections separately for different "EventTypes". It is up to the user to decide
38  * what this denotes. All I care about is that when you send me an event, you tell
39  * me the EventTypeId, which is just an integer. The rest is up to you (as it should be :).
40  * For many (most?) people, this will just be a centrality index.
41  *
42  * This class will do "phi-weighting" and "shifting" corrections, but it needs
43  * some information to do it. It will generate such information itself, but
44  * here is what you need to do, if you are starting from scratch:
45  * 1) With whatever multiplicity/Vz/whatever event cuts you are going to analyze, and
46  * on whatever dataset, run your code that calls this class. This will produce
47  * a file called EpFinderCorrectionHistograms_OUTPUT.root in the cwd.
48  * --> mv EpFinderCorrectionHistograms_OUTPUT.root EpFinderCorrectionHistos_INPUT.root
49  * That takes care of the Phi-weighting
50  * 2) Repeat the above step (including the rename of the file, overwriting the old one).
51  * That takes care of the shifting weights.
52  * 3) You are good to go.
53  *
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 EpFinder and created by EpFinder.
61  * This code creates a histogram with the root name
62  * "PhiWeight"
63  * x-axis and y-axis are USER DEFINED IN THE EpFinder constructor.
64  * The user has no direct interaction with this histogram.
65  *
66  * 2) Shifting correction. Used by EpFinder and created by EpFinder.
67  * This implements equation (6) of arxiv:nucl-ex/9805001
68  * The histogram names are
69  * - Form("EpdShiftdPsi%d_sin",ew,order)
70  * - Form("EpdShiftdPsi%d_cos",ew,order)
71  * - Form("EpdShiftFullEventPsi%d_sin",order)
72  * - Form("EpdShiftFullEventPsi%d_cos",order)
73  * In these histograms, order is "n" (as in n=2 for second-order EP)
74  * x-axis is "i" from equation (6) above. As in <cos(n*i*Psi_n)>
75  * There are _EpTermsMax bins running from 0.5 to _EPtermsMax+0.5, so there should be no confusion with this axis.
76  * y-axis is EventTypeId, the *user-defined* EventType bin number.
77  *--------->>>>>>>>>>>>>>>>>> And at this point I must make a demand of the user <<<<<<<<<<<<<<<<<<<
78  * When the user instantiates an EpFinder object, he specifies nEventTypeBins, the number of EventType bins he will use.
79  * >>>> The user MUST number these bins 0,1,2,3,4,...(nEventTypeBins-1) when he interacts with this class <<<<
80  * (If he wants to use a different convention in his code, that's fine, but when talking to EpFinder, use 0..(nEventTypeBins-1)
81  * The y-axis then has nEventTypeBins bins, going from -0.5 to nEventTypeBins-0.5
82  *
83  *************************************/
84 
85 #define _EpTermsMax 6
86 
87 // This is the structure for passing hit information into EpFinder:
88 // nMip : hit weight (energy of number of MIPs, etc.)
89 // ix : detector index in x (user defined)
90 // iy : detector index in y (user defined)
91 // samePhi : pointer is vector of index (ix,iy) pairs for decetor elements in the same phi bin as this hit (NULL is OK)
92 //
93 // ix, iy are USER DEFINED and their range is set in the EpFinder constructor. ix,iy and samePhi are used in the phi weighting correction determination.
94 
95 typedef struct{
96 
97  float nMip;
98  double phi;
99  int ix;
100  int iy;
101  std::vector<std::pair<int,int>> *samePhi;
102 
103 } EpHit;
104 
105 
106 class EpFinder{
107  public:
108 
115  EpFinder(int nEventTypeBins=10, char const* OutFileName="EpFinderCorrectionHistograms_OUTPUT.root", char const* CorrectionFileName="EpFinderCorrectionHistograms_INPUT.root",
116  int pbinsx=1, int pbinsy=1);
117  ~EpFinder(){/* no-op */};
118 
122  void SetnMipThreshold(double thresh){mThresh=thresh;};
123 
127  void SetMaxTileWeight(double MAX){mMax=MAX;};
128 
131  void Finish();
132 
138  EpInfo Results(std::vector<EpHit> *EpdHits, int EventTypeID);
139 
144  TString Report();
145 
146 
147  private:
148 
149  bool OrderOutsideRange(int order); // just makes sure order is between 1 and _EpOrderMax
150 
151  double GetPsiInRange(double Qx, double Qy, int order);
152 
153  int mNumberOfEventTypeBins; // user-defined. Default is 10. Used for correction histograms
154 
155  // tile weight = (0 if ADC< thresh), (MAX if ADC>MAX); (ADC otherwise).
156  double mThresh; // default is 0.3
157  double mMax; // default is 2.0
158 
159  TProfile* mAveCosDeltaPsi[_EpOrderMax]; // average of cos(Psi_{East,n}-Psi_{West,n}) using phi-weighted and shifted EPs
160 
163 
164  // these are shift correction factors that we MAKE now and write out
167  // these are shift correction factors that we made before, and USE now
170  // these are the phi weights
174 
175 };
176 
177 #endif