StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcFgtLHTrackQa.cxx
1 /***************************************************************************
2  *
3  * $Id: StEEmcFgtLHTrackQa.cxx,v 1.4 2012/04/13 15:08:43 sgliske Exp $
4  * Author: S. Gliske, April 2012
5  *
6  ***************************************************************************
7  *
8  * Description: See header.
9  *
10  ***************************************************************************
11  *
12  * $Log: StEEmcFgtLHTrackQa.cxx,v $
13  * Revision 1.4 2012/04/13 15:08:43 sgliske
14  * updates
15  *
16  * Revision 1.3 2012/04/12 17:12:05 sgliske
17  * update to not use A2EMaker but StEEmcRawMaker
18  *
19  * Revision 1.2 2012/04/11 22:13:24 sgliske
20  * update
21  *
22  *
23  **************************************************************************/
24 
25 #include <vector>
26 #include <TVector3.h>
27 #include <TROOT.h>
28 #include <TFile.h>
29 #include "StEEmcFgtLHTrackQa.h"
30 #include "StRoot/StFgtPool/StFgtTracking/StFgtLHTracking.h"
31 #include "StRoot/StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
32 #include "StRoot/StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
33 #include "StEEmcRawMapMaker.h"
34 
35 #define DEBUG
36 
37 StEEmcFgtLHTrackQa::StEEmcFgtLHTrackQa( const Char_t* name, const Char_t* rawMapMkrName, const Char_t* fgtLHTkrName ) :
38  StMaker( name ), mEEmcRawMapMkr(0), mFgtLHTkr(0), mThres(3) {
39 
40  mEEmcRawMapMkr = static_cast< StEEmcRawMapMaker* >( GetMaker( rawMapMkrName ) );
41  mFgtLHTkr = static_cast< StFgtLHTracking* >( GetMaker( fgtLHTkrName ) );
42 
43  for( Int_t i=0; i<4; ++i )
44  mSig[i] = mSigPer[i] = 0;
45 };
46 
47 // deconstructor
48 StEEmcFgtLHTrackQa::~StEEmcFgtLHTrackQa(){ /* */ };
49 
50 Int_t StEEmcFgtLHTrackQa::Init(){
51 
52  std::stringstream ss;
53 
54  gROOT->cd();
55  for( Int_t i=0; i<4; ++i ){
56  ss.str("");
57  ss.clear();
58  ss << "hSig_" << i;
59  mSig[i] = new TH1F( ss.str().data(), ";; Counts", 2, -0.5, 1.5 );
60 
61  ss.str("");
62  ss.clear();
63  ss << "hSigPer_" << i;
64  mSigPer[i] = new TH1F( ss.str().data(), ";; Counts", 2, -0.5, 1.5 );
65 
66  mSig[i]->GetXaxis()->SetBinLabel( 1, "Noise" );
67  mSig[i]->GetXaxis()->SetBinLabel( 2, "Signal" );
68  mSigPer[i]->GetXaxis()->SetBinLabel( 1, "Noise" );
69  mSigPer[i]->GetXaxis()->SetBinLabel( 2, "Signal" );
70  };
71 
72  assert( mEEmcRawMapMkr );
73  assert( mFgtLHTkr );
74 
75  return kStOK;
76 };
77 
79  assert( mEEmcRawMapMkr );
80  assert( mFgtLHTkr );
81 
82  const StFgtLHTrackVec& trackVec = mFgtLHTkr->getTrackVec();
83  const StEEmcRawMap* eemcMap[4];
84  Bool_t eemcEmpty = 1;
85  for( Int_t i=0; i<4; ++i ){
86  eemcMap[i] = &mEEmcRawMapMkr->getMap( i );
87  eemcEmpty &= eemcMap[i]->empty();
88  };
89 
90 #ifdef DEBUG2
91  if( !eemcMap[0]->empty() ){
92  LOG_INFO << "\t-> Towers has size " << eemcMap[0]->size() << endm;
93  };
94 #endif
95 
96  if( !trackVec.empty() && !eemcEmpty ){
97  StFgtLHTrackVec::const_iterator trackVecIter;
98 
99 #ifdef DEBUG
100  LOG_INFO << "Event " << GetEventNumber() << " # tracks " << trackVec.size() << endm;
101  //LOG_INFO << "\t-> Towers has size " << eemcMap[0]->size() << endm;
102 #endif
103 
104  std::map< Int_t, Int_t > towMap;
105  std::map< Int_t, Int_t >::iterator towMapIter;
106 
108  Int_t sec, sub, etabin;
109 
110  for( trackVecIter = trackVec.begin(); trackVecIter != trackVec.end(); ++trackVecIter ){
111 
112  // get the x and y position at the endcap
113  Double_t x = trackVecIter->line.bx + trackVecIter->line.mx*kEEmcZSMD;
114  Double_t y = trackVecIter->line.by + trackVecIter->line.my*kEEmcZSMD;
115  TVector3 pos( x, y, kEEmcZSMD );
116 
117  Bool_t found = eemcGeom.getTower( pos, sec, sub, etabin );
118 
119 #ifdef DEBUG
120  LOG_INFO << "\tTrack points to (x, y) = ( " << x << ", " << y << "), (eta,phi) = ( " << pos.Eta() << ", " << pos.Phi() << ") at SMDZ = tower at " << sec << ' ' << sub << ' ' << etabin << endm;
121 #endif
122 
123  if( found ){
124  Int_t index = etabin + kEEmcNumEtas*( sub + kEEmcNumSubSectors*sec );
125 
126  towMapIter = towMap.find( index );
127  if( towMapIter == towMap.end() )
128  towMap[index] = 1;
129  else
130  ++(towMapIter->second);
131  };
132  };
133 
134  StEEmcRawMap::const_iterator rawMapIter;
135 
136  for( towMapIter = towMap.begin(); towMapIter != towMap.end(); ++towMapIter ){
137  Int_t index = towMapIter->first;
138  Int_t num = towMapIter->second;
139 
140 #ifdef DEBUG
141  LOG_INFO << "\t---> Accessing tower index " << index << endm;
142 #endif
143 
144  for( Int_t i=0; i<4; ++i ){
145  rawMapIter = eemcMap[i]->find( index );
146 
147  if( rawMapIter != eemcMap[i]->end() ){
148  const StEEmcRawMapData& data = rawMapIter->second;
149 
150  Double_t val = (data.rawAdc - data.ped) / data.pedSigma;
151 
152  mSig[i]->Fill( (Int_t)(val > mThres) );
153  mSigPer[i]->Fill( (Int_t)(val/num > mThres) );
154 
155  cout << "EEMC tower: " << i << ' ' << index << ' ' << data.rawAdc << ' ' << data.ped << ' ' << data.pedSigma << ' ' << val << ' ' << num
156  << (val > mThres ? " SIGNAL" : " ") << endl;
157  };
158  };
159  };
160  };
161 
162  return kStOK;
163 };
164 
166  Int_t ierr = kStOk;
167 
168  if( !mFileOutName.empty() ){
169  TFile *f = new TFile( mFileOutName.data(), "RECREATE" );
170 
171  if( !f->IsOpen() ){
172  LOG_ERROR << "Error opening file '" << mFileOutName << "'" << endl;
173  ierr = kStErr;
174  } else {
175  f->cd();
176 
177  for(Int_t i=0; i<4; ++i ){
178  mSig[i]->Write();
179  mSigPer[i]->Write();
180  };
181  };
182  };
183 
184  return ierr;
185 };
186 
187 ClassImp(StEEmcFgtLHTrackQa);
static EEmcGeomSimple & Instance()
returns a reference to a static instance of EEmcGeomSimple
EEMC simple geometry.
Definition: Stypes.h:40
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
Definition: Stypes.h:44
Definition: Stypes.h:41