StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcMixQAMaker.cxx
1 #include "StEEmcMixQAMaker.h"
2 #include "StEEmcMixMaker.h"
3 #include "StEEmcPointMaker.h"
4 #include "TH1F.h"
5 #include "TH2F.h"
6 #include <stdio.h>
7 #include <iostream>
8 
9 ClassImp(StEEmcMixQAMaker);
10 
11 // ----------------------------------------------------------------------------
12 StEEmcMixQAMaker::StEEmcMixQAMaker(const Char_t *name):StMaker(name)
13 {
14 
16  maxPerSector = 100; // eg no cut
17  maxPerEvent = 100; // eg no cut
18  maxPerCluster = 2; // default number of points associated with 6-18 towers
19  // which make up the pi0 candidate's energy
20 
21  zVertexMin=-150.0;
22  zVertexMax= 50.0;
23 
25  mBins.push_back(0.);
26  mBins.push_back(1.0);
27  mBins.push_back(2.0);
28  mBins.push_back(3.0);
29  mBins.push_back(4.0);
30  mBins.push_back(6.0);
31  mBins.push_back(8.0);
32  mBins.push_back(10.0);
33  mBins.push_back(15.0);
34  mBins.push_back(20.0);
35  mBins.push_back(200.0);
36 
37  mBackground = false;
38 
39 }
40 
41 // ----------------------------------------------------------------------------
43 {
44 
45 
46  hNcandidates = new TH1F("hNcandidates","Number of pairs",30,0.,30.);
47 
48  hMassRall=new TH1F("hMassRall","Dipoint invariant mass, integrated",360,0.,3.6);
49  hZvertexRall=new TH1F("hZvertexRall","Event vertex",150,-150.,150.);
50 
52  for ( Int_t sec=0;sec<13;sec++ )
53  {
54  TString name="hYXpair";name+=sec+1;
55  TString title="Y vs X [cm] of stable pi0, sector ";title+=sec+1;
56  hYXpair.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
57  name="hYXhigh";name+=sec+1;
58  title="Y vs X [cm] of higher energy gamma, sector ";title+=sec+1;
59  hYXhigh.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
60  name.ReplaceAll("high","low");
61  title.ReplaceAll("high","low");
62  hYXlow.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
63  name="hE1E2sec";name+=sec+1;
64  title="Energy point1 vs Energy point2 [GeV], sector ";title+=sec+1;
65  hE1E2.push_back(new TH2F(name,title,100,0.,50.,100,0.,50.));
66  }
67 
68 
69 
71  for ( Int_t sec=0;sec<13;sec++ )
72  {
73 
75  std::vector<TH1F *> tmp;
76  hMassR.push_back( tmp );
77  hZvertexR.push_back( tmp );
78  hZggR.push_back( tmp );
79  hPhiggR.push_back( tmp );
80  hEnergyR.push_back( tmp );
81 
82  TString sec_name = "-sec";sec_name+=sec+1;
83  for ( UInt_t ptbin=0;ptbin<mBins.size()-1;ptbin++ )
84  {
85 
86  TString bin_name = "-bin";bin_name+=ptbin;
87 
88  TString hname="hMassR";hname+=sec_name;hname+=bin_name;
89  TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
90  htitle+=", ptbin="; htitle+=(Int_t)ptbin;
91  hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.60) );
92 
93  hname="hZvertexR";hname+=sec_name;hname+=bin_name;
94  htitle="Event vertex";htitle+=sec+1;
95  htitle+=", ptbin="; htitle+=(Int_t)ptbin;
96  hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
97 
98  hname="hZggR";hname+=sec_name;hname+=bin_name;
99  htitle="Zgg = |E1-E2|/E, sector= ";htitle+=sec+1; htitle+=", ptbin=";htitle+=(Int_t)ptbin;
100  hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
101 
102  hname="hPhiggR";hname+=sec_name;hname+=bin_name;
103  htitle="Opening angle, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
104  hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
105 
106  hname="hEnergyR";hname+=sec_name;hname+=bin_name;
107  htitle+="Energy, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
108  hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
109 
110  }
111 
113  TString hname="hMassR";hname+=sec_name;hname+="-unbinned";
114  TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
115  hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.6) );
116 
117  hname="hZvertexR";hname+=sec_name;hname+="-unbinned";
118  htitle="Event vertex, sector=";htitle+=sec+1;
119  hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
120 
121  hname="hZggR";hname+=sec_name;hname+="-unbinned";
122  htitle="Zgg = |E1-E2|/E, sector=";htitle+=sec+1;
123  hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
124 
125  hname="hPhiggR";hname+=sec_name;hname+="-unbinned";
126  htitle="Opening angle, sector=";htitle+=sec+1;
127  hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
128 
129  hname="hEnergyR";hname+=sec_name;hname+="-unbinned";
130  htitle+="Energy, sector=";htitle+=sec+1;
131  hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
132  }
133 
134 
135 
136  return StMaker::Init();
137 }
138 
139 // ----------------------------------------------------------------------------
141 {
142 
146  std::vector< StEEmcPairVec_t > pairs;
147  for ( Int_t sec=0;sec<12;sec++ )
148  {
149  StEEmcPairVec_t tmp;
150  pairs.push_back(tmp);
151  }
152 
153  hNcandidates -> Fill( mEEmixer -> numberOfCandidates() );
154 
155 
159  if ( !mBackground )
160  {
161 
163  if ( mEEmixer -> numberOfCandidates() > maxPerEvent ) return kStOK;
164 
165  for ( Int_t i=0;i<mEEmixer->numberOfCandidates();i++ )
166  {
167 
168  StEEmcPair p = mEEmixer -> candidate(i);
169  pairs[ p.point(0).sector() ].push_back(p);
170 
171  }
172 
173  }
177  else
178  {
179 
181  if ( mEEmixer -> numberOfMixedCandidates() > maxPerEvent ) return kStOK;
182 
183  for ( Int_t i=0;i<mEEmixer->numberOfMixedCandidates();i++ )
184  {
185 
186  StEEmcPair p = mEEmixer -> mixedCandidate(i);
187  pairs[ p.point(0).sector() ].push_back(p);
188 
189  }
190 
191  }
192 
193 
194 
195 
196 
200  for ( UInt_t sec=0;sec<12;sec++ )
201  {
202 
204  if ( pairs[sec].size() > (UInt_t)maxPerSector ) continue;
205 
206 
207  for ( UInt_t i=0;i<pairs[sec].size();i++ )
208  {
209 
210  StEEmcPair pair = pairs[sec][i];
211 
213  if ( !twoBodyCut( pair ) ) continue;
214 
216  Int_t bin = ptbin( pair );
217  std::cout << "sector=" << sec << " mass=" << pair.mass() << " pt = " << pair.pt() << " bin=" << bin << std::endl;
218  if ( bin < 0 ) continue;
219 
221  if ( pair.vertex().Z() < zVertexMin ||
222  pair.vertex().Z() > zVertexMax ) continue;
223 
225  hMassR[sec][bin] -> Fill( pair.mass() );
226  hMassR[ 12][bin] -> Fill( pair.mass() );
227  hMassRall -> Fill( pair.mass() );
228 
229  hMassR[sec].back() -> Fill( pair.mass() ); // unbinned
230  hMassR[ 12].back() -> Fill( pair.mass() ); // int over sectors
231 
233  if ( pair.mass() > mMin && pair.mass() <= mMax )
234  {
235 
237  hZvertexR[sec][bin] -> Fill( pair.vertex().Z() );
238  hZvertexR[ 12][bin] -> Fill( pair.vertex().Z() );
239  hZvertexRall -> Fill( pair.vertex().Z() );
240 
241  hZvertexR[sec].back() -> Fill( pair.vertex().Z() ); // unbinned
242  hZvertexR[ 12].back() -> Fill( pair.vertex().Z() ); // int sect
243 
245 
246  StEEmcPoint point1=pair.point(0);
247  StEEmcPoint point2=pair.point(1);
248 
249  TVector3 pos1 = point1.position();
250  TVector3 pos2 = point2.position();
251 
252  Float_t e1=point1.energy();
253  Float_t e2=point2.energy();
254 
255  TVector3 posp = ( e1 * pos1 + e2 * pos2 ) * ( 1.0/(e1+e2) );
256 
257  hYXpair[sec] -> Fill( posp.X(), posp.Y() );
258  hYXhigh[sec] -> Fill( pos1.X(), pos1.Y() );
259  hYXlow[sec] -> Fill( pos2.X(), pos2.Y() );
260  hE1E2[sec] -> Fill( e2, e1 );
261 
262  hYXpair[ 12] -> Fill( posp.X(), posp.Y() );
263  hYXhigh[ 12] -> Fill( pos1.X(), pos1.Y() );
264  hYXlow[ 12] -> Fill( pos2.X(), pos2.Y() );
265  hE1E2[ 12] -> Fill( e2, e1 );
266 
267  }
268 
269  }
270 
271  }
272 
273  return kStOK;
274 }
275 
276 
277 // ----------------------------------------------------------------------------
279 {
280  for ( UInt_t i=0;i<mBins.size()-1;i++ )
281  {
282  if ( pair.pt() > mBins[i] && pair.pt() <= mBins[i+1] ) return (Int_t)i;
283  }
284  return -1;
285 }
286 
287 // ----------------------------------------------------------------------------
288 void StEEmcMixQAMaker::mixer(const Char_t *name, Float_t min, Float_t max)
289 {
290  mEEmixer=(StEEmcMixMaker *)GetMaker(name);
291  assert(mEEmixer);// please specify a valid mix maker
292  mMin=min;
293  mMax=max;
294  assert(max>min && max>0.); // you gotta be kidding, right?
295 }
296 
297 // ----------------------------------------------------------------------------
298 void StEEmcMixQAMaker::points(const Char_t *name)
299 {
300  mEEpoints=(StEEmcPointMaker *)GetMaker(name);
301  assert(mEEpoints);
302 }
303 
304 // ----------------------------------------------------------------------------
306 {
307 
309 
310  Bool_t towers[720]; for (Int_t i=0;i<720;i++ ) towers[i]=false;
311  StEEmcTower t1 = pair.point(0).tower(0);
312  StEEmcTower t2 = pair.point(1).tower(0);
313 
314  for ( Int_t i=0;i<t1.numberOfNeighbors();i++ ) {
315  StEEmcTower mytow=t1.neighbor(i);
316  towers[ mytow.index() ] = true;
317  }
318  for ( Int_t i=0;i<t2.numberOfNeighbors();i++ ) {
319  StEEmcTower mytow=t2.neighbor(i);
320  towers[ t2.neighbor(i).index() ] = true;
321  }
322 
323 
324  towers[ t1.index() ] = true;
325  towers[ t2.index() ] = true;
326 
328 
331 
332 
333  Int_t count = 0;
334  for ( Int_t i=0;i<mEEpoints->numberOfPoints();i++ )
335  {
337  StEEmcTower t=p.tower(0);
338  if ( towers[ t.index() ] ) count++;
339  }
340 
341  return ( count <= maxPerCluster );
342 
343 }
Int_t numberOfNeighbors() const
get the number of neighboring towers
Definition: StEEmcTower.h:54
StEEmcMixMaker * mEEmixer
Pointer to the pi0 mixer.
Base class for representing EEMC points.
Definition: StEEmcPoint.h:24
Int_t Init()
initializes the maker
std::vector< std::vector< TH1F * > > hEnergyR
Pair energy [mMin,mMax].
void mixer(const Char_t *name, Float_t min=0., Float_t max=999.)
void energy(Float_t e, Int_t layer=0)
Set the energy of this point.
Definition: StEEmcPoint.h:34
std::vector< std::vector< TH1F * > > hPhiggR
Opening angle [mMin,mMax].
Int_t sector() const
Returns the sector.
Definition: StEEmcPoint.h:85
void neighbor(StEEmcTower *n)
add a tower to list of neighbors
Definition: StEEmcTower.h:52
StEEmcPoint point(Int_t ipoint)
Return a specified point.
Int_t Make()
processes a single event
TH1F * hZvertexRall
vertex for all events
A maker for creating pi0 histograms.
StEEmcPointMaker * mEEpoints
pointer to the point maker
Int_t numberOfCandidates()
returns the number of candidates
const TVector3 & vertex() const
Returns vertex of pair.
Definition: StEEmcPair.h:79
Class for building points from smd clusters.
std::vector< std::vector< TH1F * > > hZggR
Energy sharing [mMin,mMax].
std::vector< std::vector< TH1F * > > hZvertexR
Event vertex [mMin,mMax].
const StEEmcPoint & point(Int_t index) const
Definition: StEEmcPair.h:30
std::vector< Float_t > mBins
E1 vs E2.
Bool_t twoBodyCut(StEEmcPair p)
Int_t ptbin(StEEmcPair p)
returns the ptbin the pair is in
Int_t numberOfMixedCandidates()
returns the number of mixed-background candidates
Int_t numberOfPoints()
Return number of points.
void index(Int_t i)
Definition: StEEmcTower.cxx:76
Base class for representing tower, preshower and postshower elements.
Definition: StEEmcTower.h:11
std::vector< TH2F * > hYXhigh
Y vs X of higher energy gamma.
void points(const Char_t *name)
specifies the name of the point maker
std::vector< std::vector< TH1F * > > hMassR
Bin boundaries in pT.
Definition: Stypes.h:40
void tower(const StEEmcTower &t, Float_t w=1.)
Add a tower with specified weight to the point.
Definition: StEEmcPoint.h:38
void position(const TVector3 &p)
Set the position of this point at the SMD plane.
Definition: StEEmcPoint.h:32
StEEmcMixQAMaker(const Char_t *name)
constructor
Float_t mass() const
Returns invariant mass of pair.
Definition: StEEmcPair.h:73
A class for mixing pi0 candidates.
TH1F * hMassRall
Mass spectrum for all events.
std::vector< TH2F * > hYXlow
Y vs X of lower energy gamma.
Float_t pt() const
Returns pt of pair.
Definition: StEEmcPair.h:77
std::vector< TH2F * > hYXpair
Y vs X of pi0 pairs.
std::vector< TH2F * > hE1E2
Energy of first gamma vs energy of second.
A class to represent pairs of points.
Definition: StEEmcPair.h:9