10 #include <TApplication.h> 
   15 #include <TRootEmbeddedCanvas.h> 
   16 #include <TGStatusBar.h> 
   27   gROOT->SetStyle(
"Plain");
 
   29   gROOT->LoadMacro(
"$VMCWORKDIR/gconfig/rootlogon.C");
 
   30   gROOT->LoadMacro(
"$VMCWORKDIR/gconfig/basiclibs.C");
 
   36         f.open(
"structure.txt");
 
   40                 std::cout<<
"File does not exist"<<std::endl;
 
   42                 TTree *
tsim=(TTree *) fsim->Get(
"pndsim") ;
 
   45                 std::cout<<
"File with emc structure is created"<<std::endl;
 
   49                 ifstream in(
"structure.txt");
 
   50                 ofstream 
out(
"outfile.txt");
 
   55                 while (getline(in,line))
 
   57                         if (line[0]!=
'3') 
continue; 
 
   63                 remove(
"structure.txt");
 
   64                 rename(
"outfile.txt",
"structure.txt");
 
   65                 std::cout<<
"All but Forward emc is removed"<<std::endl;
 
   66                 std::cout<<
"Done"<<std::endl;
 
   97    void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
 
  104    TCanvas *
c1 = 
fEcan->GetCanvas();
 
  106         f.open(
"structure.txt");
 
  107    c1->Range(-120,-120,120,120);
 
  112         TPaveLabel *
pt[5000];
 
  118         while (f>>index>>iX>>iY>>x>>y>>z)
 
  121                 if ((iX<200)||(iX>300)) 
continue;
 
  122                 if (i_crys%100==0) std::cout<<
"Crystal in fwd endcap = "<<i_crys<<std::endl;
 
  133                 pt[i_crys] = 
new TPaveLabel(x-tr/2.,y-tr/2., x+tr/2., y+tr/2.,label.Data());
 
  134                 pt[i_crys]->SetBorderSize(1);
 
  135                 pt[i_crys]->SetName(name);
 
  147    printf(
"Exit application...");
 
  148    gApplication->Terminate(0);
 
  153         std::cout<<
"Recreate structure.txt"<<std::endl;
 
  155         TTree *
tsim=(TTree *) fsim->Get(
"pndsim") ;
 
  158         std::cout<<
"File with emc structure is created"<<std::endl;
 
  162         ifstream 
infile(
"structure.txt");
 
  163         ofstream 
outfile(
"outfile.txt");
 
  165         getline(infile,line);
 
  168         while (getline(infile,line))
 
  170                 if (line[0]!=
'3') 
continue; 
 
  176         remove(
"structure.txt");
 
  177         rename(
"outfile.txt",
"structure.txt");
 
  178         std::cout<<
"All but Forward emc is removed"<<std::endl;
 
  179         std::cout<<
"Done"<<std::endl;
 
  187         TCanvas *
c1 = 
fEcan->GetCanvas();
 
  188         c1->SaveAs(
"emc_structure.ps");
 
  189         std::cout<<
"Structure is saved to emc_structure.ps"<<std::endl;
 
  203    char text0[50], text1[50];
 
  204         sprintf(text0, 
"(iX,iY)=%s", selected->GetTitle());
 
  206         sprintf(text1, 
"detId=%s", selected->GetName());
 
  208    text2 = selected->GetObjectInfo(px,py);
 
  216    fEcan = 
new TRootEmbeddedCanvas(0,
this,500,400);
 
  217    Int_t wid = 
fEcan->GetCanvasWindowId();
 
  218    TCanvas *myc = 
new TCanvas(
"MyCanvas", 10,10,wid);
 
  219    fEcan->AdoptCanvas(myc);
 
  220    myc->Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
"MyMainFrame",
this,
 
  221                "EventInfo(Int_t,Int_t,Int_t,TObject*)");
 
  223    AddFrame(
fEcan, 
new TGLayoutHints(kLHintsTop | kLHintsLeft |
 
  224                                      kLHintsExpandX  | kLHintsExpandY,0,0,1,1));
 
  226    Int_t parts[] = {34, 33, 33};
 
  227    fStatusBar = 
new TGStatusBar(
this, 50, 10, kVerticalFrame);
 
  230    AddFrame(
fStatusBar, 
new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
 
  233    TGHorizontalFrame *hframe = 
new TGHorizontalFrame(
this, 200, 40);
 
  235    TGTextButton *draw = 
new TGTextButton(hframe, 
"&Draw");
 
  236    draw->Connect(
"Clicked()", 
"MyMainFrame", 
this, 
"DoDraw()");
 
  237    hframe->AddFrame(draw, 
new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
 
  238    TGTextButton *
exit = 
new TGTextButton(hframe, 
"&Exit ");
 
  239    exit->Connect(
"Pressed()", 
"MyMainFrame", 
this, 
"DoExit()");
 
  240    hframe->AddFrame(exit, 
new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
 
  242         TGTextButton *save = 
new TGTextButton(hframe, 
"&Save ");
 
  243    save->Connect(
"Clicked()", 
"MyMainFrame", 
this, 
"DoSave()");
 
  244    hframe->AddFrame(save, 
new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
 
  246         TGTextButton *recreate = 
new TGTextButton(hframe, 
"&Recreate ");
 
  247    recreate->Connect(
"Clicked()", 
"MyMainFrame", 
this, 
"DoRecreate()");
 
  248    hframe->AddFrame(recreate, 
new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
 
  250         AddFrame(hframe, 
new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
 
  253    SetWindowName(
"EMC Forward Endcap structure");
 
  257    Resize(GetDefaultSize());
 
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
void SetStatusText(const char *txt, Int_t pi)
TRootEmbeddedCanvas * fEcan
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
TString pt(TString pts, TString exts="px py pz")
void Print(string, Int_t option=1) const 
int structure_analysis_emc()
static PndEmcStructure * Instance()
void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
TFile infile("dedx_out.root","READ")
static PndEmcMapper * Instance()