StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtPointPlotter.cxx
1 
2 #include "StRoot/StEvent/StFgtCollection.h"
3 #include "StRoot/StEvent/StFgtHitCollection.h"
4 #include "StRoot/StEvent/StFgtPointCollection.h"
5 #include "StFgtPointPlotter.h"
6 
7 #include "StRoot/StEvent/StFgtHit.h"
8 #include "StRoot/StEvent/StFgtPoint.h"
9 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
10 #include "StRoot/StEvent/StEvent.h"
11 #include "StRoot/StEvent/StEventInfo.h"
12 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
13 
14 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
15 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
16 #include "StMuDSTMaker/COMMON/StMuDst.h"
17 #include "StMuDSTMaker/COMMON/StMuEvent.h"
18 #include "StarClassLibrary/StThreeVectorF.hh"
19 
20 #include <TH2D.h>
21 #include <TROOT.h>
22 #include <TStyle.h>
23 #include <TCanvas.h>
24 #include <utility>
25 #include <TArc.h>
26 #include <TLine.h>
27 #include <set>
28 
29 
30 
31 Int_t StFgtPointPlotter::Init()
32 {
33  outRootFile=new TFile("pointPlots.root","RECREATE");
34 
35  histos=new TH2D*[6*4];
36  tbHistos=new TH1D*[6*4];
37  tbCorrelation=new TH2D("tbCorrelation","tbCorrelation",15,0,15,15,0,15);
38 
39 
40  char buffer[200];
41  for(int i=0;i<6;i++)
42  {
43  for(int iq=0;iq<4;iq++)
44  {
45  sprintf(buffer,"disk_%d_quad_%d",i,iq);
46  cout <<"init histo: " << i*4+iq << ", " << buffer <<endl;
47  histos[i*4+iq]=new TH2D(buffer,buffer,100,-40,40,100,-40,40);
48  sprintf(buffer,"MaxTimeBin_disk_%d_quad_%d",i,iq);
49  tbHistos[i*4+iq]=new TH1D(buffer,buffer,15,0,14);
50  }
51  }
52  return kStOk;
53 }
54 
56 {
57 
58  Int_t ierr = kStOk;
59 
60  StEvent* eventPtr = 0;
61  eventPtr = (StEvent*)GetInputDS("StEvent");
62 
63  if( !eventPtr ) {
64  LOG_ERROR << "Error getting pointer to StEvent from '" << ClassName() << "'" << endm;
65  ierr = kStErr;
66  };
67 
68  StFgtCollection* fgtCollectionPtr = 0;
69 
70  if( eventPtr ) {
71  fgtCollectionPtr=eventPtr->fgtCollection();
72  };
73 
74  if( !fgtCollectionPtr) {
75  LOG_ERROR << "Error getting pointer to StFgtCollection from '" << ClassName() << "'" << endm;
76  ierr = kStErr;
77  };
78  StFgtPointCollection *pointCollectionPtr = fgtCollectionPtr->getPointCollection();
79 
80  if( !pointCollectionPtr ){
81  LOG_ERROR << "Error getting pointer to StFgtPointCollection from StFgtCollection" << endm;
82  ierr = kStErr;
83  };
84  Int_t numPoints=pointCollectionPtr->getNumPoints();
85 
86  cout <<"point plotter: we have " << numPoints << " points " <<endl;
87  const StSPtrVecFgtPoint& pointVec=pointCollectionPtr->getPointVec();
88  StSPtrVecFgtPointConstIterator iter1;
89  for(iter1 = pointVec.begin();iter1!=pointVec.end();++iter1)
90  {
91  Float_t R=(*iter1)->getPositionR();
92  Float_t Phi=(*iter1)->getPositionPhi();
93 
94  Int_t disk=(*iter1)->getDisc();
95  Int_t quad=(*iter1)->getQuad();
96 
97  Float_t x=R*cos(Phi);
98  Float_t y=R*sin(Phi);
99 
100  Int_t tbR=(*iter1)->getHitR()->getMaxTimeBin();
101  Int_t tbPhi=(*iter1)->getHitPhi()->getMaxTimeBin();
102 
103  cout <<"disk: " << disk <<" quad: " << quad << ", point at (" <<x << ", " << y << ") "<<endl;
104  histos[disk*4+quad]->Fill(x,y);
105  tbHistos[disk*4+quad]->Fill(tbR);
106  tbHistos[disk*4+quad]->Fill(tbPhi);
107 
108  tbCorrelation->Fill(tbR,tbPhi);
109  }
110 
111  return ierr;
112 }
113 
115 {
116  for(int i=0;i<6;i++)
117  {
118  for(int iq=0;iq<4;iq++)
119  {
120  histos[i*4+iq]->Write();
121  tbHistos[i*4+iq]->Write();
122  }
123  }
124  tbCorrelation->Write();
125  outRootFile->Write();
126  return kStOk;
127 }
128 
129 StFgtPointPlotter::~StFgtPointPlotter()
130 {
131 
132 }
133 
134 StFgtPointPlotter::StFgtPointPlotter( const Char_t* name): StMaker( name )
135 {
136 
137 }
138 
139 
140 ClassImp(StFgtPointPlotter);
Definition: Stypes.h:44
Definition: Stypes.h:41