StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcMixMaker.cxx
1 
24 #include "StEEmcMixMaker.h"
25 #include "StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
26 #include "StEEmcPool/StEEmcPointMaker/StEEmcPointMaker.h"
27 
28 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
29 #include "StMuDSTMaker/COMMON/StMuDst.h"
30 #include "StMuDSTMaker/COMMON/StMuEvent.h"
31 #include "StEvent/StTriggerIdCollection.h"
32 #include "StEvent/StTriggerId.h"
33 
34 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
35 #include "StarRoot/TH1Helper.h"
36 
37 #include "TRandom.h"
38 #include "TH1F.h"
39 #include "TH2F.h"
40 
41 #define SIMPLE_MC
42 
43 ClassImp(StEEmcMixMaker);
44 
45 // ----------------------------------------------------------------------------
46 StEEmcMixMaker::StEEmcMixMaker(const Char_t *name,Int_t s):StMaker(name)
47 {
48  mRandom=new TRandom();
49  mPoolSize=s;
50 
51  mEEmcTow = new EEmcGeomSimple();
52 
56  minET(1.0); // minimum pair E_T [GeV]
57  maxZ(0.5); // maximum pair zgg [GeV]
58  minEpoint(0.8); // minimum point energy [GeV]
59  range(0.11,0.17);
60  mTrigMode=0;
61 
63  StEEmcPointVec_t points;
64  for ( Int_t i=0; i<40; i++ ) mPool.push_back(points);
65 
66  mFixedVertex=TVector3(-999.,-999.,-999.);
67  mSigmaVertex=-999.;
68 
69  mMixLimits = 0;
70 
71 }
72 
73 // ----------------------------------------------------------------------------
75 {
77  assert(mEEpoints);
79  assert(mEEanalysis);
81  assert(mMuDstMaker);
82 
84  book();
85 
86  return StMaker::Init();
87 }
88 
89 // ----------------------------------------------------------------------------
91 {
92 
94  if ( !accept( mMuDstMaker -> muDst() -> event() ) )
95  return kStOK;
96 
97  mH1[1]->Fill("accepted",1.0);
98 
101 
103  if ( mPoints.size() <= 1 ) return kStOK;
104  mH1[1]->Fill( "2+ points", 1.0);
105 
107  mixReal();
108 
110  mixBackground();
111 
113  fill();
114 
117  fillPool();
118 
119  return kStOK;
120 }
121 
122 // ----------------------------------------------------------------------------
123 void StEEmcMixMaker::Clear( Option_t *opts )
124 {
125  mCandidates.clear();
126  mBackground.clear();
127  mPoints.clear();
128 
129  return;
130 }
131 
132 // ----------------------------------------------------------------------------
134 {
135 
136  if ( !mPoints.size() ) return;
137 
138  Float_t emax=0.;
139  Int_t count=0;
140 
141 
142  StMuEvent *event = mMuDstMaker -> muDst() -> event();
143  if ( !event ) return ;
144  StThreeVectorF v=event->primaryVertexPosition();
145  TVector3 vertex = TVector3(v.x(),v.y(),v.z());
146 
147 
149  if ( mFixedVertex.Z()<-500. ) {
150  if ( v.z()==0. && v.x()==0. && v.y()==0. ) return;
151  }
152  else {
153  vertex=mFixedVertex;
154  if ( mSigmaVertex > 0. ) vertex[2]=( mFixedVertex.Z() + mRandom->Gaus(0.,mSigmaVertex));
155  }
156 
157 
159  for ( UInt_t ipoint=0; ipoint<mPoints.size()-1; ipoint++ )
160  for ( UInt_t jpoint=ipoint+1; jpoint<mPoints.size(); jpoint++ )
161  {
162 
163  StEEmcPoint point1=mPoints[ipoint];
164  StEEmcPoint point2=mPoints[jpoint];
165 
167  Bool_t go1 = false;
168  Bool_t go2 = false;
169  for ( UInt_t isec=0;isec<mSectorList.size();isec++ )
170  {
171  go1 |= point1.sector() == mSectorList[isec];
172  go2 |= point2.sector() == mSectorList[isec];
173  }
174  if ( !(go1&&go2) ) continue;
175 
176 
178  if ( point1.sector() != point2.sector() ) continue;
179 
180  count++;
181  mCandidates.push_back ( StEEmcPair( point1, point2, vertex, vertex ) );
182  if ( mCandidates.back().energy() > emax ) {
183  emax = mCandidates.back().energy();
184  }
185 
186  }
187 
188 
189 }
190 
192 {
193 
194  if ( !mPoints.size() ) return ;
195 
197  StEEmcTower high_tower = mEEanalysis->hightower();
198 
199  Int_t bin=(Int_t)(high_tower.adc()/100);
200  if ( bin<0 ) bin=0;
201  if ( bin>40 ) bin=40;
202 
205  StEEmcPointVec_t &points = mPool[bin];
206 
207  StMuEvent *event = mMuDstMaker -> muDst() -> event();
208  if ( !event ) return;
209  StThreeVectorF v=event->primaryVertexPosition();
210  TVector3 vertex = TVector3(v.x(),v.y(),v.z());
211 
212  if ( mFixedVertex.Z()<-500. ) {
213  if ( v.z()==0. && v.x()==0. && v.y()==0. ) return;
214  }
215  else {
216  vertex=mFixedVertex;
217  if ( mSigmaVertex > 0. ) vertex[2]=( mFixedVertex.Z() + mRandom->Gaus(0.,mSigmaVertex));
218  }
219 
220 
222  for ( UInt_t i=0; i<mPoints.size(); i++ ) {
223 
224  StEEmcPoint point1=mPoints[i];
225 
227  for ( UInt_t j=0; j<points.size(); j++ ) {
228 
229  StEEmcPoint point2=points[j];
230 
232  Bool_t go1 = false;
233  Bool_t go2 = false;
234  for ( UInt_t isec=0;isec<mSectorList.size();isec++ )
235  {
236  go1 |= point1.sector() == mSectorList[isec];
237  go2 |= point2.sector() == mSectorList[isec];
238  }
239  if ( !(go1&&go2) ) continue;
240 
242  if ( point1.sector() != point2.sector() ) continue;
243 
245  mBackground.push_back( StEEmcPair( point1, point2, vertex, vertex ) );
246 
247 
248 
249  }// pool
250 
251  }// current
252 
253 }
254 
255 
256 
257 // ----------------------------------------------------------------------------
259 {
260 
261  Int_t s1=p1.sector();
262  Int_t s2=p2.sector();
263 
264  Int_t ss1=TMath::Max(s1,s2);
265  Int_t ss2=TMath::Min(s1,s2);
266 
267  Int_t d1=ss1-ss2;
268  Int_t d2=ss2+12-ss1;
269 
270  if ( d1 > mMixLimits && d2 > mMixLimits ) return false;
271 
272  return true;
273 
274 }
275 // ----------------------------------------------------------------------------
277 {
278  if ( !event ) return false;
279  StMuTriggerIdCollection tic = event -> triggerIdCollection();
280  StTriggerId l1trig = tic.l1();
281 
283  if ( mTriggerList.size() <= 0 ) {
284  mH1[0]->Fill("no selection",1.0);
285  return true;
286  }
287 
288  Int_t go=0;
289  std::vector<Int_t>::iterator iter=mTriggerList.begin();
290  while ( iter != mTriggerList.end() ) {
291  go = l1trig.isTrigger( (*iter) );
292  if ( go ) {
293  go = (*iter);
294  break;
295  }
296  iter++;
297  }
298  TString name=go;
299  mH1[0]->Fill(name,1.0);
300  return (go!=0);
301 }
302 
303 
304 // ----------------------------------------------------------------------------
306 {
307 
308  // 1D QA histograms
309  mH1.push_back(new TH1F("triggers","Number of triggers fired",1,0.,1.));
310  TH1Helper::SetCanRebin(mH1[0]);
311  mH1.push_back(new TH1F("status","Events processed up to...",1,0.,1.));
312  TH1Helper::SetCanRebin(mH1[1]);
313 
314  // 2D QA histograms
315  mH2.push_back(new TH2F("uvha","<u> vs <v> for higher-energy gamma",288,0.,288.,288,0.,288.));
316  mH2.push_back(new TH2F("uvla","<u> vs <v> for lower-energy gamma",288,0.,288.,288,0.,288.));
317  mH2.push_back(new TH2F("uvhc","<u> vs <v> for higher-energy gamma, mass cut",288,0.,288.,288,0.,288.));
318  mH2.push_back(new TH2F("uvlc","<u> vs <v> for lower-energy gamma, mass cut",288,0.,288.,288,0.,288.));
319 
320 
321  mH1real.push_back(new TH1F("massR","Invariant mass of photon pairs",360,0.,3.6) );
322  mH1real.push_back(new TH1F("energyR","Energy of photon pairs",200,0.,40.));
323  mH1real.push_back(new TH1F("zggR","Energy sharing of photon pairs",50,0.,1.));
324  mH1real.push_back(new TH1F("phiggR","Opening angle of photon pairs",100,0.,0.1));
325  mH1real.push_back(new TH1F("ptR","p_{T} of photon pairs",100,0.,10.));
326  mH1real.push_back(new TH1F("zvertexR","Z_{vertex} [cm]",100,-100.,100.));
327 
328  mH1mix.push_back(new TH1F("massM","Invariant mass of photon pairs",360,0.,3.6) );
329  mH1mix.push_back(new TH1F("energyM","Energy of photon pairs",200,0.,40.));
330  mH1mix.push_back(new TH1F("zggM","Energy sharing of photon pairs",50,0.,1.));
331  mH1mix.push_back(new TH1F("phiggM","Opening angle of photon pairs",100,0.,0.1));
332  mH1mix.push_back(new TH1F("ptM","p_{T} of photon pairs",100,0.,10.));
333  mH1mix.push_back(new TH1F("zvertexM","Z_{vertex} [cm]",100,-100.,100.));
334 
335 }
336 
337 // ----------------------------------------------------------------------------
339 {
340 
341  StEEmcPairVec_t::iterator ipair=mCandidates.begin();
342  while ( ipair != mCandidates.end() ) {
343  fill( mH1real, (*ipair ) );
344  fillQA( mH2, (*ipair ) );
345  ipair++;
346  }
347 
348  ipair=mBackground.begin();
349  while ( ipair != mBackground.end() ) {
350  fill( mH1mix, (*ipair) );
351  ipair++;
352  }
353 
354 }
355 
356 void StEEmcMixMaker::fillQA( std::vector<TH2F *> &h, StEEmcPair pair )
357 {
358 
359  StEEmcPoint p1=pair.point(0);
360  StEEmcPoint p2=pair.point(1);
361  StEEmcSmdCluster uh,ul,vh,vl;
362  if ( p1.energy() > p2.energy() ) {
363  uh=p1.cluster(0); vh=p1.cluster(1);
364  ul=p2.cluster(0); vl=p2.cluster(1);
365  }
366  else {
367  ul=p1.cluster(0); vl=p1.cluster(1);
368  uh=p2.cluster(0); vh=p2.cluster(1);
369  }
370  mH2[0]->Fill( uh.mean(), vh.mean() );
371  mH2[1]->Fill( ul.mean(), vl.mean() );
372  if ( pair.mass() > mMinMass && pair.mass() < mMaxMass ) {
373  mH2[2]->Fill( uh.mean(), vh.mean() );
374  mH2[3]->Fill( ul.mean(), vl.mean() );
375  }
376 
377 }
378 
379 void StEEmcMixMaker::fill( std::vector<TH1F*> &h, StEEmcPair pair )
380 {
381 
382  h[0]->Fill( pair.mass() );
383  if ( pair.mass() > mMinMass && pair.mass() < mMaxMass ) {
384  h[1]->Fill( pair.energy() );
385  h[2]->Fill( pair.zgg() );
386  h[3]->Fill( pair.phigg() );
387  h[4]->Fill( pair.vertex().Z() );
388  }
389 
390 }
391 
392 
393 // ----------------------------------------------------------------------------
395 {
396 
397  if ( !mPoints.size() ) return;
398 
400  StEEmcTower high_tower = mEEanalysis->hightower();
401 
402  Int_t bin=(Int_t)(high_tower.adc()/100);
403  if ( bin<0 ) bin=0;
404  if ( bin>40 ) bin=40;
405 
408  StEEmcPointVec_t &points = mPool[bin];
409 
411  std::reverse(points.begin(),points.end());
412 
414  for ( UInt_t i=0; i<mPoints.size(); i++ ) {
415 
416  TVector3 d=mPoints[i].position();
417 
419  Int_t sec,sub,eta;
420  if ( !mEEmcTow->getTower(d,sec,sub,eta) ) continue;
421 
423  if ( mTrigMode == 1 ) {
424  if ( sec==high_tower.sector() &&
425  sub==high_tower.subsector() &&
426  eta==high_tower.etabin() ) continue;
427  }
428 
430  points.push_back( mPoints[i] );
431 
432  }
433 
435  std::reverse(points.begin(),points.end());
436 
438  if ( points.size() > (UInt_t)mPoolSize ) points.resize(mPoolSize);
439 
440 }
441 
442 // ----------------------------------------------------------------------------
TString mPointMakerName
Point maker name.
void cluster(const StEEmcSmdCluster &c, Int_t plane)
Add an smd cluster to this point.
Definition: StEEmcPoint.h:40
std::vector< TH1F * > mH1mix
1D mixed histos
Int_t Init()
Initialize.
EEmc ADC –&gt; energy maker.
Base class for representing EEMC points.
Definition: StEEmcPoint.h:24
EEmcGeomSimple * mEEmcTow
Pointer to tower geom.
void book()
create 1d and 2d histograms
void minEpoint(Float_t m)
minimum energy for a given point
void energy(Float_t e, Int_t layer=0)
Set the energy of this point.
Definition: StEEmcPoint.h:34
TRandom * mRandom
Random number generator for event mixing.
void fill()
fill 1d and 2d histograms
void Clear(Option_t *opts="")
Clear.
Int_t sector() const
Returns the sector.
Definition: StEEmcPoint.h:85
std::vector< StEEmcPointVec_t > mPool
StEEmcPointVec_t points()
Return vector of all points found in endcap.
const TVector3 & vertex() const
Returns vertex of pair.
Definition: StEEmcPair.h:79
Class for building points from smd clusters.
std::vector< TH1F * > mH1real
1D real histos
TString mAnalysisName
Analaysis name.
void mixBackground()
Mix combinatoric pairs.
Int_t etabin() const
Returns the etabin of this tower, pre- or postshower element.
Definition: StEEmcTower.h:45
void mixReal()
Mix real pairs.
const StEEmcPoint & point(Int_t index) const
Definition: StEEmcPair.h:30
std::vector< TH2F * > mH2
2D histos
Int_t subsector() const
Returns subsector of this tower, pre- or postshower element.
Definition: StEEmcTower.h:43
TVector3 mFixedVertex
StEEmcPointMaker * mEEpoints
Pointer to points.
void minET(Float_t et)
set minimum ET for pair of points
Base class for representing tower, preshower and postshower elements.
Definition: StEEmcTower.h:11
StMuDstMaker * mMuDstMaker
Pointer to MuDst.
StEEmcTower & hightower(Int_t layer=0)
Int_t Make()
Process.
void maxZ(Float_t z)
set maximum Zgg for pair of points
Float_t zgg() const
Returns energy-sharing of pair.
Definition: StEEmcPair.h:75
std::vector< Int_t > mTriggerList
Int_t sector() const
Returns sector of this tower, pre- or postshower element.
Definition: StEEmcTower.h:41
Float_t energy() const
Returns energy of pair.
Definition: StEEmcPair.h:74
EEMC simple geometry.
Definition: Stypes.h:40
A base class for representing clusters of EEMC smd strips.
Int_t mPoolSize
Size of mixed event pool.
void adc(Float_t a)
Set the pedestal-subtracted ADC for this element.
Definition: StEEmcElement.h:19
std::vector< TH1F * > mH1
1D histos
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
void range(Float_t min, Float_t max)
Mass range for qa histograms.
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
Float_t mSigmaVertex
TString mMuDstMakerName
MuDst name.
StEEmcPairVec_t mBackground
Background pairs mixed on each event.
StEEmcPairVec_t mCandidates
Point pairs mixed on each event.
Bool_t accept(StMuEvent *)
Accept or reject this event (trigger, qa, etc...)
void points(const Char_t *name)
sets the name of the point maker
A class to represent pairs of points.
Definition: StEEmcPair.h:9
Collection of trigger ids as stored in MuDst.
StEEmcMixMaker(const Char_t *name, Int_t size=20)
StEEmcA2EMaker * mEEanalysis
Pointer to ADC 2 energy.
void fillQA(std::vector< TH2F * > &h, StEEmcPair pair)
Fill qa distributions.
std::vector< Int_t > mSectorList
Float_t mMinMass
Min and max mass for gated quantities.
StEEmcPointVec_t mPoints
Vector of points to mix into X–&gt;gamma gamma.