StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WtpcFilter.cxx
1 // $Id: WtpcFilter.cxx,v 1.5 2012/08/21 17:40:09 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, bool barrel=true) {
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(barrel);
45 }
46 
47 //--------------------------------------
48 //--------------------------------------
49 bool
50 WtpcFilter::accept( const StMuTrack *prTr){
51  hA[0]->Fill("inp",1.);
52 
53  hA[2]->Fill(prTr->nHitsFit());
54  if(prTr->nHitsFit()<=par_nFitPts) return false;
55 
56  hA[0]->Fill("nHit",1.);
57  float hitFrac=1.*prTr->nHitsFit()/prTr->nHitsPoss();
58  hA[3]->Fill(hitFrac);
59  if(hitFrac<par_nHitFrac) return false;
60 
61  hA[0]->Fill("Hfrac",1.);
63  hA[4]->Fill(ri.perp());
64  if(ri.perp()>par_Rmin) return false;
65 
66  hA[0]->Fill("Rin",1.);
67  StThreeVectorF ro=prTr->globalTrack()->lastPoint();
68  hA[5]->Fill(ro.perp());
69  if(ro.perp()<par_Rmax) return false;
70 
71 
72  // accepted .......
73  hA[0]->Fill("Rout",1.);
74  hA[1]->Fill(ro.pseudoRapidity(),ro.phi());
75  float dedx=prTr->dEdx()*1e6;
76  hA[6]->Fill(prTr->p().mag(),dedx);
77  return true;
78 }
79 
80 
81 //--------------------------------------
82 //--------------------------------------
83 int
84 WtpcFilter::getTpcSec(float phiRad, float etaDet){ // finds TPC sector for hit(phi,eta)
85  const float PI=TMath::Pi();
86  int sec=0;
87  float phi=phiRad/PI*180; // now in degrees
88  if (etaDet>0) { // West TPC
89  float x=75-phi;
90  while(x<0) x+=360;
91  sec=1+(int)( x/30.);
92  } else {
93  float x=phi-105;
94  while(x<0) x+=360;
95  sec=13+(int)( x/30.);
96  }
97  // printf("phi/deg=%.1f, x=%.1f\n",phi,x);
98  assert(sec>0);
99  assert(sec<=mxTpcSec);
100  return sec;
101 }
102 
103 
104 //--------------------------------------
105 //--------------------------------------
106 void
107 WtpcFilter::initHistos(bool barrel) {
108  int myCol=2+ secID%6;
109 
110  //...... data histograms
111  memset(hA,0,sizeof(hA));
112  TList *Lx; TLine *ln;TH1 *h;
113 
114  TString sufix=", TPC sec="; sufix+=secID;
115  int nCase=6;
116  hA[0]=h=new TH1F(name+"Stat","track counter"+sufix+"; Cases",nCase,0,nCase);
117  h->SetLineColor(myCol );
118  char key[][200]={"inp","nHit","Hfrac","Rin","Rout"};
119  for(int i=0;i<5;i++) h->Fill(key[i],0.); // preset the order of keys
120 
121  if(barrel) {
122  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);
123  h->SetLineColor(myCol );
124  }
125  else {
126  hA[1]=h=new TH2F(name+"Tr2D1","lastHit, accepted"+sufix+"; detector eta ; detector phi (rad)",100,-0.2,1.8,200,-3.2,3.2);
127  h->SetLineColor(myCol );
128  }
129 
130  hA[2]=h=new TH1F(name+"TrNfit","prim tr nFitP"+sufix+"; nFitPoints",50,0,50);
131  Lx=h->GetListOfFunctions();
132  ln=new TLine(par_nFitPts,0,par_nFitPts,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
133 
134 
135  hA[3]=h=new TH1F(name+"TrFitFrac","prim tr nFitFrac"+sufix+"; nFit/nPoss ",50,0,1.1);
136  Lx=h->GetListOfFunctions();
137  ln=new TLine(par_nHitFrac,0,par_nHitFrac,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
138 
139  hA[4]=h=new TH1F(name+"TrRxyIn","prim tr 1st hit filter"+sufix+"; Rxy (cm)",60,50,170.);
140  Lx=h->GetListOfFunctions();
141  ln=new TLine(par_Rmin,0,par_Rmin,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
142 
143  hA[5]=h=new TH1F(name+"TrRxyOut","prim tr last hit filter"+sufix+"; Rxy (cm)",60,100,220.);
144  Lx=h->GetListOfFunctions();
145  ln=new TLine(par_Rmax,0,par_Rmax,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
146 
147 
148  hA[6]=h=new TH2F(name+"TrdEdX"," dEdX vs. P, accpted "+sufix+"; track P (GeV); dE/dx (keV)",20,0,10,100,0,10);
149 
150 
151  // add histos to the list (if provided)
152  for(int i=0;i<mxHA;i++) {
153  if( hA[i]==0) continue;
154  HList->Add( hA[i]);
155  }
156 
157  // HList->ls();
158  // LOG_INFO<<Form("TpcFilter-%s::initHistos done",name.Data())<<endm;
159 
160 }
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