StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjEEMCMuDst.cxx
1 // $Id: StjEEMCMuDst.cxx,v 1.10 2012/03/10 10:49:16 pibero Exp $
2 #include "StjEEMCMuDst.h"
3 
4 #include "StMaker.h"
5 #include "StMuDSTMaker/COMMON/StMuDst.h"
6 #include "StMuDSTMaker/COMMON/StMuEvent.h"
7 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
8 
9 #include "StEEmcUtil/database/StEEmcDb.h"
10 #include "StEEmcUtil/database/EEmcDbItem.h"
11 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
12 
13 
14 StjEEMCMuDst::StjEEMCMuDst() : mEeDb((StEEmcDb*)StMaker::GetChain()->GetDataSet("StEEmcDb"))
15 {
16  _setVertex = false;
17 }
18 
19 void StjEEMCMuDst::Init()
20 {
21  if (mEeDb) mEeDb->setThreshold(3);
22 }
23 
24 StjTowerEnergyList StjEEMCMuDst::getEnergyList()
25 {
27 
28  StjTowerEnergyList ret;
29 
30  for (int id = 0; id < muEmc->getNEndcapTowerADC(); ++id) {
31 
32  int rawadc, sec, sub, etabin;
33  muEmc->getEndcapTowerADC(id, rawadc, sec, sub, etabin);
34 
35  // Sanity check
36  if (rawadc < 0 || rawadc >= 4095) continue;
37 
38  assert(1 <= sec && sec <= 12);
39  assert(1 <= sub && sub <= 5);
40  assert(1 <= etabin && etabin <= 12);
41 
42  // See http://www.star.bnl.gov/public/eemc/how_to/dbUsage.html
43  // See $STAR/StRoot/StEEmcUtil/database/cstructs/eemcConstDB.hh
44  //
45  // Use idividual bits of 'stat' to exclude individual
46  // channels from a particular analysis, but let other
47  // analysis make a different choice.
48  //
49  // status bits (short int)
50  //
51  // #define EEMCSTAT_ONLPED 0x0001 // only pedestal is visible
52  // #define EEMCSTAT_STKBT 0x0002 // sticky lower bits
53  // #define EEMCSTAT_HOTHT 0x0004 // masked for HT trigger
54  // #define EEMCSTAT_HOTJP 0x0008 // masked for JP trigger
55  // #define EEMCSTAT_HIGPED 0x0010 // ped is very high but channel seems to work
56  // #define EEMCSTAT_HOTSTR 0x0020 // hot esmd strip
57  // #define EEMCSTAT_JUMPED 0x0040 // jumpy ped over several chan over days
58  // #define EEMCSTAT_WIDPED 0x0080 // wide ped over:2.5 ch towers, 1.5 ch MAPMT's
59  //
60  //The remaing bits of 'stat' are free.
61  //
62  // The 'fail' 16-bits are meant as general abort of a given channel.
63  //
64  // failure bits (short int)
65  // #define EEMCFAIL_GARBG 0x0001 // faulty channel
66  // #define EEMCFAIL_HVOFF 0x0002 // HV was off or varied
67  // #define EEMCFAIL_NOFIB 0x0004 // signal fiber is broken
68  // #define EEMCFAIL_CPYCT 0x0008 // stuck in copyCat mode
69 
70  const EEmcDbItem *dbItem = mEeDb->getT(sec,sub-1+'A',etabin);
71 
72  if(dbItem->fail) continue; //drop broken channels
73  if(dbItem->stat) continue; // drop not working channels and jumpy pedestal channels
74  if(dbItem->gain<=0.) continue; // drop it, unless you work with ADC spectra
75  if(rawadc<dbItem->thr) continue; // drop raw ADC < ped+N*sigPed, N==3 in init
76 
77  double adc = rawadc - (dbItem->ped);
78  double energy = adc/(dbItem->gain);
79 
80  StjTowerEnergy energyDeposit;
81  energyDeposit.runNumber = StMuDst::event()->runId();
82  energyDeposit.eventId = StMuDst::event()->eventId();
83  energyDeposit.detectorId = kEndcapEmcTowerId;
84  energyDeposit.towerId = (sec-1)*60+(sub-1)*12+(etabin-1);
85 
87  TVector3 towerLocation = geom.getTowerCenter(sec-1,sub-1,etabin-1);
88 
89  energyDeposit.towerR = towerLocation.Perp();
90  energyDeposit.towerEta = towerLocation.Eta();
91  energyDeposit.towerPhi = towerLocation.Phi();
92 
93  if (_setVertex) {
94  energyDeposit.vertexX = _vx;
95  energyDeposit.vertexY = _vy;
96  energyDeposit.vertexZ = _vz;
97  }
98  else {
100 
101  energyDeposit.vertexX = vertex.x();
102  energyDeposit.vertexY = vertex.y();
103  energyDeposit.vertexZ = vertex.z();
104  }
105 
106  energyDeposit.energy = energy;
107  energyDeposit.adc = rawadc;
108  energyDeposit.pedestal = dbItem->ped;
109  energyDeposit.rms = dbItem->sigPed;
110  energyDeposit.status = dbItem->stat == 0;
111 
112  if(energyDeposit.energy < 0.01) continue; // drop if less than 10MeV for now
113 
114  ret.push_back(energyDeposit);
115 
116  }
117 
118  return ret;
119 }
TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const
StThreeVectorF primaryVertexPosition(int vtx_id=-1) const
The StMuDst is supposed to be structured in &#39;physical events&#39;. Therefore there is only 1 primary vert...
Definition: StMuEvent.cxx:221
static EEmcGeomSimple & Instance()
returns a reference to a static instance of EEmcGeomSimple
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:389
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
EEMC simple geometry.