StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFmsFilterMaker.cxx
1 //*-- Author : Jan Balewski
2 //
3 // $Id: StFmsFilterMaker.cxx,v 1.1 2018/05/22 19:55:42 akio Exp $
4 
5 #include <StThreeVector.hh>
6 #include <StPrimaryVertex.h>
7 
8 #include "StFmsDbMaker/StFmsDbMaker.h"
9 #include "StEvent/StFmsCollection.h"
10 #include "StEvent/StFmsHit.h"
11 
12 #include "StEvent.h"
13 #include "StMessMgr.h"
14 
15 #include "StFmsFilterMaker.h"
16 
17 ClassImp(StFmsFilterMaker)
18 
19 //_____________________________________________________________
20 //_____________________________________________________________
21 StFmsFilterMaker::StFmsFilterMaker(const char *name):StMaker(name){
22  par_E_thres= 30;
23  par_Z0_vert=-9999;
24  par_delZ_vert=0.;
25  // myMode=kUnknown;
26 }
27 
28 
29 //_____________________________________________________________
30 //_____________________________________________________________
33 
34  //
35 }
36 
37 
38 //_____________________________________________________________
39 //_____________________________________________________________
40 
41 Int_t StFmsFilterMaker::Init(){
42  SetAttr(".Privilege",1); //this maker so BFC 'listens' to it and skip events generated by this maker
43 
44  // mGeomE = new FmsGeomSimple(); //for trackXEndCap
45  mFmsDbMaker=static_cast<StFmsDbMaker*>(GetMaker("fmsDb"));
46 
47  mH0=new TH1F("mH0","Event counter",5,0.5,5.5);
48  nInpEve=nRecVert=nZverOK=nAccEve=0;
49  LOG_INFO << Form("Init ee-filter cuts: ET>%.2f Zvert=%.2f +/-%.2f (cm)", par_E_thres, par_Z0_vert, par_delZ_vert)<<endm;
50  // if(myMode==kUseFixedVertex) LOG_INFO << Form(" FIXED vertex mode is activated")<<endl;
51  // assert (myMode!=kUnknown); // probably you forgot to set all params for this maker, Jan
52  return StMaker::Init();
53 }
54 
55 //_____________________________________________________________
56 //_____________________________________________________________
57 Int_t StFmsFilterMaker::FinishRun(int runumber){
58  LOG_INFO << Form("Finish cuts: ET>%.2f Zvert=%.2f +/-%.2f (cm) fixVertexMode=%d", par_E_thres, par_Z0_vert, par_delZ_vert,myMode)<<endm;
59  LOG_INFO << Form("%s::Finish run=%d nInp=%d,nRecVer=%d, nZverOK=%d nAcc=%d",GetName(),runumber,nInpEve,nRecVert,nZverOK,nAccEve) << endm;
60  return kStOK;
61 };
62 
63 
64 //_____________________________________________________________
65 //_____________________________________________________________
67  LOG_INFO << Form("in::Make inp=%d,nVer=%d, nZverOK=%d nAcc=%d",nInpEve,nRecVert,nZverOK,nAccEve) << endm;
68  nInpEve++;
69  mH0->Fill(1);
70  StEvent* mEvent = (StEvent*)GetInputDS("StEvent");
71  assert(mEvent);//fix your chain or open the right event file
72  Float_t vertexPosZ =par_Z0_vert ;
73  /*
74  if(myMode==kUseRecoVertex) {
75  int nV=mEvent->numberOfPrimaryVertices();
76  if(nV<=0) return kStSKIP;
77  int iv=0; // pick always the first vertex, may be wrong w/ pileup, fix it,JB
78  nRecVert++;
79  mH0->Fill(2);
80  StPrimaryVertex*V=mEvent->primaryVertex(iv);
81  assert(V);
82  StThreeVectorF r=V->position();
83  vertexPosZ = r.z();
84  if(fabs(vertexPosZ - par_Z0_vert)> par_delZ_vert) return kStSKIP;
85  LOG_INFO << Form("eveID=%d nPrimVert=%d zVert=%.2f\n", mEvent->id(),nV, vertexPosZ);
86  }
87  */
88  nZverOK++;
89  mH0->Fill(3);
90 
91  StEvent* event = (StEvent*)GetInputDS("StEvent");
92  if(!event) {LOG_ERROR << "StFmsJetMaker::Make did not find StEvent"<<endm; return kStErr;}
93  mFmsColl = event->fmsCollection();
94 
95 
96  Float_t triggerPatchEt;
97  Int_t triggerConditionReturn = triggerCondition();
98 
99 
100  if(triggerConditionReturn != 1) {
101  // printf("janKill-%d Me### eve=%d zVer=%.2f highT_et=%.3f TP_ET=%.3f\n",myMode,nInpEve,vertexPosZ, highTEt,triggerPatchEt);
102  return kStSKIP;
103  }
104 
105  nAccEve++;
106  mH0->Fill(4);
107 
108  //process event only if et above threshold
109  //printf("janKeep-%d Me### eve=%d zVer=%.2f highT_et=%.3f TP_ET=%.3f\n",myMode,nInpEve,vertexPosZ, highTEt,triggerPatchEt);
110 
111  return kStOK;
112 }
113 //_____________________________________________________________
114 //_____________________________________________________________
115 
116 Int_t StFmsFilterMaker::triggerCondition()
117 {
118  int nhits=mFmsColl->numberOfHits();
119 
120  StSPtrVecFmsHit& hits = mFmsColl->hits();
121 
122  Float_t M_pi=TMath::Pi();
123  Float_t energyQuadrant[8] = {0,0,0,0,0,0,0,0};
124  Int_t binPhi = 8;
125  for(int i=0; i<nhits; i++){
126  Int_t dId = hits[i]->detectorId();
127  Float_t energy = hits[i]->energy();
128  if(dId>7&&dId<12 && energy>0.2){
129  int ch= hits[i]->channel();
130 
131  StThreeVectorF v3 =mFmsDbMaker->getStarXYZ(dId,ch);
132  Float_t x = v3.x();
133  Float_t y = v3.y();
134  Int_t id = dId*1000+ch;
135  Float_t phi = v3.phi();
136 
137  binPhi = 8;
138  if((phi< 1.0*(M_pi/4)) && (phi > -1.0*(M_pi/4))) binPhi = 0;
139  if((phi< 0*(M_pi/4)) && (phi > -2.0*(M_pi/4))) binPhi = 1;
140  if((phi< -1.0*(M_pi/4)) && (phi > -3.0*(M_pi/4))) binPhi = 2;
141  if((phi< -2.0*(M_pi/4)) && (phi > -4.0*(M_pi/4))) binPhi = 3;
142 
143  if((phi < -3.0*(M_pi/4)) && (phi > 3.0*(M_pi/4))) binPhi = 4;
144  if((phi < 4.0*(M_pi/4)) && (phi > 2.0*(M_pi/4))) binPhi = 5;
145  if((phi < 3.0*(M_pi/4)) && (phi > 1.*(M_pi/4))) binPhi = 6;
146  if((phi < 2.0*(M_pi/4)) && (phi > 0*(M_pi/4))) binPhi = 7;
147 
148  if(binPhi<8) energyQuadrant[binPhi] += energy;
149 
150 
151  }
152  }
153  Int_t iOrd[8];
154  TMath::Sort(8, energyQuadrant, iOrd);
155  if( energyQuadrant[iOrd[0]] < par_E_thres ) return 0;
156 
157  return 1;
158 
159 }
160 
161 /*
162 //_____________________________________________________________
163 //_____________________________________________________________
164 Float_t StFmsFilterMaker::transverseNRG(Float_t vertexPosZ, StFmsTower *tower)
165 {
166  //find the transverse energy for a tower when vertex != 0
167  //now we do everything with respect to the Smd plane
168 
169 
170 
171 
172  TVector3 towVector = mGeomE->getTowerCenter(tower->sector(),tower->subsector(),tower->etabin());
173  //get x,y coords at Smd plane
174  Float_t xNew = towVector.x() - (288.2 - 279.54)*(towVector.x()/288.2);
175  Float_t yNew = towVector.y() - (288.2 - 279.54)*(towVector.y()/288.2);
176 
177  TVector3 *eventTowVector = new TVector3(0,0,0);//make vector from vertex to smd plane
178  eventTowVector->SetXYZ(xNew,yNew,(279.54 - vertexPosZ));
179 
180  //Float_t newEta = eventTowVector->Eta();
181  //Float_t newPhi = eventTowVector->Phi();
182  Float_t newTheta = eventTowVector->Theta();
183 
184  Float_t factor = sin(newTheta);//multiply energy by this to get event ET
185  if(factor > 1.0 || factor < 0.0)
186  {
187  return -1.0;
188  }
189 
190  Float_t energy = tower->energy();
191 
192  Float_t transverseEnergy = energy*factor;
193 
194  return transverseEnergy;
195 
196 
197 }
198 */
199 // $Log: StFmsFilterMaker.cxx,v $
200 // Revision 1.1 2018/05/22 19:55:42 akio
201 // Initial version of after GEANT filter for FMS by Mriganka
202 //
203 // Revision 1.4 2008/06/10 12:59:12 balewski
204 // fix printout
205 //
206 // Revision 1.3 2008/05/11 18:49:17 balewski
207 // merged 2 makers, now one can us it before and after TPC tracking, run 2 independent copies
208 //
209 // Revision 1.2 2008/05/09 22:14:35 balewski
210 // new there are 2 filters
211 //
212 // Revision 1.1 2008/04/21 15:47:09 balewski
213 // star
214 //
virtual Int_t Make()
Definition: Stypes.h:48
virtual ~StFmsFilterMaker()
This is destructor.
StThreeVectorF getStarXYZ(Int_t detectorId, Float_t FmsX, Float_t FmsY)
get the Y width of the cell
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:40
aborts events based on Endcap response cuts: reco vertex in some Z-range and EEMC 2x1 cluster event-e...
Definition: Stypes.h:44