#include "TFndHdt.h"
#include "TFndCorbo.h"
#include "TFndZebini.h"
#include "TObjectTable.h"

ClassImp(TFndHdt);

 TFndHdt::TFndHdt() {
  /*
      fNevt   = 0;
      fNHSil  = 0;
      fNHTof  = 0;
      fNHLmd  = 0;
      fNHStb  = 0;
      fNHTot  = 0;
  */
      fHHdr = new TFndHHdr();
      fTrig = new TFndTrig();
      fHSil = new TObjArray();
      fHTof = new TObjArray();
      fHLmd = new TObjArray();
      fHStb = new TObjArray();
      }

 TFndHdt::TFndHdt(Int_t nevt, TFndHHdr *fHdr, TFndTrig *fTrg) {
      fNevt   = nevt;
      fNHSil  = 0;
      fNHTof  = 0;
      fNHLmd  = 0;
      fNHStb  = 0;
      fNHTot  = 0;
      fHHdr = fHdr;
      fTrig = fTrg;
      fHSil = new TObjArray();
      fHTof = new TObjArray();
      fHLmd = new TObjArray();
      fHStb = new TObjArray();
      }

 TFndHdt::TFndHdt(Int_t nevt, TFndHHdr *fHdr) {
      fNevt   = nevt;
      fNHSil  = 0;
      fNHTof  = 0;
      fNHLmd  = 0;
      fNHStb  = 0;
      fNHTot  = 0;
      fHHdr = fHdr;
      fTrig = 0;
      fHSil = new TObjArray();
      fHTof = new TObjArray();
      fHLmd = new TObjArray();
      fHStb = new TObjArray();
      }

 TFndHdt::~TFndHdt() { 
      delete fHHdr;
      delete fTrig;
      fHSil->Delete();  delete fHSil;
      fHTof->Delete();  delete fHTof; 
      fHLmd->Delete();  delete fHLmd;
      fHStb->Delete();  delete fHStb;
     } 

//******************************************************************/
//*                      DUMP     HDT                              */
//******************************************************************/

 void TFndHdt::Dump() {

  if(fHHdr) fHHdr->Print();
  if(fTrig) fTrig->Print();
  this->PrintHits();

  } 

//******************************************************************/
//*               Book  &  Fill  Off-line  ZEBRA  banks            */
//******************************************************************/

 void TFndHdt::MzBook() {

// Book General ZEBRA Bank (FGES)

   Int_t *lq = &JFRDT-1;
   Int_t *iq = lq+8;
   Int_t *q = lq+8;

   Int_t jb=1;
   char* chid = "FGES";
   Int_t nl=12;
   Int_t ns=12;
   Int_t nd=3;
   Int_t iod=2;
   Int_t nz=0;

   Int_t name = *((int*)chid);
   mzbook_(&IXDST ,&JFGES, &JFGES, &jb, &name ,&nl ,&ns ,&nd ,&iod ,&nz);
   *(iq+JFGES+1) = this->GetHdr()->GetRun();
   *(iq+JFGES+2) = this->GetHdr()->GetEvt();

  //  cout <<  "****  Corbo   ****" << endl;
  //fcrb->MzBook();

  cout <<  "****  Time of Flight   ****" << endl;

  cout << "nhtof = " << fNHTof << endl;
  for(Int_t i=0;i<fNHTof; i++) {
     TFndHTof *hit = this->GetHTof(i); 
     hit->MzBook();
     } 

  cout <<  "****  ISIM/OSIM   ****" << endl;
  cout << "nhsil = " << fNHSil << endl;

  for(Int_t Module = 1; Module <= 18; Module++) {
    
    jb=-2;
    chid = "ISMO";
    if(Module >=9) {
      jb = -3;
      chid = "OSMO";
    }
  
    Int_t nl=5;
    Int_t ns=5;
    Int_t nd=1;
    Int_t iod=2;
    Int_t nz=0;
    Int_t lsmo=0;
  
    Int_t name = *((int*)chid);
    mzbook_(&IXDST ,&lsmo ,&JFGES ,&jb ,&name ,&nl ,&ns ,&nd ,&iod,&nz);
    *(iq+lsmo) = Module;
    
    for(Int_t i=0;i<fNHSil; i++) {
      TFndHSil *hit = this->GetHSil(i); 
      hit->MzBook(lsmo,Module);
    } 
  }
  cout <<  "****  Drift  Chambers   ****" << endl;

  cout << "nhlmd = " << fNHLmd << endl;
  for(Int_t i=0;i<fNHLmd; i++) {
     TFndHLmd *hit = this->GetHLmd(i); 
     hit->MzBook();
     } 
  cout <<  "****  Straw   Tubes   ****" << endl;

  cout << "nhstb = " << fNHStb << endl;
  for(Int_t i=0;i<fNHStb; i++) {
     TFndHStb *hit = this->GetHStb(i); 
     hit->MzBook();
     } 

  } 
//******************************************************************/
//*                   Read  DST  Off-line  ZEBRA  banks            */
//******************************************************************/

 void TFndHdt::UpdateHits() {
      
// Read DST ZEBRA Bank (FDST)

  Int_t *lq = &JFRDT-1;
  Int_t *iq = lq +8;
  Float_t *q = (Float_t *) lq +8;

  Int_t lcosm = *(lq+JFDST-1);
  if(lcosm) {

    Int_t lslcl = *(lq+lcosm-1);
    while (lslcl)  {
      Int_t leslb = *(lq+lslcl-1);
      while (leslb)  {      
	Int_t phi = *(iq+leslb+1);
	for (Int_t i=0; i<fNHTof; i++) {
	  TFndHTof *hit = this->GetHTof(i);
	  Float_t x = hit->GetX();
	  Float_t y = hit->GetY();
	  Float_t angle = 0.;
	  if(x) angle = y/x;
	  Float_t Phi = atan(angle)*180./acos(-1.);
	  if(Phi < 0)  {  
	    if(y < 0.) 
	      Phi += 360.;
	    else
	      Phi += 180.;
	  } 
	  if(Phi > 0 && x < 0. && y < 0.) Phi += 180.;
     	  Int_t IPhi = (Int_t ) (Phi/5.0 + 1);
	  if(phi == IPhi) { 
	    hit->Update(0.,0.,0.,2);
	    break;
	  }
	}   
	leslb = *(lq+leslb);
      }  
      lslcl = *(lq+lslcl);
    } 
    Int_t ldch1 = *(lq+lcosm-4);
    while (ldch1)  {
      Int_t ndch1= *(iq+ldch1+1) + 10;
      Int_t nwire1= *(iq+ldch1+2);
      for (Int_t i=0; i<fNHLmd; i++) {
	TFndHLmd *hit = this->GetHLmd(i);
	Int_t hndch1 = hit->GetCham();
	Int_t hnwire1 = hit->GetWire();
	if ((ndch1 == hndch1) && (nwire1 == hnwire1))  {
	  Float_t x= *(q+ldch1+4);
	  Float_t y= *(q+ldch1+5);
	  Float_t z= *(q+ldch1+6);
	  Int_t color=2;
	  hit->Update(x,y,z,color);
	  break; 
	}      
      }    
      ldch1 = *(lq+ldch1);
    }  
    Int_t ldch2 = *(lq+lcosm-3);
    while (ldch2)  {
      Int_t ndch2= *(iq+ldch2+1) + 20;
      Int_t nwire2= *(iq+ldch2+2);
      for (Int_t i=0; i<fNHLmd; i++) {
	TFndHLmd *hit = this->GetHLmd(i);
	Int_t hndch2 = hit->GetCham();
	Int_t hnwire2 = hit->GetWire();
	if ((ndch2 == hndch2) && (nwire2 == hnwire2))  {
	  Float_t x= *(q+ldch2+4);
	  Float_t y= *(q+ldch2+5);
	  Float_t z= *(q+ldch2+6);
	  Int_t color=2;
	  hit->Update(x,y,z,color);
	  break; 
	}      
      }    
      ldch2 = *(lq+ldch2); 
    }
  }  
    
  Int_t lnois = *(lq+JFDST-2);
  if(lnois) {

    Int_t ldch1 = *(lq+lnois-4);
    while (ldch1)  {
      Int_t ndch1= *(iq+ldch1+1) + 10;
      Int_t nwire1= *(iq+ldch1+2);
      for (Int_t i=0; i<fNHLmd; i++) {
	TFndHLmd *hit = this->GetHLmd(i);
	Int_t hndch1 = hit->GetCham();
	Int_t hnwire1 = hit->GetWire();
	if ((ndch1 == hndch1) && (nwire1 == hnwire1))  {
	  Float_t x= *(q+ldch1+4);
	  Float_t y= *(q+ldch1+5);
	  Float_t z= *(q+ldch1+6);
	  Int_t color=3;
	  hit->Update(x,y,0.,color);
	  break; 
	}      
      }    
      ldch1 = *(lq+ldch1);
    }
    Int_t ldch2 = *(lq+lnois-5);
    while (ldch2)  {
      Int_t ndch2= *(iq+ldch2+1) + 20;
      Int_t nwire2= *(iq+ldch2+2);
      for (Int_t i=0; i<fNHLmd; i++) {
	TFndHLmd *hit = this->GetHLmd(i);
	Int_t hndch2 = hit->GetCham();
	Int_t hnwire2 = hit->GetWire();
	if ((ndch2 == hndch2) && (nwire2 == hnwire2))  {
	  Float_t x= *(q+ldch2+4);
	  Float_t y= *(q+ldch2+5);
	  Float_t z= *(q+ldch2+6);
	  Int_t color=3;
	  hit->Update(x,y,0.,color);
	  break; 
	}      
      }    
      ldch2 = *(lq+ldch2); 
    }
  } 
} 

//******************************************************************/
//*                        Print  HDT  Hits                        */
//******************************************************************/

 void TFndHdt::PrintHits() {

  cout <<  "****   Time of Flight   ****" << endl;

  cout << "nhtof = " << fNHTof << endl;
  for(Int_t ia=0;ia<fNHTof; ia++) {
     TFndHTof *hit = this->GetHTof(ia); 
     hit->Print();
     } 

  cout <<  "****   ISIM/OSIM   ****" << endl;


  cout << "nhsil = " << fNHSil << endl;
  for(Int_t ib=0;ib<fNHSil; ib++) {
     TFndHSil *hit = this->GetHSil(ib); 
     hit->Print();
     }

  cout <<  "****  Drift  Chambers   ****" << endl;

  cout << "nhlmd = " << fNHLmd << endl;
  for(Int_t ic=0;ic<fNHLmd; ic++) {
     TFndHLmd *hit = this->GetHLmd(ic); 
     hit->Print();
     } 

  cout <<  "****   Straw    Tubes   ****" << endl;

  cout << "nhstb = " << fNHStb << endl;
  for(Int_t id=0;id<fNHStb; id++) {
     TFndHStb *hit = this->GetHStb(id); 
     hit->Print();
     } 
  }

//******************************************************************/
//*                        Draw  HDT  Hits                        */
//******************************************************************/

 void TFndHdt::DrawHits(char *opt,Float_t size) {

  cout <<  "****   Time of Flight   ****" << endl;

  cout << "nhtof = " << fNHTof << endl;
  for(Int_t ia=0;ia<fNHTof; ia++) {
     TFndHTof *hit = this->GetHTof(ia);
     if(this->GetHdr()->GetRun() == 33) {
       if(this->GetHdr()->GetEvt() == 983) {
	 if(hit->GetSlab() <= 109) {
	   hit->Update(0.,0.,-22.7,0);
	   cout << "Update tof hit" << endl;
	 } else if(hit->GetSlab() > 109 && hit->GetSlab() <= 118) {
	   hit->Update(0.,0.,22.7,0);
	   cout << "Update tof hit" << endl;
         }
       }
     }
     hit->Draw(opt,size);
     }

  cout <<  "****   ISIM   ****" << endl;

  cout << "nhsil = " << fNHSil << endl;
  for(Int_t ib=0;ib<fNHSil; ib++) {
     TFndHSil *hit = this->GetHSil(ib);
     hit->Draw(opt,size);
     }

  cout <<  "****  Drift  Chambers   ****" << endl; 
  cout << "nhlmd = " << fNHLmd << endl;
  for(Int_t ic=0;ic<fNHLmd; ic++) {
     TFndHLmd *hit = this->GetHLmd(ic);
     hit->Draw(opt,size);
     }

  cout <<  "****   Straw    Tubes   ****" << endl;

  cout << "nhstb = " << fNHStb << endl;
  for(Int_t id=0;id<fNHStb; id++) {
     TFndHStb *hit = this->GetHStb(id);
     hit->Draw(opt,size);
     }
}


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

   if (R__b.IsReading()) {
      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
      TObject::Streamer(R__b);
      R__b >> fNevt;
      R__b >> fNHTot;
      R__b >> fNHSil;
      R__b >> fNHTof;
      R__b >> fNHLmd;
      R__b >> fNHStb;
      R__b >> fHHdr; 
      if(R__v < 4) {
	TFndCorbo *fcrb = new TFndCorbo();
	R__b >> fcrb;
	delete fcrb;
      }
      if(R__v > 1) R__b >> fTrig;
      R__b >> fHSil;
      R__b >> fHTof;
      R__b >> fHLmd;
      R__b >> fHStb;
   } else {
      R__b.WriteVersion(TFndHdt::IsA());
      TObject::Streamer(R__b);
      R__b << fNevt;
      R__b << fNHTot;
      R__b << fNHSil;
      R__b << fNHTof;
      R__b << fNHLmd;
      R__b << fNHStb;
      R__b << fHHdr;
      R__b << fTrig;
      R__b << fHSil;
      R__b << fHTof;
      R__b << fHLmd;
      R__b << fHStb;
   }
}




















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.