using namespace std;
#include "hrichpairanasim.h"
#include "hruntimedb.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hmatrixcatiter.h"
#include "hrichhit.h"
#include <iostream>
#include <iomanip>
#include "hdebug.h"
#include "hades.h"
#include "richdef.h"
#include "hhitmatchsim.h"
#include "hhitmatchheadersim.h"
#include "hlinearcategory.h"
#include "hrichutilfunc.h"
ClassImp(HRichPairAnaSim)
HRichPairAnaSim::HRichPairAnaSim(const Text_t *name,const Text_t *title) :
HReconstructor(name,title)
{
}
HRichPairAnaSim::HRichPairAnaSim()
{
}
HRichPairAnaSim::~HRichPairAnaSim(void) {
}
Bool_t HRichPairAnaSim::init() {
if (gHades) {
HEvent *event=gHades->getCurrentEvent();
HRuntimeDb *rtdb=gHades->getRuntimeDb();
HSpectrometer *spec=gHades->getSetup();
if (event && rtdb) {
HDetector *rich = spec->getDetector("Rich");
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);
pIterMatchHitHeaderSim = (HIterator*)getHitMatchHeaderCat()
->MakeIterator("native");
}
}
}
iniCounters();
iniHistos();
pFileOut = new TFile("pairanasimhist.root","RECREATE");
return kTRUE;
}
void HRichPairAnaSim::iniCounters()
{
nCntRTMfull=0;
nCntRTMnoRM=0;
nCntRTMnoTM=0;
nCntRTMnoTR=0;
nCntRTM=0;
nCntProcessedEvents=0;
nCounterNbRejectedHits=0;
}
void HRichPairAnaSim::iniHistos()
{
pHistRTMopenAngle = new TH1F("RTM_opening_angle","RTM_opening_angle",100,0,20);
pHistRMopenAngle = new TH1F("RM_opening_angle","RM_opening_angle",100,0,20);
}
Bool_t HRichPairAnaSim::finalize() {
cout<<"Number of processed events: "<<nCntProcessedEvents<<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;
pFileOut->cd();
pHistRTMopenAngle->Write();
pHistRMopenAngle->Write();
pFileOut->Close();
return kTRUE;
}
Int_t HRichPairAnaSim::countRTMobjs()
{
Int_t nRTM=0;
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
Int_t nRInd = pHM->getRichInd();
Int_t nMInd= pHM->getMdcInd();
Int_t nTInd= pHM->getTofInd();
if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1) nRTM++;
}
return nRTM;
}
Int_t HRichPairAnaSim::countRMobjs()
{
Int_t nRM=0;
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
Int_t nRInd = pHM->getRichInd();
Int_t nMInd= pHM->getMdcInd();
if (nRInd!=-1 && nMInd!=-1) nRM++;
}
return nRM;
}
void HRichPairAnaSim::countCorrelationObjects()
{
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
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++;
}
}
Int_t HRichPairAnaSim::fillRTMobjs(TObjArray* pRTM)
{
Int_t c=0;
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
Int_t nRInd = pHM->getRichInd();
Int_t nMInd = pHM->getMdcInd();
Int_t nTInd = pHM->getTofInd();
if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1)
{
c++;
pRTM->Add(pHM);
}
}
return c;
}
Int_t HRichPairAnaSim::fillRMobjs(TObjArray* pRM)
{
Int_t c=0;
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
Int_t nRInd = pHM->getRichInd();
Int_t nMInd = pHM->getMdcInd();
Int_t nRM = pHM->getMatchedRichMdc();
if (nRInd!=-1 && nMInd!=-1 && nRM==1)
{
c++;
pRM->Add(pHM);
}
}
return c;
}
Int_t HRichPairAnaSim::fillRTMfullobjs(TObjArray* pRTM)
{
Int_t c=0;
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
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
&& nRM==1 && nRT==1 && nMT==1 )
{
c++;
pRTM->Add(pHM);
}
}
return c;
}
void HRichPairAnaSim::calcOpeningAngle(TObjArray *pArr,TH1* hist)
{
Int_t nCnt=0;
Int_t nMaxArr = pArr->GetLast()+1;
for (Int_t i=0;i<nMaxArr;i++)
{
nCnt++;
for (Int_t j=nCnt;j<nMaxArr;j++)
{
Float_t t1 = ((HHitMatchSim*)(*pArr)[i])->getMdcTheta();
Float_t p1 = ((HHitMatchSim*)(*pArr)[i])->getMdcPhi();
Float_t t2 = ((HHitMatchSim*)(*pArr)[j])->getMdcTheta();
Float_t p2 = ((HHitMatchSim*)(*pArr)[j])->getMdcPhi();
Float_t opangle = HRichUtilFunc::calcOpeningAngleT(t1,p1,t2,p2);
if (opangle>0.) hist->Fill(opangle);
}
}
}
Bool_t HRichPairAnaSim::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 HRichPairAnaSim::filter()
{
HHitMatchSim *pHM=0;
pIterMatchHit->Reset();
TObjArray *tmp = new TObjArray(5);
while(( pHM= (HHitMatchSim *)pIterMatchHit->Next()))
{
if (!isGood(pHM)) tmp->Add(pHM);
}
if (!delHitMatch(tmp)) Error("execute","Bad hits not deleted");
delete tmp;
}
Bool_t HRichPairAnaSim::isGood(HHitMatchSim* h)
{
Int_t patmat = h->getRingPatMat();
Int_t houtra = h->getRingHouTra();
if (houtra>=28 && patmat==0) return kTRUE;
else return kFALSE;
}
Int_t HRichPairAnaSim::execute()
{
nCntProcessedEvents++;
HHitMatchHeaderSim *pHMH = 0;
pIterMatchHitHeaderSim->Reset();
while(( pHMH= (HHitMatchHeaderSim *)pIterMatchHitHeaderSim->Next()))
{
pHMH->dumpToStdoutSim();
}
countCorrelationObjects();
return 0;
}
Last change: Sat May 22 13:09:38 2010
Last generated: 2010-05-22 13:09
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.