00001 class StEEmcDisplay;
00002
00003 TTree *tree = 0;
00004 TFile *file = 0;
00005 StEEmcDisplay *display = 0;
00006
00007 TH2F *towers = 0;
00008 TH1F *smdu = 0;
00009 TH1F *smdv = 0;
00010
00011 TH2F *pre1 = 0;
00012 TH2F *pre2 = 0;
00013 TH2F *post = 0;
00014
00015 TEventList *event_list = 0;
00016
00017 Int_t current_event=0;
00018
00019
00020 void viewEEmcDisplay( const Char_t *fname, const Char_t fopts="" )
00021 {
00022
00023 if ( !file )
00024 {
00025 Load();
00026 file = new TFile( fname );
00027 file->cd();
00028
00029 display=new StEEmcDisplay("display");
00030
00031 mTree->SetBranchAddress("display",&display);
00032 }
00033 event_list = new TEventList("event_list","List of user-selected events");
00034 mTree->Draw(">>event_list","" );
00035 gStyle->SetPalette(1);
00036 gStyle->SetHistMinimumZero();
00037 help();
00038 }
00039
00040
00041 void help()
00042 {
00043 std::cout << std::endl;
00044 std::cout << "available commands"<<std::endl;
00045 std::cout << "---------------------------------------------------------------------------------------------" << std::endl;
00046 std::cout << "list_events() -- to get a list of events available for display" << std::endl;
00047 std::cout << "list_events(Char_t *) -- list events which satisfy some set of cuts" << std::endl;
00048 std::cout << std::endl;
00049 std::cout << "load_event(Int_t) -- loads specified event"<< std::endl;
00050 std::cout << "load_next() -- loads the next event in the event list" << std::endl;
00051 std::cout << "show_event() -- displays towers and points for the current event" << std::endl;
00052 std::cout << "show_sector(Int_t) -- zooms in on specified sector and shows smd strips/clusters"<< std::endl;
00053 std::cout << "print(Char_t*) -- eg print(\".gif\"), print(\".ps\"), print(\".root\"), etc..." <<std::endl;
00054 std::cout << std::endl;
00055 std::cout << "help() -- show this message"<<std::endl;
00056 std::cout << std::endl;
00057 }
00058
00059
00060 void load_event( Long64_t i ) { display->clear(); mTree->GetEntry(i); }
00061
00062 void load_next(){
00063 if ( current_event > event_list -> GetN() ) current_event = 0;
00064 Int_t entry = event_list->GetEntry(current_event);
00065 load_event(entry);
00066 std::cout << entry << Form("\t") << display->GetTitle()<<endl;
00067 current_event++;
00068 }
00069 void load_prev()
00070 {
00071 if ( current_event == 0 )
00072 current_event = event_list->GetN();
00073 else
00074 current_event--;
00075 Int_t entry = event_list->GetEntry(current_event);
00076 load_event(entry);
00077 std::cout << entry << Form("\t") << display->GetTitle()<<endl;
00078 }
00079
00080 void show_event() { towers=display->DrawPoints("box"); }
00081
00082 void show_sector( Int_t sector=-1, Option_t *topts="box", Option_t *sopts="" )
00083 {
00084 if ( sector<1||sector>12 )
00085 {
00086 std::cout << "specify a sector 1..12" << std::endl;
00087 return;
00088 }
00089 if ( !towers ) show_event();
00090 Int_t mysector = sector-1;
00091 Float_t xmin = 5.0 * (Float_t)mysector - 1.0;
00092 Float_t xmax = xmin+6.0;
00093 TCanvas *ctowers=display->getEEmc();
00094 ctowers->cd();
00095 towers = display->DrawPoints("box");
00096
00097
00098 towers->GetXaxis()->SetRangeUser(xmin,xmax);
00099
00100 if(ctowers)ctowers->Modified();
00101 smdu = display->DrawClusters(mysector,0,"stats");
00102 smdv = display->DrawClusters(mysector,1,"stats");
00103
00104
00105
00106 TCanvas *others[3];
00107 TH2F *hothers[3]={pre1,pre2,post};
00108 others[0]=display->getPre1();
00109 others[1]=display->getPre2();
00110 others[2]=display->getPost();
00111 for ( Int_t i=0;i<3;i++ )
00112 {
00113 if ( others[i] ) others[i]->cd();
00114 if ( hothers[i] ) _zoom( sector, hothers[i] );
00115 if ( others[i] ) others[i]->Modified();
00116 }
00117
00118 }
00119
00120 void _zoom( Int_t sector, TH2 *h )
00121 {
00122 Int_t mysector = sector-1;
00123 Float_t xmin = 5.0 * (Float_t)mysector - 1.0;
00124 Float_t xmax = xmin+6.0;
00125 h->GetXaxis()->SetRangeUser(xmin,xmax);
00126 }
00127
00128
00129 void show_layer( const Char_t *name, Int_t sector=0, Option_t *opts="box,text" )
00130 {
00131
00132
00133
00134
00135
00136
00137 TString myname(name);
00138 myname.ToLower();
00139
00140 Int_t ilayer=0;
00141 if ( myname.Contains("pre1") ) ilayer=1;
00142 if ( myname.Contains("pre2") ) ilayer=2;
00143 if ( myname.Contains("post") ) ilayer=3;
00144
00145 if ( myname.Contains("all") )
00146 {
00147 show_layer("pre1",sector,opts);
00148 show_layer("pre2",sector,opts);
00149 show_layer("post",sector,opts);
00150 return;
00151 }
00152
00153 TH2F *histo=display->DrawLayer( ilayer, opts );
00154 if ( sector ) {
00155 Int_t mysector = sector-1;
00156 Float_t xmin = 5.0 * (Float_t)mysector - 1.0;
00157 Float_t xmax = xmin+6.0;
00158 histo->GetXaxis()->SetRangeUser(xmin,xmax);
00159 }
00160
00161 if ( ilayer==1 )
00162 pre1=histo;
00163 if ( ilayer==2 )
00164 pre2=histo;
00165 if ( ilayer==3 )
00166 post=histo;
00167
00168 }
00169
00170 void print( const Char_t *type )
00171 {
00172
00173 for ( Int_t i=0;i<3;i++ ) {
00174 TCanvas *ctowers = (TCanvas*)gROOT->GetListOfCanvases()->At(i);
00175 if ( ctowers )
00176 ctowers->Print( TString(ctowers->GetName())+type );
00177 }
00178
00179 }
00180
00181 void list_events()
00182 {
00183
00184 mTree->Draw(">>event_list","");
00185 display->clear();
00186
00187 Long64_t nevents=mTree->GetEntries();
00188 std::cout << "nentries="<<nevents<<endl;
00189 for ( Long64_t i=0;i<nevents;i++ )
00190 {
00191 mTree->GetEntry(i);
00192 std::cout << i << Form("\t") << display->GetTitle()<<endl;
00193 }
00194
00195 }
00196
00197 void list_events( const Char_t *cuts )
00198 {
00199
00200 mTree->Draw(">>event_list",cuts );
00201
00202 for ( Int_t i=0;i<event_list->GetN();i++ )
00203 {
00204 Int_t entry=event_list->GetEntry(i);
00205 mTree->GetEntry(i);
00206 std::cout << entry << Form("\t") << display->GetTitle()<<endl;
00207 }
00208
00209 }
00210
00211
00212
00213 void Load()
00214 {
00215 gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
00216 loadSharedLibraries();
00217
00218 gSystem->Load("StDbLib");
00219 gSystem->Load("StDbBroker");
00220 gSystem->Load("St_db_Maker");
00221 gSystem->Load("StEEmcUtil");
00222 gSystem->Load("StEEmcDbMaker");
00223 gSystem->Load("StEEmcSimulatorMaker");
00224
00225 gSystem->Load("StEEmcA2EMaker");
00226 gSystem->Load("StEEmcClusterMaker");
00227 gSystem->Load("StEEmcPointMaker");
00228 gSystem->Load("StEEmcPi0Mixer");
00229
00230 gSystem->Load("StEEmcDisplayMaker");
00231
00232 }