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