Exemple #1
0
void chain_display()
{
  
  set_color_env();
  //    gStyle->SetOptFit(1111);
  
  Bool_t VERBOSE = 0;
  
  gStyle->SetOptStat(0);
  
  Double_t rad2deg = 180/(4*atan(1));

  const Int_t ndim = 500;

  
  Int_t    steps;
  Int_t    steps_temp, rsteps;//I need this variable 
  Int_t    fIndex;
  Int_t    fHit;
  Int_t    fPid;

  Int_t    fSenPad[ndim] =0;
  Int_t    fTDC[ndim] =0;
  Int_t    fADC[ndim] =0;
  Double_t fXRec[ndim], fYRec[ndim], fZRec[ndim];

  Double_t fX[ndim], fY[ndim], fZ[ndim];



  Double_t xrec[ndim],yrec[ndim],zrec[ndim];
  Double_t x[ndim],y[ndim],z[ndim];

  

  
  Double_t fEdep , time;

  Double_t fkineEne;
  Int_t    fPid;
  Double_t fTheta;
  Double_t fPhi;

 
  TFile *infile = new TFile("ChainEvents.root");
 
  TTree *RTPCTree=(TTree*)infile->Get("chaintree");
  
  Int_t Entries = RTPCTree->GetEntries();
  cout<<"Entries: "<<Entries<<endl;
  
  RTPCTree ->SetBranchAddress("event", &fIndex);
  RTPCTree ->SetBranchAddress("Hit", &fHit);
  RTPCTree ->SetBranchAddress("X", &fXRec[steps]);
  RTPCTree ->SetBranchAddress("Y", &fYRec[steps]);
  RTPCTree ->SetBranchAddress("Z", &fZRec[steps]);


 
  TCanvas *cGraph = new TCanvas("cGraph","Graph2D example",0,0,600,1200); 
  cGraph->SetGridx();
  
  // This histogram is neccesary to plot the axis and keep the multi graph2D 
  TH3F *frame3d = new TH3F("frame3d","RTPC - Hits/Chains",10,-70,70, 10,-70,70, 10,-220,220);
  
  frame3d->GetXaxis()->SetTitle("X (cm)"); frame3d->GetXaxis()->SetTitleOffset(1.4); frame3d->GetXaxis()->CenterTitle() ;
  frame3d->GetYaxis()->SetTitle("Y (cm)"); frame3d->GetYaxis()->SetTitleOffset(1.4); frame3d->GetYaxis()->CenterTitle() ;
  frame3d->GetZaxis()->SetTitle("Z (cm)"); frame3d->GetZaxis()->SetTitleOffset(1.4); frame3d->GetZaxis()->CenterTitle() ;
  
  frame3d->Draw();

  

  Double_t xgr, ygr, zgr;
  
    
  Int_t nentries = RTPCTree->GetEntries();

  
  Int_t p = nentries;//INDEX TO CONTROL FLUX

  cout<< " ENTRIES: "<<nentries<<endl;
  
  for(Int_t i = 0; i < p; i++)
    {
      
      RTPCTree->GetEntry(i);
      
      steps_temp = fHit;
      
      RTPCTree   ->Show(i,20)/10;  
      //	 
      
      cout<<"Hits Num: "<<fHit<<endl;
      
      steps = 0;
      rsteps = 0;
      
      for (Int_t k=0;k<steps_temp;k++)
	{
	  //	      cout<<"Step: "<<fSenPad[k]<<endl;
	  
	  if((fXRec[k]!=0) && (fYRec[k]!=0) && (fZRec[k]!=0))
	    {
	      // cout<<"fXRec[k]: "<<fZRec[k]<<endl;
	      xrec[steps] = fXRec[k];
	      yrec[steps] = fYRec[k];
	      zrec[steps] = fZRec[k];
	      
	      xgr = xrec[steps];
	      ygr = yrec[steps];
	      zgr = zrec[steps];
	      
	      steps++;
	    }


	}
      
     graph2dfile(i, steps, xrec, yrec, zrec);//The use of cm was due to the OpenGL, maybe we should return to mm dividing by 10
 
  
         
      //      cout<<"Entry: "<<fIndex<<endl;

       cout<<steps<<endl;

       TPolyLine3D *track3D = new TPolyLine3D(steps,xrec,yrec,zrec);
       
       //TGraph2D *track3D = new TGraph2D(steps,xrec,yrec,zrec);

         
       // track3D->SetLineWidth(0);
       // track3D->SetLineColor(kBlue);
       // track3D->Draw("same");
       
    }

  //Code to draw a circle
  Int_t steps_cir = 40;
  Double_t pi = 4*atan(1);
  Double_t x_cir[40], y_cir[40], z_cir[40]; 

  Double_t ar;
  
  for (Int_t pp=0; pp < steps_cir; pp++)
    {
      ar =  pp*0.05*pi;
      x_cir[pp] = 70.*cos(ar);
      y_cir[pp] = 70.*sin(ar);
      z_cir[pp] = -220;
    }

  graph2dfile(-1, steps_cir, x_cir, y_cir, z_cir);//The use of cm was due to the OpenGL, maybe we should return to mm dividing by 10
     

    
}
void setTDRStyle() {
  TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");

  set_color_env();
// For the canvas:
  tdrStyle->SetCanvasBorderMode(0);
  tdrStyle->SetCanvasColor(kWhite);
  tdrStyle->SetCanvasDefH(600); //Height of canvas
  tdrStyle->SetCanvasDefW(600); //Width of canvas
  tdrStyle->SetCanvasDefX(0);   //POsition on screen
  tdrStyle->SetCanvasDefY(0);

// For the Pad:
  tdrStyle->SetPadBorderMode(0);
  // tdrStyle->SetPadBorderSize(Width_t size = 1);
  tdrStyle->SetPadColor(kWhite);
  tdrStyle->SetPadGridX(false);
  tdrStyle->SetPadGridY(false);
  tdrStyle->SetGridColor(0);
  tdrStyle->SetGridStyle(3);
  tdrStyle->SetGridWidth(1);

// For the frame:
  tdrStyle->SetFrameBorderMode(0);
  tdrStyle->SetFrameBorderSize(1);
  tdrStyle->SetFrameFillColor(0);
  tdrStyle->SetFrameFillStyle(0);
  tdrStyle->SetFrameLineColor(1);
  tdrStyle->SetFrameLineStyle(1);
  tdrStyle->SetFrameLineWidth(2);

// For the histo:
  // tdrStyle->SetHistFillColor(1);
  // tdrStyle->SetHistFillStyle(0);
  tdrStyle->SetHistLineColor(1);
  tdrStyle->SetHistLineStyle(0);
  tdrStyle->SetHistLineWidth(1);
  // tdrStyle->SetLegoInnerR(Float_t rad = 0.5);
  // tdrStyle->SetNumberContours(Int_t number = 20);

  tdrStyle->SetEndErrorSize(0);
  //GHM  tdrStyle->SetEndErrorSize(2);
//  tdrStyle->SetErrorMarker(20);
  //tdrStyle->SetErrorX(0.);
  
  tdrStyle->SetMarkerStyle(20);

//For the fit/function:
  tdrStyle->SetOptFit(1);
  tdrStyle->SetFitFormat("5.4g");
  tdrStyle->SetFuncColor(2);
  tdrStyle->SetFuncStyle(1);
  tdrStyle->SetFuncWidth(1);

//For the date:
  tdrStyle->SetOptDate(0);
  // tdrStyle->SetDateX(Float_t x = 0.01);
  // tdrStyle->SetDateY(Float_t y = 0.01);

// For the statistics box:
  tdrStyle->SetOptFile(0);
  //tdrStyle->SetOptStat(0); // To display the mean and RMS:   SetOptStat("mr");
  tdrStyle->SetStatColor(kWhite);
  tdrStyle->SetStatFont(42);
  tdrStyle->SetStatFontSize(0.025);
  tdrStyle->SetStatTextColor(1);
  tdrStyle->SetStatFormat("6.4g");
  tdrStyle->SetStatBorderSize(1);
  tdrStyle->SetStatH(0.1);
  tdrStyle->SetStatW(0.15);
  // tdrStyle->SetStatStyle(Style_t style = 1001);
  // tdrStyle->SetStatX(Float_t x = 0);
  // tdrStyle->SetStatY(Float_t y = 0);

// Margins:
  tdrStyle->SetPadTopMargin(0.08);
  tdrStyle->SetPadBottomMargin(0.11);
  tdrStyle->SetPadLeftMargin(0.11);
  tdrStyle->SetPadRightMargin(0.03);

// For the Global title:

  tdrStyle->SetOptTitle(1);
  tdrStyle->SetTitleFont(63);
  tdrStyle->SetTitleFontSize(2);
  tdrStyle->SetTitleColor(0);
  tdrStyle->SetTitleTextColor(1);
  tdrStyle->SetTitleFillColor(0);
  tdrStyle->SetTitleH(0.075); // Set the height of the title box
  tdrStyle->SetTitleW(0); // Set the width of the title box
  tdrStyle->SetTitleX(0.2); // Set the position of the title box
  tdrStyle->SetTitleY(0.995); // Set the position of the title box
  tdrStyle->SetTitleStyle(0);
  tdrStyle->SetTitleBorderSize(0);

// For the axis titles:

  tdrStyle->SetTitleColor(1, "XYZ");
  tdrStyle->SetTitleFont(42, "XYZ");
  tdrStyle->SetTitleSize(0.06, "XYZ");
  // tdrStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
  // tdrStyle->SetTitleYSize(Float_t size = 0.02);
  tdrStyle->SetTitleXOffset(.9);
  // tdrStyle->SetTitleYOffset(1.2);
   tdrStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset

// For the axis labels:

  tdrStyle->SetLabelColor(1, "XYZ");
  tdrStyle->SetLabelFont(42, "XYZ");
  tdrStyle->SetLabelOffset(0.006, "XY");
  tdrStyle->SetLabelSize(0.05, "XYZ");

// For the axis:

  tdrStyle->SetAxisColor(1, "XYZ");
  tdrStyle->SetStripDecimals(kTRUE);
  tdrStyle->SetTickLength(0.03, "XYZ");
  tdrStyle->SetNdivisions(510, "XYZ");
  tdrStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  tdrStyle->SetPadTickY(1);
  TGaxis::SetMaxDigits(3);

// Change for log plots:
  tdrStyle->SetOptLogx(0);
  tdrStyle->SetOptLogy(0);
  tdrStyle->SetOptLogz(0);

// Postscript options:
  tdrStyle->SetPaperSize(20.,20.);
  // tdrStyle->SetLineScalePS(Float_t scale = 3);
  // tdrStyle->SetLineStyleString(Int_t i, const char* text);
  // tdrStyle->SetHeaderPS(const char* header);
  // tdrStyle->SetTitlePS(const char* pstitle);

  // tdrStyle->SetBarOffset(Float_t baroff = 0.5);
  // tdrStyle->SetBarWidth(Float_t barwidth = 0.5);
  // tdrStyle->SetPaintTextFormat(const char* format = "g");
  tdrStyle->SetPalette(1,0);
  // tdrStyle->SetTimeOffset(Double_t toffset);
  // tdrStyle->SetHistMinimumZero(kTRUE);

  tdrStyle->cd();

}