#include <iostream.h>

#include "TFndHTof.h"
#include "TFndZebini.h"
#include "TMath.h"

ClassImp(TFndHTof);

 TFndHTof::TFndHTof(Int_t a, Int_t d, Int_t e) {

  Slab   = a;      
  Tdc[0]   = 0;
  Tdc[1]   = 0; 
  Adc[0]   = 0;
  Adc[1]   = 0;

  if (e == 3){
    Tdc[0]  = d ;
  } else if (e == 4){
    Tdc[1]  = d ; 
  } else if (e == 1){
    Adc[0]  = d ;
  } else if (e == 2){
    Adc[1]  = d;
  }

  Float_t thick = 8.3;
  if(Slab == 120)  {
    y_g = 0;
    x_g = 0;
    z_g = 0.;
  } else  {
    if(Slab <= 109) {
      x_g = -110.+(Slab-101)*27.5;
      y_g = 190.+thick/2.-(Slab-100)%2*thick;
    }
    if(Slab > 109 && Slab <= 118) {
      x_g = 110.-(Slab-110)*27.5;
      y_g = -190.+thick/2.-(Slab-99)%2*thick;
    }
  }

  x_l = 0.;
  y_l = 0.;
  z_l = 0.;

  hmarker = new TMarker3DBox(x_g,y_g,z_g,0.1,0.1,0.1,0.,0.);
  hmarker->SetLineColor(3);
  hmarker->SetFillColor(3);
  if(Slab == 120) {
    hmarker->SetLineColor(2);
    hmarker->SetFillColor(2);
  }
  hmarker->SetFillStyle(1);
}

 void TFndHTof::SetAdcR(Int_t adcR) {
  Adc[1] = adcR;
}

 void TFndHTof::SetAdcF(Int_t adcF) {
  Adc[0] = adcF;
}

 void TFndHTof::SetTdcR(Int_t tdcR) {
  Tdc[1] = tdcR;
}

 void TFndHTof::SetTdcF(Int_t tdcF) {
  Tdc[0] = tdcF;
}

 TFndHTof::~TFndHTof() {
  delete hmarker;
}

 void TFndHTof::Draw(char *opt,Float_t size) {
  
  if(!z_g && Tdc[0]*Tdc[1] != 0)
    z_g = TFndConst::kVLIGHT*(((Float_t) Tdc[0]-Tdc[1]));

  hmarker->SetPosition(x_g,y_g,z_g);
  if (opt == "L") hmarker->SetPosition(x_l,y_l,z_l);
  hmarker->SetSize(size,size,size);
  hmarker->Draw();
}

 void TFndHTof::MzBook() {

   Int_t *lq = &JFRDT;
   Int_t *iq = lq+8;

   Int_t jb;
   char* chid;

   if(Slab <= 12) {
     jb=-1;
     chid = "ISLB";
     }
   else if(Slab > 12) {
     jb=-9;
     chid = "ESLB";
     }
   else {
     cout << "wrong slab number " << endl;
     return;
     }

   Int_t nl=0;
   Int_t ns=0;
   Int_t nd=10;
   Int_t iod=9;
   Int_t nz=0;
   Int_t ltof=0;

   Int_t name = *((int*)chid);
   mzbook_(&IXDST ,&ltof ,&JFGES ,&jb ,&name ,&nl ,&ns ,&nd ,&iod,&nz);

  *(iq+ltof) = Slab-100;
  for(Int_t i=1; i<6; i++) *(iq+ltof+i) = 0;
  *(iq+ltof+6) = Tdc[0];
  *(iq+ltof+7) = Tdc[1]; 
  *(iq+ltof+8) = Adc[0];
  *(iq+ltof+9) = Adc[1]; 

  //  for(Int_t i=0; i<nd; i++) cout << "ltof+" << i << " = " << *(iq+ltof+i) << endl;

  }

 void  TFndHTof::Print() { 
  printf("Slab %d, Tdc Front %d, Tdc Rear %d, Adc Front %d, Adc Rear %dn",Slab,Tdc[0],Tdc[1],Adc[0],Adc[1]);
  printf("x_c %f, y_c %f, z_c %fn",x_c,y_c,z_c);
  printf("x_l %f, y_l %f, z_l %fn",x_l,y_l,z_l);
  printf("x_g %f, y_g %f, z_g %fn",x_g,y_g,z_g);
} 

 void TFndHTof::Update(Float_t xr, Float_t yr, Float_t zr, Int_t color)  {
  
  if(xr) x_g = xr;
  if(yr) y_g = yr;
  if(zr) z_g = zr;
  if(color) {
    hmarker->SetLineColor(color);
    hmarker->SetFillColor(color);
  }
} 

 void TFndHTof::Streamer(TBuffer &R__b)
{
  // Stream an object of class TFndHTof.
  
  if (R__b.IsReading()) {
    Version_t R__v = R__b.ReadVersion(); if (R__v) { }
    TObject::Streamer(R__b);
    R__b >> Slab;
    if(R__v <= 1) {
      Int_t ChTdc[2];
      Int_t ChAdc[2];
      R__b.ReadStaticArray(ChTdc);
      R__b.ReadStaticArray(ChAdc);
    }
    R__b.ReadStaticArray(Tdc);
    R__b.ReadStaticArray(Adc);
    R__b >> x_c;
    R__b >> y_c;
    R__b >> z_c;
    if(R__v >= 1) {
      R__b >> x_l;
      R__b >> y_l;
      R__b >> z_l;
      R__b >> x_g;
      R__b >> y_g;
      R__b >> z_g;
    } 
    R__b >> hmarker;
  } else {
    R__b.WriteVersion(TFndHTof::IsA());
    TObject::Streamer(R__b);
    R__b << Slab;
    R__b.WriteArray(Tdc, 2);
    R__b.WriteArray(Adc, 2);
    R__b << x_c;
    R__b << y_c;
    R__b << z_c;
    R__b << x_l;
    R__b << y_l;
    R__b << z_l;
    R__b << x_g;
    R__b << y_g;
    R__b << z_g;
    R__b << hmarker;
  }
}
























ROOT 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 ROOT support, or contact the developers with any questions or problems regarding ROOT.