StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
viewEEmcDisplay.C
1 class StEEmcDisplay;
2 
3 TTree *tree = 0;
4 TFile *file = 0;
5 StEEmcDisplay *display = 0;
6 
7 TH2F *towers = 0;
8 TH1F *smdu = 0;
9 TH1F *smdv = 0;
10 
11 TH2F *pre1 = 0;
12 TH2F *pre2 = 0;
13 TH2F *post = 0;
14 
15 TEventList *event_list = 0;
16 
17 Int_t current_event=0;
18 
19 // ----------------------------------------------------------------------------
20 void viewEEmcDisplay( const Char_t *fname, const Char_t fopts="" )
21 {
22 
23  if ( !file )
24  {
25  Load();
26  file = new TFile( fname );
27  file->cd();
28  // tree=(TTree*)file->("mTree");
29  display=new StEEmcDisplay("display");
30  // tree->SetBranchAddress("display",&display);
31  mTree->SetBranchAddress("display",&display);
32  }
33  event_list = new TEventList("event_list","List of user-selected events");
34  mTree->Draw(">>event_list","" );
35  gStyle->SetPalette(1);
36  gStyle->SetHistMinimumZero();
37  help();
38 }
39 
40 // ----------------------------------------------------------------------------
41 void help()
42 {
43  std::cout << std::endl;
44  std::cout << "available commands"<<std::endl;
45  std::cout << "---------------------------------------------------------------------------------------------" << std::endl;
46  std::cout << "list_events() -- to get a list of events available for display" << std::endl;
47  std::cout << "list_events(Char_t *) -- list events which satisfy some set of cuts" << std::endl;
48  std::cout << std::endl;
49  std::cout << "load_event(Int_t) -- loads specified event"<< std::endl;
50  std::cout << "load_next() -- loads the next event in the event list" << std::endl;
51  std::cout << "show_event() -- displays towers and points for the current event" << std::endl;
52  std::cout << "show_sector(Int_t) -- zooms in on specified sector and shows smd strips/clusters"<< std::endl;
53  std::cout << "print(Char_t*) -- eg print(\".gif\"), print(\".ps\"), print(\".root\"), etc..." <<std::endl;
54  std::cout << std::endl;
55  std::cout << "help() -- show this message"<<std::endl;
56  std::cout << std::endl;
57 }
58 
59 // ----------------------------------------------------------------------------
60 void load_event( Long64_t i ) { display->clear(); mTree->GetEntry(i); }
61 // ----------------------------------------------------------------------------
62 void load_next(){
63  if ( current_event > event_list -> GetN() ) current_event = 0;
64  Int_t entry = event_list->GetEntry(current_event);
65  load_event(entry);
66  std::cout << entry << Form("\t") << display->GetTitle()<<endl;
67  current_event++;
68 }
69 void load_prev()
70 {
71  if ( current_event == 0 )
72  current_event = event_list->GetN();
73  else
74  current_event--;
75  Int_t entry = event_list->GetEntry(current_event);
76  load_event(entry);
77  std::cout << entry << Form("\t") << display->GetTitle()<<endl;
78 }
79 // ----------------------------------------------------------------------------
80 void show_event() { towers=display->DrawPoints("box"); }
81 // ----------------------------------------------------------------------------
82 void show_sector( Int_t sector=-1, Option_t *topts="box", Option_t *sopts="" )
83 {
84  if ( sector<1||sector>12 )
85  {
86  std::cout << "specify a sector 1..12" << std::endl;
87  return;
88  }
89  if ( !towers ) show_event();
90  Int_t mysector = sector-1;
91  Float_t xmin = 5.0 * (Float_t)mysector - 1.0;
92  Float_t xmax = xmin+6.0;
93  TCanvas *ctowers=display->getEEmc();
94  ctowers->cd();
95  towers = display->DrawPoints("box");
96 
97  //gROOT->GetListOfCanvases()->Modified(); /* refresh canvas */
98  towers->GetXaxis()->SetRangeUser(xmin,xmax);
99  // TCanvas *ctowers = (TCanvas*)gROOT->GetListOfCanvases()->At(0);
100  if(ctowers)ctowers->Modified();
101  smdu = display->DrawClusters(mysector,0,"stats");
102  smdv = display->DrawClusters(mysector,1,"stats");
103 
104 
105  // zoom in on pre/postshower if they are in existence
106  TCanvas *others[3];
107  TH2F *hothers[3]={pre1,pre2,post};
108  others[0]=display->getPre1();
109  others[1]=display->getPre2();
110  others[2]=display->getPost();
111  for ( Int_t i=0;i<3;i++ )
112  {
113  if ( others[i] ) others[i]->cd();
114  if ( hothers[i] ) _zoom( sector, hothers[i] );
115  if ( others[i] ) others[i]->Modified();
116  }
117 
118 }
119 
120 void _zoom( Int_t sector, TH2 *h )
121 {
122  Int_t mysector = sector-1;
123  Float_t xmin = 5.0 * (Float_t)mysector - 1.0;
124  Float_t xmax = xmin+6.0;
125  h->GetXaxis()->SetRangeUser(xmin,xmax);
126 }
127 
128 // ----------------------------------------------------------------------------
129 void show_layer( const Char_t *name, Int_t sector=0, Option_t *opts="box,text" )
130 {
131  // if ( sector<1||sector>12 )
132  // {
133  // std::cout << "specify a sector 1..12" << std::endl;
134  // return;
135  // }
136 
137  TString myname(name);
138  myname.ToLower();
139 
140  Int_t ilayer=0;
141  if ( myname.Contains("pre1") ) ilayer=1;
142  if ( myname.Contains("pre2") ) ilayer=2;
143  if ( myname.Contains("post") ) ilayer=3;
144 
145  if ( myname.Contains("all") )
146  {
147  show_layer("pre1",sector,opts);
148  show_layer("pre2",sector,opts);
149  show_layer("post",sector,opts);
150  return;
151  }
152 
153  TH2F *histo=display->DrawLayer( ilayer, opts );
154  if ( sector ) {
155  Int_t mysector = sector-1;
156  Float_t xmin = 5.0 * (Float_t)mysector - 1.0;
157  Float_t xmax = xmin+6.0;
158  histo->GetXaxis()->SetRangeUser(xmin,xmax);
159  }
160 
161  if ( ilayer==1 )
162  pre1=histo;
163  if ( ilayer==2 )
164  pre2=histo;
165  if ( ilayer==3 )
166  post=histo;
167 
168 }
169 // ----------------------------------------------------------------------------
170 void print( const Char_t *type )
171 {
172 
173  for ( Int_t i=0;i<3;i++ ) {
174  TCanvas *ctowers = (TCanvas*)gROOT->GetListOfCanvases()->At(i);
175  if ( ctowers )
176  ctowers->Print( TString(ctowers->GetName())+type );
177  }
178 
179 }
180 // ----------------------------------------------------------------------------
181 void list_events()
182 {
183 
184  mTree->Draw(">>event_list","");
185  display->clear();
186 
187  Long64_t nevents=mTree->GetEntries();
188  std::cout << "nentries="<<nevents<<endl;
189  for ( Long64_t i=0;i<nevents;i++ )
190  {
191  mTree->GetEntry(i);
192  std::cout << i << Form("\t") << display->GetTitle()<<endl;
193  }
194 
195 }
196 
197 void list_events( const Char_t *cuts )
198 {
199 
200  mTree->Draw(">>event_list",cuts );
201 
202  for ( Int_t i=0;i<event_list->GetN();i++ )
203  {
204  Int_t entry=event_list->GetEntry(i);
205  mTree->GetEntry(i);
206  std::cout << entry << Form("\t") << display->GetTitle()<<endl;
207  }
208 
209 }
210 
211 
212 // ----------------------------------------------------------------------------
213 void Load()
214 {
215  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
216  loadSharedLibraries();
217 
218  gSystem->Load("StDbLib");
219  gSystem->Load("StDbBroker");
220  gSystem->Load("St_db_Maker");
221  gSystem->Load("StEEmcUtil");
222  gSystem->Load("StEEmcDbMaker");
223  gSystem->Load("StEEmcSimulatorMaker");
224 
225  gSystem->Load("StEEmcA2EMaker");
226  gSystem->Load("StEEmcClusterMaker");
227  gSystem->Load("StEEmcPointMaker");
228  gSystem->Load("StEEmcPi0Mixer");
229 
230  gSystem->Load("StEEmcDisplayMaker");
231 
232 }
void clear()
clears all storage arrays, deletes all canvases and histograms
TH1F * DrawClusters(Int_t sector, Int_t plane, Option_t *opts="")
TH2F * DrawPoints(Option_t *opts="box")
TCanvas * getPre1()
Definition: StEEmcDisplay.h:51
TH2F * DrawLayer(Int_t layer, Option_t *opts="box,text")
TCanvas * getPre2()
Definition: StEEmcDisplay.h:52
TCanvas * getPost()
Definition: StEEmcDisplay.h:53
TCanvas * getEEmc()
Definition: StEEmcDisplay.h:48