#include "hpidmdcstart.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hcategory.h"
#include "hmatrixcategory.h"
#include "hlinearcategory.h"
#include "hlocation.h"
#include "hiterator.h"
#include "htool.h"
#include "hstarthit.h"
#include "hshowerhittof.h"
#include "htofcluster.h"
#include "htofhit.h"
#include "hstartdef.h"
#include "showertofinodef.h"
#include "tofdef.h"
#include "hgeantdef.h"
#include "TMath.h"
#include "TArrayF.h"
#include <iostream>
using namespace std;
ClassImp(HPidMdcStart)
HPidMdcStart::HPidMdcStart()
{
initParameters();
}
HPidMdcStart::HPidMdcStart(const Text_t *name,const Text_t *title)
:HReconstructor(name,title)
{
initParameters();
}
HPidMdcStart::~HPidMdcStart(void){
if(iterShowerHitTofCat) delete iterShowerHitTofCat;
if(iterTofClusterCat) delete iterTofClusterCat;
if(iterTofHitCat) delete iterTofHitCat;
iterShowerHitTofCat = NULL;
iterTofClusterCat = NULL;
iterTofHitCat = NULL;
}
void HPidMdcStart::initParameters(){
isEmbedding = kFALSE;
iterShowerHitTofCat = NULL;
iterTofClusterCat = NULL;
iterTofHitCat = NULL;
timeVal = 7.5;
print = kFALSE;
}
Bool_t HPidMdcStart::init(void){
HEvent* event = gHades->getCurrentEvent();
if(!event){
Error("init()","Could not retrieve current Event!");
exit(1);
}
if(event->getCategory(catGeantKine) &&
gHades->getEmbeddingMode() > 0)
{
isEmbedding = kTRUE;
} else {
isEmbedding = kFALSE;
}
pShowerHitTofCat = NULL;
pTofClusterCat = NULL;
pTofHitCat = NULL;
if(isEmbedding){
pShowerHitTofCat = (HCategory*)(event->getCategory(catShowerHitTofTrack));
if(!pShowerHitTofCat) {
Warning("init","No HShowerHitTof Input -> Switching usage of this category OFF");
}
} else {
pShowerHitTofCat = (HCategory*)(event->getCategory(catShowerHitTof));
if(!pShowerHitTofCat) {
Warning("init","No HShowerHitTof Input -> Switching usage of this category OFF");
}
}
if(pShowerHitTofCat) {
iterShowerHitTofCat = (HIterator*)pShowerHitTofCat->MakeIterator();
}
pTofClusterCat = (HMatrixCategory*)(event->getCategory(catTofCluster));
if(!pTofClusterCat) {
Warning("init","No HTofCluster Input -> Switching usage of this category OFF");
} else {
iterTofClusterCat = (HIterator*)pTofClusterCat->MakeIterator();
}
pTofHitCat = (HMatrixCategory*)(event->getCategory(catTofHit));
if(!pTofHitCat) {
Warning("init","No HTofHit Input -> Switching usage of this category OFF");
} else {
iterTofHitCat = (HIterator*)pTofHitCat->MakeIterator();
}
pStartHitCat = (HLinearCategory *)(event->getCategory(catStartHit));
if (!pStartHitCat)
{
pStartHitCat = new HLinearCategory("HStartHit");
if (!pStartHitCat) {
Error("init()","Could not create catStartHit!");
return kFALSE;
}
else {
event->addCategory(catStartHit,pStartHitCat,"Start");
}
}
return kTRUE;
}
Int_t HPidMdcStart::execute(void){
const Int_t size = 100;
const Int_t sizeSum = 200;
TArrayF aTof(size);
TArrayF aShowerTof(size);
TArrayF aSumTof(sizeSum);
aTof .Reset(1000.);
aShowerTof.Reset(1000.);
aSumTof .Reset(1000.);
Int_t ctTof = 0;
Int_t ctShowerTof = 0;
Int_t ctSumTof = 0;
if(iterTofClusterCat){
iterTofClusterCat->Reset();
HTofCluster* pTofCluster;
while((pTofCluster = (HTofCluster*)iterTofClusterCat->Next()) != 0 ) {
if(ctTof < size){
aTof [ctTof] = pTofCluster->getTof();
ctTof ++;
} else {
Warning("execute()","TofCuster skipped!");
}
if(ctSumTof < sizeSum){
aSumTof[ctSumTof] = pTofCluster->getTof();
ctSumTof ++;
} else {
Warning("execute()","TofCuster skipped!");
}
}
} else {
if(iterTofHitCat){
iterTofHitCat->Reset();
HTofHit* pTofHit;
while((pTofHit = (HTofHit*)iterTofHitCat->Next()) != 0 ) {
if(ctTof < size){
aTof [ctTof] = pTofHit->getTof();
ctTof ++;
} else {
Warning("execute()","TofCuster skipped!");
}
if(ctSumTof < sizeSum){
aSumTof[ctSumTof] = pTofHit->getTof();
ctSumTof ++;
} else {
Warning("execute()","TofCuster skipped!");
}
}
}
}
if(iterShowerHitTofCat){
iterShowerHitTofCat->Reset();
HShowerHitTof* pShowerTof;
while((pShowerTof = (HShowerHitTof*)iterShowerHitTofCat->Next()) != 0 ) {
if(ctShowerTof < size){
aShowerTof [ctShowerTof] = pShowerTof->getTof();
ctShowerTof ++;
} else {
Warning("execute()","HShowerHitTof skipped!");
}
if(ctSumTof < sizeSum){
aSumTof[ctSumTof] = pShowerTof->getTof();
ctSumTof ++;
} else {
Warning("execute()","HShowerHitTof skipped!");
}
}
}
HTool::sort(size ,aTof .GetArray(),0, kFALSE,kTRUE);
HTool::sort(size ,aShowerTof.GetArray(),0, kFALSE,kTRUE);
HTool::sort(sizeSum,aSumTof .GetArray(),0, kFALSE,kTRUE);
Float_t corr = 0;
if(ctSumTof > 0){
corr = timeVal - aSumTof[0];
}
if(print){
cout<<"-----------"<<endl;
cout<<"Event : "<<gHades->getEventCounter()<<endl;
cout<<"Mult TOF: "<<ctTof<<" Mult Shower: "<<ctShowerTof<<" Mult SUM "<<ctSumTof<<endl;
cout<<"TOF winner :" <<aTof [0]<<endl;
cout<<"Shower winner :" <<aShowerTof[0]<<endl;
cout<<"Sum winner :" <<aSumTof [0]<<endl;
cout<<"Corr :" <<corr<<endl;
for(Int_t i = 0; i < ctSumTof; i ++){
cout<<i<< " " << aSumTof[i] <<endl;
}
}
HLocation loc;
loc.set(2,0,0);
HStartHit* pHit = (HStartHit*)pStartHitCat->getObject(loc);
if(pHit){
Warning("execute()","HStartHit object exists already! will skip and not overwrite!");
return 0;
}
if(!pHit){
pHit = (HStartHit*)pStartHitCat->getNewSlot(loc);
}
if(pHit){
pHit = new (pHit) HStartHit;
pHit->setModule(0);
pHit->setStrip(0);
pHit->setTime(-corr);
pHit->setStartMult(1);
pHit->setFlag(kTRUE);
} else {
Error("execute()","NULL pointer for HStartHit slot retrieved!");
}
return 0;
}
Bool_t HPidMdcStart::finalize(void){
return kTRUE;
}
Last change: Sat May 22 13:07:11 2010
Last generated: 2010-05-22 13:07
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.