#include "hmdchitsim.h"
#include "hades.h"
#include "hmdcdef.h"
#include "hmdccal1sim.h"
#include "hevent.h"
#include "hcategory.h"
#include "hmessagemgr.h"
#include "TMath.h"
ClassImp(HMdcHitSim)
void HMdcHitSim::clear()
{
nTracks=0;
status=0;
HMdcHit::Clear();
for(Int_t i=0;i<5;i++){
listTracks[i]=0;
nTimes[i] =0;
}
}
void HMdcHitSim::setNumNoiseWires(Int_t n) {
if(n<=0) return;
if(nTracks>4) nTracks=4;
listTracks[4]=-99;
nTimes[4]=n;
}
void HMdcHitSim::setNTracks(Int_t nTr,const Int_t* listTr,const UChar_t* nTm) {
if(nTr<=0) nTracks=-1;
else {
Int_t maxTr = (nTr<6) ? nTr:5;
nTracks = 0;
for(Int_t n=0; n<maxTr; n++) {
if(listTr[n] == -99) {
listTracks[4] = listTr[n];
nTimes[4] = nTm[n];
} else {
listTracks[nTracks] = listTr[n];
nTimes[nTracks] = nTm[n];
nTracks++;
}
}
}
}
Int_t HMdcHitSim::calcNTracks(void) {
nTracks=0;
HCategory *fCalCat=gHades->getCurrentEvent()->getCategory(catMdcCal1);
if(!fCalCat) return -1;
HLocation loc;
loc.set(4,sector,module,0,0);
Int_t tmpListTracks[48];
Int_t nTimesTot=0;
for(Int_t layer=0; layer<6; layer++) {
Int_t nCells=getNCells(layer);
if(nCells==0) continue;
loc[2]=layer;
for(Int_t n=0; n<nCells; n++) {
UChar_t nCTimes=getSignId(layer,n);
loc[3]=getCell(layer,n);
HMdcCal1Sim *fCal1Sim=(HMdcCal1Sim*)fCalCat->getObject(loc);
if(fCal1Sim)
{
if(nCTimes&1) tmpListTracks[nTimesTot++]=fCal1Sim->getNTrack1();
if(nCTimes&2) tmpListTracks[nTimesTot++]=fCal1Sim->getNTrack2();
} else Error("calcNTracks","Zero pointer received!");
}
}
Short_t counter[48];
listTracks[4]=-99;
nTimes[4]=0;
for(Int_t n=0; n<nTimesTot; n++) {
if(tmpListTracks[n]<0 &&
tmpListTracks[n]!=gHades->getEmbeddingRealTrackId()) {
nTimes[4]++;
continue;
} else if(tmpListTracks[n]>0 ||
tmpListTracks[n]==gHades->getEmbeddingRealTrackId()) {
tmpListTracks[nTracks]=tmpListTracks[n];
counter[nTracks]=1;
for(Int_t m=n+1; m<nTimesTot; m++) {
if(tmpListTracks[m] != tmpListTracks[nTracks]) continue;
counter[nTracks]++;
tmpListTracks[m]=0;
}
nTracks++;
}
}
if(nTracks>0)
{
Int_t index[nTracks];
if(nTracks>1) TMath::Sort(nTracks,counter,index);
else index[0]=0;
if(nTracks>4) nTracks=(nTimes[4]==0) ? 5:4;
for(Int_t n=0; n<nTracks; n++) {
listTracks[n]=tmpListTracks[index[n]];
nTimes[n]=counter[index[n]];
}
}
return nTracks;
}
void HMdcHitSim::print(void) {
gHades->getMsg()->info(10,HMessageMgr::DET_MDC,GetName()
,"Sec.%i Mod.%i chi2=%g, %i tracks: ",
sector,module,chi2,nTracks);
for(Int_t n=0; n<nTracks; n++)
gHades->getMsg()->info(10,HMessageMgr::DET_MDC,GetName()
,"%i(%i) ",listTracks[n],nTimes[n]);
if(listTracks[4]==-99 && nTimes[4]>0) gHades->getMsg()->info(10,
HMessageMgr::DET_MDC,GetName()," noise_wires(%i) ",nTimes[4]);
INFO_msg(10,HMessageMgr::DET_MDC,"[trNum(nOfTimes)]");
HMdcHit::print();
}
Last change: Sat May 22 13:02:26 2010
Last generated: 2010-05-22 13:02
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.