using namespace std;
#include "hmdcsegsim.h"
#include "hmdchitsim.h"
#include "hmdcdef.h"
#include "hgeantkine.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hspectrometer.h"
#include "hdebug.h"
#include "hevent.h"
#include "heventheader.h"
#include "hdetector.h"
#include <iostream>
#include <iomanip>
#include "TClonesArray.h"
#include "TArrayF.h"
#include "hgeantmdc.h"
#include "hmdctrackddef.h"
#include "hmdcclusinf.h"
#include "hmdctrackddef.h"
#include "hmdcclustertohit.h"
#include "hmdcclus.h"
#include "hmdccpselector.h"
#include "piddef.h"
#include "hpidparticle.h"
#include "hpidparticlesim.h"
#include "hpidcandidate.h"
#include "hpidtrackcand.h"
#include "hmdcfunc1.h"
#include "TNtuple.h"
#include "TH1F.h"
HMdcCPSelector::HMdcCPSelector(void) {
nameHistoFile="histograms_cpselection.root";
mdc_singles=NULL;
mdc_doubles=NULL;
fGeantCat= NULL;
fMdcSegCat= NULL;
fClusInf=NULL;
iterator_mdcseg = NULL;
iterator_kine = NULL;
iterator_mdchit= NULL;
iterator_clusinf= NULL;
nThreshold = 10000;
nEvCounter=0;
special_mode=0;
mod_mdcseg=0;
arr_doub_mdcseg=NULL;
arr_sing_mdcseg=NULL;
cout_singles=0;
cout_doubles=0;
arr_doub_mdchit0=NULL;
arr_doub_mdchit1=NULL;
arr_sing_mdchit0=NULL;
arr_sing_mdchit1=NULL;
cout_singles_m0=0;
cout_singles_m1=0;
cout_doubles_m0=0;
cout_doubles_m1=0;
}
HMdcCPSelector::HMdcCPSelector(const Text_t *name,const Text_t *title,const Char_t *histoname,Int_t mode) :HReconstructor (name,title) {
special_mode=0;
mod_mdcseg=mode;
nameHistoFile=histoname;
fGeantCat= NULL;
fMdcSegCat= NULL;
iterator_kine = 0;
iterator_mdcseg = 0;
iterator_clusinf =0;
nThreshold = 100000;
index = 0;
nEvCounter=0;
arr_doub_mdcseg=NULL;
arr_sing_mdcseg=NULL;
cout_singles=0;
cout_doubles=0;
arr_doub_mdchit0=NULL;
arr_doub_mdchit1=NULL;
arr_sing_mdchit0=NULL;
arr_sing_mdchit1=NULL;
cout_singles_m0=0;
cout_singles_m1=0;
cout_doubles_m0=0;
cout_doubles_m1=0;
}
HMdcCPSelector::~HMdcCPSelector(void){
}
void HMdcCPSelector::resetArray(TArrayI *ar){
for(Int_t i=0;i<ar->GetSize();i++){
ar->AddAt(-1,i);
}
}
Bool_t HMdcCPSelector::checkArray(Int_t member,TArrayI *ar){
for(Int_t i=0;i<ar->GetSize();i++){
if(ar->At(i)==member) return kTRUE;
}
return kFALSE;
}
void HMdcCPSelector::put2Array(Int_t member,TArrayI *ar,Int_t index){
if (index<ar->GetSize()){
ar->AddAt(member,index);
} else {
ar->Set(2*ar->GetSize());
ar->AddAt(member,index);
}
}
Bool_t HMdcCPSelector::init(void) {
fGeantCat=gHades->getCurrentEvent()->getCategory(catGeantKine);
if (!fGeantCat) cout<<"there is no HGeantKine !"<<endl;
iterator_kine= (HIterator*)fGeantCat->MakeIterator();
fMdcSegCat=gHades->getCurrentEvent()->getCategory(catMdcSeg);
if (!fMdcSegCat) {
fMdcSegCat=gHades->getSetup()->getDetector("Mdc")->buildCategory(catMdcSeg);
if (!fMdcSegCat) return kFALSE;
else gHades->getCurrentEvent()->addCategory(catMdcSeg,fMdcSegCat,"Mdc");
}
iterator_mdcseg = (HIterator*)fMdcSegCat->MakeIterator("native");
fMdcHitCat=gHades->getCurrentEvent()->getCategory(catMdcHit);
if (!fMdcHitCat) {
fMdcHitCat=gHades->getSetup()->getDetector("Mdc")->buildCategory(catMdcHit);
if (!fMdcHitCat) return kFALSE;
else gHades->getCurrentEvent()->addCategory(catMdcHit,fMdcHitCat,"Mdc");
}
iterator_mdchit = (HIterator*)fMdcHitCat->MakeIterator();
fClusInf=gHades->getCurrentEvent()->getCategory(catMdcClusInf);
if(!fClusInf) {
cout<<"there is no catMdcClusInf !"<<endl;
return kFALSE;
}
iterator_clusinf = (HIterator*)fClusInf->MakeIterator();
fPidPart=gHades->getCurrentEvent()->getCategory(catPidPart);
if (!fPidPart) {
Warning("init()","no HPidParticleSim hit category in input");
}
else
{
fPidPartIter =(HIterator*) fPidPart->MakeIterator();
}
fGeantMdcCat=gHades->getCurrentEvent()->getCategory(catMdcGeantRaw);
if (!fGeantMdcCat) cout<<"there is no HGeantMdc !"<<endl;
mdc_singles = new TNtuple("mdc_singles","mdc_singles","theta:phi:cls:nwires:level:module:sector");
mdc_doubles = new TNtuple("mdc_doubles","mdc_doubles","theta:phi:cls:nwires:level:module:sector");
hsystem=new TH1F("info","various informations",100,0,10);
theta_bin_size=10;
phi_bin_size=10;
if(mod_mdcseg==0) {
printf("HMdcCPSelector choose close pairs from MdcSegSim cont \n");
}
if(mod_mdcseg==1) {
printf("HMdcCPSelector choose close pairs from HPidParticleSim cont \n");
}
arr_doub_mdcseg=new TArrayI(3);
arr_sing_mdcseg=new TArrayI(3);
arr_doub_mdchit0=new TArrayI(3);
arr_doub_mdchit1=new TArrayI(3);
arr_sing_mdchit0=new TArrayI(3);
arr_sing_mdchit1=new TArrayI(3);
return kTRUE;
}
Bool_t HMdcCPSelector::finalize(void) {
writeHisto2File();
return kTRUE;
}
Int_t HMdcCPSelector::execute(void) {
nEvCounter++;
#if DEBUG_LEVEL>2
gDebuger->enterFunc("HMdcCPSelector::execute");
#endif
if(mod_mdcseg==0) {
findConvInMdcSeg();
}
if(mod_mdcseg==1) {
findConvPairsInPidParticle();
}
return 0;
}
void HMdcCPSelector::findConvInMdcSeg() {
HMdcSegSim * pObj_mdc_seg;
iterator_mdcseg->Reset();
while ( (pObj_mdc_seg=(HMdcSegSim *)iterator_mdcseg->Next())!=NULL) {
hsystem->Fill(0.5);
findConvInMdcSeg(pObj_mdc_seg);
}
}
void HMdcCPSelector::findConvInMdcSeg(HMdcSegSim * mdcseg) {
HMdcFunc1 fun;
fun.initCategoryPointers();
HMdcHitSim* hit0=(HMdcHitSim*) fun.getMdcHit(mdcseg,0);
HMdcHitSim* hit1=(HMdcHitSim*) fun.getMdcHit(mdcseg,1);
hsystem->Fill(0.5);
if(special_mode==1){
} else {
if (hit0) {
if (fun.isSingle(hit0)) {
if(checkArray(mdcseg->getHitInd(0),arr_sing_mdchit0)==kFALSE){
put2Array(mdcseg->getHitInd(0),arr_sing_mdchit0,cout_singles_m0);
cout_singles_m0++;
hsystem->Fill(1);
fillHistoSingle(hit0,mdcseg);
}
} else if (fun.isDouble(hit0,0)) {
if(checkArray(mdcseg->getHitInd(0),arr_doub_mdchit0)==kFALSE){
hsystem->Fill(2);
put2Array(mdcseg->getHitInd(0),arr_doub_mdchit0,cout_doubles_m0);
cout_doubles_m0++;
fillHistoDouble(hit0,mdcseg);
}
} else {
hsystem->Fill(3);
}
}
if (hit1) {
if (fun.isSingle(hit1)) {
if(checkArray(mdcseg->getHitInd(1),arr_sing_mdchit1)==kFALSE){
put2Array(mdcseg->getHitInd(1),arr_sing_mdchit1,cout_singles_m1);
cout_singles_m1++;
hsystem->Fill(1.5);
fillHistoSingle(hit1,mdcseg);
}
} else if (fun.isDouble(hit1,0)) {
if(checkArray(mdcseg->getHitInd(1),arr_doub_mdchit1)==kFALSE){
hsystem->Fill(2.5);
put2Array(mdcseg->getHitInd(1),arr_doub_mdchit1,cout_doubles_m1);
cout_doubles_m1++;
fillHistoDouble(hit1,mdcseg);
}
} else {
hsystem->Fill(3.5);
}
}
}
}
void HMdcCPSelector::findConvPairsInPidParticle() {
HPidParticleSim *pPidPart =NULL;
HPidTrackCand* pPidTrackCand=NULL;
HMdcSegSim *pMdcSegSim=NULL;
HMdcFunc1 fun;
fun.initCategoryPointers();
resetArray(arr_doub_mdcseg);
resetArray(arr_sing_mdcseg);
resetArray(arr_sing_mdchit0);
resetArray(arr_sing_mdchit1);
resetArray(arr_doub_mdchit0);
resetArray(arr_doub_mdchit1);
cout_singles=0;
cout_doubles=0;
cout_singles_m0=0;
cout_singles_m1=0;
cout_doubles_m0=0;
cout_doubles_m1=0;
fPidPartIter->Reset();
while ( (pPidPart=(HPidParticleSim *)fPidPartIter->Next())!=NULL) {
hsystem->Fill(0);
if (pPidPart!=NULL) {
pPidTrackCand=fun.getPidTrackCand(pPidPart);
if (pPidTrackCand!=NULL) {
pMdcSegSim=(HMdcSegSim*)fun.getMdcSegFromPidTrackCand(pPidTrackCand);
findConvInMdcSeg(pMdcSegSim);
}
}
}
}
Bool_t HMdcCPSelector::fillHistoDouble(HMdcSegSim *mdcseg) {
HMdcFunc1 fun;
fun.initCategoryPointers();
Int_t cls0=fun.getMdcClsSize(mdcseg,0);
Int_t cls1=fun.getMdcClsSize(mdcseg,1);
Int_t nwires0=fun.getMdcNWires(mdcseg,0);
Int_t nwires1=fun.getMdcNWires(mdcseg,1);
Int_t level0=fun.getMdcLevelCls(mdcseg,0);
Int_t level1=fun.getMdcLevelCls(mdcseg,1);
Float_t mdc_phi=fun.getNormalMdcPhi(mdcseg->getSec(),mdcseg->getPhi());
Float_t mdc_theta=fun.getNormalMdcTheta(mdcseg->getTheta());
mdc_doubles->Fill(mdc_theta, mdc_phi,cls0,nwires0,level0,cls1,nwires1,level1);
return kTRUE;
}
Bool_t HMdcCPSelector::fillHistoSingle(HMdcSegSim *mdcseg) {
HMdcFunc1 fun;
fun.initCategoryPointers();
Int_t cls0=fun.getMdcClsSize(mdcseg,0);
Int_t cls1=fun.getMdcClsSize(mdcseg,1);
Int_t nwires0=fun.getMdcNWires(mdcseg,0);
Int_t nwires1=fun.getMdcNWires(mdcseg,1);
Int_t level0=fun.getMdcLevelCls(mdcseg,0);
Int_t level1=fun.getMdcLevelCls(mdcseg,1);
Float_t mdc_phi=fun.getNormalMdcPhi(mdcseg->getSec(),mdcseg->getPhi());
Float_t mdc_theta=fun.getNormalMdcTheta(mdcseg->getTheta());
mdc_singles->Fill(mdc_theta, mdc_phi,cls0,nwires0,level0,cls1,nwires1,level1);
return kTRUE;
}
Bool_t HMdcCPSelector::fillHistoSingle(HMdcHitSim *mdchit,HMdcSegSim *mdcseg) {
HMdcFunc1 fun;
fun.initCategoryPointers();
Int_t cls=fun.getMdcClsSize(mdchit);
Int_t nwires=fun.getMdcNWires(mdchit);
Int_t level=fun.getMdcLevelCls(mdchit);
Float_t mdc_phi=fun.getNormalMdcPhi(mdcseg->getSec(),mdcseg->getPhi());
Float_t mdc_theta=fun.getNormalMdcTheta(mdcseg->getTheta());
mdc_singles->Fill(mdc_theta, mdc_phi,cls,nwires,level,mdchit->getModule(),mdchit->getSector());
return kTRUE;
}
Bool_t HMdcCPSelector::fillHistoDouble(HMdcHitSim *mdchit,HMdcSegSim *mdcseg) {
HMdcFunc1 fun;
fun.initCategoryPointers();
Int_t cls=fun.getMdcClsSize(mdchit);
Int_t nwires=fun.getMdcNWires(mdchit);
Int_t level=fun.getMdcLevelCls(mdchit);
Float_t mdc_phi=fun.getNormalMdcPhi(mdcseg->getSec(),mdcseg->getPhi());
Float_t mdc_theta=fun.getNormalMdcTheta(mdcseg->getTheta());
mdc_doubles->Fill(mdc_theta, mdc_phi,cls,nwires,level,mdchit->getModule(),mdchit->getSector());
return kTRUE;
}
void HMdcCPSelector::writeHisto2File(void) {
TFile* myoutfile = new TFile(nameHistoFile.Data(),"RECREATE");
myoutfile->cd();
mdc_singles->Write();
mdc_doubles->Write();
hsystem->Write();
myoutfile->Close();
}
ClassImp(HMdcCPSelector)
Last change: Sat May 22 12:59:45 2010
Last generated: 2010-05-22 12:59
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.