StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtQaRawOctAdc.cxx
1 /***************************************************************************
2  *
3  * $Id: StFgtQaRawOctAdc.cxx,v 1.3 2012/03/05 20:35:15 sgliske Exp $
4  * Author: S. Gliske, Jan 2012
5  *
6  ***************************************************************************
7  *
8  * Description: See header.
9  *
10  ***************************************************************************
11  *
12  * $Log: StFgtQaRawOctAdc.cxx,v $
13  * Revision 1.3 2012/03/05 20:35:15 sgliske
14  * update--still not really working
15  *
16  * Revision 1.2 2012/01/31 12:53:28 sgliske
17  * updates
18  *
19  * Revision 1.1 2012/01/31 09:26:17 sgliske
20  * StFgtQaMakers moved to StFgtPool
21  *
22  * Revision 1.3 2012/01/30 10:42:23 sgliske
23  * strip containers now contain adc values for
24  * all time bins. Also fixed bug where setType modified the timebin
25  * rather than the type.
26  *
27  * Revision 1.2 2012/01/26 13:13:11 sgliske
28  * Updated to use StFgtConsts, which
29  * replaces StFgtEnums and StFgtGeomDefs
30  *
31  * Revision 1.1 2012/01/24 11:55:49 sgliske
32  * creation
33  *
34  *
35  **************************************************************************/
36 
37 #include "StFgtQaRawOctAdc.h"
38 #include "StFgtDbMaker/StFgtDbMaker.h"
39 #include "StFgtDbMaker/StFgtDb.h"
40 
41 #include <string>
42 #include <TH2F.h>
43 
44 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
45 
46 #include "StRoot/StEvent/StEvent.h"
47 #include "StRoot/StEvent/StFgtCollection.h"
48 #include "StRoot/StEvent/StFgtStripCollection.h"
49 #include "StRoot/StEvent/StFgtStrip.h"
50 #include "StRoot/StFgtUtil/StFgtConsts.h"
51 
52 // constructors
53 StFgtQaRawOctAdc::StFgtQaRawOctAdc( const Char_t* name, Int_t tb ) :
54  StMaker( name ), mHistVec( kFgtNumOctants, (TH2F*)0 ), mTimeBin( tb ), mAdcBins(256), mAdcMin(0), mAdcMax(6*mAdcBins) {
55  // nothing else
56 };
57 
58 // deconstructor
59 StFgtQaRawOctAdc::~StFgtQaRawOctAdc(){
60  HistVec_t::iterator iter;
61  for( iter = mHistVec.begin(); iter != mHistVec.end(); ++iter )
62  if( *iter )
63  delete *iter;
64 };
65 
66 Int_t StFgtQaRawOctAdc::Init(){
67  Int_t ierr = kStOk;
68 
69  std::stringstream ss;
70 
71  Char_t octName[2] = { 'L', 'S' };
72  Int_t histIdx = 0;
73  for( Int_t disc = 0; disc < kFgtNumDiscs; ++disc ){
74  for( Int_t quad = 0; quad < kFgtNumDiscs; ++quad ){
75  for( Int_t oct = 0; oct < 2; ++oct, ++histIdx ){
76  ss.str("");
77  ss.clear();
78  ss << disc+1 << (Char_t)(quad+'A') << octName[oct];
79  std::string label = ss.str();
80 
81  ss.str("");
82  ss.clear();
83  ss << "h" << GetName() << "_" << histIdx;
84 
85  Int_t chanPerOct = kFgtNumChannels*kFgtApvsPerOct;
86  mHistVec[ histIdx ] = new TH2F( ss.str().data(),
87  ( std::string("Octant " ) + label +
88  "; Number of Strips; Number of Events").data(),
89  chanPerOct, 0, chanPerOct, mAdcBins, mAdcMin, mAdcMax );
90  };
91  };
92  };
93 
94  return ierr;
95 };
96 
98  Int_t ierr = kStOk;
99 
100  StFgtDbMaker *fgtDbMkr = static_cast< StFgtDbMaker* >( GetMakerInheritsFrom( "StFgtDbMaker" ) );
101  if( !fgtDbMkr ){
102  LOG_FATAL << "Error finding StFgtDbMaker" << endm;
103  ierr = kStFatal;
104  };
105 
106  if( !ierr ){
107  StFgtDb *fgtTables = fgtDbMkr->getDbTables();
108 
109  if( !fgtTables ){
110  LOG_FATAL << "Error finding StFgtDb" << endm;
111  ierr = kStFatal;
112  };
113  };
114 
115  StEvent* eventPtr = 0;
116  StFgtCollection *fgtCollectionPtr = 0;
117 
118  eventPtr = (StEvent*)GetInputDS("StEvent");
119  if( !eventPtr ) {
120  LOG_ERROR << "Error getting pointer to StEvent in '" << ClassName() << "'" << endm;
121  ierr = kStErr;
122  } else {
123  fgtCollectionPtr=eventPtr->fgtCollection();
124 
125  if( !fgtCollectionPtr) {
126  LOG_ERROR << "Error getting pointer to StFgtCollection in '" << ClassName() << "'" << endm;
127  ierr = kStErr;
128  };
129  };
130 
131  for( Int_t disc = 0; disc < kFgtNumDiscs; ++disc ){
132 
133  StFgtStripCollection *stripCollectionPtr = 0;
134  if( !ierr ){
135  stripCollectionPtr = fgtCollectionPtr->getStripCollection( disc );
136  };
137 
138  if( stripCollectionPtr ){
139  const StSPtrVecFgtStrip &stripVec = stripCollectionPtr->getStripVec();
140  StSPtrVecFgtStripConstIterator stripIter;
141 
142  for( stripIter = stripVec.begin(); stripIter != stripVec.end(); ++stripIter ){
143  Int_t rdo, arm, apv, channel;
144  (*stripIter)->getElecCoords( rdo, arm, apv, channel );
145 
146  Char_t layer, oct = StFgtGeom::getOctant( apv );
147  Short_t disc2, quad, strip;
148  StFgtGeom::decodeGeoId( (*stripIter)->getGeoId(), disc2, quad, layer, strip );
149 
150  int histIdx = disc2*kFgtNumQuads*2 + quad*2 + (oct=='S');
151 
152  mHistVec[ histIdx ]->Fill( ((apv%12)%5)*kFgtNumChannels + channel, (*stripIter)->getAdc( mTimeBin ) );
153  };
154  };
155  };
156 
157  return ierr;
158 };
159 
160 ClassImp(StFgtQaRawOctAdc);
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:44
Definition: Stypes.h:41