//*-- Created 30.3.2006 by B. Spruck

using namespace std;
#include "hhodohit2start.h"
#include "hododef.h"
#include "hhodohit.h"
#include "hhododetector.h"
#include "hstartdef.h"
#include "hstarthit.h"
#include "hdebug.h"
#include "hades.h"
#include "hiterator.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hevent.h"
#include "hcategory.h"
#include "hlinearcategory.h"
#include <iostream>
#include <iomanip>

//_HADES_CLASS_DESCRIPTION 
////////////////////////////////////////////////////////////////
//
//  HHodoHit2Start: Was intended for testing data w/o real data
//
////////////////////////////////////////////////////////////////


 HHodoHit2Start::HHodoHit2Start(void)
{
  hitHodoCat=0;
  hitStartCat=0;
  iter=0;
}

 HHodoHit2Start::HHodoHit2Start(Text_t *name,Text_t *title) : HReconstructor(name,title)
{
  hitHodoCat=0;
  hitStartCat=0;
  iter=0;
}

 HHodoHit2Start::~HHodoHit2Start(void)
{
}

 Bool_t HHodoHit2Start::init(void)
{
   HHodoDetector *hodo;
   hodo=(HHodoDetector *)gHades->getSetup()->getDetector("Hodo");

   if(!hodo){
      Error("init","No Hodo Det. found.");
      return kFALSE;
   }

   // Categories
   hitHodoCat=hodo->buildCategory(catHodoHit);
   if (!hitHodoCat) return kFALSE;

   // Start is not having nice function for that
   hitStartCat=gHades->getCurrentEvent()->getCategory(catStartHit);
   if (!hitStartCat) {
      hitStartCat = new HLinearCategory("HStartHit");
      if (!hitStartCat){
         Error("init","hitStartCat = new HLinearCategory("HStartHit"); failed!");
         return kFALSE;
      }else{
         gHades->getCurrentEvent()->addCategory(catStartHit,hitStartCat,"Start");
      }
  }

  iter=(HIterator *)hitHodoCat->MakeIterator();

  loc.set(1,0);// this is fixed for StartHit
  fActive=kTRUE;

  return kTRUE;
}

 Int_t HHodoHit2Start::execute(void)
{// What will be done here
 // Copy all Hit data from Hodo module XX to Start module YY
 // Used for may06 where hodo is used as a start det.
 // Do not use unless you know what you are doing!

   HHodoHit *pHodoHit=0;
   HStartHit *pStartHit=0;

   iter->Reset();

   //  Hit finding & storing.
   pStartHit=(HStartHit *)hitStartCat->getNewSlot(loc);
   if (pStartHit) {
      Int_t cnt=0;
      Int_t mod=-1, strip=-1;
      Int_t mult=-1;
      Float_t time=-1000.0;
      Bool_t flag=kFALSE;

      pStartHit = new(pStartHit) HStartHit;
      pStartHit->setModule(-1);
      pStartHit->setStrip(-1);
      pStartHit->setTime(-1000);
      pStartHit->setStartMult(-1);
      pStartHit->setFlag(kFALSE);

      cnt=0;
      while ((pHodoHit=(HHodoHit *)iter->Next())!=0) {
         pHodoHit->getAddress(mod,strip);
         if (mod==0 && strip>=0){
            // Check Hodo mod==0
            // and set Start mod=0

            time=pHodoHit->getTime();
            mult=pHodoHit->getHodoMult();// not filled yet
            flag=pHodoHit->getFlag();// not filled yet
            cnt++;
         }
      }

      if( cnt==1){
         pStartHit->setModule(0);// =0 Is fixed für Start Hits
         pStartHit->setStrip(strip);
         pStartHit->setTime(time);
         pStartHit->setFlag(kTRUE);// flag  not filled yet
         pStartHit->setStartMult(1);// mult  not filled yet
      }
   } else {
      Error("execute()",
      "Can't get slotn");
      return EXIT_FAILURE;
   }

	return EXIT_SUCCESS;
}

ClassImp(HHodoHit2Start)


ROOT page - Class index - Class Hierarchy - 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.