using namespace std;
#include "hrichtrackletfiltersim.h"
#include "hlinearcategory.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hrichdetector.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hades.h"
#include "richdef.h"
#include "TObjArray.h"
#include "hhitmatchsim.h"
#include "hhitmatchheadersim.h"
#include "hgeantkine.h"
#include "hrichutilfunc.h"
#include <iostream>
#include <iomanip>
ClassImp(HRichTrackletFilterSim)
HRichTrackletFilterSim::HRichTrackletFilterSim(const Text_t *name,const Text_t *title) :
HReconstructor(name,title)
{
}
HRichTrackletFilterSim::HRichTrackletFilterSim()
{
}
HRichTrackletFilterSim::~HRichTrackletFilterSim(void) {
}
Bool_t HRichTrackletFilterSim::init() {
if (gHades) {
HEvent *event=gHades->getCurrentEvent();
HRuntimeDb *rtdb=gHades->getRuntimeDb();
HSpectrometer *spec=gHades->getSetup();
if (event && rtdb) {
HDetector *rich = spec->getDetector("Rich");
fGeantKineCat =(HLinearCategory*) event->getCategory(catGeantKine);
if (!fGeantKineCat)
{
Error("HRichCorrelatorSim::init",
"no GEANT Kine category available");
}
iter_kine = (HIterator *)fGeantKineCat ->MakeIterator("native");
if (rich) {
pHitMatchCat=event->getCategory(catMatchHit);
if (!pHitMatchCat) {
pHitMatchCat=rich->buildCategory(catMatchHit);
if (!pHitMatchCat) {
Error("init","No HIT MATCH category defined");
return kFALSE;
}
else event->addCategory(catMatchHit, pHitMatchCat, "Rich");
}
pIterMatchHit = (HIterator*)getHitMatchCat()->MakeIterator("native");
pHitMatchHeaderCat=event->getCategory(catMatchHitHeader);
pIterMatchHitHeader = (HIterator*)getHitMatchHeaderCat()
->MakeIterator("native");
}
}
}
resetCounters();
return kTRUE;
}
Bool_t HRichTrackletFilterSim::finalize() {
return kTRUE;
}
Bool_t HRichTrackletFilterSim::delHitMatch(TObjArray *t)
{
if (t)
{
for (Int_t i=0;i<(t->GetLast()+1);i++)
{
((TClonesArray*)((HLinearCategory*)getHitMatchCat())
->getCollection())->Remove( (HHitMatchSim*)((*t)[i]) );
((TClonesArray*)((HLinearCategory*)getHitMatchCat())
->getCollection())->Compress();
nCounterNbRejectedHits++;
}
return kTRUE;
}
return kFALSE;
}
void HRichTrackletFilterSim::filterTrackletIndividual(Int_t swt)
{
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
TObjArray *tmp = new TObjArray(5);
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
if (!isGood(pHM,swt)) tmp->Add(pHM);
}
if (!delHitMatch(tmp)) Error("execute","Bad hits not deleted");
delete tmp;
}
void HRichTrackletFilterSim::filterTrackletInGroup(Int_t swt)
{
switch(swt)
{
case 0:
{
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
Int_t nHM = ((HLinearCategory*)getHitMatchCat())->getEntries();
cout<<"Nb of tracklets : "<<nHM<<endl;
if (nHM==0) break;
TObjArray *pArr = new TObjArray[nHM+1];
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next())) pArr->Add(pHM);
TObjArray *deltmp = new TObjArray(5);
Int_t nMaxArr = pArr->GetLast()+1;
for (Int_t i=0;i<nMaxArr-1;i++)
{
Bool_t isSingle=kTRUE;
for (Int_t j=i+1;j<nMaxArr;j++)
{
cout<<"index i: "<<i<<" / index j: "<<j<<" ";
Int_t r1 = ((HHitMatchSim*)(*pArr)[i])->getRichInd();
Int_t r2 = ((HHitMatchSim*)(*pArr)[j])->getRichInd();
Int_t m1 = ((HHitMatchSim*)(*pArr)[i])->getMdcInd();
Int_t m2 = ((HHitMatchSim*)(*pArr)[j])->getMdcInd();
cout<<"r1: "<<r1<<" r2: "<<r2<<" m1: "<<m1<<" m2: "<<m2<<endl;
if (r1==r2 && m1==m2)
{
HHitMatchSim* ht = ((HHitMatchSim*)(*pArr)[i]);
if (deltmp->IndexOf(ht)==-1) deltmp->Add(ht);
cout<<"removed index i: "<<i<<" / r1: "<<r1<<" m1: "<<m1<<endl;
}
if (r1==r2) isSingle=kFALSE;
}
if (isSingle)
{
HHitMatchSim* ht = ((HHitMatchSim*)(*pArr)[i]);
if (deltmp->IndexOf(ht)==-1) deltmp->Add(ht);
}
}
if (!delHitMatch(deltmp)) Error("execute","Bad hits not deleted");
deltmp->Clear();
pArr->Clear();
}
break;
}
}
Bool_t HRichTrackletFilterSim::isGood(HHitMatchSim* h,Int_t swt)
{
Bool_t kSwitch = kFALSE;
HTrackInfo* t = h->getTrackInfoObj();
Int_t nPartNr = t->getPartNr();
switch (swt)
{
case 0:
{
if (nPartNr>=2) kSwitch=kTRUE;
break;
}
case 1:
{
if (h->getRichInd() > -1) kSwitch=kTRUE;
break;
}
case 2:
{
for (Int_t i=0;i<nPartNr;i++)
{
if (t->getParId(i)==2 || t->getParId(i)==3)
{
HGeantKine* lepton = HRichUtilFunc::getKineObj(
t->getTrkNb(i),
(HLinearCategory*)
getGeantKineCat() );
Int_t aPar, aMed, aMech;
lepton->getCreator(aPar,aMed,aMech);
if (aMed>=8 && aMed<=19)
{
HGeantKine *lepton_parent =
HRichUtilFunc::findParent(lepton,
(HLinearCategory*) getGeantKineCat());
if(lepton_parent){
Int_t aTrackp, nLepParID;
lepton_parent->getParticle(aTrackp,nLepParID);
if ((nLepParID==1 && aMech==6) ||
(nLepParID==7 && aMech==5))
{
kSwitch=kTRUE;
}
}
}
}
}
}
}
return kSwitch;
}
Int_t HRichTrackletFilterSim::execute()
{
filterTrackletIndividual(2);
Int_t kReturnValue=0;
return kReturnValue;
}
void HRichTrackletFilterSim::resetCounters()
{
nCntRTM=0;
nCntRTMfull=0;
nCntRTMnoTM=0;
nCntRTMnoTR=0;
nCntRTMnoRM=0;
nCntProcessedObjs=0;
}
Int_t HRichTrackletFilterSim::countCorrelationObjects()
{
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
Int_t nC=0;
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
nCntProcessedObjs++;
nC++;
Int_t nRInd = pHM->getRichInd();
Int_t nMInd= pHM->getMdcInd();
Int_t nTInd= pHM->getTofInd();
Int_t nRM = pHM->getMatchedRichMdc();
Int_t nRT = pHM->getMatchedRichTof();
Int_t nMT = pHM->getMatchedMdcTof();
if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1) nCntRTM++;
if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 &&
nRM==1 && nRT==1 && nMT==1 ) nCntRTMfull++;
else if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 &&
nRM==1 && nRT==1) nCntRTMnoTM++;
else if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 &&
nRM==1 && nMT==1) nCntRTMnoTR++;
else if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 &&
nRT==1 && nMT==1) nCntRTMnoRM++;
}
return nC;
}
void HRichTrackletFilterSim::dumpCorrelationObjectStat()
{
cout<<"Number of processed objects: "<<nCntProcessedObjs<<endl;
cout<<"********************************"<<endl;
cout<<"Full RTM (i.e. RT,RM,TM) correlation: "<<nCntRTMfull<<endl;
cout<<"Objs containing RTM indexes: "<<nCntRTM<<endl;
cout<<"RT,RM (no TM): "<<nCntRTMnoTM<<endl;
cout<<"RT,TM (no RM): "<<nCntRTMnoRM<<endl;
cout<<"RM,TM (no TR): "<<nCntRTMnoTR<<endl;
cout<<"********************************"<<endl;
}
Last change: Sat May 22 13:10:36 2010
Last generated: 2010-05-22 13:10
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.