StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcMixMaker.cxx
1 #include "StEEmcMixMaker.h"
2 #include "StEEmcPointMaker.h"
3 #include "StEEmcA2EMaker.h"
4 
5 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
6 #include "StMuDSTMaker/COMMON/StMuDst.h"
7 #include "StMuDSTMaker/COMMON/StMuEvent.h"
8 #include "StEvent/StTriggerIdCollection.h"
9 #include "StEvent/StTriggerId.h"
10 
11 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
12 #include "StarRoot/TH1Helper.h"
13 
14 #include "TRandom.h"
15 #include "TH1F.h"
16 #include "TH2F.h"
17 
18 #define SIMPLE_MC
19 
20 ClassImp(StEEmcMixMaker);
21 
22 // ----------------------------------------------------------------------------
23 StEEmcMixMaker::StEEmcMixMaker(const Char_t *name,Int_t s):StMaker(name)
24 {
25  mRandom=new TRandom();
26  mPoolSize=s;
27 
28  mEEmcTow = new EEmcGeomSimple();
29 
33  minET(1.0); // minimum pair E_T [GeV]
34  maxZ(0.5); // maximum pair zgg [GeV]
35  minEpoint(0.8); // minimum point energy [GeV]
36  range(0.11,0.17);
37  mTrigMode=0;
38 
40  StEEmcPointVec_t points;
41  for ( Int_t i=0; i<40; i++ ) mPool.push_back(points);
42 
43  mFixedVertex=TVector3(-999.,-999.,-999.);
44  mSigmaVertex=-999.;
45 
46 }
47 
48 // ----------------------------------------------------------------------------
50 {
52  assert(mEEpoints);
54  assert(mEEanalysis);
56  assert(mMuDstMaker);
57 
59  book();
60 
61  return StMaker::Init();
62 }
63 
64 // ----------------------------------------------------------------------------
66 {
67 
69  if ( !accept( mMuDstMaker -> muDst() -> event() ) )
70  return kStOK;
71 
72  mH1[1]->Fill("accepted",1.0);
73 
76 
78  if ( mPoints.size() <= 1 ) return kStOK;
79  mH1[1]->Fill( "2+ points", 1.0);
80 
82  mixReal();
83 
85  mixBackground();
86 
88  fill();
89 
92  fillPool();
93 
94  return kStOK;
95 }
96 
97 // ----------------------------------------------------------------------------
98 void StEEmcMixMaker::Clear( Option_t *opts )
99 {
100  mCandidates.clear();
101  mBackground.clear();
102  mPoints.clear();
103 
104  return;
105 }
106 
107 // ----------------------------------------------------------------------------
109 {
110 
111  if ( !mPoints.size() ) return;
112 
113  Float_t emax=0.;
114  Int_t count=0;
115 
116 
117  StMuEvent *event = mMuDstMaker -> muDst() -> event();
118  if ( !event ) return ;
119  StThreeVectorF v=event->primaryVertexPosition();
120  TVector3 vertex = TVector3(v.x(),v.y(),v.z());
121 
122 
124  if ( mFixedVertex.Z()<-500. ) {
125  if ( v.z()==0. && v.x()==0. && v.y()==0. ) return;
126  }
127  else {
128  vertex=mFixedVertex;
129  if ( mSigmaVertex > 0. ) vertex[2]=( mFixedVertex.Z() + mRandom->Gaus(0.,mSigmaVertex));
130  }
131 
132 
134  for ( UInt_t ipoint=0; ipoint<mPoints.size()-1; ipoint++ )
135  for ( UInt_t jpoint=ipoint+1; jpoint<mPoints.size(); jpoint++ )
136  {
137 
138  StEEmcPoint point1=mPoints[ipoint];
139  StEEmcPoint point2=mPoints[jpoint];
140 
142  Bool_t go1 = false;
143  Bool_t go2 = false;
144  for ( UInt_t isec=0;isec<mSectorList.size();isec++ )
145  {
146  go1 |= point1.sector() == mSectorList[isec];
147  go2 |= point2.sector() == mSectorList[isec];
148  }
149  if ( !(go1&&go2) ) continue;
150 
151 
153  if ( point1.sector() != point2.sector() ) continue;
154 
155  count++;
156  mCandidates.push_back ( StEEmcPair( point1, point2, vertex, vertex ) );
157  if ( mCandidates.back().energy() > emax ) {
158  emax = mCandidates.back().energy();
159  }
160 
161  }
162 
163 
164 }
165 
167 {
168 
169  if ( !mPoints.size() ) return ;
170 
172  StEEmcTower high_tower = mEEanalysis->hightower();
173 
174  Int_t bin=(Int_t)(high_tower.adc()/100);
175  if ( bin<0 ) bin=0;
176  if ( bin>40 ) bin=40;
177 
180  StEEmcPointVec_t &points = mPool[bin];
181 
182  StMuEvent *event = mMuDstMaker -> muDst() -> event();
183  if ( !event ) return;
184  StThreeVectorF v=event->primaryVertexPosition();
185  TVector3 vertex = TVector3(v.x(),v.y(),v.z());
186 
187  if ( mFixedVertex.Z()<-500. ) {
188  if ( v.z()==0. && v.x()==0. && v.y()==0. ) return;
189  }
190  else {
191  vertex=mFixedVertex;
192  if ( mSigmaVertex > 0. ) vertex[2]=( mFixedVertex.Z() + mRandom->Gaus(0.,mSigmaVertex));
193  }
194 
195 
197  for ( UInt_t i=0; i<mPoints.size(); i++ ) {
198 
199  StEEmcPoint point1=mPoints[i];
200 
202  for ( UInt_t j=0; j<points.size(); j++ ) {
203 
204  StEEmcPoint point2=points[j];
205 
207  Bool_t go1 = false;
208  Bool_t go2 = false;
209  for ( UInt_t isec=0;isec<mSectorList.size();isec++ )
210  {
211  go1 |= point1.sector() == mSectorList[isec];
212  go2 |= point2.sector() == mSectorList[isec];
213  }
214  if ( !(go1&&go2) ) continue;
215 
217  if ( point1.sector() != point2.sector() ) continue;
218 
220  mBackground.push_back( StEEmcPair( point1, point2, vertex, vertex ) );
221 
222 
223 
224  }// pool
225 
226  }// current
227 
228 }
229 
230 
231 
232 // ----------------------------------------------------------------------------
233 Bool_t StEEmcMixMaker::accept( StMuEvent *event )
234 {
235  if ( !event ) return false;
236  StMuTriggerIdCollection tic = event -> triggerIdCollection();
237  StTriggerId l1trig = tic.l1();
238 
240  if ( mTriggerList.size() <= 0 ) {
241  mH1[0]->Fill("no selection",1.0);
242  return true;
243  }
244 
245  Int_t go=0;
246  std::vector<Int_t>::iterator iter=mTriggerList.begin();
247  while ( iter != mTriggerList.end() ) {
248  go = l1trig.isTrigger( (*iter) );
249  if ( go ) {
250  go = (*iter);
251  break;
252  }
253  iter++;
254  }
255  TString name=go;
256  mH1[0]->Fill(name,1.0);
257  return (go!=0);
258 }
259 
260 
261 // ----------------------------------------------------------------------------
263 {
264 
265  // 1D QA histograms
266  mH1.push_back(new TH1F("triggers","Number of triggers fired",1,0.,1.));
267  TH1Helper::SetCanRebin(mH1[0]);
268  mH1.push_back(new TH1F("status","Events processed up to...",1,0.,1.));
269  TH1Helper::SetCanRebin(mH1[1]);
270 
271  // 2D QA histograms
272  mH2.push_back(new TH2F("uvha","<u> vs <v> for higher-energy gamma",288,0.,288.,288,0.,288.));
273  mH2.push_back(new TH2F("uvla","<u> vs <v> for lower-energy gamma",288,0.,288.,288,0.,288.));
274  mH2.push_back(new TH2F("uvhc","<u> vs <v> for higher-energy gamma, mass cut",288,0.,288.,288,0.,288.));
275  mH2.push_back(new TH2F("uvlc","<u> vs <v> for lower-energy gamma, mass cut",288,0.,288.,288,0.,288.));
276 
277 
278  mH1real.push_back(new TH1F("massR","Invariant mass of photon pairs",360,0.,3.6) );
279  mH1real.push_back(new TH1F("energyR","Energy of photon pairs",200,0.,40.));
280  mH1real.push_back(new TH1F("zggR","Energy sharing of photon pairs",50,0.,1.));
281  mH1real.push_back(new TH1F("phiggR","Opening angle of photon pairs",100,0.,0.1));
282  mH1real.push_back(new TH1F("ptR","p_{T} of photon pairs",100,0.,10.));
283  mH1real.push_back(new TH1F("zvertexR","Z_{vertex} [cm]",100,-100.,100.));
284 
285  mH1mix.push_back(new TH1F("massM","Invariant mass of photon pairs",360,0.,3.6) );
286  mH1mix.push_back(new TH1F("energyM","Energy of photon pairs",200,0.,40.));
287  mH1mix.push_back(new TH1F("zggM","Energy sharing of photon pairs",50,0.,1.));
288  mH1mix.push_back(new TH1F("phiggM","Opening angle of photon pairs",100,0.,0.1));
289  mH1mix.push_back(new TH1F("ptM","p_{T} of photon pairs",100,0.,10.));
290  mH1mix.push_back(new TH1F("zvertexM","Z_{vertex} [cm]",100,-100.,100.));
291 
292 }
293 
294 // ----------------------------------------------------------------------------
296 {
297 
298  StEEmcPairVec_t::iterator ipair=mCandidates.begin();
299  while ( ipair != mCandidates.end() ) {
300  fill( mH1real, (*ipair ) );
301  fillQA( mH2, (*ipair ) );
302  ipair++;
303  }
304 
305  ipair=mBackground.begin();
306  while ( ipair != mBackground.end() ) {
307  fill( mH1mix, (*ipair) );
308  ipair++;
309  }
310 
311 }
312 
313 void StEEmcMixMaker::fillQA( std::vector<TH2F *> &h, StEEmcPair pair )
314 {
315 
316  StEEmcPoint p1=pair.point(0);
317  StEEmcPoint p2=pair.point(1);
318  StEEmcSmdCluster uh,ul,vh,vl;
319  if ( p1.energy() > p2.energy() ) {
320  uh=p1.cluster(0); vh=p1.cluster(1);
321  ul=p2.cluster(0); vl=p2.cluster(1);
322  }
323  else {
324  ul=p1.cluster(0); vl=p1.cluster(1);
325  uh=p2.cluster(0); vh=p2.cluster(1);
326  }
327  mH2[0]->Fill( uh.mean(), vh.mean() );
328  mH2[1]->Fill( ul.mean(), vl.mean() );
329  if ( pair.mass() > mMinMass && pair.mass() < mMaxMass ) {
330  mH2[2]->Fill( uh.mean(), vh.mean() );
331  mH2[3]->Fill( ul.mean(), vl.mean() );
332  }
333 
334 }
335 
336 void StEEmcMixMaker::fill( std::vector<TH1F*> &h, StEEmcPair pair )
337 {
338 
339  h[0]->Fill( pair.mass() );
340  if ( pair.mass() > mMinMass && pair.mass() < mMaxMass ) {
341  h[1]->Fill( pair.energy() );
342  h[2]->Fill( pair.zgg() );
343  h[3]->Fill( pair.phigg() );
344  h[4]->Fill( pair.vertex().Z() );
345  }
346 
347 }
348 
349 
350 // ----------------------------------------------------------------------------
352 {
353 
354  if ( !mPoints.size() ) return;
355 
357  StEEmcTower high_tower = mEEanalysis->hightower();
358 
359  Int_t bin=(Int_t)(high_tower.adc()/100);
360  if ( bin<0 ) bin=0;
361  if ( bin>40 ) bin=40;
362 
365  StEEmcPointVec_t &points = mPool[bin];
366 
368  std::reverse(points.begin(),points.end());
369 
371  for ( UInt_t i=0; i<mPoints.size(); i++ ) {
372 
373  TVector3 d=mPoints[i].position();
374 
376  Int_t sec,sub,eta;
377  if ( !mEEmcTow->getTower(d,sec,sub,eta) ) continue;
378 
380  if ( mTrigMode == 1 ) {
381  if ( sec==high_tower.sector() &&
382  sub==high_tower.subsector() &&
383  eta==high_tower.etabin() ) continue;
384  }
385 
387  points.push_back( mPoints[i] );
388 
389  }
390 
392  std::reverse(points.begin(),points.end());
393 
395  if ( points.size() > (UInt_t)mPoolSize ) points.resize(mPoolSize);
396 
397 }
398 
399 // ----------------------------------------------------------------------------
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.