37 #include "StFgtSingleEventQA.h"
38 #include "StRoot/StFgtUtil/StFgtConsts.h"
44 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
46 #include "StRoot/StEvent/StEvent.h"
47 #include "StRoot/StEvent/StFgtCollection.h"
48 #include "StRoot/StEvent/StFgtStripCollection.h"
49 #include "StRoot/StEvent/StFgtStrip.h"
52 StFgtSingleEventQA::StFgtSingleEventQA(
const Char_t* name ) :
StMaker( name ), mTFile( 0 ) {
57 StFgtSingleEventQA::~StFgtSingleEventQA(){
64 Int_t StFgtSingleEventQA::Init(){
69 if( mFilename.empty() ){
70 mFilename =
"fgtSingleEvents.root";
71 LOG_INFO <<
"Empty filename. Defaulting to '" << mFilename <<
"'" << endl;
74 mTFile =
new TFile( mFilename.data(),
"RECREATE" );
75 if( !mTFile->IsOpen() ){
76 LOG_FATAL <<
"Error opening file '" << mFilename <<
"' "<< endm;
87 mFgtCollectionPtr = 0;
89 eventPtr = (
StEvent*)GetInputDS(
"StEvent");
91 LOG_ERROR <<
"Error getting pointer to StEvent in '" << ClassName() <<
"'" << endm;
94 mFgtCollectionPtr=eventPtr->fgtCollection();
96 if( !mFgtCollectionPtr) {
97 LOG_ERROR <<
"Error getting pointer to StFgtCollection in '" << ClassName() <<
"'" << endm;
102 for( Int_t disc = 0; disc < kFgtNumDiscs; ++disc ){
105 stripCollectionPtr = mFgtCollectionPtr->getStripCollection( disc );
108 if( stripCollectionPtr ){
109 TH2F *hP[kFgtNumOctantsPerDisc*kFgtNumTimeBins], *hR[kFgtNumOctantsPerDisc*kFgtNumTimeBins];
110 for( TH2F** hPptr = hP, **hRptr = hR; hPptr != &hP[kFgtNumOctantsPerDisc*kFgtNumTimeBins]; ++hPptr, ++hRptr )
111 (*hPptr) = (*hRptr) = 0;
113 const StSPtrVecFgtStrip &stripVec = stripCollectionPtr->getStripVec();
114 StSPtrVecFgtStripConstIterator stripIter;
116 for( stripIter = stripVec.begin(); stripIter != stripVec.end(); ++stripIter ){
117 Int_t geoId = (*stripIter)->getGeoId();
119 for( Int_t tb = 0; tb < kFgtNumTimeBins; ++tb ){
120 Short_t adc = (*stripIter)->getAdc(tb);
123 Short_t disc, quad, strip;
125 StFgtGeom::decodeGeoId( geoId, disc, quad, layer, strip );
135 Bool_t octIsShort = ( layer ==
'R' ? (strip > 279) : (strip > 359) );
137 Int_t bin = ( quad*2 + octIsShort )*kFgtNumTimeBins + tb;
139 makeHists( mEventNum, tb, disc, quad, octIsShort, hP[bin], hR[bin] );
142 Double_t pos, high = 0, low = 0;
143 StFgtGeom::getPhysicalCoordinate( geoId, disc, quad, layer, pos, low, high );
145 hP[bin]->SetBinContent( strip+1, 2, adc );
147 hP[bin]->SetBinContent( strip+1, 1, adc );
149 hR[bin]->SetBinContent( 1, strip+1, adc );
155 if( mTFile && mTFile->IsOpen() )
156 for( TH2F **hPptr = hP, **hRptr = hR; hPptr != &hP[kFgtNumOctantsPerDisc*kFgtNumTimeBins]; ++hPptr, ++hRptr )
173 void StFgtSingleEventQA::makeHists( Int_t ev, Int_t tb, Int_t disc, Int_t quad, Bool_t isShort, TH2F* &hP, TH2F* &hR ){
174 std::stringstream ss;
180 << ( isShort ?
'S' :
'L' );
181 std::string nameP = ss.str() +
"_P";
182 std::string nameR = ss.str() +
"_R";
186 hP =
new TH2F( nameP.data(),
"", 360, 0, 360, 2, 0, 2 );
187 hR =
new TH2F( nameR.data(),
"", 1, 0, 0.7854, 280, 0, 280 );
189 hP =
new TH2F( nameP.data(),
"", 360, 360, 720, 2, 0, 2 );
190 hR =
new TH2F( nameR.data(),
"", 1, 0.7854, 1.5708, 280, 400, 680 );