using namespace std;
#include "hrichpca.h"
#include "hrichcut.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hcategory.h"
#include "hiterator.h"
#include <iostream>
#include <iomanip>
#include "hdebug.h"
#include "hades.h"
#include "richdef.h"
#include "hhitmatch.h"
#include "hlinearcategory.h"
#include "hrichutilfunc.h"
#include "TVectorD.h"
#include "TMatrixD.h"
#include "TH1.h"
ClassImp(HRichPCA)
HRichPCA::HRichPCA(const Text_t *name,const Text_t *title) :
HReconstructor(name,title)
{
}
HRichPCA::HRichPCA()
{
}
HRichPCA::HRichPCA(const Text_t *name,const Text_t *title,const Char_t* filename) :
HReconstructor(name,title)
{
pFile = new TFile(filename,"RECREATE");
}
HRichPCA::~HRichPCA(void) {
}
Bool_t HRichPCA::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)
{
Error("init","No HIT MATCH category defined");
return kFALSE;
}
pIterMatchHit = (HIterator*)getHitMatchCat()->MakeIterator("native");
}
}
nNbVariables = 6;
principal = new TPrincipal(nNbVariables,"ND");
pFile = new TFile("pcah.root","RECREATE");
h3 = new TH3D("h3","h3",100,0,1500,100,0,100,20,0,20);
h3t = new TH3D("h3t","h3t",40,-2,2,100,-5,5,200,-10,10);
h2 = new TH2D("h2","h2",100,0,1500,100,0,100);
}
return kTRUE;
}
Int_t HRichPCA::execute()
{
HHitMatch *h=0;
pIterMatchHit->Reset();
Int_t nEnt = (getHitMatchCat())->getEntries();
Int_t *nRichInd = new Int_t[nEnt];
for (Int_t i=0;i<nEnt;i++) nRichInd[i]=-2;
while(( h= (HHitMatch *)pIterMatchHit->Next()))
{
Int_t richind = h->getRichInd();
if (HRichCut::isNewIndex(richind,nRichInd,nEnt) &&
HRichCut::isFullRichMdcMetaTracklet(h) &&
HRichCut::isRMThetaDiff(h,2.) )
{
Double_t * data = new Double_t[nNbVariables];
data[2] = h->getRingAmplitude();
data[1] = h->getRingPadNr();
data[0] = h->getRingLocalMax4();
data[3] = h->getRingPatMat();
data[4] = h->getRingHouTra();
data[5] = h->getRadius();
h3->Fill(data[0],data[1],data[2]);
principal->AddRow(data);
delete [] data;
}
}
delete [] nRichInd;
return kTRUE;
}
Bool_t HRichPCA::finalize() {
principal->MakePrincipals();
principal->Print("MSVE");
principal->MakeHistograms();
TList *listofhistos = principal->GetHistograms();
TVectorD eigenvalues((TVectorD)(*principal->GetEigenValues()));
TMatrixD covmatrix((TMatrixD)(*principal->GetCovarianceMatrix()));
TVectorD meanvalues((TVectorD)(*principal->GetMeanValues()));
TMatrixD eigenvectors((TMatrixD)(*principal->GetEigenVectors()));
TVectorD sigmas((TVectorD)(*principal->GetSigmas()));
TVectorD userdata((TVectorD)(*principal->GetUserData()));
Double_t * out = new Double_t[nNbVariables];
Double_t *out2 = new Double_t[nNbVariables-1];
delete [] out;
delete [] out2;
pFile->cd();
TH1 *h=0;
TIter next(listofhistos);
next.Reset();
while (( h = (TH1 *) next() )) h->Write();
pFile->Close();
return kTRUE;
}
Last change: Sat May 22 13:09:27 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.