#include "hshowerhittoftrackmatcher.h"
#include "hruntimedb.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hshowerdetector.h"
#include "htofinodetector.h"
#include "hcategory.h"
#include "hlinearcategory.h"
#include "hlocation.h"
#include "hshowerhittof.h"
#include "hshowertrack.h"
#include "hshowerhittoftrack.h"
#include "hdebug.h"
#include "hades.h"
#include "hiterator.h"
#include "showerdef.h"
#include "showertofinodef.h"
#include <cmath>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
#define ADDRESS_SHIFT 1.0e+4
ClassImp(HShowerHitTofTrackMatcher)
HShowerHitTofTrackMatcher::HShowerHitTofTrackMatcher(const Text_t *name,const Text_t *title) :
HReconstructor(name,title)
{
fHitIter=NULL;
fTrackIter=NULL;
m_zeroLoc.set(0);
}
HShowerHitTofTrackMatcher::HShowerHitTofTrackMatcher()
{
fHitIter=NULL;
fTrackIter=NULL;
m_zeroLoc.set(0);
}
HShowerHitTofTrackMatcher::~HShowerHitTofTrackMatcher(void) {
if (fHitIter) delete fHitIter;
if (fTrackIter) delete fTrackIter;
}
Bool_t HShowerHitTofTrackMatcher::init() {
printf("initialization of Shower/Tofino hit-track matcher\n");
HShowerDetector *pShowerDet = (HShowerDetector*)gHades->getSetup()
->getDetector("Shower");
HTofinoDetector *pTofinoDet = 0;
pTofinoDet = (HTofinoDetector*)gHades->getSetup()
->getDetector("Tofino");
m_pTrackCat=gHades->getCurrentEvent()->getCategory(catShowerTrack);
if (!m_pTrackCat) {
m_pTrackCat=pShowerDet->buildCategory(catShowerTrack);
if (!m_pTrackCat) return kFALSE;
else gHades->getCurrentEvent()
->addCategory(catShowerTrack, m_pTrackCat, "Shower");
}
m_pHitCat=gHades->getCurrentEvent()->getCategory(catShowerHitTof);
if (!m_pHitCat) {
m_pHitCat=pShowerDet->buildCategory(catShowerHitTof);
if (!m_pHitCat) return kFALSE;
else gHades->getCurrentEvent()
->addCategory(catShowerHitTof, m_pHitCat, "Tofino");
}
m_pHitTrackCat = gHades->getCurrentEvent()
->getCategory(catShowerHitTofTrack);
if (!m_pHitTrackCat) {
m_pHitTrackCat = new HLinearCategory("HShowerHitTofTrack", 1000);
if (!m_pHitTrackCat) return kFALSE;
else gHades->getCurrentEvent()
->addCategory(catShowerHitTofTrack, m_pHitTrackCat, "Tofino");
}
fHitIter=(HIterator*)m_pHitCat->MakeIterator();
fTrackIter=(HIterator*)m_pTrackCat->MakeIterator();
return kTRUE;
}
Bool_t HShowerHitTofTrackMatcher::finalize(void) {
return kTRUE;
}
Int_t HShowerHitTofTrackMatcher::execute()
{
map<Int_t, vector<Int_t> > trackMap;
HShowerTrack* pTrack;
fTrackIter->Reset();
while((pTrack = (HShowerTrack *) fTrackIter->Next()))
{
Int_t addTr = pTrack->getAddress();
Int_t trackNr = pTrack->getTrack();
map<Int_t,vector<Int_t> >::iterator pos = trackMap.find(addTr);
if( pos == trackMap.end() ) {
vector<Int_t> v;
v.push_back(trackNr);
trackMap.insert( make_pair( addTr, v ) );
} else {
(pos->second).push_back(trackNr);
}
}
HShowerHitTof* pHitTof;
fHitIter ->Reset();
while((pHitTof = (HShowerHitTof*)fHitIter->Next()))
{
Int_t Addr = pHitTof->getAddress();
Int_t trueAddr = pHitTof->getTrueAddress();
if( Addr != trueAddr && !(pHitTof->getSum(0) == 0 && pHitTof->getSum(1) != 0) ) {
Error("execute()","trueAddress differnt from Address, but pHitTof->getSum(0) == 0 && pHitTof->getSum(1) != 0 not fullfilled!");
}
map<Int_t,vector<Int_t> >::iterator pos = trackMap.find(trueAddr);
if( pos != trackMap.end() ) {
HShowerHitTofTrack* pHitTofTrack=(HShowerHitTofTrack *)m_pHitTrackCat->getNewSlot(m_zeroLoc);
if (pHitTofTrack != NULL) {
pHitTofTrack = new (pHitTofTrack) HShowerHitTofTrack;
*pHitTofTrack = *pHitTof;
vector<Int_t>& list = pos->second;
for( UInt_t i = 0; i < list.size(); ++ i ) {
pHitTofTrack->setTrack(list[i]);
}
} else {
Error("execute()","Zero pointer retrieved for HShowerHitTofTrack!");
}
} else {
Error("execute()","Corresponding pad address of the HShowerTrack list not found in HShowerHitTof!");
}
}
return 0;
}
Last change: Sat May 22 13:13:48 2010
Last generated: 2010-05-22 13:13
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.