#include <iostream.h>

#include "TFndZebini.h"
#include "TMath.h"
#include "TFndHLmd.h"

ClassImp(TFndHLmd);

 TFndHLmd::TFndHLmd(Int_t a, Int_t b, Int_t c, Int_t e) {
  Cham     = a;  
  Wire     = b;  
  Tdc[0]   = 0;
  Tdc[1]   = 0; 
  Adc[0]   = 0;
  Adc[1]   = 0;
  
  if (e == 3){
    Tdc[0]  = c;
  } else if (e == 4){
    Tdc[1]  = c; 
  } else if (e == 1){
    Adc[0]  = c;
  } else if (e == 2){
    Adc[1]  = c;
  }
  x_g = 0.;
  y_g = 0.;
  z_g = 0.;
  
  hmarker = new TMarker3DBox(x_g,y_g,z_g,0.1,0.1,0.1,0.,0.);
  hmarker->SetLineColor(3);
  hmarker->SetFillColor(3);
  hmarker->SetFillStyle(1);
}            

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

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

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

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

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

 void TFndHLmd::Draw(char *opt,Float_t size) {

  Int_t n = Cham/10 -1;
  Double_t rad = TFndConst::kRADLMD[n];  
  Double_t fof = (1 - n)*TMath::Pi()*TFndConst::kROTANGLE/180.;
  Double_t angof = TMath::ATan2(TFndConst::kY0[n],TFndConst::kX0[n]);
  Double_t angin = angof+fof;
  Double_t angle = angin + (Cham - 1 - (n+1)*10)*(TMath::Pi()/4.);
  x_c = rad*TMath::Cos(angle);
  y_c = rad*TMath::Sin(angle);
  Double_t len = 62.5;
  if(n == 1) len = 127.5;
  if(Adc[0]*Adc[1] != 0)
    z_c = 0.5*len*(((Float_t)Adc[0]-Adc[1])/(Adc[0]+Adc[1]));  
  else
    z_c = 0.;
  // to be updated

  Double_t xof = 15.;
  if(n == 1) xof = 27.5;
  Double_t d_l = 2.5 + ((Wire-1)/2)*5.0 - xof;
  x_l = d_l*TMath::Sin(angle-angof);
  y_l = d_l*TMath::Cos(angle-angof);
  /*  
  x_g = x_c - x_l;
  y_g = y_c + y_l;
  z_g = z_c;
  */
  if (opt == "L"){
    x_g = x_l;
    y_g = y_l;
  }
  hmarker->SetPosition(x_g,y_g,z_g);
  hmarker->SetSize(size,size,size);
  hmarker->Draw();
}

 void TFndHLmd::MzBook() {

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

   Int_t jb;
   char* chid;
   Int_t cham=0;

   if(Cham >= 11 && Cham <= 18) {
     jb=-4;
     chid = "DCH1";
     cham = Cham-10;
     }
   else if(Cham >= 21 && Cham <= 28) {
     jb=-5;
     chid = "DCH2";
     cham = Cham-20;
     }
   else {
     cout << "wrong drift number " << endl;
     return;
     }

   Int_t nl=0;
   Int_t ns=0;
   Int_t nd=20;
   Int_t iod=9;
   Int_t nz=0;
   Int_t ldch1=0;

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

  *(iq+ldch1) = cham;
  *(iq+ldch1+1) = Wire;
  *(iq+ldch1+2) = 0; 
  *(iq+ldch1+3) = 0;
  *(iq+ldch1+4) = 0;
  *(iq+ldch1+5) = Tdc[0]; 
  *(iq+ldch1+6) = Tdc[1];
  *(iq+ldch1+7) = Adc[0];
  *(iq+ldch1+8) = Adc[1];
  for(Int_t i=9; i<nd; i++) *(iq+ldch1+i) = 0;

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

  }


 void TFndHLmd::Print() {
  cout << "LMD Hit: ";
  cout << "DC " << Cham << ", ";
  cout << "Wire " << Wire << endl;
  cout << "Front/Rear  ADC: " << Adc[0] << ", " << Adc[1] << ", ";
  cout << "Front/Rear  TDC: " << Tdc[0] << ", " << Tdc[1] << endl;
  printf("Center coordinate: x_c %f, y_c %f, z_c %fn",x_c,y_c,z_c);
  printf("Local coordinate: x_l %f, y_l %f, z_l %fn",x_l,y_l,z_l);
  printf("Global coordinate: x_g %f, y_g %f, z_g %fn",x_g,y_g,z_g);
}

 void TFndHLmd::Update(Float_t xr, Float_t yr, Float_t zr, Int_t color)  {
  x_g = xr;
  y_g = yr;
  Double_t len = 62.5;
  if(Cham > 20) len = 127.5;
  if(Adc[0]*Adc[1] != 0)
    z_g = 0.5*len*(((Float_t)Adc[0]-Adc[1])/(Adc[0]+Adc[1]));  
  else
    z_g = 0.;
  hmarker->SetLineColor(color);
  hmarker->SetFillColor(color);
} 

 void TFndHLmd::Streamer(TBuffer &R__b) {
   // Stream an object of class TFndHLmd.

   if (R__b.IsReading()) {
      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
      TObject::Streamer(R__b);
      R__b >> Cham;
      R__b >> Wire;
      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(TFndHLmd::IsA());
     TObject::Streamer(R__b);
     R__b << Cham;
     R__b << Wire;
     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.