using namespace std;
#include <TRandom.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include "hwallhitf.h" //FK//
#include "walldef.h" //FK//
#include "hdebug.h"
#include "hades.h"
#include "hiterator.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hwalldetector.h" //FK//
#include "hwallraw.h" //FK//
#include "hevent.h"
#include "hpartialevent.h"
#include "hcategory.h"
#include "hmatrixcategory.h"
#include "hrecevent.h"
#include "hlocation.h"
#include "hwallcalpar.h" //FK//
#include "hwallhit.h" //FK//
#include "hstartdef.h"
#include "hstarthit.h"
#include "hwallgeompar.h" //FK//
#include "hdetgeompar.h" //FK//
#include "hgeomvector.h" //FK//
#include "hspecgeompar.h" //FK//
#include "hgeomvolume.h" //FK//
#include "hgeomcompositevolume.h" //FK//
#include "hgeomtransform.h" //FK//
//*-- Created : 24/06/2000 by M.Golubeva
//*-- Modified : 27/04/2001 by T.Wojcik
//*-- Modified: 11/8/2005 by F. Krizek
//_HADES_CLASS_DESCRIPTION
/////////////////////////////////////////////////////////////////////
//
// HWallHitf calibrates raw Wall data and puts output
// values into cal data category
//
/////////////////////////////////////////////////////////////////////
void HWallHitF::initParContainer() {
pWallCalPar = (HWallCalPar *)gHades->getRuntimeDb()
->getContainer("WallCalPar");
pWallGeometry=(HWallGeomPar *)gHades->getRuntimeDb()->getContainer("WallGeomPar");
pSpecGeometry = (HSpecGeomPar *)gHades->getRuntimeDb()->getContainer("SpecGeomPar");
}
HWallHitF::HWallHitF(void) {
fHitCat=NULL;
fRawCat=NULL;
fStartHitCat=NULL;
pWallCalPar = NULL;
pWallGeometry = NULL;
fLoc.set(1,-1);
iter=NULL;
}
HWallHitF::HWallHitF(Text_t *name,Text_t *title) :
HReconstructor(name,title) {
fHitCat=NULL;
fRawCat=NULL;
fStartHitCat=NULL;
pWallCalPar = NULL;
pWallGeometry = NULL;
pSpecGeometry = NULL;
fLoc.set(1,-1);
iter=NULL;
}
HWallHitF::~HWallHitF(){
if(iter){delete iter; iter=NULL;}
}
void HWallHitF::fillHit(HWallHit *hit, HWallRaw *raw) {
}
Bool_t HWallHitF::init(void) {
initParContainer();
HDetector *start = gHades->getSetup()->getDetector("Start");
fRawCat = gHades->getCurrentEvent()->getCategory(catWallRaw);
if (!fRawCat) {
fRawCat = gHades->getSetup()->getDetector("Wall")
->buildCategory(catWallRaw);
if (!fRawCat)
return kFALSE;
else
gHades->getCurrentEvent()->addCategory(catWallRaw,fRawCat,"Wall");
}
iter = (HIterator *)fRawCat->MakeIterator("native");
fHitCat = gHades->getCurrentEvent()->getCategory(catWallHit);
if (!fHitCat) {
fHitCat = gHades->getSetup()->getDetector("Wall")
->buildCategory(catWallHit);
if (!fHitCat)
return kFALSE;
else
gHades->getCurrentEvent()->addCategory(catWallHit,fHitCat,"Wall");
}
// Get Start Hit category. If StartHit is not defined or the start detector
// is not in the setup a Warning is displayed and fStartHitCat is set to 0
if (start) {
fStartHitCat =gHades->getCurrentEvent()->getCategory(catStartHit);
if (!fStartHitCat)
Warning("init","Start Hit level not defining: setting start time to 0");
} else {
Warning("init","Start detector not found. Setting start time to 0");
fStartHitCat = 0;
}
return kTRUE;
}
void HWallHitF::fillGeometry(HWallHit *hit) {
// Fills in the LAB position parameters for the given HTofHit.
//
// This is done by transforming the point (x,0,0) in the ROD coordinate
// system to the LAB coordinate system. Where x is the reconstructed
// x position inside the hit.
HGeomVector rLocal,r;
Float_t d,phi,theta,xx,yy,zz;
Float_t rad2deg = 180./TMath::Pi();
// HModGeomPar *mother=pWallGeometry->getModule(0);
// HGeomTransform &trans = mother->getLabTransform();
//HGeomVolume *cellVol=mother->getRefVolume()->getComponent(hit->getCell());
//HGeomTransform &cellTrans=cellVol->getTransform();
HModGeomPar *module= pWallGeometry->getModule(0);
HGeomTransform &trans = module->getLabTransform();
HGeomVolume *cellVol = module->getRefVolume()->getComponent(hit->getCell());
HGeomTransform &cellTrans=cellVol->getTransform();
// Fill r with the hit coordinates in the cell coordinate system
// Since we do not have information about x,y,z coordinates of impact
// hi occures in centre thus z=0, x=0 and y=0.
// Note that (0,0,0) corresponds to the rod center.
r.setX(0.);
r.setY(0.);
r.setZ(0.);
rLocal=cellTrans.transFrom(r); // transform to module coordinate system
r=trans.transFrom(rLocal); // transform from module to LAB system
HGeomVolume *tv=pSpecGeometry->getTarget(0);
if (tv) r -= tv->getTransform().getTransVector(); // correct for target position
// Fill output
d = r.length();
theta = (d>0.) ? (rad2deg * TMath::ACos(r.getZ() / d)) : 0.;
phi = rad2deg * TMath::ATan2( r.getY(), r.getX());
if (phi < 0.) phi += 360.;
if (tv) r += tv->getTransform().getTransVector(); // correct for target position
hit->setXYZLab(r.getX(), r.getY(), r.getZ());
hit->setDistance( d );
hit->setTheta(theta);
hit->setPhi(phi);
hit->getXYZLab(xx,yy,zz);
}
Int_t HWallHitF::execute(void) {
HWallRaw* raw = NULL;
HWallHit* hit = NULL;
Bool_t startFlag;
Float_t startTime = 0, calTime = 0;
Int_t startStrip, startModule;
fLoc.set(1,-1);
if (fStartHitCat) {
HStartHit *h=NULL;
if((h=(HStartHit *)fStartHitCat->getObject(0))!=NULL){
startTime = h->getTime();
startFlag = h->getFlag();
startStrip = h->getStrip();
startModule = h->getModule();
}
else{
startTime =0.0;
startFlag = kFALSE;
}
/*
cout <<"startTime,strip,module = " <<startTime <<" " <<startStrip <<" " <<startModule <<endl;
if(startFlag)
cout <<"startFlag = kTRUE" <<endl;
if(!startFlag)
cout <<"startFlag = kFALSE" <<endl;
*/
} else {
startTime = 0.0;
startFlag = kFALSE;
}
iter->Reset(); // this works only in split mode=2
// (for 0 and 1 the iterator must be recreated)
while ((raw=(HWallRaw *)iter->Next())!=0) {
fLoc[0] = raw->getCell();
if(fLoc[0] == -1) continue;
if(raw->getTime() > 0.) {
fLoc[0] = raw->getCell();
HWallCalParCell &pPar=(*pWallCalPar)[fLoc[0]];
calTime = pPar.getTDC_Slope()*raw->getTime()-pPar.getTDC_Offset();
// printf("slope %f offset %f rawtime %f caltime %f n",pPar.getTDC_Slope(),pPar.getTDC_Offset(),(raw->getTime()),calTime);
if(startFlag) calTime -= startTime;
hit = (HWallHit*) fHitCat->getSlot(fLoc);
if(hit != NULL) {
hit = new(hit) HWallHit;
hit->setTime(calTime);
hit->setCharge(pPar.getADC_Slope()*(raw->getCharge())-pPar.getADC_Offset());
// printf("slope %f offset %f rawcharge %f calcharge %f n",pPar.getADC_Slope(),pPar.getADC_Offset(),raw->getCharge(),pPar.getADC_Slope()*(raw->getCharge())-pPar.getADC_Offset());
hit->setAddress(fLoc[0]);
fillHit(hit,raw);
fillGeometry(hit); //FK// TADY TO KRACHUJE
} //if(hit != NULL)
// } //if(calTime > 0.)
} //if(raw->getTime() > 0.)
} // while ((geant=(HGeantTof *)iter->Next())!=0)
return 0;
} // htofinocalibrater
ClassImp(HWallHitF)
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.