StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WtpcFilter.cxx
1 // $Id: WtpcFilter.cxx,v 1.3 2011/09/14 14:23:21 stevens4 Exp $
2 //
3 //*-- Author : Jan Balewski, MIT
4 
5 #include <assert.h>
6 #include <TObjArray.h>
7 #include <StMessMgr.h>
8 #include <TH2.h>
9 #include <TList.h>
10 #include <TLine.h>
11 #include <TMath.h>
12 
13 #include <StMuDSTMaker/COMMON/StMuTrack.h>
14 //----------------------------
15 //------- Sector dependent TPC track filter
16 //----------------------------
17 
18 #include "WtpcFilter.h"
19 #include "WanaConst.h"
20 
21 //--------------------------------------
22 //--------------------------------------
23 WtpcFilter::WtpcFilter() {
24  secID=0;
25  HList=0;
26  name="fixMe";
27  par_nFitPts=-1;
28 }
29 
30 
31 //--------------------------------------
32 //--------------------------------------
33 void
34 WtpcFilter::init(const char *core, int sec, TObjArray *HListX) {
35  HList=HListX;
36  secID=sec;
37  name=core; name+=secID; name+="_";
38  assert(HList);
39  assert(secID);
40  assert(par_nFitPts>0);
41 
42  LOG_INFO<<Form("::InitTPC filter (sec=%d) done, name=%s= nFit>%d, hitFrac>%.2f Rin<%.1fcm, Rout>%.1fcm",secID,name.Data(),par_nFitPts, par_nHitFrac, par_Rmin, par_Rmax)<<endm;
43 
44  initHistos();
45 }
46 
47 //--------------------------------------
48 //--------------------------------------
49 bool
50 WtpcFilter::accept( const StMuTrack *prTr){
51 
52  hA[0]->Fill("inp",1.);
53 
54  hA[2]->Fill(prTr->nHitsFit());
55  if(prTr->nHitsFit()<=par_nFitPts) return false;
56 
57  hA[0]->Fill("nHit",1.);
58  float hitFrac=1.*prTr->nHitsFit()/prTr->nHitsPoss();
59  hA[3]->Fill(hitFrac);
60  if(hitFrac<par_nHitFrac) return false;
61 
62  hA[0]->Fill("Hfrac",1.);
64  hA[4]->Fill(ri.perp());
65  if(ri.perp()>par_Rmin) return false;
66 
67  hA[0]->Fill("Rin",1.);
68  StThreeVectorF ro=prTr->globalTrack()->lastPoint();
69  hA[5]->Fill(ro.perp());
70  if(ro.perp()<par_Rmax) return false;
71 
72 
73  // accepted .......
74  hA[0]->Fill("Rout",1.);
75  hA[1]->Fill(ro.pseudoRapidity(),ro.phi());
76  float dedx=prTr->dEdx()*1e6;
77  hA[6]->Fill(prTr->p().mag(),dedx);
78  return true;
79 }
80 
81 
82 //--------------------------------------
83 //--------------------------------------
84 int
85 WtpcFilter::getTpcSec(float phiRad, float etaDet){ // finds TPC sector for hit(phi,eta)
86  const float PI=TMath::Pi();
87  int sec=0;
88  float phi=phiRad/PI*180; // now in degrees
89  if (etaDet>0) { // West TPC
90  float x=75-phi;
91  while(x<0) x+=360;
92  sec=1+(int)( x/30.);
93  } else {
94  float x=phi-105;
95  while(x<0) x+=360;
96  sec=13+(int)( x/30.);
97  }
98  // printf("phi/deg=%.1f, x=%.1f\n",phi,x);
99  assert(sec>0);
100  assert(sec<=mxTpcSec);
101  return sec;
102 }
103 
104 
105 //--------------------------------------
106 //--------------------------------------
107 void
108 WtpcFilter::initHistos() {
109  int myCol=2+ secID%6;
110 
111  //...... data histograms
112  memset(hA,0,sizeof(hA));
113  TList *Lx; TLine *ln;TH1 *h;
114 
115  TString sufix=", TPC sec="; sufix+=secID;
116  int nCase=6;
117  hA[0]=h=new TH1F(name+"Stat","track counter"+sufix+"; Cases",nCase,0,nCase);
118  h->SetLineColor(myCol );
119 
120  hA[1]=h=new TH2F(name+"Tr2D1","lastHit, accepted"+sufix+"; detector eta ; detector phi (rad)",100,-1.1,1.1,200,-3.2,3.2);
121  h->SetLineColor(myCol );
122 
123  hA[2]=h=new TH1F(name+"TrNfit","prim tr nFitP"+sufix+"; nFitPoints",50,0,50);
124  Lx=h->GetListOfFunctions();
125  ln=new TLine(par_nFitPts,0,par_nFitPts,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
126 
127 
128  hA[3]=h=new TH1F(name+"TrFitFrac","prim tr nFitFrac"+sufix+"; nFit/nPoss ",50,0,1.1);
129  Lx=h->GetListOfFunctions();
130  ln=new TLine(par_nHitFrac,0,par_nHitFrac,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
131 
132  hA[4]=h=new TH1F(name+"TrRxyIn","prim tr 1st hit filter"+sufix+"; Rxy (cm)",60,50,170.);
133  Lx=h->GetListOfFunctions();
134  ln=new TLine(par_Rmin,0,par_Rmin,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
135 
136  hA[5]=h=new TH1F(name+"TrRxyOut","prim tr last hit filter"+sufix+"; Rxy (cm)",60,100,220.);
137  Lx=h->GetListOfFunctions();
138  ln=new TLine(par_Rmax,0,par_Rmax,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
139 
140 
141  hA[6]=h=new TH2F(name+"TrdEdX"," dEdX vs. P, accpted "+sufix+"; track P (GeV); dE/dx (keV)",20,0,10,100,0,10);
142 
143 
144  // add histos to the list (if provided)
145  for(int i=0;i<mxHA;i++) {
146  if( hA[i]==0) continue;
147  HList->Add( hA[i]);
148  }
149 
150  // HList->ls();
151  //LOG_INFO<<Form("TpcFilter-%s::initHistos done",name.Data())<<endm;
152 
153 }
UShort_t nHitsFit() const
Return total number of hits used in fit.
Definition: StMuTrack.h:239
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
Definition: StMuTrack.h:259
const StThreeVectorF & firstPoint() const
Returns positions of first measured point.
Definition: StMuTrack.h:261
UShort_t nHitsPoss() const
Return number of possible hits on track.
Definition: StMuTrack.cxx:242
const StThreeVectorF & lastPoint() const
Returns positions of last measured point.
Definition: StMuTrack.h:262
Double_t dEdx() const
Returns measured dE/dx value.
Definition: StMuTrack.h:248
const StMuTrack * globalTrack() const
Returns pointer to associated global track. Null pointer if no global track available.
Definition: StMuTrack.h:272