StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtQaClusterChargePerAPV.cxx
1 
6 /***************************************************************************
7  *
8  * $Id: StFgtQaClusterChargePerAPV.cxx,v 1.2 2012/01/31 16:48:34 wwitzke Exp $
9  * Author: S. Gliske, Oct 2011
10  *
11  ***************************************************************************
12  *
13  * Description: Maker to make a histogram of the charge per cluster,
14  * combined for all r (or phi) strips connected to single APV.
15  *
16  ***************************************************************************
17  *
18  * $Log: StFgtQaClusterChargePerAPV.cxx,v $
19  * Revision 1.2 2012/01/31 16:48:34 wwitzke
20  * Changed for cosmic test stand.
21  *
22  * Revision 1.1 2012/01/31 09:26:17 sgliske
23  * StFgtQaMakers moved to StFgtPool
24  *
25  * Revision 1.2 2011/11/01 19:07:24 sgliske
26  * Updated to correspond with StEvent containers, take 2.
27  *
28  * Revision 1.1 2011/10/10 17:40:36 sgliske
29  * creation
30  *
31  *
32  **************************************************************************/
33 
34 #include "StFgtQaClusterChargePerAPV.h"
35 
36 #include <string>
37 #include <TH2F.h>
38 
39 #include "StFgtQaMaker.h"
40 #include "StRoot/StFgtPool/StFgtCosmicTestStandGeom/StFgtCosmicTestStandGeom.h"
41 
42 #include "StRoot/StEvent/StFgtCollection.h"
43 #include "StRoot/StEvent/StFgtHitCollection.h"
44 #include "StRoot/StEvent/StFgtHit.h"
45 
46 
47 StFgtQaClusterChargePerAPV::StFgtQaClusterChargePerAPV( const Char_t* name,
48  Short_t discId,
49  Short_t quadId,
50  Short_t apvId,
51  const Char_t* quadName ) :
52  StFgtQaMaker( name, discId, quadId, quadName ),
53  mNbins( 160 ), mChargeMin( -512 ), mChargeMax( 2048 ), mUnits("arb. units")
54 {
55  //initialize hist pointers
56  for( Int_t i=0; i<10; ++i ){
57  mHistR[i] = 0;
58  mHistPhi[i] = 0;
59  };
60 };
61 
62 StFgtQaClusterChargePerAPV::StFgtQaClusterChargePerAPV(const StFgtQaClusterChargePerAPV& other ) :
63  StFgtQaMaker(other),
64  mNbins( 160 ), mChargeMin( -512 ), mChargeMax( 2048 ), mUnits("arb. units") {
65 
66  //initialize hist pointers
67  for( Int_t i=0; i<10; ++i ){
68  mHistR[i] = 0;
69  mHistPhi[i] = 0;
70 
71  if( other.mHistR[i] ){
72  std::string name = std::string( other.mHistR[i]->GetName() ) + "_copy";
73  mHistR[i] = static_cast< TH1F* >( other.mHistR[i]->Clone(name.data()) );
74  };
75 
76  if( other.mHistPhi ){
77  std::string name = std::string( other.mHistPhi[i]->GetName() ) + "_copy";
78  mHistPhi[i] = static_cast< TH1F* >( other.mHistPhi[i]->Clone( name.data() ) );
79  };
80  };
81 };
82 
83 // deconstructor
84 StFgtQaClusterChargePerAPV::~StFgtQaClusterChargePerAPV(){
85  for( Int_t i=0; i<10; ++i ){
86  if( mHistR[i] )
87  delete mHistR[i];
88  if( mHistPhi[i] )
89  delete mHistPhi[i];
90  };
91 };
92 
93 // equals operator
94 StFgtQaClusterChargePerAPV& StFgtQaClusterChargePerAPV::operator=(const StFgtQaClusterChargePerAPV& rhs ){
95  StFgtQaMaker::operator=( rhs );
96 
97  for( Int_t i=0; i<10; ++i ){
98  if( mHistR[i] )
99  delete mHistR[i];
100  if( mHistPhi[i] )
101  delete mHistPhi[i];
102 
103  mHistR[i] = 0;
104  mHistPhi[i] = 0;
105  };
106 
107  // copy hist pointers
108  for( Int_t i=0; i<10; ++i ){
109  mHistR[i] = 0;
110  mHistPhi[i] = 0;
111 
112  if( rhs.mHistR[i] ){
113  std::string name = std::string( rhs.mHistR[i]->GetName() ) + "_copy";
114  mHistR[i] = static_cast< TH1F* >( rhs.mHistR[i]->Clone(name.data()) );
115  };
116 
117  if( rhs.mHistPhi ){
118  std::string name = std::string( rhs.mHistPhi[i]->GetName() ) + "_copy";
119  mHistPhi[i] = static_cast< TH1F* >( rhs.mHistPhi[i]->Clone( name.data() ) );
120  };
121  };
122 
123  return *this;
124 };
125 
126 Int_t StFgtQaClusterChargePerAPV::Init(){
127  Int_t ierr = StFgtQaMaker::Init();
128 
129  if( !ierr ){
130  // Take care of the histogram
131 
132  for( Int_t i=0; i<10; ++i ){
133  if( mHistR[i] )
134  delete mHistR[i];
135  if( mHistPhi[i] )
136  delete mHistPhi[i];
137 
138  mHistR[i] = 0;
139  mHistPhi[i] = 0;
140 
141  std::string name;
142  {
143  std::stringstream ss;
144  ss << GetName() << "_" << mDiscId << "_" << mQuadId << "_" << i;
145  ss >> name;
146  };
147 
148  mHistR[i] = new TH1F( ( name + "_histR" ).data(), "", mNbins, mChargeMin, mChargeMax );
149  mHistPhi[i] = new TH1F( ( name + "_histPhi").data(), "", mNbins, mChargeMin, mChargeMax );
150 
151  std::string titleR = "R-strip Charge per Cluster,";
152  std::string titlePhi = "#phi-strip Charge per Cluster,";
153 
154  std::string middle;
155  {
156  std::stringstream ss;
157  ss << "Quad " << mQuadName << ", APV " << i;
158  ss >> middle;
159  };
160  middle += "; Charge per strip [";
161  middle += mUnits;
162  middle += "];";
163 
164 
165  titleR += middle;
166  titlePhi += middle;
167 
168  titleR += "R-strip Id.";
169  titlePhi += "#phi-strip Id.";
170 
171  mHistR[i]->SetTitle( titleR.data() );
172  mHistPhi[i]->SetTitle( titlePhi.data() );
173  };
174  };
175 
176  return ierr;
177 };
178 
180  Int_t ierr = StFgtQaMaker::Make();
181 
182  StFgtHitCollection *hitCollectionPtr = 0;
183  if( !ierr ){
184  hitCollectionPtr = mFgtCollectionPtr->getHitCollection( mDiscId );
185  };
186 
187  if( hitCollectionPtr ){
188  const StSPtrVecFgtHit &hitVec = hitCollectionPtr->getHitVec();
189  StSPtrVecFgtHitConstIterator hitIter;
190  stripWeightMap_t::iterator stripMapIter;
191 
192  for( hitIter = hitVec.begin(); hitIter != hitVec.end(); ++hitIter ){
193  stripWeightMap_t& stripWeightMap = (*hitIter)->getStripWeightMap();
194 
195  Float_t maxCharge = -99999;
196  Int_t geoId4Max = 0;
197 
198  // find the geoId for the strip with the most charge
199  // contributing to the cluster
200  for( stripMapIter = stripWeightMap.begin(); stripMapIter != stripWeightMap.end(); ++stripMapIter ){
201  const StFgtStrip *stripPtr = stripMapIter->first;
202  Float_t w = stripMapIter->second;
203 
204  Float_t stripCharge = 0;
205  if( stripPtr && w )
206  stripCharge = w*stripPtr->getCharge();
207 
208  if( stripCharge > maxCharge ){
209  geoId4Max = stripPtr->getGeoId();
210  maxCharge = stripCharge;
211  };
212  };
213 
214  if( maxCharge > -99999 ){
215  // now find the quadrant and apv
216  Int_t rdo, arm, apv, channel;
217  Short_t disc, quad, strip;
218  Char_t layer;
219 
220  StFgtCosmicTestStandGeom::decodeGeoId( geoId4Max, disc, quad, layer, strip );
221  if( quad == mQuadId && disc == mDiscId ){
222  StFgtCosmicTestStandGeom::getNaiveElecCoordFromGeoId( geoId4Max, rdo, arm, apv, channel);
223 
224  apv %= 12;
225  if( apv > -1 && apv < 10 )
226  ( layer == 'R' ? mHistR[apv] : mHistPhi[apv] )->Fill( maxCharge );
227  };
228  };
229  };
230  };
231 
232  return ierr;
233 };
234 
236  // nothing for the moment.
237  return kStOk;
238 };
239 
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
virtual Int_t Make()
Definition: Stypes.h:41