StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBET4pMaker.cxx
1 // $Id: StBET4pMaker.cxx,v 1.15 2010/05/24 17:42:26 pibero Exp $
2 #include "StBET4pMaker.h"
3 #include "StBET4pMakerImp.h"
4 #include "StBET4pMakerImpBuilder.h"
5 #include "StMuDSTMaker/COMMON/StMuTypes.hh"
6 
7 #include "StjeTrackListToStMuTrackFourVecList.h"
8 #include "StjeTowerEnergyListToStMuTrackFourVecList.h"
9 
10 #include "StjeBemcEnergySumCalculator.h"
11 #include "StjeBemcEnergySumCalculatorBuilder.h"
12 
13 #include "StEmcADCtoEMaker/StEmcADCtoEMaker.h"
14 #include "StjTowerEnergyCorrectionForTracksMip.h"
15 
16 #include <iostream>
17 
18 using namespace std;
19 
20 ClassImp(StBET4pMaker)
21 
22 StBET4pMaker::StBET4pMaker(const char* name, StMuDstMaker* uDstMaker, bool doTowerSwapFix, StjAbstractTowerEnergyCorrectionForTracks* correctTowerEnergyForTracks)
23  : StFourPMaker(name)
24  , _entryMaker(0)
25  , _uDstMaker(uDstMaker), _doTowerSwapFix(doTowerSwapFix)
26  , _correctTowerEnergyForTracks(correctTowerEnergyForTracks ? correctTowerEnergyForTracks : new StjTowerEnergyCorrectionForTracksMip)
27  , _useTPC(true), _useBEMC(true), _useEEMC(false)
28  , _use2003Cuts(false), _use2005Cuts(false), _use2006Cuts(false), _use2009Cuts(false)
29  , _useBEMCEnergySum(true)
30  , _useRandomSelector(false)
31  , _useBEMCEnergyVariation(false), _bemcEnergyVariationRatio(0.05)
32  , _imp(0)
33  , _bemcEnergySumCalculator(0)
34  , _track2four(*(new StjeTrackListToStMuTrackFourVecList))
35  , _energy2four(*(new StjeTowerEnergyListToStMuTrackFourVecList))
36  , _randomSelectorProb(1.0), _randomSelectorAt(false)
37  , _randomSelectorSeed(0)
38 { }
39 
40 Int_t StBET4pMaker::Init()
41 {
42  StBET4pMakerImpBuilder impBuilder;
43  _imp = impBuilder.build(_useTPC, _useBEMC, _useEEMC, _use2003Cuts, _use2005Cuts, _use2006Cuts, _use2009Cuts, _useBEMCEnergyVariation, _bemcEnergyVariationRatio, _useRandomSelector, _uDstMaker, _doTowerSwapFix, _correctTowerEnergyForTracks, _randomSelectorProb, _randomSelectorAt, _randomSelectorSeed);
44  _imp->Init();
45 
46  StjeBemcEnergySumCalculatorBuilder bemcEnergySumCalculatorBuilder;
47  _bemcEnergySumCalculator = bemcEnergySumCalculatorBuilder.build(_useBEMCEnergySum && _useBEMC, _use2003Cuts, _use2005Cuts, _uDstMaker, _doTowerSwapFix);
48  _bemcEnergySumCalculator->Init();
49 
50  return StMaker::Init();
51 }
52 
53 
54 void StBET4pMaker::Clear(Option_t* opt)
55 {
56  for (size_t i = 0; i < _vertexNodes.size(); ++i) {
57  VertexNode& node = _vertexNodes[i];
58  node.vertex = 0;
59  for (size_t j = 0; j < node.tracks.size(); ++j) {
60  delete node.tracks[j];
61  node.tracks[j] = 0;
62  }
63  node.tracks.clear();
64  }
65 
66  _vertexNodes.clear();
67 
68  _bemcEnergySumCalculator->Clear();
69 
70  return StMaker::Clear(opt);
71 }
72 
74 {
75  if(isBemcCorrupted()) return kStOk;
76 
77  _bemcEnergySumCalculator->Make();
78 
79  if (_bemcEnergySumCalculator->sumEmcEt() > 500.) return kStOk;
80 
81  // Save current vertex index
82  int currentVertexIndex = StMuDst::currentVertexIndex();
83 
84  // Loop over primary vertices and get those with positive rank
85  for (unsigned int vertexIndex = 0; vertexIndex < StMuDst::numberOfPrimaryVertices(); ++vertexIndex) {
86  StMuDst::setVertexIndex(vertexIndex);
88  if (vertex->ranking() > 0) {
89  _vertexNodes.push_back(VertexNode());
90  VertexNode& node = _vertexNodes.back();
91  node.vertex = vertex;
92 
93  pair<StjTrackList,StjTowerEnergyList> trackAndEnergyList = _imp->getTrackAndEnergyList();
94 
95  FourList tpc4pList = _track2four(trackAndEnergyList.first);
96  node.tracks.insert(node.tracks.end(),tpc4pList.begin(),tpc4pList.end());
97 
98  FourList energy4pList = _energy2four(trackAndEnergyList.second);
99  node.tracks.insert(node.tracks.end(),energy4pList.begin(),energy4pList.end());
100  }
101  }
102 
103  // Restore current vertex index
104  if (StMuDst::currentVertexIndex() != currentVertexIndex) StMuDst::setVertexIndex(currentVertexIndex);
105 
106  return kStOk;
107 }
108 
109 bool StBET4pMaker::isBemcCorrupted() const
110 {
111  if(StEmcADCtoEMaker* adc2e = dynamic_cast<StEmcADCtoEMaker*>(const_cast<StBET4pMaker*>(this)->GetMaker("Eread")))
112  return adc2e->isCorrupted();
113 
114  return false;
115 }
116 
117 int StBET4pMaker::nDylanPoints() const
118 {
119  return _bemcEnergySumCalculator->nDylanPoints();
120 }
121 
122 double StBET4pMaker::sumEmcEt() const
123 {
124  return _bemcEnergySumCalculator->sumEmcEt();
125 }
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:322
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StMaker.cxx:634
void Clear(Option_t *opt="")
User defined functions.
static Int_t currentVertexIndex()
Get the index number of the current primary vertex.
Definition: StMuDst.h:260
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Definition: StMuDst.cxx:273
Definition: Stypes.h:41