using namespace std;
#include "hrpcdetector.h"
#include "hrpccalibrater.h"
#include "rpcdef.h"
#include "hrpcraw.h"
#include "hrpccal.h"
#include "hrpccalpar.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 <iostream>
#include <iomanip>
#include <cstdlib>
HRpcCalibrater::HRpcCalibrater(void)
{
pRawCat=NULL;
pCalCat=NULL;
iter=NULL;
pCalPar=NULL;
}
HRpcCalibrater::HRpcCalibrater(const Text_t *name,const Text_t *title) :
HReconstructor(name,title)
{
pRawCat=NULL;
pCalCat=NULL;
iter=NULL;
pCalPar=NULL;
}
HRpcCalibrater::~HRpcCalibrater(void)
{
if (iter) delete iter;
iter=NULL;
}
Bool_t HRpcCalibrater::init(void)
{
HRpcDetector *rpc;
rpc=(HRpcDetector *)gHades->getSetup()->getDetector("Rpc");
if(!rpc){
Error("init","No Rpc Detector found");
return kFALSE;
}
pRawCat=gHades->getCurrentEvent()->getCategory(catRpcRaw);
if (!pRawCat) {
Error("init","No RpcRaw Category");
return kFALSE;
}
pCalCat=gHades->getCurrentEvent()->getCategory(catRpcCal);
if (!pCalCat) {
pCalCat=gHades->getSetup()->getDetector("Rpc")->buildCategory(catRpcCal);
if (!pCalCat) return kFALSE;
else gHades->getCurrentEvent()->addCategory(catRpcCal,pCalCat,"Rpc");
}
pCalPar=(HRpcCalPar*)(gHades->getRuntimeDb()->getContainer("RpcCalPar"));
if (!pCalPar){
Error("init","No RpcCalPar Parameters");
return kFALSE;
}
iter=(HIterator *)pRawCat->MakeIterator();
loc.set(3,0,0,0);
fActive=kTRUE;
return kTRUE;
}
Int_t HRpcCalibrater::execute(void)
{
HRpcRaw *pRaw=0;
HRpcCal *pCal=0;
iter->Reset();
while ( (pRaw=(HRpcRaw *)iter->Next()) != NULL) {
loc[0] = pRaw->getSector();
loc[1] = pRaw->getColumn();
loc[2] = pRaw->getCell();
if(loc[2]>31) continue;
pCal=(HRpcCal*)pCalCat->getSlot(loc);
if (pCal) {
pCal=new (pCal) HRpcCal;
if ( !pCal ) return EXIT_FAILURE;
pCal->setAddress(pRaw->getAddress());
pCal->setLogBit(pRaw->getRightLogBit());
Float_t rightTimeOffset,leftTimeOffset,rightTotOffset,leftTotOffset,tdc2time,tot2charge,tzero=0.0;
HRpcCalParCol* pCalParCol=pCalPar->getCol(loc[0],loc[1]);
if(pCalParCol) {
HRpcCalParCell* pCalParCell=pCalParCol->getCell(loc[2]);
if(pCalParCell) {
pCalParCell->getAddress(rightTimeOffset,leftTimeOffset,rightTotOffset,leftTotOffset,tdc2time,
tot2charge,tzero);
Float_t rightTime,leftTime;
Float_t rightTot,leftTot,rightTot2,leftTot2;
rightTime = ((pRaw->getLeftTime() - pRaw->getRightTime()) + rightTimeOffset ) * tdc2time;
leftTime = (pRaw->getLeftTime()+leftTimeOffset) * tdc2time;
rightTot = (pRaw->getRightTot()+rightTotOffset) * tot2charge;
leftTot = (pRaw->getLeftTot()+leftTotOffset) * tot2charge;
rightTot2 = (pRaw->getRightTotLast()+rightTotOffset) * tot2charge;
leftTot2 = (pRaw->getLeftTotLast()+leftTotOffset) * tot2charge;
pCal->setRightTime(rightTime);
pCal->setLeftTime(leftTime);
pCal->setRightCharge(rightTot);
pCal->setRightCharge2(rightTot2);
pCal->setLeftCharge(leftTot);
pCal->setLeftCharge2(leftTot2);
} else { Warning("execute","Can't get CalParCell"); }
} else { Warning("execute","Can't get CalParCol"); }
} else {
Error ("execute()", "Can't get slot in calibrater: sec %i, col %i, cell %i",loc[0],loc[1],loc[2]);
return -1;
}
}
return EXIT_SUCCESS;
}
ClassImp(HRpcCalibrater)
Last change: Sat May 22 13:11:04 2010
Last generated: 2010-05-22 13:11
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.