StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
gl3RICH.cxx
1 //-----------------------------------------------------------------
2 //: FILE: gl3RICH.cc
3 //: HISTORY:
4 //: 22Jun2K version 1.00
5 //:<------------------------------------------------------------------
6 #include "gl3RICH.h"
7 
8 #include <math.h>
9 //#include <L3io.h>
10 
11 //####################################################################
12 //
13 //####################################################################
14 int gl3RICH::init( )
15 {
16  // RICH coordinates
17  //
18  mGlobalRichEdgeXmin= 83.988;
19  mGlobalRichEdgeXmax= 156.503;
20  mGlobalRichEdgeYmin=-228.489;
21  mGlobalRichEdgeYmax=-186.983;
22  mGlobalRichEdgeZmin= -65.781;
23  mGlobalRichEdgeZmax= 65.163;
24 
25  // Cylindrical coordinates: 5 o'clock = -60 degrees
26  mLocalOriginR = 243.13;
27  mLocalOriginPhi = -M_PI/3.;
28 
29  // histograms
30 #ifdef GL3ROOT
31  hXVertex = new TH1D("hXVertex","event vertices x [cm]",50,-2.5,2.5);
32  hYVertex = new TH1D("hYVertex","event vertices y [cm]",50,-2.5,2.5);
33  hZVertex = new TH1D("hZVertex","event vertices z [cm]",800,-200,200);
34 
35  hPtGlobalPosRICH = new TH1D("hPtGlobalPosRICH","Pt global h+ in RICH",300,0,6);
36  hPGlobalPosRICH = new TH1D("hPGlobalPosRICH","P global h + in RICH",300,0,6);
37 
38  hPtGlobalNegRICH = new TH1D("hPtGlobalNegRICH","Pt global h- in RICH",300,0,6);
39  hPGlobalNegRICH = new TH1D("hPGlobalNegRICH","P global h- in RICH",300,0,6);
40 
41  hnHitsGlobalPosRICH = new TH1D("hnHitsGlobalPosRICH","nHits globals + in RICH",46,0,46);
42  hnHitsGlobalNegRICH = new TH1D("hnHitsGlobalNegRICH","nHits globals - in RICH",46,0,46);
43 
44  hdcaGlobal = new TH1D("hdcaGlobal", "dca global tracks", 104, -1, 25);
45  hetaRICH = new TH1D("hethaRICH","etha global RICH",200,-1,1);
46  hRLast = new TH1D("hRLast","last hit of TPC track",200,0,200);
47 #endif
48 
49  return 0 ;
50 }
51 
52 //####################################################################
53 //
54 //####################################################################
55 int gl3RICH::setParameters(int maxAbsVertZ, int minNoOfHits, int are, int place , int holders, float minP, float minPt, float minR, float maxDCA, float minimumAbsEta )
56 {
57  // zvert
58  if(maxAbsVertZ>=0 && maxAbsVertZ<=200) maxAbsEventVertZ = maxAbsVertZ;
59  else maxAbsEventVertZ=30.0; // zvert
60  // nHits
61  if(minNoOfHits>=5 && minNoOfHits<=45) minNoOfHitsOnTrack = minNoOfHits;
62  else minNoOfHitsOnTrack=23; // nhits
63  // P min to trigger on
64  if(minP>=0.0 && minP<10.0) minPExtrapolated2Rich=minP;
65  else minPExtrapolated2Rich=1.0;// GeV
66  // Pt min to trigger on
67  if(minPt>=0.0 && minPt<10.0) minPtExtrapolated2Rich=minPt;
68  else minPtExtrapolated2Rich=1.0;// GeV
69  // min Radius of last point in tpc
70  if(minR>=50.0 && minR<200.0 ) minRofLastPointOnTrack=minR;
71  else minRofLastPointOnTrack=160; // cm
72  // DCA
73  if(maxDCA>=0.0 && maxDCA<=100) maxDCAToEventVertex=maxDCA;
74  else maxDCAToEventVertex=10; // cm
75  // eta
76  if(minimumAbsEta>0.0 && minimumAbsEta<0.5) minAbsEta=minimumAbsEta;
77  else minAbsEta=2;
78 
79  return 0;
80 }
81 
82 
83 //####################################################################
84 //
85 //####################################################################
86 int gl3RICH::decide ( )
87 {
88  // DEBUG
89  // printf ( "doing gl3RICH process!!!\n");
90 
91  // init
92 //VPunused short sector = 0 ;
93  gl3Track* gTrack ;
94 
95 
96  int noOfTracksExtrapolated2RICH=0;
97 
98  event->makeVertex();
99 
100  // DEBUG
101  //cout<<"Vx:"<<event->getVertex().Getx()<<" Vy:"<<event->getVertex().Gety()<<" Vz:"<<event->getVertex().Getz()<<endl;
102 
103  if( fabs(event->getVertex().Getz()) <= maxAbsEventVertZ)
104  {
105 #ifdef GL3ROOT
106  hXVertex->Fill(event->getVertex().Getx());
107  hYVertex->Fill(event->getVertex().Gety());
108  hZVertex->Fill(event->getVertex().Getz());
109 #endif
110 
111  // RICH plane parameters as used by intersectorZLine
112  const float a = -1./tan(mLocalOriginPhi);
113  const float b = ( mLocalOriginR*sin(mLocalOriginPhi)
114  - a*mLocalOriginR*cos(mLocalOriginPhi) );
115 
116  Ftf3DHit closestHitToEventVertex;
117  Ftf3DHit richHit1, /*richHit2,*/ lastHit;
118 
119  // loop over gtracks
120  for (int trkcnt = 0 ; trkcnt<event->getNTracks(); trkcnt++ )
121  {
122  gTrack = event->getTrack(trkcnt);
123 
124  //momentum
125  double px = gTrack->pt * cos(gTrack->psi);
126  double py = gTrack->pt * sin(gTrack->psi);
127  double pz = gTrack->pt * gTrack->tanl;
128  double p = ::sqrt(px*px+py*py+pz*pz);
129  // pseudorapidity
130  double eta = -::log(tan(acos(pz/p)/2));
131 
132 
133  // cut nHits, P, Pt and eta
134  if( gTrack->nHits>=minNoOfHitsOnTrack && p>=minPExtrapolated2Rich && gTrack->pt>=minPtExtrapolated2Rich && fabs(eta)<=minAbsEta )
135  {
136 
137  // traversing the rich ???
138  if (
139 // 0==gTrack->intersectorZLine( a, b, richHit1, richHit2)
140  0==gTrack->intersectorZLine( a, b, richHit1 )
141 
142  &&
143 // (
144  ( richHit1.x > mGlobalRichEdgeXmin &&
145  richHit1.x < mGlobalRichEdgeXmax &&
146  richHit1.y > mGlobalRichEdgeYmin &&
147  richHit1.y < mGlobalRichEdgeYmax &&
148  richHit1.z > mGlobalRichEdgeZmin &&
149  richHit1.z < mGlobalRichEdgeZmax )
150 // ||
151 // ( richHit2.x > mGlobalRichEdgeXmin &&
152 // richHit2.x < mGlobalRichEdgeXmax &&
153 // richHit2.y > mGlobalRichEdgeYmin &&
154 // richHit2.y < mGlobalRichEdgeYmax &&
155 // richHit2.z > mGlobalRichEdgeZmin &&
156 // richHit2.z < mGlobalRichEdgeZmax )
157 // )
158  ) {
159 
160  // length
161  double trackLength= gTrack->length/cos(atan(gTrack->tanl));
162  lastHit=gTrack->extrapolate2PathLength(trackLength);
163 
164  // check if extrapolation makes sense
165  if( lastHit.z>=mGlobalRichEdgeZmin && lastHit.z<=mGlobalRichEdgeZmax )
166  {
167  // Rlast
168  double Rlast=::sqrt(lastHit.x*lastHit.x+lastHit.y*lastHit.y);
169 
170  // dca
171  closestHitToEventVertex = gTrack->closestApproach( event->getVertex().Getx(), event->getVertex().Gety() );
172  double dx=fabs( event->getVertex().Getx() - closestHitToEventVertex.x );
173  double dy=fabs( event->getVertex().Gety() - closestHitToEventVertex.y );
174  double dz=fabs( event->getVertex().Getz() - closestHitToEventVertex.z );
175  double dca=::sqrt(dx*dx+dy*dy+dz*dz);
176 
177 #ifdef GL3ROOT
178 
179 #endif
180 
181  if(dca<maxDCAToEventVertex && Rlast>minRofLastPointOnTrack)
182  {
183  noOfTracksExtrapolated2RICH++;
184 
185  // DEBUG
186  //cout<<"# "<<noOfTracksExtrapolated2RICH<<" nHits:"<<gTrack->nHits<<" dca:"<<dca<<" trlen:"<<trackLength<<" Rlast:"<<Rlast<<" pt:"<<gTrack->pt<<" p:"<<p<<" eta:"<<eta<<endl;
187 
188  // DEBUG
189  // ftfLog("Found a RICH track!\n");
190  // cout << richHit1 << " " << richHit2 << endl;
191 
192 #ifdef GL3ROOT
193  hetaRICH->Fill(eta);
194  hdcaGlobal->Fill(dca);
195  hRLast->Fill(Rlast);
196 
197  if(gTrack->q>0)
198  {
199  hPtGlobalPosRICH->Fill(gTrack->pt);
200  hPGlobalPosRICH->Fill(p);
201  hnHitsGlobalPosRICH->Fill(gTrack->nHits);
202  }
203  else
204  {
205  hPtGlobalNegRICH->Fill(gTrack->pt);
206  hPGlobalNegRICH->Fill(p);
207  hnHitsGlobalNegRICH->Fill(gTrack->nHits);
208  }
209 #endif
210  } // if(dca<maxDCAToEventVertex)
211 
212  } // zLast check
213 
214  } // traversing the RICH
215 
216  } // if( gTrack->nHits>=minNoOfHitsOnTrack && p>=minPExtrapolated2Rich && eta>=minAbsEta )
217 
218  } // trackloop
219 
220  } //if( fabs(event->getVertex().Getz()) <= maxAbsEventVertz)
221 
222  // DECISION
223  if( noOfTracksExtrapolated2RICH>0 ) {
224  // DEBUG
225  //cout<<"Event triggered! #tracks:"<<noOfTracksExtrapolated2RICH<<endl;
226  return 1;
227  } else {
228  // DEBUG
229  //cout<<"Event rejectetd! "<<endl;
230  return 0;
231  }
232 }
233 
234 //####################################################################
235 //
236 //####################################################################
237 int gl3RICH::end ( ) {
238 
239 #ifdef GL3ROOT
240  hPtGlobalPosRICH->Write();
241  hPtGlobalNegRICH->Write();
242 
243  hPGlobalPosRICH->Write();
244  hPGlobalNegRICH->Write();
245 
246  hnHitsGlobalPosRICH->Write();
247  hnHitsGlobalNegRICH->Write();
248 
249  hXVertex->Write();
250  hYVertex->Write();
251  hZVertex->Write();
252 
253  hdcaGlobal->Write();
254  hetaRICH->Write();
255  hRLast->Write();
256 #endif
257 
258  return 0 ;
259 }
260 
261 
262 
263 
264