HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hmdcclustfromseg.cc
Go to the documentation of this file.
1 #include "hmdcclustfromseg.h"
2 #include "hades.h"
3 #include "hevent.h"
4 #include "hiterator.h"
5 #include "hmdctrackddef.h"
6 #include "hmdctrackgdef.h"
7 #include "hmdcclus.h"
8 #include "hmetamatch2.h"
9 #include "hsplinetrack.h"
10 #include "hmdcseg.h"
11 #include "hmdctrkcand.h"
12 #include "hmdchit.h"
13 #include "hmdcclusinf.h"
14 #include "hmdcgetcontainers.h"
15 #include "hmdcsizescells.h"
16 #include "hparamlist.h"
17 
19 
21  clear();
22  initCut(NULL);
23 }
24 
25 HMdcClustFromSeg::HMdcClustFromSeg(const Text_t *name,const Text_t *title) :
26  HReconstructor(name,title) {
27  clear();
28  initCut(NULL);
29 }
30 
31 HMdcClustFromSeg::HMdcClustFromSeg(const Text_t *name,const Text_t *title,
32  HParamList *cut) : HReconstructor(name,title) {
33  clear();
34  initCut(cut);
35 }
36 
38 
39  fInnerChi2 = -2.; // no check
40  fOuterChi2 = -2.;
41  fMinMomentum = 0.;
42  fMinBeta = -1000.; // open window
43  fMaxBeta = 1000.;
44  fPolarity = 2; // all particles
45  if(cut) {
46  // use user defined cut parameter
47  cut->fill("min_momentum",&fMinMomentum);
48  cut->fill("min_beta", &fMinBeta);
49  cut->fill("max_beta", &fMaxBeta);
50  cut->fill("polarity", &fPolarity);
51  cut->fill("innerChi2", &fInnerChi2);
52  cut->fill("outerChi2", &fOuterChi2);
53  // some basic checks - without a strong physical meaning
54  if(fMinMomentum<0 || fMinBeta>fMaxBeta || fPolarity==0) {
55  ERROR_msg( 1, "Invalid cut parameter set!" );
56  exit( 1 ); // uhgg ... but there is no "gHades->terminate()"
57  }
58  } else {
59  // by default select pi-
60  fMinMomentum=250.0;
61  fMinBeta =0.88;
62  fMaxBeta =1.12;
63  fPolarity =-1;
64  }
65  cout << "==> Cluster from Segment Filler - Cut Parameter:" << "\n"
66  << "==> min_momentum = " << fMinMomentum << "\n"
67  << "==> min_beta = " << fMinBeta << "\n"
68  << "==> max_beta = " << fMaxBeta << "\n"
69  << "==> polarity = " << fPolarity << "\n"
70  << "==> innerChi2 = " << fInnerChi2 << "\n"
71  << "==> outerChi2 = " << fOuterChi2 << endl;
72 }
73 
75  pCatMetaMatch=0;
76  iterMetaMatch=0;
78  pCatMdcSeg=0;
80  pSizesCells=0;
81  pCatMdcHit=0;
82 }
83 
85  // destructor
86  if(iterMetaMatch) delete iterMetaMatch;
87 }
88 
89 
90 Bool_t HMdcClustFromSeg::init(void) {
95  pCatMdcTrkCand = fGetCont->getCatMdcTrkCand();
97  pCatMdcClusInf = fGetCont->getCatMdcClusInf();
99  !pCatMdcHit || !pCatMdcClusInf) return kFALSE;
100  iterMetaMatch=(HIterator*)pCatMetaMatch->MakeIterator();
101  if(!iterMetaMatch) return kFALSE;
102 
103  pCatMdcClus = fGetCont->getCatMdcClus(kTRUE);
104  if(!pCatMdcClus) return kFALSE;
106  if(!pSizesCells) return kFALSE;
107  return kTRUE;
108 }
109 
111  if(!pSizesCells->initContainer()) return kFALSE;
112  return kTRUE;
113 }
114 
116  return kTRUE;
117 }
118 
120  iterMetaMatch->Reset();
121  HMetaMatch2* pMetaMatch;
122 
123  // clear cluster category if there
124  // was running the rackfinder before
125  pCatMdcClus->Clear();
126 
127  while((pMetaMatch=(HMetaMatch2*)iterMetaMatch->Next()) !=0) {
128  Short_t spInd = pMetaMatch->getSplineInd();
129  if(spInd<0) continue;
130  //if(!pMetaMatch->isSplineAccepted()) continue;
131  if(pMetaMatch->getNCandForRich() > 0) continue;
132  if(pMetaMatch->getNCandForIPU() > 0) continue;
133  Int_t system = pMetaMatch->getSystem();
134  if(system<0) continue;
135  HSplineTrack* pSplineTrack=(HSplineTrack*)pCatSplineTrack->getObject(spInd);
136  Char_t pol=pSplineTrack->getPolarity();
137  Float_t beta = pSplineTrack->getBeta();
138  Float_t mom = pSplineTrack->getP();
139 
140  // apply the cuts - for defaults, see constructor
141  if(fPolarity != 2){
142  if (fPolarity > 0 && pol < 0) continue;
143  if (fPolarity < 0 && pol >= 0) continue;
144  }
145  if (beta<fMinBeta || beta>fMaxBeta) continue;
146  if (mom<fMinMomentum) continue;
147 
148  Short_t trkCndInd = pMetaMatch->getTrkCandInd();
149  HMdcTrkCand* pMdcTrkCand=(HMdcTrkCand*)pCatMdcTrkCand->getObject(trkCndInd);
150  fillCluster(pMdcTrkCand->getSeg1Ind());
151  fillCluster(pMdcTrkCand->getSeg2Ind());
152  }
153  return 0;
154 }
155 
156 void HMdcClustFromSeg::fillCluster(Short_t segInd) {
157  if(segInd<0) return;
158  HMdcSeg* pSeg=(HMdcSeg*)pCatMdcSeg->getObject(segInd);
159  if(!pSeg) return;
160  if (pSeg->getIOSeg() == 0 && pSeg->getChi2() < fInnerChi2) return;
161  else if(pSeg->getIOSeg() == 1 && pSeg->getChi2() < fOuterChi2) return;
162 
163  Int_t nLay[2]={0,0};
164  for(Int_t l=0;l<12;l++) if(pSeg->getNCells(l)>0) nLay[l/6]++;
165  if(nLay[0]<5 && nLay[1]<5) return;
166 
167  for(Int_t m=0;m<2;m++) {
168  if(nLay[m]<5) continue;
169  Int_t hitInd = pSeg->getHitInd(m);
170  if(hitInd<0) {nLay[m]=0; continue;}
171  HMdcHit* pHit=(HMdcHit*)pCatMdcHit->getObject(hitInd);
172  if(pHit==0) {nLay[m]=0; continue;}
173  Short_t clusInfIndex = pHit->getClusInfIndex();
174  if(clusInfIndex<0) {nLay[m]=0; continue;}
175  HMdcClusInf* pClusInf=(HMdcClusInf*)pCatMdcClusInf->getObject(clusInfIndex);
176  if(pClusInf==0) {nLay[m]=0; continue;}
177  Char_t levelClFinding = pClusInf->getLevelClFinding();
178 if(levelClFinding>5) nLay[m]=0; //!!!!!!!!!!!!!!
179  }
180  if(nLay[0]<5 && nLay[1]<5) return;
181 
182  HMdcClus* pClus=getClusterSlot(pSeg);
183 
184  Int_t l1=(nLay[0]>=5) ? 0:6;
185  Int_t l2=(nLay[1]>=5) ? 12:6;
186  pClus->setMinCl(l1==0 ? 5:0, l2==12 ? 5:0);
187  if(l1!=0 || l2!=12) {
188  pClus->setTypeClFinder(1);
189  Int_t mod = pSeg->getIOSeg()*2;
190  pClus->setMod((l1==0) ? mod:mod+1);
191  }
192  for(Int_t layer=l1;layer<l2;layer++) {
193  Int_t nCells=pSeg->getNCells(layer);
194  if(nCells==0) continue;
195  for(Int_t n=0; n<nCells; n++) {
196  UChar_t nCTimes=pSeg->getSignId(layer,n);
197  Int_t cell=pSeg->getCell(layer,n);
198  pClus->setTime(layer,cell,nCTimes);
199  }
200  }
201  pSeg->setClusIndex(pClus->getOwnIndex());
202  pClus->setSegIndex(segInd);
203 }
204 
206  Int_t sector = pSeg->getSec();
207  HMdcSizesCellsSec& fSCSec=(*pSizesCells)[sector];
208  if(&fSCSec==0) return 0;
209  Int_t seg = pSeg->getIOSeg();
210  HMdcSizesCellsMod* pSCMod1=&(fSCSec[seg*2]);
211  HMdcSizesCellsMod* pSCMod2=&(fSCSec[seg*2+1]);
212  if(pSCMod1==0 && pSCMod2==0) return 0;
213  if(pSCMod2==0) pSCMod2=pSCMod1;
214  else if(pSCMod1==0) pSCMod1=pSCMod2;
215  locClus.set(2,sector,seg);
216  Int_t index;
217  HMdcClus* pClus = (HMdcClus*)pCatMdcClus->getNewSlot(locClus,&index);
218  if(!pClus) {
219  Warning("getClusterSlot","Sec.%i Segment %i No slot HMdcClus available",
220  sector+1,seg+1);
221  return 0;
222  }
223  pClus=new(pClus) HMdcClus();
224 
225  pClus->setSecSegInd(sector,seg,index);
226 
227  HMdcSizesCellsLayer& fSCLay1=(*pSCMod1)[0];
228  HMdcSizesCellsLayer& fSCLay2=(*pSCMod2)[5];
229  trackLine.setFirstPlane(&fSCLay1);
230  trackLine.setSecondPlane(&fSCLay2);
231  trackLine.setSegmentLine(pSeg->getZ(),pSeg->getR(),
232  pSeg->getTheta(),pSeg->getPhi());
233 
234  pClus->setTarget(trackLine.x1(),0.,trackLine.y1(),0.,trackLine.z1(),0.);
235  pClus->setPrPlane(fSCLay2.A(),fSCLay2.B(),fSCLay2.D());
236  pClus->setXY(trackLine.x2(),0.,trackLine.y2(),0.);
237  pClus->setOwnIndex(index);
238  return pClus;
239 }
Int_t getTrkCandInd(void) const
Definition: hmetamatch2.h:138
Bool_t initContainer(void)
Double_t B() const
Definition: hmdcgeomobj.h:125
Int_t getSystem(void) const
Definition: hmetamatch2.cc:239
void setXY(Float_t xl, Float_t errx, Float_t yl, Float_t erry)
Definition: hmdcclus.h:96
Double_t y2(void) const
Definition: hmdcgeomobj.h:254
HMdcSizesCells * pSizesCells
Int_t getIOSeg(void) const
Definition: hmdcseg.h:139
void setTarget(Float_t xl, Float_t ex, Float_t yl, Float_t ey, Float_t zl, Float_t ez)
Definition: hmdcclus.h:108
static HMdcGetContainers * getObject()
void setTypeClFinder(Int_t type)
Definition: hmdcclus.h:94
Float_t getChi2(void) const
Definition: hmdcseg.h:134
Int_t getSeg1Ind(void) const
Definition: hmdctrkcand.h:118
HCategory * pCatSplineTrack
virtual Int_t execute(void)
Char_t getLevelClFinding(void)
Definition: hmdcclusinf.h:80
HCategory * pCatMdcHit
HIterator * iterMetaMatch
Char_t getPolarity(void) const
Definition: hbasetrack.h:74
HCategory * pCatMdcClus
HEvent *& getCurrentEvent(void)
Definition: hades.cc:422
Double_t z1(void) const
Definition: hmdcgeomobj.h:252
Int_t n
Float_t getTheta(void) const
Definition: hmdcseg.h:103
Int_t setTime(Int_t lay, Int_t cell, UChar_t time)
static HMdcSizesCells * getObject(void)
virtual Bool_t init(void)
Int_t getHitInd(Int_t i) const
Definition: hmdcseg.h:166
void setClusIndex(Int_t ind)
Definition: hmdcseg.h:88
Float_t getBeta(void) const
Definition: hbasetrack.h:76
Double_t x2(void) const
Definition: hmdcgeomobj.h:253
const Cat_t catMdcHit
Definition: hmdcdef.h:6
Double_t x1(void) const
Definition: hmdcgeomobj.h:250
virtual Bool_t reinit(void)
void setSecondPlane(HMdcPlane *sp)
Definition: hmdcgeomobj.h:225
Double_t D() const
Definition: hmdcgeomobj.h:127
Float_t getPhi(void) const
Definition: hmdcseg.h:104
#define ERROR_msg(det, text)
Definition: hmessagemgr.h:36
const Cat_t catMetaMatch
Definition: hmdctrackgdef.h:7
Double_t y1(void) const
Definition: hmdcgeomobj.h:251
void setSegIndex(Int_t si)
Definition: hmdcclus.h:130
void setMinCl(Int_t m1or3, Int_t m2or4)
Definition: hmdcclus.h:86
void setFirstPlane(HMdcPlane *fp)
Definition: hmdcgeomobj.h:224
void setSecSegInd(Int_t sc, Int_t sg, Int_t ind)
Definition: hmdcclus.h:84
HCategory * pCatMdcSeg
Int_t getCell(Int_t layer, Int_t idx)
Double_t A() const
Definition: hmdcgeomobj.h:124
Hades * gHades
Definition: hades.cc:1213
Float_t getZ(void) const
Definition: hmdcseg.h:101
Int_t getSeg2Ind(void) const
Definition: hmdctrkcand.h:119
UChar_t getNCandForIPU(void) const
Definition: hmetamatch2.h:209
Short_t getOwnIndex(void) const
Definition: hmdcclus.h:137
void setSegmentLine(Double_t r, Double_t z, Double_t theta, Double_t phi)
Definition: hmdcgeomobj.cc:531
HCategory * pCatMetaMatch
void fillCluster(Short_t segInd)
UChar_t getNCandForRich(void) const
Definition: hmetamatch2.h:208
ClassImp(HMdcClustFromSeg) HMdcClustFromSeg
Int_t getSplineInd(void) const
Definition: hmetamatch2.h:185
void setMod(Int_t m)
Definition: hmdcclus.h:81
Float_t getP(void) const
Definition: hbasetrack.h:69
Int_t getSec(void) const
Definition: hmdcseg.h:138
HMdcLineParam trackLine
void initCut(HParamList *cut)
HCategory * pCatMdcClusInf
const Cat_t catMdcSeg
Definition: hmdcdef.h:10
Int_t getNCells(Int_t layer)
virtual HCategory * getCategory(Cat_t aCat)=0
void setOwnIndex(Int_t ind)
Definition: hmdcclus.h:83
Short_t getClusInfIndex(void)
Definition: hmdchit.h:137
Float_t getR(void) const
Definition: hmdcseg.h:102
HCategory * getCatMdcClusInf(Bool_t create=kFALSE)
HCategory * getCatMdcTrkCand(Bool_t create=kFALSE)
Bool_t fill(const Text_t *, Text_t *, const Int_t)
Definition: hparamlist.cc:561
void setPrPlane(Float_t a, Float_t b, Float_t d)
Definition: hmdcclus.h:113
HMdcClus * getClusterSlot(HMdcSeg *pSeg)
HCategory * getCatMdcClus(Bool_t create=kFALSE)
HCategory * pCatMdcTrkCand
virtual Bool_t finalize(void)
const Cat_t catSplineTrack
Definition: hmdctrackgdef.h:6
Int_t getSignId(Int_t layer, Int_t idx)