StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plotPedsFromFile.C
1 /***************************************************************************
2  *
3  * $Id: plotPedsFromFile.C,v 1.5 2011/09/30 19:09:07 sgliske Exp $
4  * Author: S. Gliske, Sept 2011
5  *
6  ***************************************************************************
7  *
8  * Description: Plots peds from a file
9  *
10  ***************************************************************************
11  *
12  * $Log: plotPedsFromFile.C,v $
13  * Revision 1.5 2011/09/30 19:09:07 sgliske
14  * general update
15  *
16  * Revision 1.4 2011/09/29 18:39:43 sgliske
17  * Update for geoId->elecCoord function now in StFgtCosmicTestStandGeom
18  *
19  * Revision 1.3 2011/09/27 00:49:00 sgliske
20  * cosmic QA update
21  *
22  * Revision 1.2 2011/09/26 16:55:52 sgliske
23  * Continued work on cosmic QA plots
24  *
25  * Revision 1.1 2011/09/22 21:22:03 sgliske
26  * creation
27  *
28  *
29  **************************************************************************/
30 
31 // forward declarations
32 class StFgtPedPlotter;
33 
34 StFgtPedPlotter *pedPlotter = 0;
35 TCanvas *can = 0;
36 
37 int plotPedsFromFile( const Char_t *filenameIn = "testfile.Ped.txt",
38  const Char_t *filenameOut = "testfile.Ped.eps",
39  Short_t disc = 0,
40  Short_t quad = 0,
41  Char_t* quadName = "FGT #010",
42  Char_t plotVsStrip = 'c',
43  Bool_t doPlotStDev = 1,
44  Short_t timeBin = 4 ){
45  LoadLibs();
46  Int_t ierr = 0;
47 
48  cout << "Constructing the ped plotter" << endl;
49  pedPlotter = new StFgtPedPlotter;
50  pedPlotter->setReadFromFile( filenameIn );
51  pedPlotter->setTimeBinMask( 1<<timeBin );
52  pedPlotter->setPlotVsStrip( plotVsStrip );
53  pedPlotter->setDisc( disc );
54  pedPlotter->setQuad( quad );
55  pedPlotter->setPlotStDev( doPlotStDev );
56 
57  cout << "making the graphs" << endl;
58  ierr = pedPlotter->makePlots();
59  cout << "\tdone" << endl;
60 
61  if( ierr ){
62  cerr << "Error making plots" << endl;
63  } else {
64  gROOT->SetStyle("Plain");
65  gStyle->SetOptStat(0);
66  gStyle->SetEndErrorSize(0);
67  gStyle->SetTitleBorderSize(0);
68  gStyle->SetTitleTextColor(kRed);
69 
70  Int_t width = 1800;
71  Int_t height = 600;
72  if( plotVsStrip == 'R' || plotVsStrip == 'r' || plotVsStrip == 'P' ){
73  width /= 3;
74  height = width+1;
75  };
76 
77  can = new TCanvas("can","Pedistal Canvas",width,height);
78  can->SetRightMargin( 0.02 );
79  can->SetGridx(0);
80  can->SetGridy(0);
81 
82  Float_t xlow = 0;
83  Float_t xhigh = 1280;
84  if( plotVsStrip == 'R' ){
85  xlow = 10;
86  xhigh = 40;
87  } else if ( plotVsStrip == 'P' ){
88  xlow = 0;
89  xhigh = 6.28/4;
90  };
91 
92  //Float_t maxX = pedPlotter->getMaxX();
93  Float_t maxY = pedPlotter->getMaxY()*1.05;
94  if( maxY < 512 )
95  maxY = 512;
96 
97  TH2F *hist = new TH2F ("hist", "", 1, xlow, xhigh, 1, 0, maxY );
98  hist->Draw("H");
99 
100  const TGraphErrors* gr = pedPlotter->getGraph( timeBin );
101  if( gr ){
102  gr->SetLineColor( kBlue );
103  gr->SetMarkerStyle( 20 );
104  gr->SetMarkerSize( 0.4 );
105  if( doPlotStDev )
106  gr->SetMarkerColor( kBlue );
107  gr->Draw("PE same");
108  hist->SetTitle( gr->GetTitle() );
109  };
110 
111  std::string title = hist->GetTitle();
112  title += std::string(", ") + quadName;
113  hist->SetTitle( title.data() );
114 
115  if( filenameOut )
116  can->Print( filenameOut );
117  };
118 
119  return;
120 };
121 
122 
123 // load the shared libraries
124 void LoadLibs() {
125  // common shared libraries
126 
127 // gSystem->Load("libPhysics");
128 // gSystem->Load("St_base");
129 // gSystem->Load("StChain");
130 // gSystem->Load("StEvent");
131 // cout << "loaded StEvent library" << endl;
132 
133  gSystem->Load("StUtilities");
134  gSystem->Load("StFgtUtil");
135  gSystem->Load("StFgtPedPlotter");
136 };