StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Pileup.h
1 /**********************************************************************
2  *
3  * $Id: Pileup.h,v 1.2 2011/02/12 00:07:04 prindle Exp $
4  *
5  * Author: Duncan Prindle
6  *
7  **********************************************************************
8  *
9  * Description: Using first/last points on tracks characterize event vertex structure.
10  * An event, meaning the TPC readout for a trigger, can have multiple vertices.
11  * Usually only one of these will be `good', although it is possible for two (or more)
12  * collisions on the same beam crossing.
13  *
14  *
15  *
16  * Probably you want to make a Pileup object at the beginning of your job and call
17  * int nearest(StMuDst *muDst, double z, double *dist, int *mult);
18  * for each event.
19  * Inputs are:
20  * muDst pointer to the StMuDst object containing the event
21  * z Usually the z position of the primary vertex of interest.
22  * Output arguments are:
23  * dist Distance from z to the nearest pileup vertex (if a pileup is found).
24  * mult Multiplicity associated with this pileup vertex.
25  * Method returns the number of pileup vertices found.
26  *
27  * I usually reject events with fabs(z) < 20cm. If you keep a histogram of z you can
28  * estimate how many good events you rejected, and for 20cm this is usually a small fraction.
29  *
30  *
31  *
32  *
33  * We flag vertices with seven possible meanings (in flag).
34  * 1) Found vertex in +Z and -Z at same point. Probably good.
35  * Which = 1 -> Average position(z), sum of tracks (n).
36  * 2 -> Position determined by +Z TPC (z), tracks in +Z TPC (n), width of +Z TPC peak (width)
37  * 3 -> Position determined by -Z TPC (z), tracks in -Z TPC (n), width of -Z TPC peak (width)
38  * 4 -> Difference between +Z TPC and -Z TPC (z).
39  * 2) Offset +Z, -Z vertex matches distance expected for pre pileup
40  * Which = 1 -> Average position (should be actual vertex position), sum of tracks.
41  * 2 -> Apparent position determined by +Z TPC, tracks in +Z TPC
42  * 3 -> Apparent position determined by -Z TPC, tracks in -Z TPC
43  * 4 -> Distance between vertices minus expected distance
44  * 3) Offset +Z, -Z vertex matches distance expected for post pileup
45  * Which : Same meanings as for 2)
46  * 4) Expected pre pileup. Found vertex with mFlag=1 is consistent with pre pileup.
47  * Which = 1 -> Position of `good' vertex, number of `good tracks.
48  * 2 -> Position of pileup vertex, number of pileup tracks.
49  * 3 -> Distance between vertices minus expected pre pileup distance
50  * 4 -> Expected position of pileup near good vertex.
51  * 5) Expected post pileup. Found vertex with mFlag=1 is consistent with post pileup.
52  * Which = 1 -> Position of `good' vertex, number of `good tracks.
53  * 2 -> Position of pileup vertex, number of pileup tracks.
54  * 3 -> Distance between vertices minus expected post pileup distance
55  * 4 -> Expected position of pileup near good vertex.
56  * 6) Have two vertices left over that could be pre or post pileup, but don't match expected distance.
57  * Which = 1 -> Average position, sum of tracks
58  * 2 -> Position of first vertex, number of first tracks.
59  * 3 -> Position of second vertex, number of second tracks.
60  * 7) Vertex left over which doesn't match another pileup candidate
61  * Which = 1 -> Position of vertex, number of tracks.
62  *
63  * Note: When we find a peak we determine the position as the weighted mean of bins in the peak.
64  * If there is only one bin then the positions will be quantized to the size of our
65  * internal histograms, currently 1cm.
66  **********************************************************************/
67 
68 #ifndef _Pileup
69 #define _Pileup
70 
71 #include "StMuDSTMaker/COMMON/StMuEvent.h"
72 #include "StMuDSTMaker/COMMON/StMuTrack.h"
73 #include "TH1D.h"
74 #include "TH2D.h"
75 #include "Stiostream.h"
76 
77 class TH1F;
78 
79 class Pileup : public TObject {
80 
81  private:
82  TH1D *mHPileup[6];
83  TH1D *mHQA1D[3];
84  TH2D *mHQA2D[3];
85  StMuDst *mMuDst;
86  double mDead[7];
87  double mZEndplate;
88  double mZStartStopMatchMin;
89  double mZStartStopMatchMax;
90  double mZPileMatchMin;
91  double mZPileMatchMax;
92  double mZPeakMatchMin;
93  double mZPeakMatchMax;
94  int mFlag[10];
95  int mVerbose;
96 
97  public:
98  Pileup();
99  virtual ~Pileup();
100  int mNVerts;
101 
102  // Given position z find nearest vertex identified as pileup.
103  // Return distance to that vertex and its multiplicity in arguments.
104  // Return total number of pileup vertices found in this event.
105  int nearest(StMuDst *muDst, double z, double *dist, int *mult);
106 
107  int find(StMuDst *muDst);
108  int findPeaks(int ih);
109  int testFindPeaks(TH1D *h, int ih);
110  TH1D* lowPass(TH1D *h, int width);
111  int findPiles();
112  double z(int iv, int which = 1);
113  int n(int iv, int which = 1);
114  int flag(int iv);
115  int fillHistos(StMuDst *muDst);
116  int fillQAHistos(StMuDst *muDst);
117  TH1D *hist(int ih);
118  TH1D *histQA1D(int ih);
119  TH2D *histQA2D(int ih);
120  int verbose();
121  void verbose(int val);
122  double zEndplate();
123  void zEndplate(double val);
124  double zStartStopMatchMin();
125  void zStartStopMatchMin(double val);
126  double zPileMatchMin();
127  void zPileMatchMin(double val);
128  double zPeakMatchMin();
129  void zPeakMatchMin(double val);
130  double zStartStopMatchMax();
131  void zStartStopMatchMax(double val);
132  double zPileMatchMax();
133  void zPileMatchMax(double val);
134  double zPeakMatchMax();
135  void zPeakMatchMax(double val);
136  double dead(int ih);
137  void dead(int ih, double dead);
138 
139  // Some "private" stuff I don't want to write accessor functions for.
140  // Useful for optimizing code.
141  // Allow up to 5 peaks in each of the pileup histograms.
142  int mNPeaks[6];
143  double mPos[6][5];
144  double mArea[6][5];
145  double mWidth[6][5];
146  // Allow as many as 10 pileup candidates. Why ten?
147  int mNPiles;
148  double mPileDist[10];
149  int mPileFlag[10];
150  // Each of + and - vertex histograms can have at most 5 peaks.
151  int mMatchM[5];
152  int mMatchP[5];
153  int mUsedM[5];
154  int mUsedP[5];
155  // Combined we allow ten vertex candidates.
156  double mVerts[10][5];
157 
158  ClassDef(Pileup,1)
159 };
160 
161 
162 
163 #endif
164 
165 
166 /**********************************************************************
167  *
168  * $Log: Pileup.h,v $
169  * Revision 1.2 2011/02/12 00:07:04 prindle
170  * Just changed comments. Hopefully it is understandble how to use the package
171  * just from the comments now.
172  *
173  * Revision 1.1 2008/12/02 23:47:44 prindle
174  * Code to check for possible pileup. Really belongs in some vertex finding
175  * package but is here for now.
176  *
177  * initial check in of Pileup characterizer
178  *
179  *
180  *********************************************************************/
Definition: Pileup.h:79