StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcPi0Maker.cxx
1 #include "StEEmcPi0Maker.h"
2 #include "StMessMgr.h"
3 
4 #include "StEEmcPair.h"
5 
6 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
7 #include "StMuDSTMaker/COMMON/StMuDst.h"
8 #include "StMuDSTMaker/COMMON/StMuEvent.h"
9 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
10 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
11 
12 #include "StEvent/StEvent.h"
13 #include "StEvent/StTriggerIdCollection.h"
14 #include "StEvent/StTriggerId.h"
15 
16 #include "StarClassLibrary/StThreeVectorF.hh"
17 #include "StarRoot/TH1Helper.h"
18 
19 #include "TH1F.h"
20 #include "TH2F.h"
21 
22 #include "TFile.h"
23 #include "TTree.h"
24 #include "StEEmcMixEvent.h"
25 
26 ClassImp(StEEmcPi0Maker);
27 
28 //34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
29 // 1 2 3 4 5 6 7 *
30 
31 // ---------------------------------------------------------------------------
32 StEEmcPi0Maker::StEEmcPi0Maker( const Char_t *name,
33  StEEmcA2EMaker *a2e,
35  StEEmcGenericPointMaker *pt ) : StMaker(name)
36 {
37  mEEanalysis=a2e; assert(a2e);
38  mEEclusters=cl; assert(cl);
39  mEEpoints=pt; assert(pt);
40  mCheckTrigger=false;
41  setFile(0);
42  mTree=0;
43 }
44 
45 void StEEmcPi0Maker::setFile( TFile *f ){ mFile=f; }
46 TTree *StEEmcPi0Maker::tree(){ return mTree; }
47 
48 // ---------------------------------------------------------------------------
49 Int_t StEEmcPi0Maker::Init()
50 {
51  hMass = new TH2F("hMass","Diphoton invariant mass; M [GeV]",120,0.,1.2,20,0.,20.);
52  hMass_cut = new TH2F("hMass_cut","Diphoton invariant mass; M [GeV]",120,0.,1.2,20,0.,20.);
53  hMass_split = new TH2F("hMass_split","Mass for events w/ a split smd cluster",120,0.,1.2,20,0.,20.);
54 
55  hPT = new TH1F("hPT","Diphoton p_{T}; p_{T} [GeV]",20,0.,20.);
56  hPT_cut = new TH1F("hPT_cut","Diphoton p_{T}; p_{T} [GeV]",20,0.,20.);
57  hXF = new TH1F("hXF","x_{F}=#frac{p_{L}}{#sqrt{s}/2}",50,0.,1.);
58  hEnergy = new TH1F("hEnergy","Diphoton energy; E [GeV]",50,0.,50.);
59  hEta = new TH1F("hEta","Diphoton #eta",24,0.8,2.2);
60  hPhi = new TH1F("hPhi","Diphoton #phi",30,-3.142,3.142);
61  hZvertex= new TH1F("hZvertex","z vertex",150,-150.,150.);
62  hZgg = new TH1F("hZgg","energy sharing",50,0.,1.);
63  hZgg_cut = new TH1F("hZgg_cut","energy sharing",50,0.,1.);
64 
65  hEChi2 = new TH1F("hEChi2","#sum_{points} #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
66  hE1Chi2 = new TH1F("hE1Chi2","point1 #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
67  hE2Chi2 = new TH1F("hE2Chi2","point2 #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
68 
69  hEChi2_low = new TH1F("hEChi2_low","#sum_{points} #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
70  hE1Chi2_low = new TH1F("hE1Chi2_low","point1 #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
71  hE2Chi2_low = new TH1F("hE2Chi2_low","point2 #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
72 
73  hEChi2_hi = new TH1F("hEChi2_hi","#sum_{points} #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
74  hE1Chi2_hi = new TH1F("hE1Chi2_hi","point1 #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
75  hE2Chi2_hi = new TH1F("hE2Chi2_hi","point2 #frac{(Eu-Ev)^{2}}{Nmip}",50,0.,10.);
76 
77  hRatio = new TH1F("hRatio","E_{smd} / E_{towers}",20,0.,0.05);
78  hRatio_low = new TH1F("hRatio_low","E_{smd} / E_{towers}",20,0.,0.05);
79  hRatio_hi = new TH1F("hRatio_hi","E_{smd} / E_{towers}",20,0.,0.05);
80 
81  hEvents = new TH1F("hEvents","event counter",1,0.,1.);
82  TH1Helper::SetCanRebin(hEvents);
83 
84  //hdEds = new TH2F("hdEds","smd energy derivative; #frac{1}{E}#frac{dE}{ds}; rel. strip",30,-2.0,1.0,10,-5.,5.);
85 
86  if ( mFile )
87  {
88  mTree=new TTree("mPi0Tree","EEmc pi0 events");
89  mPi0Event=new StEEmcMixEvent();
90  mTree->Branch("pi0event",&mPi0Event,32000,99);
91  mTree->SetDirectory( mFile );
92  }
93 
94  return StMaker::Init();
95 }
96 
97 // ---------------------------------------------------------------------------
99 {
100 
101  StMuDstMaker *mudst=(StMuDstMaker*)GetMaker("MuDst");
102  assert(mudst);
103 
104  hEvents->Fill("event",1.0);
105 
106  if ( !checkTrigger() ) return kStOK;
107  hEvents->Fill("trigger",1.0);
108 
110  TVector3 vertex( pv.x(), pv.y(), pv.z() );
111 
112  if ( pv.z() < -150. || pv.z() > 150.0 || pv.z()==0.0 ) return kStOK;
113  hEvents->Fill("vertex",1.0);
114 
115  // get the points from the point maker
116  StEEmcPointVec_t points = mEEpoints->points();
117 
118  if ( points.size() < 2 ) return kStOK;
119  hEvents->Fill("two+ points",1.0);
120 
121  mPi0Event->setEvent( mudst->muDst()->event() );
122 
123  // loop over all pairs of points
124  for ( UInt_t ipoint=0;ipoint<points.size();ipoint++ )
125  {
126  StEEmcPoint p1 = points[ipoint];
127 
128 
129  for ( UInt_t jpoint=0;jpoint<points.size();jpoint++ )
130  {
131  if (ipoint>=jpoint) continue;
132  StEEmcPoint p2=points[jpoint];
133 
134 
135  Int_t phibin1 = p1.tower(0).phibin();
136  Int_t phibin2 = p2.tower(0).phibin();
137 
138  //Int_t etabin1 = p1.tower(0).etabin();
139  //Int_t etabin2 = p2.tower(0).etabin();
140 
141  //Int_t deta = TMath::Abs(etabin1-etabin2);
142  Int_t dphi = phibin1-phibin2;
143  if ( dphi < 0 ) dphi+=60;
144  if ( dphi > 30 ) dphi=60-dphi;
145 
146  if ( dphi > 10 ) continue;
149  StEEmcPair pair(p1,p2,vertex,vertex);
150 
151 
152  /***********************************************
153  **
154  ** Fill the TTre and the list of pi0 pairs
155  **
156  ***********************************************/
157 
158  mPairs.push_back( pair );
159  mPi0Event->addPair( pair );
160 
161  //Int_t index1 = p1.tower(0).index();
162  //Int_t index2 = p2.tower(0).index();
163 
164  StEEmcClusterVec_t tower_clusters; // tower clusters associated w/ pair (should be 1 or 2)
165  StEEmcCluster c1 = p1.clusters(0)[0];
166  StEEmcCluster c2 = p2.clusters(0)[0];
167  tower_clusters.push_back( c1 );
168  if ( c1.key() != c2.key() ) {
169  tower_clusters.push_back(c2);
170  }
171 
172  mPi0Event->mNumberOfTowerClusters.push_back( (Int_t)tower_clusters.size() );
173 
174  Int_t ntracks = 0;
175  Int_t npoints = 0;
176  for ( UInt_t i=0;i<tower_clusters.size();i++ )
177  {
178  ntracks += mEEclusters->numberOfTracks( tower_clusters[i] );
179  npoints += mEEpoints->numberOfPoints( tower_clusters[i] );
180  }
181  mPi0Event->mNumberOfTracks.push_back( ntracks );
182  mPi0Event->mNumberOfPoints.push_back( npoints );
183 
184 
185 
186  /***********************************************/
187 
188 
189 
190 
192 
193 
194  hEvents->Fill("pair",1.0);
195 
196  if ( pair.momentum().Perp() < 3.0 ) continue;
197 
198  hEvents->Fill("pair pt>3",1.0);
199 
200 
201  // printf("------------------- retrieve tower clusters from points -------------------\n");
202  StEEmcCluster cluster1=p1.clusters(0).at(0); //mEEpoints->cluster( p1 );
203  StEEmcCluster cluster2=p2.clusters(0).at(0); //mEEpoints->cluster( p2 );
204 
205  // require both points to match same tower cluster
206  //555 if ( cluster1.key() != cluster2.key() ) continue;
207 
208  hEvents->Fill("pair in cl",1.0);
209  // require 2 and only 2 smd clusters matched to tower cluster
210  // in each view
211 
212  if ( cluster1.numberOfMatchingClusters(4) > 2 ||
213  cluster1.numberOfMatchingClusters(5) > 2 ) continue;
214 
215  StEEmcSmdCluster u1=p1.cluster(0);
216  StEEmcSmdCluster u2=p2.cluster(0);
217  StEEmcSmdCluster v1=p1.cluster(1);
218  StEEmcSmdCluster v2=p2.cluster(1);
219 
220  Bool_t didSplit = false;
221  if ( u1.key() == u2.key() || v1.key() == v2.key() ) didSplit=true;
222 
223 
224  // printf("cluster1 key=%i E=%5.2f cluster2 key=%i E=%5.2f\n",
225  // cluster1.key(),cluster1.energy(),cluster2.key(),cluster2.energy());
226 
227  Float_t esum_smd = u1.energy()+u2.energy()+v1.energy()+v2.energy(); // [GeV]
228  Float_t esum_tow = cluster1.energy();
229  if ( cluster1.key() != cluster2.key() ) esum_tow += cluster2.energy();
230 
231 
232 
233  hEvents->Fill("pair ncl",1.0);
234 
235  hMass->Fill( pair.mass(), pair.pt() );
236  if( didSplit ) hMass_split->Fill( pair.mass(), pair.pt() );
237 
238  Float_t ediff1 = 1000.0*(u1.energy()-v1.energy());
239  Float_t ediff2 = 1000.0*(u2.energy()-v2.energy());
240  Float_t nmip1 = 1000.0*(u1.energy()+v1.energy())/1.3;
241  Float_t nmip2 = 1000.0*(u2.energy()+v2.energy())/1.3;
242  if ( nmip1>0. && nmip2>0. )
243  {
244  Float_t e1chi2 = ediff1*ediff1/nmip1;
245  Float_t e2chi2 = ediff2*ediff2/nmip2;
246  Float_t echi2 = e1chi2+e2chi2;
247 
248  if ( e1chi2 < 4.0 && e2chi2 < 4.0 ) {
249  hMass_cut -> Fill( pair.mass(), pair.pt() );
250  if ( pair.mass()>0.1 && pair.mass()<0.18 ) hPT_cut->Fill( pair.pt() );
251  if ( pair.mass()>0.1 && pair.mass()<0.18 ) hZgg_cut->Fill( pair.zgg() );
252  }
253 
254  if ( pair.mass() < 0.1 ) {
255  hEChi2_low->Fill(echi2);
256  hE1Chi2_low->Fill(e1chi2);
257  hE2Chi2_low->Fill(e2chi2);
258  hRatio_low -> Fill( esum_smd/esum_tow );
259  }
260  if ( pair.mass() > 0.2 ) {
261  hEChi2_hi->Fill(echi2);
262  hE1Chi2_hi->Fill(e1chi2);
263  hE2Chi2_hi->Fill(e2chi2);
264  hRatio_hi -> Fill( esum_smd/esum_tow );
265  }
266  }
267 
268 
269  if ( pair.mass() > 0.1 && pair.mass() < 0.18 ) {
270 
271  hPT->Fill( pair.momentum().Perp() );
272  hXF->Fill( pair.momentum().Z()/100.0 );
273  hEnergy->Fill( pair.energy() );
274  hEta->Fill( pair.momentum().Eta() );
275  hPhi->Fill( pair.momentum().Phi() );
276  hZvertex->Fill( pair.vertex().Z() );
277  hZgg->Fill( pair.zgg() );
278 
279  if ( nmip1==0. || nmip2==0. ) continue;
280  Float_t e1chi2 = ediff1*ediff1/nmip1;
281  Float_t e2chi2 = ediff2*ediff2/nmip2;
282  Float_t echi2 = e1chi2+e2chi2;
283 
284  hEChi2->Fill(echi2);
285  hE1Chi2->Fill(e1chi2);
286  hE2Chi2->Fill(e2chi2);
287  hRatio -> Fill( esum_smd/esum_tow );
288  printf("esum_smd/esum_tow = %5.3f\n", esum_smd/esum_tow );
289 
290  }
291 
292  }
293  }
294 
295  if ( mTree )
296  mTree->Fill();
297 
298  return kStOK;
299 }
300 
301 
302 
303 // ---------------------------------------------------------------------------
304 void StEEmcPi0Maker::Clear(Option_t *opts)
305 {
306  mPairs.clear();
307  mPi0Event->Clear();
308 }
309 
310 
311 
312 // ----------------------------------------------------------------------------
313 void StEEmcPi0Maker::setCheckTrigger(Bool_t t){ mCheckTrigger=t; }
314 void StEEmcPi0Maker::addTrigger(Int_t t){ mTriggerList.push_back(t); }
315 
317 {
318 
320  if ( mTriggerList.size() == 0 ) return 1;
321 
322  StTriggerId nominal;
323 
325  StMuDstMaker *mumk = (StMuDstMaker*)GetMaker("MuDst");
326  StEvent *event = (StEvent*)GetInputDS("StEvent");
327 
328  if ( mumk )
329  {
330  nominal = mumk->muDst()->event()->triggerIdCollection().nominal();
331  goto CHECK_TRIGGER;
332  }
333 
335 
336  if ( event )
337  {
338  nominal=*event->triggerIdCollection()->nominal();
339  goto CHECK_TRIGGER;
340  }
341 
343  goto NO_DATA;
344 
345 
346  CHECK_TRIGGER:
347 
348  for ( UInt_t ii=0;ii<mTriggerList.size();ii++ )
349  {
350  if ( nominal.isTrigger( mTriggerList[ii] ) ) return mTriggerList[ii];
351  }
352  return 0;
353 
354  NO_DATA:
355  assert(2+2==5); // noooo data $
356  return 0;
357 
358 }
void cluster(const StEEmcSmdCluster &c, Int_t plane)
Add an smd cluster to this point.
Definition: StEEmcPoint.h:40
void Clear(Option_t *opts="")
User defined functions.
StThreeVectorF primaryVertexPosition(int vtx_id=-1) const
The StMuDst is supposed to be structured in &#39;physical events&#39;. Therefore there is only 1 primary vert...
Definition: StMuEvent.cxx:221
EEmc ADC –&gt; energy maker.
Base class for representing EEMC points.
Definition: StEEmcPoint.h:24
StMuDst * muDst()
Definition: StMuDstMaker.h:425
StEEmcGenericClusterMaker * mEEclusters
Int_t numberOfPoints() const
Number of points.
const TVector3 & momentum() const
Returns momentum of pair.
Definition: StEEmcPair.h:78
const TVector3 & vertex() const
Returns vertex of pair.
Definition: StEEmcPair.h:79
copied from muDst
std::vector< Int_t > mNumberOfPoints
Float_t zgg() const
Returns energy-sharing of pair.
Definition: StEEmcPair.h:75
StEEmcPointMaker * mEEpoints
pointer to the point maker
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Float_t energy() const
Returns energy of pair.
Definition: StEEmcPair.h:74
Int_t key()
Return a unique key assigned by the cluster maker.
StEEmcGenericPointMaker * mEEpoints
Definition: Stypes.h:40
A base class for representing clusters of EEMC smd strips.
Float_t energy() const
Get energy of this cluster.
Definition: StEEmcCluster.h:62
StEEmcPointVec_t & points()
Return vector of EEmc points.
void tower(const StEEmcTower &t, Float_t w=1.)
Add a tower with specified weight to the point.
Definition: StEEmcPoint.h:38
std::vector< Int_t > mNumberOfTracks
A base class for describing clusters of EEMC towers.
Definition: StEEmcCluster.h:50
Float_t mass() const
Returns invariant mass of pair.
Definition: StEEmcPair.h:73
StEEmcA2EMaker * mEEanalysis
pointer to analysis maker
Float_t pt() const
Returns pt of pair.
Definition: StEEmcPair.h:77
A class to represent pairs of points.
Definition: StEEmcPair.h:9
Int_t numberOfTracks(const StEEmcCluster &cluster) const
StEEmcClusterVec_t & clusters(Int_t layer)
Returns tower clusters for the specified layer 0=T, 1=P, 2=Q, 3=R, 4+=crash.
Definition: StEEmcPoint.h:53