StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjFCSMuDst.cxx
1 #include "StjFCSMuDst.h"
2 
3 #include "StMaker.h"
4 #include "StChain.h"
5 #include "StMuDSTMaker/COMMON/StMuDst.h"
6 #include "StMuDSTMaker/COMMON/StMuEvent.h"
7 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
8 
9 #include "StMuDSTMaker/COMMON/StMuFcsCollection.h"
10 #include "StMuDSTMaker/COMMON/StMuFcsHit.h"
11 
12 #include "StFcsDbMaker/StFcsDbMaker.h"
13 #include "StFcsDbMaker/StFcsDb.h"
14 #include "StEventTypes.h"
15 #include "StEvent/StEvent.h"
16 #include "StEvent/StFcsCollection.h"
17 #include "StEvent/StFcsHit.h"
18 #include "StEvent/StFcsPoint.h"
19 #include "StMuDSTMaker/COMMON/StMuTypes.hh"
20 
21 #include <iostream>
22 #include <fstream>
23 #include "StMessMgr.h"
24 #include "StEventTypes.h"
25 using namespace std;
26 
27 StjFCSMuDst::StjFCSMuDst()
28 {
29  _setVertex = false;
30 
31  _vx = 0.0;
32  _vy = 0.0;
33  _vz = 0.0;
34 
35  useECal = false;
36  useHCal = false;
37 
38  mFcsDb = nullptr;
39  StMaker* chain = StMaker::GetChain();
40  if (chain) {
41  if(chain->GetDataSet("fcsDb")){
42  mFcsDb = static_cast<StFcsDb*>(chain->GetDataSet("fcsDb"));
43  mFcsDb->setDbAccess(0);
44  }else{
45  LOG_ERROR << "No fcdDb found in chain. Please initialize StFcsDbMaker within your chain." << endm;
46  }
47  }
48  if (!chain) {
49  LOG_ERROR << "StjFCSMuDst Initializing failed due to missing chain." << endm;
50  }
51 }
52 
53 StjTowerEnergyList StjFCSMuDst::getEnergyList(){
54  StjTowerEnergyList fcsEnergyList;
55 
56  mMuFcsColl = StMuDst::muFcsCollection();
57 
58  if(mMuFcsColl->numberOfHits()!=0){
59 
60  StjTowerEnergy energyDeposit;
61  for(int det = 0; det <= kFcsHcalSouthDetId; det++){
62 
63  int nhits = mMuFcsColl->numberOfHits(det);
64  int det_hit_index = mMuFcsColl->indexOfFirstHit(det);
65 
66  for(int hit_i = 0 ; hit_i < nhits; hit_i++){
67 
68  int hit_index = hit_i + det_hit_index;
69  StMuFcsHit* hit = mMuFcsColl->getHit(hit_index);
70 
71  if(det <= 1 && useECal){
72  fcsEnergyList.push_back(hitenergyDeposit(*hit));
73  }
74  if(det >= 2 && useHCal){
75  fcsEnergyList.push_back(hitenergyDeposit(*hit));
76  }
77 
78  }// Hit loop
79 
80  }//Det Loop
81  }
82 
83  return fcsEnergyList;
84 }
85 
86 StjTowerEnergy StjFCSMuDst::hitenergyDeposit(const StMuFcsHit& hit){
87  StjTowerEnergy energyDeposit;
88 
89  StThreeVectorD xyz = mFcsDb->getStarXYZ(hit.detectorId(),hit.id());
90 
91  float x = xyz.x();
92  float y = xyz.y();
93  float z = xyz.z();
94 
95  energyDeposit.runNumber = StMuDst::event()->runId();
96  energyDeposit.eventId = StMuDst::event()->eventId();
97 
98  energyDeposit.towerId = hit.id();
99  energyDeposit.detectorId = hit.detectorId();
100  energyDeposit.towerR = TMath::Sqrt(x*x + y*y);
101  energyDeposit.towerEta = xyz.pseudoRapidity();
102  energyDeposit.towerPhi = xyz.phi();
103  energyDeposit.vertexX = _vx;
104  energyDeposit.vertexY = _vy;
105  energyDeposit.vertexZ = _vz;
106  energyDeposit.energy = hit.energy();
107  energyDeposit.adc = hit.adcSum();
108  energyDeposit.pedestal = 0;
109  energyDeposit.rms = 0;
110  energyDeposit.status = 1;
111 
112  return energyDeposit;
113 }
114 
115 
static StMuFcsCollection * muFcsCollection()
returns pointer to current StMuFcsCollection
Definition: StMuDst.h:395
StThreeVectorD getStarXYZ(int det, float FcsX, float FcsY, float FcsZ=-1.0, float zVertex=0.0) const
get the STAR frame cooridnates from local XYZ [cm]
Definition: StFcsDb.cxx:868
void setDbAccess(int v=1)
debug level
Definition: StFcsDb.cxx:250
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320