StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcFilterMaker.cxx
1 //*-- Author : Jan Balewski
2 //
3 // $Id: StEEmcFilterMaker.cxx,v 1.4 2008/06/10 12:59:12 balewski Exp $
4 
5 #include <StThreeVector.hh>
6 #include <StPrimaryVertex.h>
7 #include "StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
8 
9 #include "StEvent.h"
10 #include "StMessMgr.h"
11 
12 #include "StEEmcFilterMaker.h"
13 
14 ClassImp(StEEmcFilterMaker)
15 
16 //_____________________________________________________________
17 //_____________________________________________________________
18 StEEmcFilterMaker::StEEmcFilterMaker(const char *name):StMaker(name){
19  par_Et_thres=-1;
20  par_Z0_vert=-9999;
21  par_delZ_vert=0.;
22  myMode=kUnknown;
23 }
24 
25 
26 //_____________________________________________________________
27 //_____________________________________________________________
30 
31  //
32 }
33 
34 
35 //_____________________________________________________________
36 //_____________________________________________________________
37 
38 Int_t StEEmcFilterMaker::Init(){
39  SetAttr(".Privilege",1); //this maker so BFC 'listens' to it and skip events generated by this maker
40 
41  mGeomE = new EEmcGeomSimple(); //for trackXEndCap
42 
43  mH0=new TH1F("mH0","Event counter",5,0.5,5.5);
44  nInpEve=nRecVert=nZverOK=nAccEve=0;
45  LOG_INFO << Form("Init ee-filter cuts: ET>%.2f Zvert=%.2f +/-%.2f (cm)", par_Et_thres, par_Z0_vert, par_delZ_vert)<<endm;
46  if(myMode==kUseFixedVertex) LOG_INFO << Form(" FIXED vertex mode is activated")<<endl;
47  assert (myMode!=kUnknown); // probably you forgot to set all params for this maker, Jan
48  return StMaker::Init();
49 }
50 
51 //_____________________________________________________________
52 //_____________________________________________________________
53 Int_t StEEmcFilterMaker::FinishRun(int runumber){
54  LOG_INFO << Form("Finish cuts: ET>%.2f Zvert=%.2f +/-%.2f (cm) fixVertexMode=%d", par_Et_thres, par_Z0_vert, par_delZ_vert,myMode)<<endm;
55  LOG_INFO << Form("%s::Finish run=%d nInp=%d,nRecVer=%d, nZverOK=%d nAcc=%d",GetName(),runumber,nInpEve,nRecVert,nZverOK,nAccEve) << endm;
56  return kStOK;
57 };
58 
59 
60 //_____________________________________________________________
61 //_____________________________________________________________
63  LOG_INFO << Form("in::Make inp=%d,nVer=%d, nZverOK=%d nAcc=%d",nInpEve,nRecVert,nZverOK,nAccEve) << endm;
64  nInpEve++;
65  mH0->Fill(1);
66  StEvent* mEvent = (StEvent*)GetInputDS("StEvent");
67  assert(mEvent);//fix your chain or open the right event file
68  Float_t vertexPosZ =par_Z0_vert ;
69  if(myMode==kUseRecoVertex) {
70  int nV=mEvent->numberOfPrimaryVertices();
71  if(nV<=0) return kStSKIP;
72  int iv=0; // pick always the first vertex, may be wrong w/ pileup, fix it,JB
73  nRecVert++;
74  mH0->Fill(2);
75  StPrimaryVertex*V=mEvent->primaryVertex(iv);
76  assert(V);
77  StThreeVectorF r=V->position();
78  vertexPosZ = r.z();
79  if(fabs(vertexPosZ - par_Z0_vert)> par_delZ_vert) return kStSKIP;
80  LOG_INFO << Form("eveID=%d nPrimVert=%d zVert=%.2f\n", mEvent->id(),nV, vertexPosZ);
81  }
82 
83  nZverOK++;
84  mH0->Fill(3);
85  StEEmcA2EMaker *a2eMK=(StEEmcA2EMaker *)GetMaker("EE_A2E");
86  assert(a2eMK); //for endcap tower stuff
87  StEEmcTower highTow = a2eMK->hightower(0);//find high tower
88 
89  Float_t highTEt = highTow.et();
90  LOG_INFO << Form("eveID=%d highTEt=%.2f\n", mEvent->id(),highTEt);
91 
92  Float_t triggerPatchEt;
93  Int_t triggerConditionReturn = triggerCondition(vertexPosZ,&highTow,triggerPatchEt);
94 
95 
96  if(triggerConditionReturn != 1) {
97  printf("janKill-%d Me### eve=%d zVer=%.2f highT_et=%.3f TP_ET=%.3f\n",myMode,nInpEve,vertexPosZ, highTEt,triggerPatchEt);
98  return kStSKIP;
99  }
100 
101  nAccEve++;
102  mH0->Fill(4);
103  //process event only if et above threshold
104  printf("janKeep-%d Me### eve=%d zVer=%.2f highT_et=%.3f TP_ET=%.3f\n",myMode,nInpEve,vertexPosZ, highTEt,triggerPatchEt);
105 
106 
107  return kStOK;
108 }
109 //_____________________________________________________________
110 //_____________________________________________________________
111 Int_t StEEmcFilterMaker::triggerCondition( Float_t vertexPosZ, StEEmcTower *highTow, Float_t &patchEt)
112 {
113 
114  //Float_t eemcPatchEt = highTow.et();//use my et function
115  Float_t eemcPatchEt = transverseNRG(vertexPosZ,highTow);
116  Int_t Nneigh = highTow->numberOfNeighbors();
117  for(int Nn=0; Nn < Nneigh; Nn++)
118  {
119  StEEmcTower neighHighTow = highTow->neighbor(Nn);
120  Float_t neighEemcPatchEt = transverseNRG(vertexPosZ,&neighHighTow);
121  eemcPatchEt += neighEemcPatchEt;
122  }
123 
124  patchEt = eemcPatchEt;
125 
126  if(eemcPatchEt < par_Et_thres) return 0;
127 
128  return 1;
129 
130 }
131 //_____________________________________________________________
132 //_____________________________________________________________
133 Float_t StEEmcFilterMaker::transverseNRG(Float_t vertexPosZ, StEEmcTower *tower)
134 {
135  //find the transverse energy for a tower when vertex != 0
136  //now we do everything with respect to the Smd plane
137 
138  TVector3 towVector = mGeomE->getTowerCenter(tower->sector(),tower->subsector(),tower->etabin());
139  //get x,y coords at Smd plane
140  Float_t xNew = towVector.x() - (288.2 - 279.54)*(towVector.x()/288.2);
141  Float_t yNew = towVector.y() - (288.2 - 279.54)*(towVector.y()/288.2);
142 
143  TVector3 *eventTowVector = new TVector3(0,0,0);//make vector from vertex to smd plane
144  eventTowVector->SetXYZ(xNew,yNew,(279.54 - vertexPosZ));
145 
146  //Float_t newEta = eventTowVector->Eta();
147  //Float_t newPhi = eventTowVector->Phi();
148  Float_t newTheta = eventTowVector->Theta();
149 
150  Float_t factor = sin(newTheta);//multiply energy by this to get event ET
151  if(factor > 1.0 || factor < 0.0)
152  {
153  return -1.0;
154  }
155 
156  Float_t energy = tower->energy();
157 
158  Float_t transverseEnergy = energy*factor;
159 
160  return transverseEnergy;
161 }
162 
163 // $Log: StEEmcFilterMaker.cxx,v $
164 // Revision 1.4 2008/06/10 12:59:12 balewski
165 // fix printout
166 //
167 // Revision 1.3 2008/05/11 18:49:17 balewski
168 // merged 2 makers, now one can us it before and after TPC tracking, run 2 independent copies
169 //
170 // Revision 1.2 2008/05/09 22:14:35 balewski
171 // new there are 2 filters
172 //
173 // Revision 1.1 2008/04/21 15:47:09 balewski
174 // star
175 //
TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const
virtual Int_t Make()
Int_t numberOfNeighbors() const
get the number of neighboring towers
Definition: StEEmcTower.h:54
EEmc ADC –&gt; energy maker.
Definition: Stypes.h:48
void neighbor(StEEmcTower *n)
add a tower to list of neighbors
Definition: StEEmcTower.h:52
Int_t etabin() const
Returns the etabin of this tower, pre- or postshower element.
Definition: StEEmcTower.h:45
Int_t subsector() const
Returns subsector of this tower, pre- or postshower element.
Definition: StEEmcTower.h:43
Base class for representing tower, preshower and postshower elements.
Definition: StEEmcTower.h:11
virtual ~StEEmcFilterMaker()
This is destructor.
StEEmcTower & hightower(Int_t layer=0)
aborts events based on Endcap response cuts: reco vertex in some Z-range and EEMC 2x1 cluster event-e...
Int_t sector() const
Returns sector of this tower, pre- or postshower element.
Definition: StEEmcTower.h:41
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
EEMC simple geometry.
Definition: Stypes.h:40
void et(Float_t e)
Definition: StEEmcTower.h:34
void energy(Float_t e)
Set the energy (adc-ped+0.5)/gain for this element.
Definition: StEEmcElement.h:21