StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcEnergyMaker.cxx
1 /*
2  * Created by S. Gliske, May 2012
3  *
4  * Description: maker to fill the EEmcEnergy_t structure.
5  *
6  */
7 
8 #include "StEEmcEnergyMaker.h"
9 
10 #include "StRoot/StEEmcPool/./EEmcTreeContainers/EEmcEnergy.h"
11 #include "StRoot/StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
12 
14 StEEmcEnergyMaker_t::StEEmcEnergyMaker_t( const Char_t *myName, const Char_t *a2EMakerName ) : StMaker( myName ), mA2EMkrName( a2EMakerName ),
15  mNumTowers( 0 ), mTowerThres( 1 ), mStripThres( 0.0005 ) { /* */ };
16 
19 
22  Int_t ierr = kStOk;
23 
24  mA2EMkr = static_cast< StEEmcA2EMaker* >( GetMaker( mA2EMkrName.data() ) );
25 
26  if( !mA2EMkr ){
27  LOG_ERROR << "Cannot find maker with the name '" << mA2EMkrName << "'" << endm;
28  ierr = kStFatal;
29  };
30 
31  return ierr;
32 };
33 
36  assert( mA2EMkr ); // already checked this in ::Init
37 
38  static ETowEnergy_t *etowLayerPtrArr[4] = { &mEEmcEnergy.eTow,
39  &mEEmcEnergy.ePre1,
40  &mEEmcEnergy.ePre2,
41  &mEEmcEnergy.ePost };
42 
43  mEEmcEnergy.nTowers = 0;
44  mEEmcEnergy.nStrips = 0;
45 
46 #ifdef DEBUG
47  cout << GetEventNumber() << " Number of towers/strips in A2CMaker? ";
48  for( Int_t i=0; i<4; ++i )
49  cout << mA2EMkr->towers( i ).size() << ' ';
50  cout << "| ";
51  for( Int_t layer = 0; layer < 2; ++layer ){
52  for( Int_t sector = 0; sector < kEEmcNumSectors; ++sector )
53  cout << mA2EMkr->strips( sector, layer ).size() << ' ';
54  if( !layer )
55  cout << "| ";
56  };
57  cout << endl;
58 #endif
59 
60  for( Int_t iLayer=0; iLayer<4; ++iLayer ){
61  StEEmcTowerVec_t& towVec = mA2EMkr->towers( iLayer );
62  ETowEnergy_t* etowEptr = etowLayerPtrArr[iLayer];
63 
64  if( !towVec.empty() ){
65  StEEmcTowerVec_t::iterator towIter;
66 
67  for( towIter = towVec.begin(); towIter != towVec.end(); ++towIter ){
68  EEmcElement_t& element = etowEptr->getByIdx( towIter->index() );
69  element.energy = towIter->energy();
70  element.fail = towIter->fail() || towIter->stat();
71 
72  if( iLayer == 0 && element.energy > mTowerThres && !element.fail )
73  ++mEEmcEnergy.nTowers;
74 
75 #ifdef DEBUG2
76  cout << "Tower Layer " << iLayer << ", idx " << towIter->index() << ", E = " << element.energy << ", num = " << mEEmcEnergy.nTowers << endl;
77 #endif
78  };
79  };
80 
81  if( iLayer == 0 && mEEmcEnergy.nTowers < mNumTowers )
82  return kStOk;
83  };
84 
85  for( Int_t sector = 0; sector < kEEmcNumSectors; ++sector ){
86  for( Int_t layer = 0; layer < 2; ++layer ){
87  StEEmcStripVec_t &stripVec = mA2EMkr->strips( sector, layer );
88 
89  if( !stripVec.empty() ){
90  ESmdLayer_t& esmdLayer = mEEmcEnergy.eSmd.sec[ sector ].layer[ layer ];
91  esmdLayer.nStrips = 0;
92  StEEmcStripVec_t::iterator stripIter;
93 
94  for( stripIter = stripVec.begin(); stripIter != stripVec.end(); ++stripIter ){
95  EEmcElement_t& element = esmdLayer.strip[ stripIter->index() ];
96 
97  element.energy = stripIter->energy();
98  element.fail = stripIter->fail() || stripIter->stat();
99 
100  if( element.energy > mStripThres && !element.fail ){
101  ++esmdLayer.nStrips;
102  ++mEEmcEnergy.nStrips;
103  };
104 
105 #ifdef DEBUG2
106  cout << "SMD Sector/Layer " << sector << (layer ? 'v' : 'u' )
107  << ", idx " << stripIter->index() << ", E = " << element.energy << ", num = " << mEEmcEnergy.nStrips << endl;
108 #endif
109  };
110  };
111  };
112  };
113 
114  return kStOk;
115 };
116 
118 void StEEmcEnergyMaker_t::Clear(Option_t *opts ){
119  mEEmcEnergy.Clear();
120 };
121 
122 ClassImp( StEEmcEnergyMaker_t );
123 
124 /*
125  * $Id: StEEmcEnergyMaker.cxx,v 1.2 2013/02/21 21:59:02 sgliske Exp $
126  * $Log: StEEmcEnergyMaker.cxx,v $
127  * Revision 1.2 2013/02/21 21:59:02 sgliske
128  * general update
129  *
130  * Revision 1.1 2012/11/26 19:06:10 sgliske
131  * moved from offline/users/sgliske/StRoot/StEEmcPool/StEEmcTreeMaker to StRoot/StEEmcPool/StEEmcTreeMaker
132  *
133  *
134  */
EEmc ADC –&gt; energy maker.
EEmcEnergy_t mEEmcEnergy
StEEmcTowerVec_t & towers(Int_t layer=0)
void Clear(Option_t *opts="")
Clear for next event.
StEEmcStripVec_t & strips(Int_t sec, Int_t pln)
Returns a vector of hit strips, given the sector and plane.
StEEmcEnergyMaker_t(const Char_t *myName, const Char_t *a2EMakerName)
constructor
Int_t Init()
Initialize.
virtual ~StEEmcEnergyMaker_t()
deconstructor
Definition: Stypes.h:41
Int_t Make()
Build an event.