HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hparticlecandfiller.cc
Go to the documentation of this file.
1 #include "hparticlecandfiller.h"
2 #include "hcategorymanager.h"
3 #include "hparticletool.h"
4 #include "hparticleconstants.h"
5 #include "hgeomvolume.h"
6 //---------- detector def ----------
7 #include "hgeantdef.h"
8 #include "hparticledef.h"
9 #include "hmdcdef.h"
10 #include "hmdctrackddef.h"
11 #include "hmdctrackgdef.h"
12 #include "tofdef.h"
13 #include "showerdef.h"
14 #include "richdef.h"
15 #include "rpcdef.h"
16 #include "emcdef.h"
17 //---------- hades etc -------------
18 #include "hades.h"
19 #include "hiterator.h"
20 #include "hcategory.h"
21 #include "hlinearcategory.h"
22 #include "hlocation.h"
23 #include "hruntimedb.h"
24 #include "hspectrometer.h"
25 #include "hdetector.h"
26 #include "hevent.h"
27 //--------- data objects -----------
28 #include "hmetamatch2.h"
29 #include "hmdcseg.h"
30 #include "hmdcsegsim.h"
31 #include "hmdctrkcand.h"
32 #include "hsplinetrack.h"
33 #include "hrktrackB.h"
34 #include "hshowerhitsim.h"
35 #include "htofhit.h"
36 #include "htofcluster.h"
37 #include "hrichhit.h"
38 #include "hrichhitsim.h"
39 #include "hrpccluster.h"
40 #include "hrpcclustersim.h"
41 
42 #include "hparticlecand.h"
43 #include "hparticlecandsim.h"
44 #include "hparticlemdc.h"
45 #include "hparticlecandfillerpar.h"
46 #include "hrich700digipar.h"
47 #include "htofwalkpar.h"
48 #include "hparticleanglecor.h"
49 
50 #include "hmdclayer.h"
51 
52 #include "TVector2.h"
53 
54 #include <iostream>
55 #include <iomanip>
56 #include <stdlib.h>
57 #include <algorithm>
58 #include <numeric>
59 
60 using namespace std;
61 using namespace Particle;
62 
63 //_HADES_CLASS_DESCRIPTION
64 ///////////////////////////////////////////////////////////////////////////////
65 //
66 // HParticleCandFiller
67 //
68 // This tasks loops over HMetaMatch2 objects and fills
69 // the output objects HParticleCand. The taks detects
70 // if it is running in simulation or read data mode automatically
71 // by the existence of the HGeantKine category in the input file.
72 // Different filter options can be applied (see description of
73 // setConditions() ).
74 ///////////////////////////////////////////////////////////////////////////////
75 
77 
78 HParticleCandFiller::HParticleCandFiller (const Option_t par[]):
80 {
81  // Constructor calls the constructor of class HReconstructor without the name
82  // and the title as arguments. Optional parameters are explained in setConditions().
83 
84  initVars ();
85  setConditions(par);
86 }
87 
89  const Text_t * title,
90  const Option_t par[]):
91 HReconstructor (name, title)
92 {
93  // Constructor calls the constructor of class HReconstructor with the name
94  // and the title as arguments. Optional parameters are explained in setConditions().
95 
96  initVars ();
97  setConditions(par);
98 }
99 
101 {
102  // destructor deletes the iterator
103  if(fMetaMatchIter) delete fMetaMatchIter;
104 
105 }
106 void HParticleCandFiller::setConditions(const Option_t par[])
107 {
108  // Set parameters by names. Options (may be separated by comma or blank chars),
109  // By default (no option specified) all values will be kFALSE:
110  // GOODSEG0 - skip the track when inner seg chi2 < 0
111  // GOODSEG1 - skip the track when outer seg chi2 < 0
112  // GOODMETA - skip the track when no META was fired
113  // GOODRK - skip the track when RK chi2 < 0
114  // KALMAN - switch from RK to Kalman for mom reco
115  // GOODLEPTON - skip all candidates which have no RICH matching
116  // DEBUG - write out candidate objects for debugging
117  // NORICHALIGN- dont align rich phi and theta
118  // NORICHVERTEXCORR- dont do vertex correction in ring sorting
119  // NOMETAQANORM - dont do normaization of RK dx
120  // NOGEANTACCEPTANCE - dont fill geant acceptance and crop bits
121  // NOFAKE - skip fake marked candidates
122  // ACCEPTFAKE - do not skip fake marked candidates
123 
124  TString s = par;
125  s.ToUpper();
126 
127  fbgoodSeg0 = (strstr(s.Data(), "GOOGSEG0") != NULL);
128  fbgoodSeg1 = (strstr(s.Data(), "GOODSEG1") != NULL);
129  fbgoodMeta = (strstr(s.Data(), "GOODMETA") != NULL);
130  fbgoodRK = (strstr(s.Data(), "GOODRK") != NULL);
131  fbgoodLepton = (strstr(s.Data(), "GOODLEPTON")!= NULL);
132  fmomSwitch = (strstr(s.Data(), "KALMAN") != NULL) ? Particle::kMomKalman : Particle::kMomRK;
133  fbIsDebug = (strstr(s.Data(), "DEBUG") != NULL);
134  fbdoRichAlign= (strstr(s.Data(), "NORICHALIGN")!= NULL)? kFALSE : kTRUE;
135  fbdoRichVertexCorr = (strstr(s.Data(), "NORICHVERTEXCORR")!= NULL)? kFALSE : kTRUE;
136  fbdoMETAQANorm = (strstr(s.Data(), "NOMETAQANORM")!= NULL)? kFALSE : kTRUE;
137  fbdoMomentumCorr = (strstr(s.Data(), "NOMOMENTUMCORR")!= NULL)? kFALSE : kTRUE;
138  fbdoPathLengthCorr = (strstr(s.Data(), "NOPATHLENGTHCORR")!= NULL)? kFALSE : kTRUE;
139  fbdoGeantAcceptance= (strstr(s.Data(), "NOGEANTACCPETANCE")!= NULL)? kFALSE : kTRUE;
140  fbnoFake = (strstr(s.Data(), "NOFAKE") != NULL);
141  if(strstr(s.Data(), "ACCEPTFAKE")!= NULL)fbnoFake=kFALSE;
142 }
143 
145 {
146  // set internal variables to start values
147 
148  fCatMdcTrkCand = NULL;
149  fCatMetaMatch = NULL;
150 
151  fCatMdcSeg = NULL;
152  fCatTofHit = NULL;
153  fCatTofCluster = NULL;
154  fCatEmcCluster = NULL;
155  fCatShowerHit = NULL;
156  fCatRichHit = NULL;
157  fCatRpcCluster = NULL;
158  fCatSpline = NULL;
159  fCatRK = NULL;
160  fCatKalman = NULL;
161  fCatParticleCand = NULL;
162  fCatGeantKine = NULL;
163 
164  fMetaMatchIter = NULL;
165 
166  fCatParticleCand = NULL;
167  fCatParticleDebug= NULL;
168  fCatParticleMdc = NULL;
169 
170  fFillerPar = NULL;
171  fTofWalkPar = NULL;
172 
173 
174  fbIsSimulation = kFALSE;
175  fbIsDebug = kFALSE;
176  fbFillMdc = kFALSE;
177  fbgoodSeg0 = kFALSE;
178  fbgoodSeg1 = kFALSE;
179  fbgoodMeta = kFALSE;
180  fbgoodRK = kFALSE;
181  fbgoodLepton = kFALSE;
183  fsortSwitch = 0; // metaquality
184  fbdoRichAlign = kTRUE;
185  fbdoRichVertexCorr=kTRUE;
186  fbdoMETAQANorm =kTRUE;
187  fbdoMomentumCorr =kTRUE;
188  fbdoPathLengthCorr=kTRUE;
189  fbdoGeantAcceptance=kTRUE;
190  fbnoFake =kFALSE;
191 
193  fScaleGhostTrack = 0.1;
194  fScaleGoodTrack = 3.0;
195  fAngleCloseTrack = 15.;
196 
197  all_candidates.resize( 2000, 0 ); // increase capacity to avoid later copying of data
198  all_candidates.clear(); // capacity is still large
199 
201 }
202 
203 
204 
206 {
207  // Get Categories and Parameters etc....
208 
209  HEvent *ev = gHades->getCurrentEvent ();
210  if (ev) {
211 
213  if (fCatGeantKine) { fbIsSimulation = kTRUE; }
214  else { fbIsSimulation = kFALSE;}
215 
216  if(!(fCatMetaMatch = HCategoryManager::getCategory(catMetaMatch ,kFALSE,"catMetaMatch" ))) return kFALSE;
217  if(!(fCatMdcTrkCand = HCategoryManager::getCategory(catMdcTrkCand,kFALSE,"catMdcTrkCand"))) return kFALSE;
218  if(!(fCatMdcSeg = HCategoryManager::getCategory(catMdcSeg ,kFALSE,"catMdcSeg" ))) return kFALSE;
219 
220  fCatTofHit = HCategoryManager::getCategory(catTofHit ,kTRUE,"catTofHit");
224  fCatSpline = HCategoryManager::getCategory(catSplineTrack ,kTRUE,"catSplineTrack");
227 
230 
231  if (fbIsSimulation) {
232  fCatParticleCand = HCategoryManager::addCategory(catParticleCand,"HParticleCandSim",5000,"Particle");
233  } else {
234  fCatParticleCand = HCategoryManager::addCategory(catParticleCand,"HParticleCand" ,5000,"Particle");
235  }
236  if (!fCatParticleCand) { return kFALSE; }
237 
238  if (fbIsDebug) {
239  fCatParticleDebug = HCategoryManager::addCategory(catParticleDebug,"candidate",5000,"Particle",kTRUE);
240  if (!fCatParticleDebug) { return kFALSE; }
241  }
242  if (fbFillMdc) {
243  fCatParticleMdc = HCategoryManager::addCategory(catParticleMdc,"HParticleMdc",5000,"Particle",kTRUE);
244  if (!fCatParticleMdc) { return kFALSE; }
245  }
246 
247  Int_t beamID = gHades->getBeamTimeID();
248 
249  if(beamID == Particle::kUnknownBeam) {
250  Error ("init()", "gHades->getBeamTimeID() == Particle::kUnknownBeam! Not set properly, use Particle::eBeamTime definition (hparticledef.h), RICH correction will depend on it.");
251  HParticleConstants::printSpace("Particle::eBeam");
252  return kFALSE;
253  } else {
254  if(beamID == Particle::kApr12 ||
255  beamID == Particle::kJul14 ||
257  else fRichCorrectionVersion = 1;
258  Info ("init()", "gHades->getBeamTimeID() == %i !, use Particle::eBeamTime definition (hparticledef.h) to set RICH correction properly.",beamID);
259  HParticleConstants::printSpace("Particle::eBeam");
260  }
261 
262 
263  fMetaMatchIter = (HIterator*) fCatMetaMatch->MakeIterator("native");
264  if(!fMetaMatchIter){
265  Error ("init()", "Retrieve ZERO pointer for MetaMatch iter!");
266  return kFALSE;
267  }
268 
269  fFillerPar =(HParticleCandFillerPar*) gHades->getRuntimeDb()->getContainer("ParticleCandFillerPar");
270  if(!fFillerPar) {
271  Error ("init()", "Retrieve ZERO pointer for HParticleCandFillerPar!");
272  return kFALSE;
273  }
274 
276  if(!fRich700DigiPar) {
277  Error ("init()", "Retrieve ZERO pointer for HRich700DigiPar!");
278  return kFALSE;
279  }
280 
282  if(!fTofWalkPar) {
283  Error ("init()", "Retrieve ZERO pointer for HTofWalkPar!");
284  return kFALSE;
285  }
286 
288  if(!fSizesCells)
289  {
290  Error ("init()", "Retrieve ZERO pointer for HMdcSizesCells!");
291  return kFALSE;
292  }
293 
294  } else {
295  Error ("init()", "Retrieve ZERO pointer for fMetaMatchIter!");
296  return kFALSE;
297  }
298  return kTRUE;
299 }
300 
302 {
303  Bool_t result = fSizesCells->initContainer();
304 
305  cropLay = 0;
306  if(result){
307  cropLay = new HMdcLayer();
308 
312  //---------------------------------------------------
313 
314  }
315 
316  return result;
317 }
318 
320 {
321  // loop on HMetaMatch2 objects and fill an intermediate
322  // working candidate object. Selections are performed on this
323  // objects. All objects which are flagged to be used are
324  // transported to the output HParticleCand category.
325  clearVector();
326 
327  HMetaMatch2* metaMatch = 0;
328  fMetaMatchIter->Reset();
329  while( (metaMatch = (HMetaMatch2*)fMetaMatchIter->Next()) != 0){
330  fillCand(metaMatch);
331  }
334  fillOutput();
335  clearVector();
337  return 0;
338 }
339 
341 {
342  // jobs to be done after last event is finished.
343  return kTRUE;
344 }
345 
347 {
348  // returns the best rich slot in HMetaMatch2
349  // corrections for RICH phi+theta are taken into
350  // account
351 
352 
353  if(!meta || !mdcSeg1 || !fCatRichHit || !fFillerPar) return -1;
354 
355  Int_t nrich = meta->getNCandForRich();
356  Int_t slot = -1;
357  if(nrich >= 1){
358  Float_t zVertex = gHades->getCurrentEvent()->getHeader()->getVertexZ();
359  HVertex& vertexClust = gHades->getCurrentEvent()->getHeader()->getVertexCluster();
360 
361  Float_t chi2Clust = vertexClust.getChi2(); // -1 = no vertex found , 0 = ok
362 
363 
364  Double_t qabest = 100000;
365  Double_t qa = 0;
366 
367  HRichHit* richHit = 0;
368  for(Int_t i = 0; i < nrich; i ++){
369 
370  richHit = HCategoryManager::getObject(richHit ,fCatRichHit ,meta->getARichInd(i));
371 
372  Float_t richCorr = 0.;
373  Float_t theta = richHit->getTheta();
374  Float_t phi = richHit->getPhi(); // deg , lab
375 
376  if(fbdoRichVertexCorr && chi2Clust > -0.5 && zVertex > -999.9F && zVertex < 100 )
377  {
378  if(fRichCorrectionVersion == 0) {
379  richCorr = fFillerPar->getRichCorr(zVertex,theta,phi); // vertex z [mm] . theta [deg]
380  theta += richCorr; // first correct z position emission
381  } else {
382  Float_t x = (Float_t)richHit->getRich700CircleCenterX();
383  Float_t y = (Float_t)richHit->getRich700CircleCenterY();
384  fRich700DigiPar->getInterpolatedSectorThetaPhi(x,y,zVertex, theta,phi); // first correct z position emission
385  }
386  }
387 
388  Float_t thetaCor = theta;
389  Float_t phiCor = phi;
390 
391  if(!fbIsSimulation && fbdoRichAlign){ // only align for real data
392 
393  if(fRichCorrectionVersion == 0) {
394  Double_t thcor = theta;
395  Double_t phcor = phi;
396  HParticleAngleCor::alignRichRing(theta,phi,thcor,phcor); // apr12 - aug14 second correct theta/phi
397  thetaCor = (Float_t)thcor;
398  phiCor = (Float_t)phcor;
399 
400  } else {
401  fRich700DigiPar->getAlignedThetaPhi(theta,phi,thetaCor,phiCor); // mar19 and later
402  }
403  }
404  qa = HParticleTool::calcRichQA(mdcSeg1, thetaCor, phiCor); // richTheta and richPhi in deg in lab system
405 
406 
407  if(qa >= 0 && qa < qabest) {
408  slot = i;
409  qabest = qa;
410  }
411 
412  } // end richhit cand
413  }
414 
415  return slot;
416 
417 }
418 
419 
420 void HParticleCandFiller::fillCandNoMeta(Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num)
421 {
422 
423  HMdcTrkCand* mdcTrkCand = 0;
424  HMdcSeg* mdcSeg1 = 0;
425  HMdcSeg* mdcSeg2 = 0;
426  HTofCluster* tofClst = 0;
427  HTofHit* tofHit1 = 0;
428  HTofHit* tofHit2 = 0;
429  HShowerHit* showerHit = 0;
430  HEmcCluster* emcClst = 0;
431  HRpcCluster* rpcClst = 0;
432  HRichHit* richHit = 0;
433  HSplineTrack* spline = 0;
434  HRKTrackB* rk = 0;
435  HKalTrack* kal = 0;
436 
437  cand.rkSuccess = rkSuccess;
438  cand.nCand = num;
439  //--------------------------------------------------------------------
440  // fill common info
441  cand .fillMeta(meta);
442  cand.mdctrk .fillMeta(meta);
443  cand.spline .fillMeta(meta);
444 
445  mdcTrkCand = HCategoryManager::getObject(mdcTrkCand,fCatMdcTrkCand,cand.mdctrk.ind);
446  if(mdcTrkCand){
447  cand.seg1.ind = mdcTrkCand->getSeg1Ind();
448  cand.seg2.ind = mdcTrkCand->getSeg2Ind();
449  }
450  mdcSeg1 = HCategoryManager::getObject(mdcSeg1 ,fCatMdcSeg ,cand.seg1.ind);
451  mdcSeg2 = HCategoryManager::getObject(mdcSeg2 ,fCatMdcSeg ,cand.seg2.ind);
452  spline = HCategoryManager::getObject(spline ,fCatSpline ,cand.spline.ind);
453 
454  Int_t slot = findBestRich(meta,mdcSeg1);
455  cand.richhit.fillMeta(meta,slot); // set richindex : only best matched rich ?
456  richHit = HCategoryManager::getObject(richHit ,fCatRichHit ,cand.richhit.ind);
457 
458 
459  cand.mdctrk .fill(mdcTrkCand);
460  cand.seg1 .fill(mdcSeg1);
461  cand.seg2 .fill(mdcSeg2);
462  cand.spline .fill(spline);
463  cand.richhit .fill(richHit); // get all rich vars
464  //--------------------------------------------------------------------
465 
466  cand.system = -1;
467  cand.selectTof = kNoUse;
468  cand.usedMeta = kNoUse;
469  cand.rk.selectTof = kNoUse;
470  cand.rk.usedMeta = kNoUse;
471  cand.kal.selectTof = kNoUse;
472  cand.kal.usedMeta = kNoUse;
473 
474  cand.objects.reset();
475  cand.objects.pMdcTrk = mdcTrkCand;
476  cand.objects.pSeg1 = (HMdcSegSim* ) mdcSeg1;
477  cand.objects.pSeg2 = (HMdcSegSim* ) mdcSeg2;
478  cand.objects.pRichHit = (HRichHitSim*) richHit;
479  cand.objects.pTofClst = (HTofClusterSim*) tofClst;
480  cand.objects.pTofHit1 = (HTofHitSim*) tofHit1;
481  cand.objects.pTofHit2 = (HTofHitSim*) tofHit2;
482  cand.objects.pRpcClst = (HRpcClusterSim*) rpcClst;
483  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
484  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
485  cand.objects.pSpline = spline;
486 
487  if (fmomSwitch == Particle::kMomRK ) {
488  cand.rk.ind = meta->getRungeKuttaInd();
490  cand.rk.fill(rk);
491  cand.objects.pRk = rk;
492  }
493  else if(fmomSwitch == Particle::kMomKalman) {
494  cand.kal.ind = meta->getKalmanFilterInd();
496  cand.kal.fill(kal);
497  cand.objects.pKalman = kal;
498  }
499  else {Error("fillCandNoMeta","Unknown momentum option");}
500 
501 }
502 
503 void HParticleCandFiller::fillCandTof(Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num, Int_t n)
504 {
505  HMdcTrkCand* mdcTrkCand = 0;
506  HMdcSeg* mdcSeg1 = 0;
507  HMdcSeg* mdcSeg2 = 0;
508  HTofCluster* tofClst = 0;
509  HTofHit* tofHit1 = 0;
510  HTofHit* tofHit2 = 0;
511  HShowerHit* showerHit = 0;
512  HEmcCluster* emcClst = 0;
513  HRpcCluster* rpcClst = 0;
514  HRichHit* richHit = 0;
515  HSplineTrack* spline = 0;
516  HRKTrackB* rk = 0;
517  HKalTrack* kal = 0;
518 
519  cand.rkSuccess = rkSuccess;
520  cand.nCand = num;
521  //--------------------------------------------------------------------
522  // fill common info
523  cand .fillMeta(meta);
524  cand.mdctrk .fillMeta(meta);
525  cand.spline .fillMeta(meta);
526 
527  mdcTrkCand = HCategoryManager::getObject(mdcTrkCand,fCatMdcTrkCand,cand.mdctrk.ind);
528  if(mdcTrkCand){
529  cand.seg1.ind = mdcTrkCand->getSeg1Ind();
530  cand.seg2.ind = mdcTrkCand->getSeg2Ind();
531  }
532  mdcSeg1 = HCategoryManager::getObject(mdcSeg1 ,fCatMdcSeg ,cand.seg1.ind);
533  mdcSeg2 = HCategoryManager::getObject(mdcSeg2 ,fCatMdcSeg ,cand.seg2.ind);
534  spline = HCategoryManager::getObject(spline ,fCatSpline ,cand.spline.ind);
535 
536  Int_t slot = findBestRich(meta,mdcSeg1);
537  cand.richhit.fillMeta(meta,slot); // set richindex : only best matched rich ?
538  richHit = HCategoryManager::getObject(richHit ,fCatRichHit ,cand.richhit.ind);
539 
540 
541  cand.mdctrk .fill(mdcTrkCand);
542  cand.seg1 .fill(mdcSeg1);
543  cand.seg2 .fill(mdcSeg2);
544  cand.spline .fill(spline);
545  cand.richhit .fill(richHit); // get all rich vars
546  //--------------------------------------------------------------------
547 
548  //--------------------------------------------------------------------
549  // fill META hits
550  cand.tof[kTofClst].fillMeta(meta,n,kTofClst);
551  cand.tof[kTofHit1].fillMeta(meta,n,kTofHit1);
552  cand.tof[kTofHit2].fillMeta(meta,n,kTofHit2);
553 
554  tofClst = HCategoryManager::getObject(tofClst ,fCatTofCluster,cand.tof[kTofClst].ind);
555  tofHit1 = HCategoryManager::getObject(tofHit1 ,fCatTofHit ,cand.tof[kTofHit1].ind);
556  tofHit2 = HCategoryManager::getObject(tofHit2 ,fCatTofHit ,cand.tof[kTofHit2].ind);
557 
558  cand.tof[kTofClst].fill(tofClst,kTofClst);
559  cand.tof[kTofHit1].fill(tofHit1,kTofHit1);
560  cand.tof[kTofHit2].fill(tofHit2,kTofHit2);
561  //--------------------------------------------------------------------
562 
563  //--------------------------------------------------------------------
564  // define system for this candidate
565  cand.system = 1;
566  cand.selectTof = kNoUse;
567  cand.usedMeta = kNoUse;
568  cand.rk.usedMeta = kNoUse;
569  cand.rk.selectTof = kNoUse;
570  cand.kal.usedMeta = kNoUse;
571  cand.kal.selectTof = kNoUse;
572  //--------------------------------------------------------------------
573 
574  //--------------------------------------------------------------------
575  // make decision what to fill
576  // for rk. For different cases some preselection
577  // has to be done
578 
579 
580  //--------------------------------------------------------------------
581  // selection from Meta
582  Float_t tofqua[3] = {-1,-1,-1};
583  Float_t minTof = 1e37;
584  Int_t minIndMeta = kNoUse;
585 
586  if(tofClst||tofHit1||tofHit2) {
587 
588  // find best match TOF
589  for(Int_t i = 0; i < 3; i ++) {
590  tofqua[i] = cand.tof[i].quality;
591  if (tofqua[i] >= 0 && tofqua[i] < minTof){ minTof = tofqua[i]; minIndMeta = i;}
592  }
593  cand.selectTof = minIndMeta; // best TOF
594  }
595  cand.usedMeta = minIndMeta;
596  //--------------------------------------------------------------------
597 
598  cand.objects.reset();
599 
600  cand.objects.pMdcTrk = mdcTrkCand;
601  cand.objects.pSeg1 = (HMdcSegSim* ) mdcSeg1;
602  cand.objects.pSeg2 = (HMdcSegSim* ) mdcSeg2;
603  cand.objects.pRichHit = (HRichHitSim*) richHit;
604  cand.objects.pTofClst = (HTofClusterSim*) tofClst;
605  cand.objects.pTofHit1 = (HTofHitSim*) tofHit1;
606  cand.objects.pTofHit2 = (HTofHitSim*) tofHit2;
607  cand.objects.pRpcClst = (HRpcClusterSim*) rpcClst;
608  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
609  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
610  cand.objects.pSpline = spline;
611 
612  //--------------------------------------------------------------------
613  if(!rkSuccess){ // RK failed
614  cand.rk.ind = meta->getRungeKuttaInd();
615  cand.rk.usedMeta = kNoUse;
616  cand.kal.ind = meta->getKalmanFilterInd();
617  cand.kal.usedMeta = kNoUse;
618 
619  } else {
621  {
622  //--------------------------------------------------------------------
623  // vars for tof selection with rk
624  HRKTrackB* rkhit [3] = { 0, 0, 0};
625  Float_t rkqua [3] = {-1,-1,-1};
626  Float_t min = 1e37;
627  Int_t minInd = kNoUse;
628 
629  //--------------------------------------------------------------------
630 
631  //--------------------------------------------------------------------
632  // select tof hits
633  // Strategy : select by best quality of rk matching
634  rkhit[kTofClst] = tofClst ? HCategoryManager::getObject(rkhit[kTofClst],fCatRK,meta->getRungeKuttaIndTofClst(n)): 0 ;
635  rkhit[kTofHit1] = tofHit1 ? HCategoryManager::getObject(rkhit[kTofHit1],fCatRK,meta->getRungeKuttaIndTofHit1(n)): 0 ;
636  rkhit[kTofHit2] = tofHit2 ? HCategoryManager::getObject(rkhit[kTofHit2],fCatRK,meta->getRungeKuttaIndTofHit2(n)): 0 ;
637 
638  if(fsortSwitch==0){
639  if(tofClst && rkhit[kTofClst]) { rkqua[kTofClst] = rkhit[kTofClst]->getQualityTof();}
640  if(tofHit1 && rkhit[kTofHit1]) { rkqua[kTofHit1] = rkhit[kTofHit1]->getQualityTof();}
641  if(tofHit2 && rkhit[kTofHit2]) { rkqua[kTofHit2] = rkhit[kTofHit2]->getQualityTof();}
642  } else if (fsortSwitch==1) {
643  if(tofClst && rkhit[kTofClst]) { rkqua[kTofClst] = rkhit[kTofClst]->getMetaRadius();}
644  if(tofHit1 && rkhit[kTofHit1]) { rkqua[kTofHit1] = rkhit[kTofHit1]->getMetaRadius();}
645  if(tofHit2 && rkhit[kTofHit2]) { rkqua[kTofHit2] = rkhit[kTofHit2]->getMetaRadius();}
646  } else { Error("fillCandTof","Unknown sort option");}
647 
648  // find best match
649  for(Int_t i = 0; i < 3; i ++) {
650  if (rkqua[i] > 1e37 ) rkqua[i] = 1e36;
651  if (rkqua[i] >= 0 && rkqua[i] < min){ min = rkqua[i]; minInd = i;}
652  }
653  cand.rk.selectTof = minInd; // best TOF
654  //--------------------------------------------------------------------
655 
656  //--------------------------------------------------------------------
657 
658  if (minInd == kTofClst) { cand.rk.ind = meta->getRungeKuttaIndTofClst(n); cand.rk.usedMeta = kTofClst;}
659  else if(minInd == kTofHit1) { cand.rk.ind = meta->getRungeKuttaIndTofHit1(n); cand.rk.usedMeta = kTofHit1;}
660  else if(minInd == kTofHit2) { cand.rk.ind = meta->getRungeKuttaIndTofHit2(n); cand.rk.usedMeta = kTofHit2;}
661  else {
662  Error("fillCand()","(system == 1) No valid rk object!");
663  }
664  //--------------------------------------------------------------------
665 
666  }
667  else if(fmomSwitch == Particle::kMomKalman)
668  {
669  //--------------------------------------------------------------------
670  // vars for tof selection with rk
671  HKalTrack* rkhit [3] = { 0, 0, 0};
672  Float_t rkqua [3] = {-1,-1,-1};
673  Float_t min = 1e37;
674  Int_t minInd = kNoUse;
675 
676  //--------------------------------------------------------------------
677 
678  //--------------------------------------------------------------------
679  // select tof hits
680  // Strategy : select by best quality of rk matching
681  rkhit[kTofClst] = tofClst ? HCategoryManager::getObject(rkhit[kTofClst],fCatKalman,meta->getKalmanFilterIndTofClst(n)): 0 ;
682  rkhit[kTofHit1] = tofHit1 ? HCategoryManager::getObject(rkhit[kTofHit1],fCatKalman,meta->getKalmanFilterIndTofHit1(n)): 0 ;
683  rkhit[kTofHit2] = tofHit2 ? HCategoryManager::getObject(rkhit[kTofHit2],fCatKalman,meta->getKalmanFilterIndTofHit2(n)): 0 ;
684 
685  if(fsortSwitch==0){
686  if(tofClst && rkhit[kTofClst]) { rkqua[kTofClst] = rkhit[kTofClst]->getQualityTof();}
687  if(tofHit1 && rkhit[kTofHit1]) { rkqua[kTofHit1] = rkhit[kTofHit1]->getQualityTof();}
688  if(tofHit2 && rkhit[kTofHit2]) { rkqua[kTofHit2] = rkhit[kTofHit2]->getQualityTof();}
689  } else if(fsortSwitch==1){
690  if(tofClst && rkhit[kTofClst]) { rkqua[kTofClst] = rkhit[kTofClst]->getMetaRadius();}
691  if(tofHit1 && rkhit[kTofHit1]) { rkqua[kTofHit1] = rkhit[kTofHit1]->getMetaRadius();}
692  if(tofHit2 && rkhit[kTofHit2]) { rkqua[kTofHit2] = rkhit[kTofHit2]->getMetaRadius();}
693  } else { Error("fillCandTof","Unknown sort option");}
694  // find best match
695  for(Int_t i = 0; i < 3; i ++) {
696  if (rkqua[i] > 1e37 ) rkqua[i] = 1e36;
697  if (rkqua[i] >= 0 && rkqua[i] < min){ min = rkqua[i]; minInd = i;}
698  }
699  cand.kal.selectTof = minInd; // best TOF
700  //--------------------------------------------------------------------
701 
702  //--------------------------------------------------------------------
703 
704  if (minInd == kTofClst) { cand.kal.ind = meta->getKalmanFilterIndTofClst(n); cand.kal.usedMeta = kTofClst;}
705  else if(minInd == kTofHit1) { cand.kal.ind = meta->getKalmanFilterIndTofHit1(n); cand.kal.usedMeta = kTofHit1;}
706  else if(minInd == kTofHit2) { cand.kal.ind = meta->getKalmanFilterIndTofHit2(n); cand.kal.usedMeta = kTofHit2;}
707  else {
708  Error("fillCand()","(system == 1) No valid kaltrack object!");
709  }
710  //--------------------------------------------------------------------
711 
712  } else {
713  Error("fillCandTof","Unknown momentum option");
714 
715  }
716  }
717 
719  {
720  //--------------------------------------------------------------------
722  cand.rk.fill(rk);
723  cand.objects.pRk = rk;
724  //--------------------------------------------------------------------
725  } else if(fmomSwitch == Particle::kMomKalman) {
726  //--------------------------------------------------------------------
728  cand.kal.fill(kal);
729  cand.objects.pKalman = kal;
730  //--------------------------------------------------------------------
731  } else {
732  Error("fillCandTof","Unknown momentum option");
733  }
734 
735 
736 
737 }
738 
739 void HParticleCandFiller::fillCandRpc(Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num, Int_t n)
740 {
741 
742  HMdcTrkCand* mdcTrkCand = 0;
743  HMdcSeg* mdcSeg1 = 0;
744  HMdcSeg* mdcSeg2 = 0;
745  HTofCluster* tofClst = 0;
746  HTofHit* tofHit1 = 0;
747  HTofHit* tofHit2 = 0;
748  HShowerHit* showerHit = 0;
749  HEmcCluster* emcClst = 0;
750  HRpcCluster* rpcClst = 0;
751  HRichHit* richHit = 0;
752  HSplineTrack* spline = 0;
753  HRKTrackB* rk = 0;
754  HKalTrack* kal = 0;
755 
756  cand.rkSuccess = rkSuccess;
757  cand.nCand = num;
758  //--------------------------------------------------------------------
759  // fill common info
760  cand .fillMeta(meta);
761  cand.mdctrk .fillMeta(meta);
762  cand.spline .fillMeta(meta);
763 
764  mdcTrkCand = HCategoryManager::getObject(mdcTrkCand,fCatMdcTrkCand,cand.mdctrk.ind);
765  if(mdcTrkCand){
766  cand.seg1.ind = mdcTrkCand->getSeg1Ind();
767  cand.seg2.ind = mdcTrkCand->getSeg2Ind();
768  }
769  mdcSeg1 = HCategoryManager::getObject(mdcSeg1 ,fCatMdcSeg ,cand.seg1.ind);
770  mdcSeg2 = HCategoryManager::getObject(mdcSeg2 ,fCatMdcSeg ,cand.seg2.ind);
771  spline = HCategoryManager::getObject(spline ,fCatSpline ,cand.spline.ind);
772 
773  Int_t slot = findBestRich(meta,mdcSeg1);
774  cand.richhit.fillMeta(meta,slot); // set richindex : only best matched rich ?
775  richHit = HCategoryManager::getObject(richHit ,fCatRichHit ,cand.richhit.ind);
776 
777 
778  cand.mdctrk .fill(mdcTrkCand);
779  cand.seg1 .fill(mdcSeg1);
780  cand.seg2 .fill(mdcSeg2);
781  cand.spline .fill(spline);
782  cand.richhit .fill(richHit); // get all rich vars
783  //--------------------------------------------------------------------
784 
785  //--------------------------------------------------------------------
786  // fill META hits
787  cand.rpcclst .fillMeta(meta,n); // automatic match between best RPC and SHOWER ?
788  rpcClst = HCategoryManager::getObject(rpcClst ,fCatRpcCluster,cand.rpcclst.ind);
789  cand.rpcclst .fill(rpcClst);
790  //--------------------------------------------------------------------
791 
792 
793  //--------------------------------------------------------------------
794  // define system for this candidate
795  cand.system = 0;
796  cand.selectTof = kRpcClst;
797  cand.usedMeta = kRpcClst;
798 
799  if(rkSuccess) {
800  cand.rk.usedMeta = kRpcClst;
801  cand.rk.selectTof = kRpcClst;
802  cand.rk.ind = meta->getRungeKuttaIndRpcClst(n);
803  cand.kal.usedMeta = kRpcClst;
804  cand.kal.selectTof = kRpcClst;
805  cand.kal.ind = meta->getKalmanFilterIndRpcClst(n);
806 
807  } else {
808  cand.rk.usedMeta = kNoUse;
809  cand.rk.selectTof = kNoUse;
810  cand.rk.ind = meta->getRungeKuttaInd();
811  cand.kal.usedMeta = kNoUse;
812  cand.kal.selectTof = kNoUse;
813  cand.kal.ind = meta->getKalmanFilterInd();
814  }
815  //--------------------------------------------------------------------
816 
817  cand.objects.reset();
818 
819  cand.objects.pMdcTrk = mdcTrkCand;
820  cand.objects.pSeg1 = (HMdcSegSim* ) mdcSeg1;
821  cand.objects.pSeg2 = (HMdcSegSim* ) mdcSeg2;
822  cand.objects.pRichHit = (HRichHitSim*) richHit;
823  cand.objects.pTofClst = (HTofClusterSim*) tofClst;
824  cand.objects.pTofHit1 = (HTofHitSim*) tofHit1;
825  cand.objects.pTofHit2 = (HTofHitSim*) tofHit2;
826  cand.objects.pRpcClst = (HRpcClusterSim*) rpcClst;
827  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
828  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
829  cand.objects.pSpline = spline;
830 
832  {
833  //--------------------------------------------------------------------
835  cand.rk.fill(rk);
836  cand.objects.pRk = rk;
837  //--------------------------------------------------------------------
838  } else if(fmomSwitch == Particle::kMomKalman) {
839  //--------------------------------------------------------------------
841  cand.kal.fill(kal);
842  cand.objects.pKalman = kal;
843  //--------------------------------------------------------------------
844  } else {
845  Error("fillCandRpc","Unknown momentum option");
846  }
847 
848 }
849 
850 void HParticleCandFiller::fillCandShower(Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num, Int_t n)
851 {
852  HMdcTrkCand* mdcTrkCand = 0;
853  HMdcSeg* mdcSeg1 = 0;
854  HMdcSeg* mdcSeg2 = 0;
855  HTofCluster* tofClst = 0;
856  HTofHit* tofHit1 = 0;
857  HTofHit* tofHit2 = 0;
858  HShowerHit* showerHit = 0;
859  HEmcCluster* emcClst = 0;
860  HRpcCluster* rpcClst = 0;
861  HRichHit* richHit = 0;
862  HSplineTrack* spline = 0;
863  HRKTrackB* rk = 0;
864  HKalTrack* kal = 0;
865 
866  cand.rkSuccess = rkSuccess;
867  cand.nCand = num;
868  //--------------------------------------------------------------------
869  // fill common info
870  cand .fillMeta(meta);
871  cand.mdctrk .fillMeta(meta);
872  cand.spline .fillMeta(meta);
873 
874  mdcTrkCand = HCategoryManager::getObject(mdcTrkCand,fCatMdcTrkCand,cand.mdctrk.ind);
875  if(mdcTrkCand){
876  cand.seg1.ind = mdcTrkCand->getSeg1Ind();
877  cand.seg2.ind = mdcTrkCand->getSeg2Ind();
878  }
879  mdcSeg1 = HCategoryManager::getObject(mdcSeg1 ,fCatMdcSeg ,cand.seg1.ind);
880  mdcSeg2 = HCategoryManager::getObject(mdcSeg2 ,fCatMdcSeg ,cand.seg2.ind);
881  spline = HCategoryManager::getObject(spline ,fCatSpline ,cand.spline.ind);
882 
883  Int_t slot = findBestRich(meta,mdcSeg1);
884  cand.richhit.fillMeta(meta,slot); // set richindex : only best matched rich ?
885  richHit = HCategoryManager::getObject(richHit ,fCatRichHit ,cand.richhit.ind);
886 
887 
888  cand.mdctrk .fill(mdcTrkCand);
889  cand.seg1 .fill(mdcSeg1);
890  cand.seg2 .fill(mdcSeg2);
891  cand.spline .fill(spline);
892  cand.richhit .fill(richHit); // get all rich vars
893  //--------------------------------------------------------------------
894 
895  //--------------------------------------------------------------------
896  // fill META hits
897  cand.showerhit .fillMeta(meta,n);
898  showerHit = HCategoryManager::getObject(showerHit ,fCatShowerHit ,cand.showerhit.ind);
899  cand.showerhit .fill(showerHit);
900  //--------------------------------------------------------------------
901 
902 
903  //--------------------------------------------------------------------
904  // define system for this candidate
905  cand.system = 0;
906  cand.selectTof = kShowerHit;
907  cand.usedMeta = kShowerHit;
908 
909  if(rkSuccess) {
910  cand.rk.usedMeta = kShowerHit;
911  cand.rk.selectTof = kShowerHit;
912  cand.rk.ind = meta->getRungeKuttaIndShowerHit(n);
913  cand.kal.usedMeta = kShowerHit;
914  cand.kal.selectTof = kShowerHit;
915  cand.kal.ind = meta->getKalmanFilterIndShowerHit(n);
916 
917  } else {
918  cand.rk.usedMeta = kNoUse;
919  cand.rk.selectTof = kNoUse;
920  cand.rk.ind = meta->getRungeKuttaInd();
921  cand.kal.usedMeta = kNoUse;
922  cand.kal.selectTof = kNoUse;
923  cand.kal.ind = meta->getKalmanFilterInd();
924  }
925  //--------------------------------------------------------------------
926 
927  cand.objects.reset();
928 
929  cand.objects.pMdcTrk = mdcTrkCand;
930  cand.objects.pSeg1 = (HMdcSegSim* ) mdcSeg1;
931  cand.objects.pSeg2 = (HMdcSegSim* ) mdcSeg2;
932  cand.objects.pRichHit = (HRichHitSim*) richHit;
933  cand.objects.pTofClst = (HTofClusterSim*) tofClst;
934  cand.objects.pTofHit1 = (HTofHitSim*) tofHit1;
935  cand.objects.pTofHit2 = (HTofHitSim*) tofHit2;
936  cand.objects.pRpcClst = (HRpcClusterSim*) rpcClst;
937  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
938  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
939  cand.objects.pSpline = spline;
940 
942  {
943  //--------------------------------------------------------------------
945  cand.rk.fill(rk);
946  cand.objects.pRk = rk;
947  //--------------------------------------------------------------------
948  } else if(fmomSwitch == Particle::kMomKalman) {
949  //--------------------------------------------------------------------
951  cand.kal.fill(kal);
952  cand.objects.pKalman = kal;
953  //--------------------------------------------------------------------
954  } else {
955  Error("fillCandRpc","Unknown momentum option");
956  }
957 
958 }
959 
960 void HParticleCandFiller::fillCandEmc(Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num, Int_t n)
961 {
962  HMdcTrkCand* mdcTrkCand = 0;
963  HMdcSeg* mdcSeg1 = 0;
964  HMdcSeg* mdcSeg2 = 0;
965  HTofCluster* tofClst = 0;
966  HTofHit* tofHit1 = 0;
967  HTofHit* tofHit2 = 0;
968  HShowerHit* showerHit = 0;
969  HEmcCluster* emcClst = 0;
970  HRpcCluster* rpcClst = 0;
971  HRichHit* richHit = 0;
972  HSplineTrack* spline = 0;
973  HRKTrackB* rk = 0;
974  HKalTrack* kal = 0;
975 
976  cand.rkSuccess = rkSuccess;
977  cand.nCand = num;
978  //--------------------------------------------------------------------
979  // fill common info
980  cand .fillMeta(meta);
981  cand.mdctrk .fillMeta(meta);
982  cand.spline .fillMeta(meta);
983 
984  mdcTrkCand = HCategoryManager::getObject(mdcTrkCand,fCatMdcTrkCand,cand.mdctrk.ind);
985  if(mdcTrkCand){
986  cand.seg1.ind = mdcTrkCand->getSeg1Ind();
987  cand.seg2.ind = mdcTrkCand->getSeg2Ind();
988  }
989  mdcSeg1 = HCategoryManager::getObject(mdcSeg1 ,fCatMdcSeg ,cand.seg1.ind);
990  mdcSeg2 = HCategoryManager::getObject(mdcSeg2 ,fCatMdcSeg ,cand.seg2.ind);
991  spline = HCategoryManager::getObject(spline ,fCatSpline ,cand.spline.ind);
992 
993  Int_t slot = findBestRich(meta,mdcSeg1);
994  cand.richhit.fillMeta(meta,slot); // set richindex : only best matched rich ?
995  richHit = HCategoryManager::getObject(richHit ,fCatRichHit ,cand.richhit.ind);
996 
997 
998  cand.mdctrk .fill(mdcTrkCand);
999  cand.seg1 .fill(mdcSeg1);
1000  cand.seg2 .fill(mdcSeg2);
1001  cand.spline .fill(spline);
1002  cand.richhit .fill(richHit); // get all rich vars
1003  //--------------------------------------------------------------------
1004 
1005  //--------------------------------------------------------------------
1006  // fill META hits
1007  cand.emcclst .fillMeta(meta,n);
1008  emcClst = HCategoryManager::getObject(emcClst ,fCatEmcCluster ,cand.emcclst.ind);
1009  cand.emcclst .fill(emcClst);
1010  //--------------------------------------------------------------------
1011 
1012 
1013  //--------------------------------------------------------------------
1014  // define system for this candidate
1015  cand.system = 0;
1016  cand.selectTof = kEmcClst;
1017  cand.usedMeta = kEmcClst;
1018 
1019  if(rkSuccess) {
1020  cand.rk.usedMeta = kEmcClst;
1021  cand.rk.selectTof = kEmcClst;
1022  cand.rk.ind = meta->getRungeKuttaIndEmcCluster(n);
1023  cand.kal.usedMeta = kShowerHit;
1024  cand.kal.selectTof = kShowerHit;
1025  cand.kal.ind = meta->getKalmanFilterIndEmcCluster(n);
1026 
1027  } else {
1028  cand.rk.usedMeta = kNoUse;
1029  cand.rk.selectTof = kNoUse;
1030  cand.rk.ind = meta->getRungeKuttaInd();
1031  cand.kal.usedMeta = kNoUse;
1032  cand.kal.selectTof = kNoUse;
1033  cand.kal.ind = meta->getKalmanFilterInd();
1034  }
1035  //--------------------------------------------------------------------
1036 
1037  cand.objects.reset();
1038 
1039  cand.objects.pMdcTrk = mdcTrkCand;
1040  cand.objects.pSeg1 = (HMdcSegSim* ) mdcSeg1;
1041  cand.objects.pSeg2 = (HMdcSegSim* ) mdcSeg2;
1042  cand.objects.pRichHit = (HRichHitSim*) richHit;
1043  cand.objects.pTofClst = (HTofClusterSim*) tofClst;
1044  cand.objects.pTofHit1 = (HTofHitSim*) tofHit1;
1045  cand.objects.pTofHit2 = (HTofHitSim*) tofHit2;
1046  cand.objects.pRpcClst = (HRpcClusterSim*) rpcClst;
1047  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
1048  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
1049  cand.objects.pSpline = spline;
1050 
1052  {
1053  //--------------------------------------------------------------------
1054  rk = HCategoryManager::getObject(rk,fCatRK,cand.rk.ind);
1055  cand.rk.fill(rk);
1056  cand.objects.pRk = rk;
1057  //--------------------------------------------------------------------
1058  } else if(fmomSwitch == Particle::kMomKalman) {
1059  //--------------------------------------------------------------------
1061  cand.kal.fill(kal);
1062  cand.objects.pKalman = kal;
1063  //--------------------------------------------------------------------
1064  } else {
1065  Error("fillCandRpc","Unknown momentum option");
1066  }
1067 
1068 }
1069 
1070 
1071 
1073  // create candidate meta objects for all selected matches
1074  // in HMetaMatch2. In Simulation the GEANT information is
1075  // filled too. This function is the heart of the task.
1076  // Selections which META hit to use are performed here.
1077 
1078  if(fbnoFake) if(meta->isFake()) { return; }
1079 
1080  Bool_t isEMC = meta->isEmcCluster();
1081 
1082  //--------------------------------------------------------------------
1083  // was rk succesful ? (rk indedx has to taken from another place ....)
1084  // also quality parameters ...
1085  // caution : meta->getRungeKuttaInd();
1086  // is filled in case a.) no METAHIT b.) rk failed
1087 
1088  HRKTrackB* rk = 0;
1089  HKalTrack* kal = 0;
1090  Bool_t rkSuccess = kTRUE;
1091  Float_t rkchi2 = -1;
1092 
1094  {
1095  Int_t rkReplaceInd = meta->getRungeKuttaInd();
1096  if ( (rk = HCategoryManager::getObject(rk,fCatRK,rkReplaceInd)) != 0 ) {
1097  rkchi2 = rk->getChiq();
1098  if (rkchi2 < 0) { rkSuccess = kFALSE; }
1099  }
1100  } else if(fmomSwitch == Particle::kMomKalman) {
1101  Int_t rkReplaceInd = meta->getKalmanFilterInd();
1102  if ( (kal = HCategoryManager::getObject(kal,fCatKalman,rkReplaceInd)) != 0 ) {
1103  rkchi2 = kal->getChi2();
1104  if (rkchi2 < 0) { rkSuccess = kFALSE; }
1105  }
1106  } else {
1107  Error("fillCand","Unknown momentum option");
1108  }
1109  //--------------------------------------------------------------------
1110 
1111  Int_t bestShrInd = -1;
1112  HShowerHit* bestShr = 0;
1113  HRKTrackB* bestRKShr = 0;
1114  HKalTrack* bestKalShr = 0;
1115 
1116  Int_t bestEmcInd = -1;
1117  HEmcCluster* bestEmc = 0;
1118  HRKTrackB* bestRKEmc = 0;
1119  HKalTrack* bestKalEmc = 0;
1120 
1121  if(isEMC){
1122  //--------------------------------------------------------------------
1123  // find best EmcCluster match
1124  Float_t emcQA = 10000.;
1125  HEmcCluster* hit =0;
1126  Float_t qa =-1;
1127  for(UInt_t i=0; i < meta->getNEmcClusters();i++){
1128  Int_t ind = meta->getEmcClusterInd (i);
1130  if(hit){
1131  if(!rkSuccess){
1132  qa=meta->getEmcClusterQuality(i);
1133  if(qa>=0 && qa < emcQA) {
1134  emcQA = qa;
1135  bestEmc = hit;
1136  bestEmcInd = i;
1137  }
1138  } else {
1139  HRKTrackB* rkEmc=0;
1140  HKalTrack* kalEmc=0;
1141  if (fmomSwitch == Particle::kMomRK) {
1143  if (fsortSwitch==0)qa=rkEmc->getQualityEmc();
1144  else if(fsortSwitch==1)qa=rkEmc->getMetaRadius();
1145  else { Error("fillCand","Unknown sort option");}
1146  }
1147  else if(fmomSwitch == Particle::kMomKalman) {
1149  if (fsortSwitch==0)qa=kalEmc->getQualityEmc();
1150  else if(fsortSwitch==1)qa=kalEmc->getMetaRadius();
1151  else { Error("fillCand","Unknown sort option");}
1152  }
1153  else { Error("fillCand","Unknown momentum option");}
1154 
1155  if(qa>=0 && qa < emcQA) {
1156  emcQA = qa;
1157  bestEmc = hit;
1158  bestEmcInd = i;
1159  bestRKEmc = rkEmc;
1160  bestKalEmc = kalEmc;
1161  }
1162  }
1163  }
1164  }
1165  //--------------------------------------------------------------------
1166  } else {
1167  //--------------------------------------------------------------------
1168  // find best ShowerHit match
1169  Float_t shrQA = 10000.;
1170  HShowerHit* hit =0;
1171  Float_t qa =-1;
1172  for(UInt_t i=0; i < meta->getNShrHits();i++){
1173  Int_t ind = meta->getShowerHitInd (i);
1175  if(hit){
1176  if(!rkSuccess){
1177  qa=meta->getShowerHitQuality(i);
1178  if(qa>=0 && qa < shrQA) {
1179  shrQA = qa;
1180  bestShr = hit;
1181  bestShrInd = i;
1182  }
1183  } else {
1184  HRKTrackB* rkShr=0;
1185  HKalTrack* kalShr=0;
1186  if (fmomSwitch == Particle::kMomRK) {
1188  if (fsortSwitch==0)qa=rkShr->getQualityShower();
1189  else if(fsortSwitch==1)qa=rkShr->getMetaRadius();
1190  else { Error("fillCand","Unknown sort option");}
1191  }
1192  else if(fmomSwitch == Particle::kMomKalman) {
1194  if (fsortSwitch==0)qa=kalShr->getQualityShower();
1195  else if(fsortSwitch==1)qa=kalShr->getMetaRadius();
1196  else { Error("fillCand","Unknown sort option");}
1197  }
1198  else { Error("fillCand","Unknown momentum option");}
1199 
1200  if(qa>=0 && qa < shrQA) {
1201  shrQA = qa;
1202  bestShr = hit;
1203  bestShrInd = i;
1204  bestRKShr = rkShr;
1205  bestKalShr = kalShr;
1206  }
1207  }
1208  }
1209  }
1210  //--------------------------------------------------------------------
1211  }
1212 
1213  HShowerHit* showerHit = 0;
1214  HEmcCluster* emcClst = 0;
1215 
1216  //--------------------------------------------------------------------
1217  if(meta->getSystem()==-1) // nothing to do for TOF,RPC,SHOWER
1218  {
1219  Int_t num = 1;
1220  candidate& cand = *(new candidate);
1221  cand.reset();
1222  cand.isEMC = isEMC;
1223 
1224  fillCandNoMeta(rkSuccess,meta,cand,num);
1225 
1226  //--------------------------------------------------------------------
1227  // simulation part
1228  if(fbIsSimulation){
1229  fillCandSim(cand);
1230  }
1231  //--------------------------------------------------------------------
1232 
1233  all_candidates.push_back(&cand);
1234  }
1235  //####################################################################
1236  else if(meta->getSystem()==1) // TOF case : select the best TOF for TOF hit or TOF Cluster
1237  {
1238  Int_t numTof = meta->getNTofHits();
1239 
1240  //--------------------------------------------------------------------
1241  // fill the different candiates each selected TOF row
1242  for(Int_t n = 0; n < numTof; n ++)
1243  {
1244  candidate& cand = *(new candidate);
1245  cand.reset();
1246  cand.isEMC = isEMC;
1247 
1248  fillCandTof(rkSuccess,meta,cand,numTof,n);
1249 
1250  //--------------------------------------------------------------------
1251  // simulation part
1252  if(fbIsSimulation){
1253  fillCandSim(cand);
1254  }
1255  //--------------------------------------------------------------------
1256 
1257  all_candidates.push_back(&cand);
1258 
1259  } // end ntof loop
1260 
1261  }
1262  //####################################################################
1263  else if(meta->getSystem()==0) // RPC + SHOWER/EMC
1264  {
1265  Int_t numRpc = meta->getNRpcClusters();
1266 
1267  //--------------------------------------------------------------------
1268  // fill the different candiates for each selected RPC row
1269  for(Int_t n = 0; n < numRpc; n ++)
1270  {
1271  candidate& cand = *(new candidate);
1272  cand.reset();
1273  cand.isEMC = isEMC;
1274 
1275  fillCandRpc(rkSuccess,meta,cand,numRpc,n);
1276  if(isEMC){
1277  if(bestEmc){
1278  if (fmomSwitch == Particle::kMomRK) cand.emcclst .fillMeta(meta,bestEmcInd,bestRKEmc);
1279  else if(fmomSwitch == Particle::kMomKalman) cand.emcclst .fillMetaKal(meta,bestEmcInd,bestKalEmc);
1280  else { Error("fillCand","Unknown momentum option");}
1281  emcClst = HCategoryManager::getObject(emcClst ,fCatEmcCluster ,cand.emcclst.ind);
1282  cand.emcclst .fill(emcClst);
1283  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
1284  }
1285  } else {
1286  if(bestShr){
1287  if (fmomSwitch == Particle::kMomRK) cand.showerhit .fillMeta(meta,bestShrInd,bestRKShr);
1288  else if(fmomSwitch == Particle::kMomKalman) cand.showerhit .fillMetaKal(meta,bestShrInd,bestKalShr);
1289  else { Error("fillCand","Unknown momentum option");}
1290  showerHit = HCategoryManager::getObject(showerHit ,fCatShowerHit ,cand.showerhit.ind);
1291  cand.showerhit .fill(showerHit);
1292  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
1293  }
1294  }
1295  //--------------------------------------------------------------------
1296  // simulation part
1297  if(fbIsSimulation){
1298  fillCandSim(cand);
1299  }
1300  //--------------------------------------------------------------------
1301 
1302  all_candidates.push_back(&cand);
1303 
1304  } // end loop RpcClst
1305  //--------------------------------------------------------------------
1306 
1307  //--------------------------------------------------------------------
1308  if(numRpc <= 0 && (bestShr||bestEmc)){ // if there was no RPC : fill best showerHit/emcClst
1309  //--------------------------------------------------------------------
1310  // fill the different candiates for each selected RPC row
1311 
1312  candidate& cand = *(new candidate);
1313  cand.reset();
1314  cand.isEMC = isEMC;
1315 
1316  if(isEMC){
1317  Int_t numEmc=meta->getNEmcClusters();
1318  fillCandEmc(rkSuccess,meta,cand,numEmc,bestEmcInd ); // RKSHOWER ?????
1319  if (fmomSwitch == Particle::kMomRK) cand.emcclst .fillMeta(meta,bestEmcInd,bestRKEmc);
1320  else if(fmomSwitch == Particle::kMomKalman) cand.emcclst .fillMetaKal(meta,bestEmcInd,bestKalEmc);
1321  else { Error("fillCand","Unknown momentum option");}
1322  } else {
1323  Int_t numShr=meta->getNShrHits();
1324  fillCandShower(rkSuccess,meta,cand,numShr,bestShrInd ); // RKSHOWER ?????
1325  if (fmomSwitch == Particle::kMomRK) cand.showerhit .fillMeta(meta,bestShrInd,bestRKShr);
1326  else if(fmomSwitch == Particle::kMomKalman) cand.showerhit .fillMetaKal(meta,bestShrInd,bestKalShr);
1327  else { Error("fillCand","Unknown momentum option");}
1328  }
1329  //--------------------------------------------------------------------
1330  // simulation part
1331  if(fbIsSimulation){
1332  fillCandSim(cand);
1333  }
1334  //--------------------------------------------------------------------
1335 
1336  all_candidates.push_back(&cand);
1337 
1338  }
1339  //--------------------------------------------------------------------
1340 
1341 
1342  }
1343  //####################################################################
1344  else if(meta->getSystem()==2) // RPC/SHOWER/EMC + TOF
1345  {
1346  Int_t numTof = meta->getNTofHits();
1347  Int_t numRpc = meta->getNRpcClusters();
1348 
1349 
1350  //--------------------------------------------------------------------
1351  // fill the different candiates for each selected TOF row
1352  for(Int_t n = 0; n < numTof; n ++)
1353  {
1354  candidate& cand = *(new candidate);
1355  cand.reset();
1356  cand.isEMC = isEMC;
1357 
1358  fillCandTof(rkSuccess,meta,cand,numTof+numRpc,n);
1359  cand.system = 2;
1360 
1361  if(isEMC){
1362  if(bestEmc){
1363  if (fmomSwitch == Particle::kMomRK) cand.emcclst .fillMeta(meta,bestEmcInd,bestRKEmc);
1364  else if(fmomSwitch == Particle::kMomKalman) cand.emcclst .fillMetaKal(meta,bestEmcInd,bestKalEmc);
1365  else { Error("fillCand","Unknown momentum option");}
1366  emcClst = HCategoryManager::getObject(emcClst ,fCatEmcCluster ,cand.emcclst.ind);
1367  cand.emcclst .fill(emcClst);
1368  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
1369  }
1370  } else {
1371  if(bestShr){
1372  if (fmomSwitch == Particle::kMomRK) cand.showerhit .fillMeta(meta,bestShrInd,bestRKShr);
1373  else if(fmomSwitch == Particle::kMomKalman) cand.showerhit .fillMetaKal(meta,bestShrInd,bestKalShr);
1374  else { Error("fillCand","Unknown momentum option");}
1375  showerHit = HCategoryManager::getObject(showerHit ,fCatShowerHit ,cand.showerhit.ind);
1376  cand.showerhit .fill(showerHit);
1377  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
1378  }
1379  }
1380  //--------------------------------------------------------------------
1381  // simulation part
1382  if(fbIsSimulation){
1383  fillCandSim(cand);
1384  }
1385  //--------------------------------------------------------------------
1386 
1387  all_candidates.push_back(&cand);
1388 
1389  } // end ntof loop
1390 
1391 
1392  //--------------------------------------------------------------------
1393  // fill the different candiates for each selected RPC row
1394  for(Int_t n = 0; n < numRpc; n ++)
1395  {
1396  candidate& cand = *(new candidate);
1397  cand.reset();
1398  cand.isEMC = isEMC;
1399 
1400  fillCandRpc(rkSuccess,meta,cand,numTof+numRpc,n);
1401  cand.system=2;
1402 
1403  if(isEMC){
1404  if(bestEmc){
1405  if (fmomSwitch == Particle::kMomRK) cand.emcclst .fillMeta(meta,bestEmcInd,bestRKEmc);
1406  else if(fmomSwitch == Particle::kMomKalman) cand.emcclst .fillMetaKal(meta,bestEmcInd,bestKalEmc);
1407  else { Error("fillCand","Unknown momentum option");}
1408  emcClst = HCategoryManager::getObject(emcClst ,fCatEmcCluster ,cand.emcclst.ind);
1409  cand.emcclst .fill(emcClst);
1410  cand.objects.pEmcClst = (HEmcClusterSim*) emcClst;
1411  }
1412  } else {
1413  if(bestShr){
1414  if (fmomSwitch == Particle::kMomRK) cand.showerhit .fillMeta(meta,bestShrInd,bestRKShr);
1415  else if(fmomSwitch == Particle::kMomKalman) cand.showerhit .fillMetaKal(meta,bestShrInd,bestKalShr);
1416  else { Error("fillCand","Unknown momentum option");}
1417  showerHit = HCategoryManager::getObject(showerHit ,fCatShowerHit ,cand.showerhit.ind);
1418  cand.showerhit .fill(showerHit);
1419  cand.objects.pShowerHit = (HShowerHitSim*) showerHit;
1420  }
1421  }
1422  //--------------------------------------------------------------------
1423  // simulation part
1424  if(fbIsSimulation){
1425  fillCandSim(cand);
1426  }
1427  //--------------------------------------------------------------------
1428 
1429  all_candidates.push_back(&cand);
1430 
1431  } // end loop RpcClst
1432  //--------------------------------------------------------------------
1433 
1434 
1435  } else {
1436  Error("fillCand()","metamatch system other than -1 to 2 = %i!",meta->getSystem());
1437  return;
1438  }
1439 
1440 }
1441 
1442 
1444 {
1445  //--------------------------------------------------------------------
1446  // for simulation we have to fill HGEANT infos
1447  // in addition. The GEANT track infos are collected
1448  // in trackVec objects for each detector and for
1449  // all detectors together. The tracks in the common
1450  // vector are sorted by 3 criteria:
1451  // 1. number of detectors which have seen this track
1452  // 2. sum of weights of the track
1453  // 3. correlation flag
1454  // The best track number will be transported
1455  // to HParticleCandSim output object.
1456 
1457 
1458  Int_t tr = -1;
1459 
1460  pointers& objects = cand.objects;
1461 
1462  //--------------------------------------------------------------------
1463  // MDC
1464 
1465  //--------------------------------------------------------------------
1466  // search for "good tracks" (ghosts identified by MDC tracking)
1467  vector<Int_t> goodTracks; // good inner+outer or inner (if no outer segment)
1468 
1469  Int_t nGoodInnerTracks = objects.pSeg1->getNNotFakeTracks();
1470  Int_t nGoodOuterTracks = 0;
1471  //--------------------------------------------------------------------
1472  // global decision on ghost done on MDC
1473  Int_t nwInnerCut = objects.pSeg1->getSumWires()/2 + 1;
1474 
1475  Int_t ghostFlag=0;
1476  if( nGoodInnerTracks == 0) {
1477  ghostFlag = kIsGhost|kIsInnerGhost ;
1478  } else {
1479  if(objects.pSeg1->getTrack(0) == gHades->getEmbeddingRealTrackId() ) ghostFlag |= kIsGhost|kIsInnerGhost ;
1480  if(nwInnerCut > objects.pSeg1->getNTimes(0) || objects.pSeg1->getNTimes(0)<fMinWireGoodTrack) ghostFlag |= kIsGhost|kIsInnerGhost;
1481  }
1482 
1483  Int_t nwOuterCut = 0;
1484  if(objects.pSeg2){
1485 
1486  nGoodOuterTracks = objects.pSeg2->getNNotFakeTracks();
1487  if( nGoodOuterTracks == 0) {
1488  ghostFlag |= kIsGhost|kIsOuterGhost ;
1489  } else {
1490  nwOuterCut = objects.pSeg2->getSumWires()/2 + 1;
1491  if(nwOuterCut > objects.pSeg2->getNTimes(0) || objects.pSeg2->getNTimes(0)<fMinWireGoodTrack) ghostFlag |= kIsGhost|kIsOuterGhost;
1492  if(objects.pSeg1->getTrack(0) != objects.pSeg2->getTrack(0)) ghostFlag |= kIsGhost;
1493  if(objects.pSeg2->getTrack(0) == gHades->getEmbeddingRealTrackId() ) ghostFlag |= kIsGhost|kIsOuterGhost ;
1494  }
1495  }
1496  //--------------------------------------------------------------------
1497 
1498 
1499 
1500  for(Int_t i = 0; i < nGoodInnerTracks; i ++) {
1501  tr = objects.pSeg1->getTrack(i);
1502  if(objects.pSeg2) tr = objects.pSeg1->getGoodTrack(i,objects.pSeg2,fMinWireGoodTrack); // if out seg, check if it matches
1503  if(tr > 0 ) { // good track!
1504  goodTracks.push_back(tr);
1505  }
1506  }
1507  //--------------------------------------------------------------------
1508  Int_t ghost = 0;
1509  if(objects.pSeg1) { //we found an inner mdc segment
1510  for(Int_t i = 0; i < objects.pSeg1->getNTracks(); i++) { //loop over all contributing tracks ...
1511  ghost = kIsInnerGhost;
1512  if(i < nGoodInnerTracks && objects.pSeg1->getNTimes(i) >= fMinWireGoodTrack) ghost = 0; // good track
1513 
1514  tr = objects.pSeg1->getTrack(i);
1515  if(tr < 1 && tr != gHades->getEmbeddingRealTrackId() ) continue; // skip cells which contain no valid hit
1516  if(tr > 0 && find(goodTracks.begin(),goodTracks.end(),tr) == goodTracks.end()) { // ghost
1518  } else { // good or real track
1519  if(tr > 0 ) cand.mdc1Tracks.addTrack(tr,objects.pSeg1->getNTimes(i),kIsInInnerMDC,fScaleGoodTrack); // GEANT
1520  else cand.mdc1Tracks.addTrack(tr,objects.pSeg1->getNTimes(i),kIsInInnerMDC); // REAL
1521  }
1522  }
1523  cand.mdc1Tracks.calcWeights();
1524 
1525  }
1526  if(objects.pSeg2) { //we found an outer mdc segment
1527 
1528  for(Int_t i = 0; i < objects.pSeg2->getNTracks(); i++) { //loop over all contributing tracks ...
1529  ghost = kIsOuterGhost;
1530  if(i < nGoodOuterTracks && objects.pSeg2->getNTimes(i) >= fMinWireGoodTrack) ghost = 0; // good track
1531 
1532  tr = objects.pSeg2->getTrack(i);
1533  if(tr < 1 && tr != gHades->getEmbeddingRealTrackId() ) continue; // skip cells which contain no valid hit
1534  if(tr > 0 && find(goodTracks.begin(),goodTracks.end(),tr) == goodTracks.end()) { // ghost
1536  } else { // good or real track
1537  if(tr > 0 ) cand.mdc2Tracks.addTrack(tr,objects.pSeg2->getNTimes(i),kIsInOuterMDC,fScaleGoodTrack); // GEANT
1538  else cand.mdc2Tracks.addTrack(tr,objects.pSeg2->getNTimes(i),kIsInOuterMDC); // REAL
1539  }
1540  }
1541  cand.mdc2Tracks.calcWeights();
1542  }
1543  //--------------------------------------------------------------------
1544 
1545 
1546  //--------------------------------------------------------------------
1547  // RICH
1548  //Check for up to three possibly contributing leptons in this ring
1549  if(objects.pRichHit){
1550  if(objects.pRichHit->weigTrack1 > 0.0 && (objects.pRichHit->track1 > 0 || objects.pRichHit->track1 == gHades->getEmbeddingRealTrackId())) {
1552  }
1553  if(objects.pRichHit->weigTrack2 > 0.0 && (objects.pRichHit->track2 > 0 || objects.pRichHit->track2 == gHades->getEmbeddingRealTrackId())) {
1555  }
1556  if(objects.pRichHit->weigTrack3 > 0.0 && (objects.pRichHit->track3 > 0 || objects.pRichHit->track3 == gHades->getEmbeddingRealTrackId())) {
1558  }
1559  cand.richTracks.calcWeights();
1560  }
1561  //--------------------------------------------------------------------
1562 
1563 
1564  //--------------------------------------------------------------------
1565  // META
1566  //
1567  // we have to copy the GEANT infos of the selected objects!
1568 
1569 
1570  //--------------------------------------------------------------------
1571  // RK success or failed ?
1572  Int_t selMetaHit = kNoUse;
1573  if(cand.rkSuccess) {
1574  if (fmomSwitch == Particle::kMomRK) selMetaHit = cand.rk.usedMeta;
1575  else if(fmomSwitch == Particle::kMomKalman) selMetaHit = cand.kal.usedMeta;
1576  else Error("fillCandSim()","Unknown momswitch !");
1577  } else { selMetaHit = cand.usedMeta; } // from segment matching
1578  //--------------------------------------------------------------------
1579 
1580  //--------------------------------------------------------------------
1581  if (selMetaHit == kTofClst) {
1582 
1583  if(objects.pTofClst) {
1584  Int_t nTr = objects.pTofClst ->getNParticipants();
1585 
1586  for(Int_t i = 0; i < nTr && i < 3; i ++)
1587  {
1588  //Get track numbers
1589  tr = objects.pTofClst->getNTrack1(i);
1591  Bool_t good = kFALSE;
1592  if( tr > 0 || tr == gHades->getEmbeddingRealTrackId() ) {
1593  cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA);
1594  good = kTRUE;
1595  }
1596  if(objects.pTofClst->getNTrack1(i) != objects.pTofClst->getNTrack2(i) ){ // skip same track
1597  tr = objects.pTofClst ->getNTrack2(i);
1599  if( tr > 0 || tr == gHades->getEmbeddingRealTrackId() ) {
1600  cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA);
1601  }
1602  } else { if (good) cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA); } // same track accepeted
1603  cand.tofTracks.calcWeights();
1604  }
1605  }
1606 
1607  //--------------------------------------------------------------------
1608  } else if(selMetaHit == kTofHit1) {
1609 
1610  if(objects.pTofHit1){
1611  tr = objects.pTofHit1 ->getNTrack1();
1613  Bool_t good = kFALSE;
1614  if( tr > 0 || tr == gHades->getEmbeddingRealTrackId() ) {
1615  cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA);
1616  good = kTRUE;
1617  }
1618  if(objects.pTofHit1 ->getNTrack1() != objects.pTofHit1 ->getNTrack2() ){ // skip same track
1619  tr = objects.pTofHit1 ->getNTrack2();
1621  if( tr > 0 || tr == gHades->getEmbeddingRealTrackId() ) {
1622  cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA);
1623  }
1624  } else { if (good) cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA); } // same track accepeted
1625  cand.tofTracks.calcWeights();
1626  }
1627 
1628  //--------------------------------------------------------------------
1629  } else if(selMetaHit == kTofHit2) {
1630 
1631  if(objects.pTofHit2){
1632  tr = objects.pTofHit2 ->getNTrack1();
1634  Bool_t good = kFALSE;
1635  if( tr > 0 || tr == gHades->getEmbeddingRealTrackId() ) {
1636  cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA);
1637  good = kTRUE;
1638  }
1639 
1640  if(objects.pTofHit2 ->getNTrack1() != objects.pTofHit2 ->getNTrack2() ){ // skip same track
1641  tr = objects.pTofHit2 ->getNTrack2();
1643  if( tr > 0 || tr == gHades->getEmbeddingRealTrackId() ) {
1644  cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA);
1645  }
1646  } else { if (good) cand.tofTracks.addTrack(tr,1,kIsInTOF|kIsInMETA); } // same track accepeted
1647  cand.tofTracks.calcWeights();
1648  }
1649 
1650  //--------------------------------------------------------------------
1651  } else if(selMetaHit == kRpcClst) {
1652 
1653  if(objects.pRpcClst){
1654  Int_t tracks[4];
1655  Bool_t atbox[4];
1656  objects.pRpcClst->getTrackList (tracks);
1657  objects.pRpcClst->getIsAtBoxList(atbox);
1658  Int_t nTr = objects.pRpcClst->howManyTracks();
1659  if(nTr > 4) {
1660  Warning("fillCandSim()","RPC number of tracks > 4! Should not happen.");
1661  nTr = 4;
1662  }
1663  for(Int_t i = 0; i < nTr; i ++) {
1664  tr = tracks[i];
1665  if( tr >= 0 || tr == gHades->getEmbeddingRealTrackId()){
1666  if(tr >= 0 ) { // sim tracks
1667  if(atbox[i]) { cand.rpcTracks.addTrack(tr,1,kIsInRPC|kIsInMETA);}
1668  else {
1669  Warning("fillCandSim()","RPC track not at box! Should not happen.");
1670  }
1671  } else { // embedded tracks
1672  cand.rpcTracks.addTrack(tr,1,kIsInRPC|kIsInMETA);
1673  }
1674  }
1675  }
1676  cand.rpcTracks.calcWeights();
1677  }
1678 
1679  //--------------------------------------------------------------------
1680  } else if(selMetaHit == kShowerHit){
1681 
1682  //--------------------------------------------------------------------
1683  } else if(selMetaHit == kEmcClst){
1684 
1685  //--------------------------------------------------------------------
1686 
1687  } else { ; } // NO META
1688  //--------------------------------------------------------------------
1689 
1690 
1691  //--------------------------------------------------------------------
1692  // Always fill SHOWER/EMC if existing
1693  if(objects.pEmcClst){
1694  Int_t nTr = objects.pEmcClst->getNTracks();
1695  for(Int_t i = 0; i < nTr; i ++) {
1696  tr = objects.pEmcClst->getTrack(i);
1697  if( tr >= 0 || tr == gHades->getEmbeddingRealTrackId()){
1698  cand.emcTracks.addTrack(tr,1,kIsInEMC|kIsInMETA);
1699  }
1700  }
1701  cand.emcTracks.calcWeights();
1702  }
1703 
1704  if(objects.pShowerHit){
1705  Int_t nTr = objects.pShowerHit->getNTracks();
1706  for(Int_t i = 0; i < nTr; i ++) {
1707  tr = objects.pShowerHit->getTrack(i);
1708  if( tr >= 0 || tr == gHades->getEmbeddingRealTrackId()){
1710  }
1711  }
1712  cand.showerTracks.calcWeights();
1713  }
1714  //--------------------------------------------------------------------
1715 
1716 
1717 
1718 
1719 
1720 
1721  //--------------------------------------------------------------------
1722  // now add all detector tracks to commonTracks
1723  // and sort them by 1. flag and 2. weight
1729  if(cand.isEMC)cand.commonTracks.addTrackWeight(cand.emcTracks);
1730  else cand.commonTracks.addTrackWeight(cand.showerTracks);
1732 
1733  if(cand.commonTracks.tracks.size()>0)cand.commonTracks.tracks[0]->flag |= ghostFlag; // make sure MDC decision is transported
1734  //--------------------------------------------------------------------
1735 
1736 }
1738 {
1739 
1740  // selection for single tracks done in this loop
1741  // 1. RICH-MDC matching flags are set
1742  // 2. all cuts (GOODSEG0 .... ) are performed here.
1743  // Rejected candidate objects will have use == 0.
1744 
1745  Float_t zVertex = gHades->getCurrentEvent()->getHeader()->getVertexZ();
1746  HVertex& vertexClust = gHades->getCurrentEvent()->getHeader()->getVertexCluster();
1747 
1748  Float_t chi2Clust = vertexClust.getChi2(); // -1 = no vertex found , 0 = ok
1749 
1750  for(UInt_t i = 0; i < all_candidates.size(); i ++){
1751  candidate& cand = *(all_candidates[i]);
1752 
1753  //-----------------------------------------------------
1754  // RICH - MDC matching
1755  // 1. correct rings for vertex position
1756  // 2. check matching for RK
1757  if(cand.richhit.ind >= 0){
1758  Float_t richCorr = 0;
1759 
1760  if(fbdoRichVertexCorr && chi2Clust > -0.5 && zVertex > -999.9F && zVertex < 100 )
1761  {
1762  if(fRichCorrectionVersion == 0) {
1763  richCorr = fFillerPar->getRichCorr(zVertex,cand.richhit.theta,cand.richhit.phi); // vertex z [mm] . theta [deg]
1764  } else {
1765  Float_t th = cand.richhit.theta;
1766  fRich700DigiPar->getInterpolatedSectorThetaPhi(cand.richhit.centerx,cand.richhit.centery,zVertex, th,cand.richhit.phi); // first correct z position emission
1767  richCorr = th - cand.richhit.theta;
1768  }
1769  }
1770 
1771  cand.corrThetaRich = richCorr;
1772  cand.richhit.theta += richCorr;
1773  if(!fbIsSimulation && fbdoRichAlign){ // for real data do alignment of rich
1774 
1775  Float_t thetaCor = cand.richhit.theta;
1776  Float_t phiCor = cand.richhit.phi;
1777 
1778  if(fRichCorrectionVersion == 0) {
1779  Double_t thcor = cand.richhit.theta;
1780  Double_t phcor = cand.richhit.phi;
1781  HParticleAngleCor::alignRichRing(cand.richhit.theta,cand.richhit.phi,thcor,phcor); // apr12 - aug14 second correct theta/phi
1782  thetaCor = (Float_t)thcor;
1783  phiCor = (Float_t)phcor;
1784 
1785  } else {
1786  fRich700DigiPar->getAlignedThetaPhi(cand.richhit.theta,cand.richhit.phi,thetaCor,phiCor); // mar19 and later
1787  }
1788 
1789  cand.alignThetaRich = thetaCor - cand.richhit.theta;
1790  cand.alignPhiRich = phiCor - cand.richhit.phi;
1791  cand.richhit.theta = thetaCor;
1792  cand.richhit.phi = phiCor;
1793  }
1794 
1795  Float_t dTheta = cand.deltaThetaSeg1(); // delta theta
1796  Float_t dPhi = cand.deltaPhiSeg1(); // delta phi
1797  Float_t mom = cand.spline.p; // initial mom from spline
1798 
1799  if (fmomSwitch == Particle::kMomRK ) { if( cand.rk.chi2 > 0) mom = cand.rk.p; } //
1800  else if(fmomSwitch == Particle::kMomKalman) { if( cand.kal.chi2 > 0) mom = cand.kal.p;} //
1801  else Error("fillSingleProperties()","Unknown momswitch !");
1802 
1803  cand.richMdcQuality = sqrt( dTheta * dTheta + dPhi * dPhi);
1804  cand.richRkQuality = -1;
1805  cand.hasRingCorrelation = 0;
1806  if(fFillerPar->acceptPhiTheta(cand.sector,mom,dPhi,dTheta)){
1808  }
1809 
1810  if( (fmomSwitch == Particle::kMomRK && cand.rk.chi2 > 0 ) ||
1811  (fmomSwitch == Particle::kMomKalman && cand.kal.chi2 > 0 )
1812  ){
1814  dTheta = cand.deltaThetaRk(); // delta theta
1815  dPhi = cand.deltaPhiRk(); // delta phi
1816  } else if(fmomSwitch == Particle::kMomKalman){
1817  dTheta = cand.deltaThetaKal(); // delta theta
1818  dPhi = cand.deltaPhiKal(); // delta phi
1819  } else Error("fillSingleProperties()","Unknown momswitch !");
1820 
1821  cand.richRkQuality = sqrt( dTheta * dTheta + dPhi * dPhi);
1822  if(fFillerPar->acceptPhiTheta(cand.sector,mom,dPhi,dTheta)){
1823  cand.hasRingCorrelation = cand.hasRingCorrelation | kIsRICHRK; // add flag
1824  }
1825  }
1826  }
1827  //-----------------------------------------------------
1828 
1829  //-----------------------------------------------------
1830  // filter candidates by options. cand.used=0 will be skipped
1831  // when creating output objects
1832  if(fbgoodSeg0 && cand.seg1.chi2 < 0) { cand.used = 0; }
1833  if(fbgoodSeg1 && cand.seg2.chi2 < 0) { cand.used = 0; }
1834  if(fbgoodMeta && cand.system < 0) { cand.used = 0; }
1835  if(fbgoodLepton && cand.hasRingCorrelation == 0){ cand.used = 0; }
1836  if(fbgoodRK ){
1837  if (fmomSwitch == Particle::kMomRK ) { if( cand.rk.chi2 < 0) { cand.used = 0; }}
1838  else if(fmomSwitch == Particle::kMomKalman ) { if( cand.kal.chi2 < 0) { cand.used = 0; }}
1839  else Error("fillSingleProperties()","Unknown momswitch !");
1840  }
1841  //-----------------------------------------------------
1842 
1843  }
1844 }
1845 
1847 {
1848 
1849  // collect information of the environment of a
1850  // candidate
1851  // 1. calculation openening angles etc. to fitted
1852  // and not fitted other candidates (in inner MDC)
1853 
1854  UInt_t size = all_candidates.size();
1855 
1856  if(size < 2) return;
1857 
1858  Float_t phi1=0.,phi2=0.,theta1=0.,theta2=0.;
1859  Float_t oAngle = -1;
1860  Int_t ind = 0;
1861 
1862  //----------------------------------------------------------
1863  for(UInt_t i = 0; i < size ; i ++){ // outer loop
1864  candidate& cand = *(all_candidates[i]);
1865 
1866  if(cand.rkSuccess){
1868  phi1 = cand.rk.phi;
1869  theta1 = cand.rk.theta;
1870  } else if(fmomSwitch == Particle::kMomKalman){
1871  phi1 = cand.kal.phi;
1872  theta1 = cand.kal.theta;
1873  } else Error("fillCollectiveProperties()","Unknown momswitch !");
1874 
1875  } else {
1876  phi1 = cand.seg1.phi;
1877  theta1 = cand.seg1.theta;
1878  }
1879 
1880  //----------------------------------------------------------
1881  for(UInt_t j = 0; j < size; j ++){ // inner loop
1882  candidate& cand2 = *(all_candidates[j]);
1883  if(cand.ind == cand2.ind) continue; // skip candidate from same MetaMatch
1884  if(cand.sector != cand2.sector) continue; // only in same sector
1885  if(cand.seg1.ind == cand2.seg1.ind) continue; // skip cands from same inner segment
1886 
1887  if(cand2.rkSuccess){
1889  phi2 = cand2.rk.phi;
1890  theta2 = cand2.rk.theta;
1891  } else if(fmomSwitch == Particle::kMomKalman){
1892  phi1 = cand.kal.phi;
1893  theta1 = cand.kal.theta;
1894  } else Error("fillCollectiveProperties()","Unknown momswitch !");
1895 
1896  } else {
1897  phi2 = cand2.seg1.phi;
1898  theta2 = cand2.seg1.theta;
1899  }
1900 
1901  oAngle = HParticleTool::getOpeningAngle(phi1,theta1,phi2,theta2);
1902  if(oAngle < fAngleCloseTrack){ // only for small angle
1903  cand.closeTracks.addTrack(j,oAngle);
1904  }
1905  } // end inner
1906 
1907  //----------------------------------------------------------
1908  // find closest fitted/nonfitted tracks
1909  UInt_t ntr = (cand.closeTracks).tracks.size();
1910  for(UInt_t l = 0; l < ntr; l ++){
1911  ind = (cand.closeTracks).tracks[l].ind;
1912  oAngle = (cand.closeTracks).tracks[l].oAngle;
1913  candidate& c = *(all_candidates[ind]);
1914  if(c.seg1.chi2 > 0){
1915  if(oAngle < fabs(cand.oAFitted)){
1916  cand.oAFitted = oAngle;
1917  if( c.hasRingCorrelation == 0) { cand.oAFitted *= -1; } // hadron case
1918  }
1919  } else {
1920  if(oAngle < fabs(cand.oANoFitted)){
1921  cand.oANoFitted = oAngle;
1922  if( c.hasRingCorrelation == 0) { cand.oANoFitted *= -1; } // hadron case
1923  }
1924  }
1925  }
1926  //----------------------------------------------------------
1927 
1928  } // end outer
1929  //----------------------------------------------------------
1930 }
1931 
1932 
1934 {
1935  // From the candidate objects the output HParticleCand
1936  // will be filled if the candidate flage useed == 1
1937  // All additional categories objects will be filled
1938  // in the same order so that the objects later can be
1939  // easily matched.
1940 
1941  HParticleCand* part = 0;
1942  HParticleCandSim* partS = 0;
1943  Int_t index = -1;
1944 
1945 
1946 
1947 
1949  Float_t sweights= vertex.getSumOfWeights();
1950  HGeomVector vvertex = vertex.getPos();
1951  Int_t nmin = 8;
1952  for(UInt_t i = 0; i < all_candidates.size(); i ++){
1953  candidate* cand = all_candidates[i];
1954  if(!cand->used) continue;
1955  pointers& objects = cand->objects;
1956 
1957  if(fbIsSimulation) {
1958  if((partS = HCategoryManager::newObject(partS,fCatParticleCand,index)) != 0 )
1959  {
1960  cand->fillParticleCand (partS,index,fmomSwitch);
1961  cand->fillParticleCandSim(partS,fCatGeantKine);
1965  checkCropLayer(partS);
1966  }
1967  } else {
1968  if((part = HCategoryManager::newObject(part,fCatParticleCand,index)) != 0 )
1969  {
1970  cand->fillParticleCand (part,index,fmomSwitch);
1974  checkCropLayer(part);
1975  }
1976  }
1977 
1978  if(fbIsDebug){
1979  candidate* c;
1980 
1982  if(c){
1983  c = new (c) candidate(*cand);
1984  }
1985 
1986  }
1987 
1988  if(fbFillMdc) {
1989  HParticleMdc* partMdc = 0;
1990  partMdc = HCategoryManager::newSlot(partMdc,fCatParticleMdc,index);
1991 
1992  if(partMdc){
1993  partMdc = new (partMdc) HParticleMdc();
1994  partMdc->setIndex(index);
1995  partMdc->fill(objects.pSeg1);
1996  partMdc->fill(objects.pSeg2);
1997  partMdc->fill(objects.pMdcTrk);
1998  }
1999 
2000 
2001  }
2002 
2003 
2004 
2005 
2006  }
2007 }
2009 {
2011 
2012  Int_t n = fCatGeantKine->getEntries();
2013  HGeantKine* kine = 0;
2014  Bool_t cropped [4] ;
2015  for(Int_t i = 0 ; i < n ; i ++){
2017  if(kine){
2018  if(!kine->isAcceptanceFilled()) kine->fillAcceptanceBit();
2019  if(cropLay){
2020  for(Int_t j = 0 ; j < 4 ; j ++) cropped[j] = kFALSE;
2022  for(Int_t j = 0 ; j < 4 ; j ++) {
2023  kine->unsetAtMdcEdge(j);
2024  if(cropped[j]) kine->setAtMdcEdge(j);
2025  }
2026  kine->setCropedFilled();
2027  }
2028  }
2029  }
2030  }
2031 }
2032 
2034 {
2035  if(!cropLay) return;
2036  Int_t sec = c->getSector();
2037  if(!fSizesCells->modStatus(sec,0) && !fSizesCells->modStatus(sec,1)) return;
2038 
2039  Int_t layers[2] = {0,5};
2040  HMdcSeg* seg[2] = {0,0} ;
2041 
2042  Double_t x,y,z;
2043  Double_t xmin,xmax,ymin,ymax;
2044 
2045  for(Int_t s = 0; s < 2; s++){ // segment
2046  if(s==0) seg[0] = HParticleTool::getMdcSeg(c->getInnerSegInd());
2047  else seg[1] = HParticleTool::getMdcSeg(c->getOuterSegInd());
2048  if(!seg[s]) continue;
2049  for(Int_t m = 0; m < 2; m++){ // module in segment
2050  Int_t mod = 2*s+m; // real module
2051  if(!fSizesCells->modStatus(sec,mod)) continue;
2052  Int_t lay = layers[m];
2053  (*fSizesCells)[sec][mod][lay].calcSegIntersec(seg[s]->getZ(),seg[s]->getR(),seg[s]->getTheta(),seg[s]->getPhi(),x,y,z);
2054  (*fSizesCells)[sec][mod][lay].transTo(x,y,z);
2055  TVector2 p(x,y);
2056  if(!cropLay->getCropedLayersEdge(p, sec,mod,lay, xmin,xmax,ymin,ymax)){
2057  c->setAtMdcEdge(s*2+m);
2058  }
2059  }
2060  }
2061 
2062 }
2063 
2065 {
2066  // clear the working objects at the end of each event.
2067  UInt_t nt = all_candidates.size();
2068  for(UInt_t i = 0; i < nt; i ++){
2069  candidate* cand = all_candidates[i];
2070  delete cand;
2071  }
2072  all_candidates.clear();
2073 }
void fill(HEmcCluster *hit)
HParticleCandFiller(const Option_t pOpt[]="")
void fillCandRpc(Bool_t rkSuccess, HMetaMatch2 *meta, candidate &cand, Int_t num, Int_t slot)
Float_t theta
Float_t richRkQuality
Short_t getKalmanFilterInd(void) const
Definition: hmetamatch2.h:199
Float_t phi
Bool_t initContainer(void)
Float_t getPhi()
Definition: hrichhit.h:114
Int_t getSystem(void) const
Definition: hmetamatch2.cc:239
static Int_t getEmbeddingRealTrackId()
Definition: hades.h:102
Definition: hevent.h:17
Int_t hasRingCorrelation
void setConditions(const Option_t par[])
ClassImp(HParticleCandFiller) HParticleCandFiller
const Cat_t catRichHit
Definition: richdef.h:41
Int_t getTrack(Short_t n=0) const
void addTrack(Int_t tr, Int_t n, Int_t flag=0, Float_t scale=1.)
Int_t getNTrack2(Int_t i=0)
Float_t getTheta()
Definition: hrichhit.h:113
UChar_t getNShrHits(void) const
Definition: hmetamatch2.h:151
Bool_t fbdoPathLengthCorr
true: (default) do systematic corrections on momentum
Float_t centerx
Float_t getMetaRadius()
Definition: hrktrackB.h:69
Float_t quality
void addTrack(Int_t index, Float_t oAngle)
Float_t oANoFitted
Float_t fScaleGhostTrack
minium number of wire from same track for good track (MDC), otherwise ghost
void fill(HMdcTrkCand *trk)
void fillAcceptanceBit()
Definition: hgeantkine.cc:1115
HRichHitSim * pRichHit
HMdcSegSim * pSeg1
Float_t fAngleCloseTrack
scale weight of wires of good track (MDC)
Float_t deltaThetaRk()
void setAtMdcEdge(UInt_t i)
Definition: hgeantkine.h:288
static Bool_t correctPathLength(HParticleCand *pCand, HGeomVector &vertex, const HMdcPlane *planes, const HGeomVector &targetMidPoint, Double_t beamEnergy=1230)
Int_t getInnerSegInd() const
void fillCand(HMetaMatch2 *meta)
Bool_t fbdoGeantAcceptance
true: (default) do correction of path length to vertex
Int_t getSeg1Ind(void) const
Definition: hmdctrkcand.h:118
Short_t getRungeKuttaIndTofHit2(UChar_t n) const
Definition: hmetamatch2.h:192
HTofClusterSim * pTofClst
Bool_t fbdoMETAQANorm
true: (default) do correction for vertexz pos in ring sorting
const Cat_t catRKTrackB
Definition: hmdctrackgdef.h:9
pointers objects
Int_t getSumWires()
Definition: hmdccellgroup.h:64
void fillLayerPoints(HMdcSizesCells *fSizesCells, Bool_t secsys=kFALSE)
Definition: hmdclayer.cc:302
Bool_t fbdoMomentumCorr
true: (default) do normalization of RK meta dx
Float_t getEmcClusterQuality(UChar_t n) const
Definition: hmetamatch2.h:164
static Bool_t normDX(HParticleCand *c, TString beamtime="apr12")
Int_t findBestRich(HMetaMatch2 *meta, HMdcSeg *seg)
HRKTrackB * pRk
Bool_t fbdoRichAlign
true: keep only candidate which is not markerd as fake rejected
void fillMetaKal(HMetaMatch2 *meta, Int_t n=0, HKalTrack *rk=0)
Short_t getRungeKuttaIndTofClst(UChar_t n) const
Definition: hmetamatch2.h:190
Bool_t modStatus(Int_t s, Int_t m) const
Bool_t fbgoodLepton
true: keep only fitted RK
static Bool_t checkCropedLayer(HGeantKine *kine, HMdcLayer *mdcLayer, Bool_t *croped=0, Bool_t checkHit=kTRUE)
HRuntimeDb * getRuntimeDb(void)
Definition: hades.h:111
HKalTrack * pKalman
HEvent *& getCurrentEvent(void)
Definition: hades.cc:422
const Cat_t catGeantKine
Definition: hgeantdef.h:8
Float_t getChiq(void) const
Definition: hrktrackB.h:52
tracksVec commonTracks
emc_clst emcclst
Short_t getKalmanFilterIndTofClst(UChar_t n) const
Definition: hmetamatch2.h:203
void fill(HShowerHit *hit)
void getAlignedThetaPhi(const Float_t theta, const Float_t phi, Float_t &thetaCor, Float_t &phiCor)
Short_t getShowerHitInd(UChar_t n) const
Definition: hmetamatch2.h:156
Bool_t fbgoodSeg0
true: fill catParticleMdc
virtual HEventHeader * getHeader(void) const
Definition: hevent.h:36
Int_t fsortSwitch
: Particle::kMomRK or Particle::kMomKalman
Double_t phi1
Int_t n
Int_t getNParticipants()
closeVec closeTracks
void addObjectToOutput(TObject *obj)
Definition: hades.cc:1041
static HMdcSizesCells * getObject(void)
Float_t deltaPhiKal()
Int_t fRichCorrectionVersion
take into account for filling neighbour tracks with open angle < this
Bool_t fbgoodMeta
true: keep only fitted seg1
void checkCropLayer(HParticleCand *c)
HMdcSegSim * pSeg2
Float_t getChi2(void)
Definition: heventheader.h:18
HTofHitSim * pTofHit2
Float_t oAFitted
Float_t deltaPhiRk()
Bool_t rkSuccess
Double_t theta
Bool_t getCropedLayersEdge(TVector2 &p, Int_t s, Int_t m, Int_t l, Double_t &xmin, Double_t &xmax, Double_t &ymin, Double_t &ymax)
Definition: hmdclayer.cc:184
Int_t track2
Definition: hrichhitsim.h:32
static T * getObject(T *pout, Short_t num=-1, Int_t index=-1, Bool_t silent=kFALSE)
static HCategory * getCategory(Short_t num, Int_t warn=0, TString name="")
Short_t getEmcClusterInd(UChar_t n) const
Definition: hmetamatch2.h:157
void fillMeta(HMetaMatch2 *meta, Int_t n=0, HRKTrackB *rk=0)
Int_t track3
Definition: hrichhitsim.h:32
Float_t fScaleGoodTrack
scale weight of wires of ghost track (MDC)
static T * newObject(T *pout, Short_t num, Int_t &index)
const HGeomVector & getTargetMidPoint()
Definition: hmdclayer.h:58
HTofHitSim * pTofHit1
Int_t fmomSwitch
true: (default) loop geant kine and fill acceptance + crop bits
tracksVec mdc2Tracks
Bool_t fbnoFake
true: keep only candidate with ring match
HGeomVector & getPos(void)
Definition: heventheader.h:23
void fillCandShower(Bool_t rkSuccess, HMetaMatch2 *meta, candidate &cand, Int_t num, Int_t slot)
HRich700DigiPar * fRich700DigiPar
Bool_t fbFillMdc
debug mode ?
Short_t getRungeKuttaInd() const
Definition: hmetamatch2.h:195
Int_t getNTrack1(void) const
Definition: htofhitsim.h:19
const Cat_t catKalTrack
Definition: hmdctrackgdef.h:11
const Cat_t catTofCluster
Definition: tofdef.h:9
Bool_t fbdoRichVertexCorr
true: (default)align the rich (real data)
const Cat_t catEmcCluster
Definition: emcdef.h:10
Float_t getRichCorr(Float_t zVertex, Float_t thetaRich, Float_t phiRich)
UChar_t getNTimes(Int_t n) const
Definition: hmdcsegsim.h:72
const Cat_t catMetaMatch
Definition: hmdctrackgdef.h:7
void sortWeightNdet(void)
HSplineTrack * pSpline
void fillRKPlane(HMdcSizesCells *fSizesCells)
Definition: hmdclayer.cc:278
static void printSpace(TString space)
HEmcClusterSim * pEmcClst
void initVars()
-1=init 0=apr12,aug14,jul14 , 1 = mar19
void fill(HMdcSeg *)
HVertex & getVertexCluster(void)
Definition: heventheader.h:119
tracksVec mdc1Tracks
Int_t getOuterSegInd() const
kal_track kal
tracksVec tofTracks
Short_t getRungeKuttaIndEmcCluster(UChar_t n) const
Definition: hmetamatch2.h:189
Float_t alignPhiRich
const Cat_t catParticleMdc
Definition: hparticledef.h:14
tracksVec rpcTracks
const Cat_t catTofHit
Definition: tofdef.h:7
void fillMeta(HMetaMatch2 *meta, Int_t n=0)
Int_t getBeamTimeID()
Definition: hades.h:107
void fill(HKalTrack *trk)
void calcWeights(void)
void fillParticleCand(HParticleCand *part, Int_t index, Int_t momSwitch=Particle::kMomRK)
Hades * gHades
Definition: hades.cc:1213
HRpcClusterSim * pRpcClst
Double_t getRich700CircleCenterY()
Definition: hrichhit.h:120
rich_hit richhit
Float_t corrThetaRich
Int_t getSeg2Ind(void) const
Definition: hmdctrkcand.h:119
void setAtMdcEdge(UInt_t i)
Bool_t acceptPhiTheta(Int_t s, Float_t mom, Float_t dphi, Float_t dtheta)
void fillMeta(HMetaMatch2 *meta)
void fillCandSim(candidate &cand)
void fillParticleCandSim(HParticleCandSim *part, HCategory *kineCat=0)
tof_hit tof[3]
const Cat_t catRpcCluster
Definition: rpcdef.h:10
HShowerHitSim * pShowerHit
Float_t richMdcQuality
Float_t getQualityEmc() const
Definition: hrktrackB.h:67
void addTrackWeight(trackinfo *inf)
Int_t howManyTracks() const
HParSet * getContainer(const Text_t *)
Definition: hruntimedb.cc:124
tracksVec showerTracks
tracksVec emcTracks
HVertex & getVertexReco(void)
Definition: heventheader.h:120
static Float_t setCorrectedMomentum(HParticleCand *c)
tracksVec richTracks
Float_t getQualityShower() const
Definition: hrktrackB.h:66
Short_t getKalmanFilterIndRpcClst(UChar_t n) const
Definition: hmetamatch2.h:206
Int_t getNTracks(void) const
Definition: hmdcsegsim.h:33
void getTrackList(Int_t *array)
UChar_t getNCandForRich(void) const
Definition: hmetamatch2.h:208
void unsetAtMdcEdge(UInt_t i)
Definition: hgeantkine.h:289
Float_t deltaThetaSeg1()
void fill(HRKTrackB *rk)
Int_t getInterpolatedSectorThetaPhi(Float_t x, Float_t y, Float_t &theta, Float_t &phi)
static Float_t calcRichQA(HMdcSeg *seg, HRichHit *hit)
Float_t chi2
shower_hit showerhit
void fillMeta(HMetaMatch2 *meta)
UChar_t getNEmcClusters(void) const
Definition: hmetamatch2.h:152
Short_t getKalmanFilterIndTofHit2(UChar_t n) const
Definition: hmetamatch2.h:205
Int_t fMinWireGoodTrack
vector for all metaMatch objects candidates.
Int_t weigTrack1
Definition: hrichhitsim.h:33
Int_t weigTrack3
Definition: hrichhitsim.h:33
Short_t getRungeKuttaIndTofHit1(UChar_t n) const
Definition: hmetamatch2.h:191
Int_t getTrack(Int_t n) const
Definition: hmdcsegsim.h:68
void fillMeta(HMetaMatch2 *meta, Int_t n=0, HRKTrackB *rk=0)
HMdcSizesCells * fSizesCells
Int_t getNTrack1(Int_t i=0)
spline_track spline
Double_t getRich700CircleCenterX()
Definition: hrichhit.h:119
rpc_clst rpcclst
Short_t getRungeKuttaIndShowerHit(UChar_t n) const
Definition: hmetamatch2.h:188
Float_t deltaPhiSeg1()
void setCropedFilled()
Definition: hgeantkine.h:305
HMdcTrkCand * pMdcTrk
void fillMetaKal(HMetaMatch2 *meta, Int_t n=0, HKalTrack *rk=0)
Bool_t fbgoodSeg1
true: keep only fitted seg0
Int_t getNTrack2(void) const
Definition: htofhitsim.h:20
Float_t getShowerHitQuality(UChar_t n) const
Definition: hmetamatch2.h:163
void fillMeta(HMetaMatch2 *meta, Int_t n=0)
HParticleCandFillerPar * fFillerPar
sort by quality (0), radius(1)
void getIsAtBoxList(Bool_t *array)
Float_t theta
const Cat_t catMdcSeg
Definition: hmdcdef.h:10
Float_t getSumOfWeights(void)
Definition: heventheader.h:19
Short_t getKalmanFilterIndTofHit1(UChar_t n) const
Definition: hmetamatch2.h:204
void setIndex(Short_t ind)
Definition: hparticlemdc.h:46
Float_t phi
Definition: drawAccCuts.C:15
virtual HCategory * getCategory(Cat_t aCat)=0
Short_t getARichInd(UChar_t id) const
Definition: hmetamatch2.h:210
void reset(void)
void fillMeta(HMetaMatch2 *meta, Int_t n=0, Int_t hit=0)
Double_t getVertexZ()
Definition: heventheader.h:115
Bool_t isFake()
Definition: hmetamatch2.h:213
void fillCandNoMeta(Bool_t rkSuccess, HMetaMatch2 *meta, candidate &cand, Int_t num)
void fillMeta(HMetaMatch2 *meta)
Short_t getNTracks(void) const
Short_t getKalmanFilterIndEmcCluster(UChar_t n) const
Definition: hmetamatch2.h:202
void fill(HSplineTrack *trk)
static HMdcSeg * getMdcSeg(Int_t segind)
Int_t getGoodTrack(Int_t i1, HMdcSegSim *outerSeg, Int_t nWiresCut=5) const
Definition: hmdcsegsim.cc:280
UChar_t getNTofHits(void) const
Definition: hmetamatch2.h:153
UChar_t getNRpcClusters(void) const
Definition: hmetamatch2.h:150
Bool_t fbgoodRK
true: keep only candidate with META
static Float_t getOpeningAngle(Float_t phi1, Float_t theta1, Float_t phi2, Float_t theta2)
Int_t weigTrack2
Definition: hrichhitsim.h:33
void fill(HRpcCluster *clst)
void reset(void)
Short_t getKalmanFilterIndShowerHit(UChar_t n) const
Definition: hmetamatch2.h:201
const HMdcPlane * getMdcPlanes()
Definition: hmdclayer.h:60
Int_t track1
Definition: hrichhitsim.h:32
Char_t getNNotFakeTracks(void) const
Definition: hmdcsegsim.h:34
void fill(HMdcSeg *seg)
Bool_t isEmcCluster(void) const
Definition: hmetamatch2.h:143
Short_t getSector() const
Float_t theta
void fill(HRichHit *hit)
static Bool_t alignRichRing(const Double_t theta, const Double_t phi, Double_t &thetaCor, Double_t &phiCor)
Definition: htofhit.h:6
const Cat_t catShowerHit
Definition: showerdef.h:10
static HCategory * addCategory(Short_t num, TString name="", Int_t size=1000, TString partev="", Bool_t dynamicsize=kFALSE)
Short_t getRungeKuttaIndRpcClst(UChar_t n) const
Definition: hmetamatch2.h:193
Float_t chi2
void fillCandEmc(Bool_t rkSuccess, HMetaMatch2 *meta, candidate &cand, Int_t num, Int_t slot)
Bool_t isEMC
keep pointers for this candidate
Float_t alignThetaRich
Int_t getNTracks()
Definition: hshowerhitsim.h:22
vector< trackinfo * > tracks
const Cat_t catMdcTrkCand
Definition: hmdcdef.h:13
static Int_t findFirstHitInTof(Int_t trackID, Int_t modeTrack=2)
Int_t getTrack(Int_t n=0) const
Definition: hshowerhitsim.h:21
Float_t deltaThetaKal()
vector< candidate * > all_candidates
const Cat_t catSplineTrack
Definition: hmdctrackgdef.h:6
Bool_t isAcceptanceFilled()
Definition: hgeantkine.h:310
const Cat_t catParticleDebug
Definition: hparticledef.h:11
Float_t centery
void fillCandTof(Bool_t rkSuccess, HMetaMatch2 *meta, candidate &cand, Int_t num, Int_t slot)
static T * newSlot(T *pout, Short_t num, Int_t &index)
const Cat_t catParticleCand
Definition: hparticledef.h:9
void fill(HTofHit *hit, Int_t type=1)