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