StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcMixQAMaker.cxx
1 
38 #include "StEEmcMixQAMaker.h"
39 #include "StEEmcMixMaker.h"
40 #include "StEEmcPool/StEEmcPointMaker/StEEmcPointMaker.h"
41 #include "TH1F.h"
42 #include "TH2F.h"
43 #include <stdio.h>
44 #include <iostream>
45 
46 ClassImp(StEEmcMixQAMaker);
47 
48 // ----------------------------------------------------------------------------
50 {
51 
53  maxPerSector = 100; // eg no cut
54  maxPerEvent = 100; // eg no cut
55  maxPerCluster = 2; // default number of points associated with 6-18 towers
56  // which make up the pi0 candidate's energy
57  zVertexMin=-150.0;
58  zVertexMax= 150.0;
59 
60  minZgg = 0.0;
61  maxZgg = 1.0;
62 
63  minTowerFrac = 0.0;
64 
66  mBins.push_back(0.);
67  mBackground = false;
68 
69 }
70 
71 // ----------------------------------------------------------------------------
73 {
74 
75 
76  hNcandidates = new TH1F("hNcandidates","Number of pairs",30,0.,30.);
77  hNcandidatesR = new TH1F("hNcandidatesR","Number of pairs [0.1,0.18] per sector",12,0.,12.);
78 
79  hMassRall=new TH1F("hMassRall","Dipoint invariant mass, integrated",360,0.,3.6);
80  hZvertexRall=new TH1F("hZvertexRall","Event vertex",150,-150.,150.);
81 
83  for ( Int_t sec=0;sec<13;sec++ )
84  {
85  TString name="hYXpair";name+=sec+1;
86  TString title="Y vs X [cm] of stable pi0, sector ";title+=sec+1;
87  hYXpair.push_back(new TH2F(name,title,125,-250.,250.,125,-250.,250.));
88  name="hYXhigh";name+=sec+1;
89  title="Y vs X [cm] of higher energy gamma, sector ";title+=sec+1;
90  hYXhigh.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
91  name.ReplaceAll("high","low");
92  title.ReplaceAll("high","low");
93  hYXlow.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
94  name="hE1E2sec";name+=sec+1;
95  title="Energy point1 vs Energy point2 [GeV], sector ";title+=sec+1;
96  hE1E2.push_back(new TH2F(name,title,100,0.,50.,100,0.,50.));
97  }
98 
99 
100 
102  for ( Int_t sec=0;sec<13;sec++ )
103  {
104 
106  std::vector<TH1F *> tmp;
107  hMassR.push_back( tmp );
108  hZvertexR.push_back( tmp );
109  hZggR.push_back( tmp );
110  hPhiggR.push_back( tmp );
111  hEnergyR.push_back( tmp );
112 
113  TString sec_name = "-sec";sec_name+=sec+1;
114  for ( UInt_t ptbin=0;ptbin<mBins.size()-1;ptbin++ )
115  {
116 
117  TString bin_name = "-bin";bin_name+=ptbin;
118 
119  TString hname="hMassR";hname+=sec_name;hname+=bin_name;
120  TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
121  htitle+=", ptbin="; htitle+=(Int_t)ptbin;
122  hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.60) );
123 
124  hname="hZvertexR";hname+=sec_name;hname+=bin_name;
125  htitle="Event vertex";htitle+=sec+1;
126  htitle+=", ptbin="; htitle+=(Int_t)ptbin;
127  hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
128 
129  hname="hZggR";hname+=sec_name;hname+=bin_name;
130  htitle="Zgg = |E1-E2|/E, sector= ";htitle+=sec+1; htitle+=", ptbin=";htitle+=(Int_t)ptbin;
131  hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
132 
133  hname="hPhiggR";hname+=sec_name;hname+=bin_name;
134  htitle="Opening angle, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
135  hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
136 
137  hname="hEnergyR";hname+=sec_name;hname+=bin_name;
138  htitle+="Energy, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
139  hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
140 
141  }
142 
144  TString hname="hMassR";hname+=sec_name;hname+="-unbinned";
145  TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
146  hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.6) );
147 
148  hname="hZvertexR";hname+=sec_name;hname+="-unbinned";
149  htitle="Event vertex, sector=";htitle+=sec+1;
150  hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
151 
152  hname="hZggR";hname+=sec_name;hname+="-unbinned";
153  htitle="Zgg = |E1-E2|/E, sector=";htitle+=sec+1;
154  hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
155 
156  hname="hPhiggR";hname+=sec_name;hname+="-unbinned";
157  htitle="Opening angle, sector=";htitle+=sec+1;
158  hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
159 
160  hname="hEnergyR";hname+=sec_name;hname+="-unbinned";
161  htitle+="Energy, sector=";htitle+=sec+1;
162  hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
163 
164  }
165 
166 
167 
168  return StMaker::Init();
169 }
170 
171 // ----------------------------------------------------------------------------
173 {
174 
178  std::vector< StEEmcPairVec_t > pairs;
179  for ( Int_t sec=0;sec<12;sec++ )
180  {
181  StEEmcPairVec_t tmp;
182  pairs.push_back(tmp);
183  }
184 
185  hNcandidates -> Fill( mEEmixer -> numberOfCandidates() );
186 
190  if ( !mBackground )
191  {
192 
194  if ( mEEmixer -> numberOfCandidates() > maxPerEvent ) return kStOK;
195 
196  for ( Int_t i=0;i<mEEmixer->numberOfCandidates();i++ )
197  {
198 
199  StEEmcPair p = mEEmixer -> candidate(i);
200  pairs[ p.point(0).sector() ].push_back(p);
201 
202  }
203 
204  }
208  else
209  {
210 
212  if ( mEEmixer -> numberOfMixedCandidates() > maxPerEvent ) return kStOK;
213 
214  for ( Int_t i=0;i<mEEmixer->numberOfMixedCandidates();i++ )
215  {
216 
217  StEEmcPair p = mEEmixer -> mixedCandidate(i);
218  pairs[ p.point(0).sector() ].push_back(p);
219 
220  }
221 
222  }
223 
224 
225 
226 
227 
231  for ( UInt_t sec=0;sec<12;sec++ )
232  {
233 
235  if ( pairs[sec].size() > (UInt_t)maxPerSector ) continue;
236 
237 
238  for ( UInt_t i=0;i<pairs[sec].size();i++ )
239  {
240 
241  StEEmcPair pair = pairs[sec][i];
242 
244  if ( !twoBodyCut( pair ) ) continue;
245 
247  Int_t bin = ptbin( pair );
248  std::cout << "pair=" << i << " ptmin=" << mBins[bin] << " ptmax=" << mBins[bin+1] << " mass=" << pair.mass() << " zgg=" << pair.zgg() << std::endl;
249 
253 
255  if ( pair.zgg() < minZgg || pair.zgg() > maxZgg ) continue;
256 
258  if ( pair.vertex().Z() < zVertexMin ||
259  pair.vertex().Z() > zVertexMax ) continue;
260 
262  if ( bin>=0 ) hMassR[sec][bin] -> Fill( pair.mass() );
263  if ( bin>=0 ) hMassR[ 12][bin] -> Fill( pair.mass() );
264  hMassRall -> Fill( pair.mass() );
265 
266  hMassR[sec].back() -> Fill( pair.mass() ); // unbinned
267  hMassR[ 12].back() -> Fill( pair.mass() ); // int over sectors
268 
270  if ( pair.mass() > mMin && pair.mass() <= mMax )
271  {
272 
273  hNcandidatesR->Fill( pair.point(0).sector() ) ;
274 
276  if ( bin>=0 ) hZvertexR[sec][bin] -> Fill( pair.vertex().Z() );
277  if ( bin>=0 ) hZvertexR[ 12][bin] -> Fill( pair.vertex().Z() );
278  hZvertexRall -> Fill( pair.vertex().Z() );
279  hZvertexR[sec].back() -> Fill( pair.vertex().Z() ); // unbinned
280  hZvertexR[ 12].back() -> Fill( pair.vertex().Z() ); // int sect
281 
282  if ( bin>= 0 ) hZggR[sec][bin] -> Fill( pair.zgg() );
283  if ( bin>= 0 ) hZggR[ 12][bin] -> Fill( pair.zgg() );
284  hZggR[sec].back() -> Fill( pair.zgg() );
285  hZggR[ 12].back() -> Fill( pair.zgg() );
286 
287  if ( bin>= 0 ) hPhiggR[sec][bin] -> Fill( pair.phigg() );
288  if ( bin>= 0 ) hPhiggR[ 12][bin] -> Fill( pair.phigg() );
289  hPhiggR[sec].back() -> Fill( pair.phigg() );
290  hPhiggR[ 12].back() -> Fill( pair.phigg() );
291 
292  if ( bin>= 0 ) hEnergyR[sec][bin] -> Fill( pair.energy() );
293  if ( bin>= 0 ) hEnergyR[ 12][bin] -> Fill( pair.energy() );
294  hEnergyR[sec].back() -> Fill( pair.energy() );
295  hEnergyR[ 12].back() -> Fill( pair.energy() );
296 
297 
298 
299 
301 
302  StEEmcPoint point1=pair.point(0);
303  StEEmcPoint point2=pair.point(1);
304 
305  TVector3 pos1 = point1.position();
306  TVector3 pos2 = point2.position();
307 
308  Float_t e1=point1.energy();
309  Float_t e2=point2.energy();
310 
311  TVector3 posp = ( e1 * pos1 + e2 * pos2 ) * ( 1.0/(e1+e2) );
312 
313  hYXpair[sec] -> Fill( posp.X(), posp.Y() );
314  hYXhigh[sec] -> Fill( pos1.X(), pos1.Y() );
315  hYXlow[sec] -> Fill( pos2.X(), pos2.Y() );
316  hE1E2[sec] -> Fill( e2, e1 );
317 
318  hYXpair[ 12] -> Fill( posp.X(), posp.Y() );
319  hYXhigh[ 12] -> Fill( pos1.X(), pos1.Y() );
320  hYXlow[ 12] -> Fill( pos2.X(), pos2.Y() );
321  hE1E2[ 12] -> Fill( e2, e1 );
322 
323  }
324 
325  }
326 
327  }
328 
329  return kStOK;
330 }
331 
332 
333 // ----------------------------------------------------------------------------
335 {
336  for ( UInt_t i=0;i<mBins.size()-1;i++ )
337  {
338  if ( pair.pt() > mBins[i] && pair.pt() <= mBins[i+1] ) return (Int_t)i;
339  }
340  return -1;
341 }
342 
343 // ----------------------------------------------------------------------------
344 void StEEmcMixQAMaker::mixer(const Char_t *name, Float_t min, Float_t max)
345 {
346  mEEmixer=(StEEmcMixMaker *)GetMaker(name);
347  assert(mEEmixer);// please specify a valid mix maker
348  mMin=min;
349  mMax=max;
350  assert(max>min && max>0.); // you gotta be kidding, right?
351 }
352 
353 // ----------------------------------------------------------------------------
354 void StEEmcMixQAMaker::points(const Char_t *name)
355 {
356  mEEpoints=(StEEmcPointMaker *)GetMaker(name);
357  assert(mEEpoints);
358 }
359 
360 // ----------------------------------------------------------------------------
362 {
363 
365 
366  Bool_t towers[720]; for (Int_t i=0;i<720;i++ ) towers[i]=false;
367  StEEmcTower t1 = pair.point(0).tower(0);
368  StEEmcTower t2 = pair.point(1).tower(0);
369 
370  Float_t Etowers=0.;
371  Etowers += t1.energy();
372 
373  towers[ t1.index() ] = true;
374  towers[ t2.index() ] = true;
375 
376  for ( Int_t i=0;i<t1.numberOfNeighbors();i++ ) {
377  StEEmcTower mytow=t1.neighbor(i);
378  towers[ mytow.index() ] = true;
379  Etowers += mytow.energy();
380  }
381  for ( Int_t i=0;i<t2.numberOfNeighbors();i++ ) {
382  StEEmcTower mytow=t2.neighbor(i);
383  if ( !towers[mytow.index()] ) Etowers += mytow.energy();
384  towers[ mytow.index() ] = true;
385  }
386 
387 
388 
390 
393 
394  Int_t count = 0;
395  for ( Int_t i=0;i<mEEpoints->numberOfPoints();i++ )
396  {
398  StEEmcTower t=p.tower(0);
399  if ( towers[ t.index() ] ) count++;
400  }
401 
402  Float_t Epoints = pair.energy();
403 
404  return ( count <= maxPerCluster && Epoints > minTowerFrac * Etowers );
405 
406 }
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
Float_t zgg() const
Returns energy-sharing of pair.
Definition: StEEmcPair.h:75
std::vector< TH2F * > hYXhigh
Y vs X of higher energy gamma.
void points(const Char_t *name)
specifies the name of the point maker
Float_t energy() const
Returns energy of pair.
Definition: StEEmcPair.h:74
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.
Float_t phigg() const
Returns opening-angle of pair.
Definition: StEEmcPair.h:76
TH1F * hMassRall
Mass spectrum for all events.
void energy(Float_t e)
Set the energy (adc-ped+0.5)/gain for this element.
Definition: StEEmcElement.h:21
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