A fancy peak example

{
// This example shows how to plot a region of interest.
// To see the result of this macro, click  here 
// The access of data is made by it's time.
// Some ploting options are also shown at the end.
 
   gROOT->Reset();

   // Open a new window (canvas)   

   c1 = new TCanvas("c1","A fancy peak example",1);

// ===== Creates the needed pads by dividing the initial canvas =====

   // first divide the main canvas

   c1->Divide(1,2);
   
   // then, make the first pad active and divide it in 2 subpads
   // gPad is always the current selected pad

   c1->cd(1);
   gPad->Divide(2,1);
   
// ===== Opens the frame channel =====

   fc = new VFrameChannel("demoDB.root");

// ===== Gets the needed vectors and draws them =====
// ===== First the upper plots                  =====

   // Gets the needed vectors
   FrVect* frv1 = fc->GetVect("adc.MYGO_ADC1",600000010.,3.);
   FrVect* frvSeis = fc->GetVect("adc.MYGO_Seis",600000010.,3.);

   // Draws them. 
   // pads created by an automatic division of a canvas are labelled
   // c1_1, c1_2, etc...

   c1_1->cd(1); // select the first subpad of the upper pad c1_1
   gVM->Draw(frv1);

   // The last plot created is a VSPlot which is saved in a variable vsp1
   // to further embelish it

   VSPlot* vsp1 = gVM->GetLastPlot();

   c1_1->cd(2); // select the second subpad of the upper pad c1_1
   gVM->Draw(frvSeis);
   VSPlot* vsp2 = gVM->GetLastPlot();
   
// ===== Gets the needed vectors and draws them =====
// ===== Second the same plots superimposed     =====

   // Gets the needed vectors again but zooming on the region of interest
   frv2 = fc->GetVect("adc.MYGO_ADC1",600000010.24,0.06);
   frvSeis2 = fc->GetVect("adc.MYGO_Seis",600000010.24,0.06);
   
   // Draws them in the second pad, superimposed on top of each other
   c1->cd(2);
   gVM->Draw(frv2);
   VSPlot* vsp3 = gVM->GetLastPlot();
   gVM->Draw(frvSeis2,"same");
   VSPlot* vsp4 = gVM->GetLastPlot();

   // As the last plot is not big enough, rescale it.
   vsp4->Scale(3.);

// ===== Now makes the plots fancy (well, it's a matter of taste...) =====

// Important comment : one doesn't need to type all the lines below.
//   Usually, one just draws all the objects interactively, changing
//   colors, sizes, text, etc.. with the interactive editor.
//   Then, one just has to save the canvas as canvas.C in the File menu.
//   The resulting file contains all these lines.

   // First, the color of the pads and canvas
   c1->SetFillColor(42);
   c1->SetBorderSize(2);
   c1_1->SetFillColor(44);
   c1_1->cd(1);
   gPad->SetFillColor(44);
   gPad->GetFrame()->SetFillColor(19);
   c1_1->cd(2);
   gPad->SetFillColor(44);
   gPad->GetFrame()->SetFillColor(19);

   c1_2->SetFillColor(44);
   c1_2->GetFrame()->SetFillColor(41);
   
   // Then, the colors of the plots themselves
   vsp1->SetLineColor(9);
   vsp2->SetLineColor(50);
   vsp3->SetLineColor(9);
   vsp4->SetLineColor(50);

   // Finally, add some comments, arrows, etc... in the subpad 2
   c1_2->cd();
   
   arrow = new TArrow(0.0316555,-727.685,0.0300062,-102.31,0.03,"|>");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->Draw();
   TPaveText *pt = new TPaveText(0.0307692,-1344.41,0.046,-640.385,"br");
   pt->SetFillColor(18);
   pt->SetLineColor(12);
   pt->SetTextColor(2);
   TText *text = pt->AddText("Seismometer (x3)");
   pt->Draw();
   
   TArrow *arrow = new TArrow(0.0340746,1610.67,0.030336,958.109,0.03,"|>");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->Draw();
   pt = new TPaveText(0.0342857,1498.77,0.0420879,2067.4,"br");
   pt->SetFillColor(18);
   pt->SetLineColor(12);
   pt->SetTextColor(4);
   text = pt->AddText("ADC1");
   pt->Draw();

   text = new TText(0.019011,2554.81,"Start time : 600000010.24");
   text->SetTextColor(12);
   text->SetTextSize(0.075035);
   text->Draw();
}


- ROOT page - VEGA page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to , or contact with any questions or problems regarding ROOT or VEGA.