HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hparticlebtringf.cc
Go to the documentation of this file.
1 //*-- Author : Patrick Sellheim, Georgy Kornakov
2 //*-- Created : 09/01/2014
3 
4 //_HADES_CLASS_DESCRIPTION
5 //////////////////////////////////////////////////////////////////////////////
6 //
7 // HParticleBtRingF
8 //
9 // This class predicts fired pads based on theta and phi angle of a track.
10 // Predicted pads and rich cal hits are stored and used to search for
11 // fired pads matching to prediction area.
12 //
13 //
14 //
15 //
16 //////////////////////////////////////////////////////////////////////////////
17 
18 #include "hparticlebtringf.h"
19 #include "TF2.h"
20 #include "hcategory.h"
21 #include "hparticlecand.h"
22 #include "heventheader.h"
23 
24 #include "hrichcal.h"
25 #include "hades.h"
26 #include "hruntimedb.h"
27 #include "hcategorymanager.h"
28 #include "hparticlebtangletrafo.h"
29 
30 
31 
32 // ----------------------------------------------------------------
33 
35 
36 // ----------------------------------------------------------------
37 
39 
40 }
41 
43 
44 }
45 
46 
48 
49  fNSector = 6;
50 
51  fBtPar =(HParticleBtPar*) gHades->getRuntimeDb()->getContainer("ParticleBtPar");
52  if(!fBtPar) {
53  Error ("init()", "Retrieve ZERO pointer for ParticleBtPar!");
54  return kFALSE;
55  }
56  //Init constants
63 
67 
71  memcpy(&fChargeLimit[0] ,fBtPar->getChargeThres() , sizeof(fChargeLimit) );
73 
76 
80 
81  memcpy(&fPhiOff[0] , fBtPar->getPhiOffset() , sizeof(fPhiOff ) );
82  memcpy(&fPhiOff2[0], fBtPar->getPhiOffset2(), sizeof(fPhiOff2 ) );
84 
85 
86  fPol2DMean.resize(fNRingSeg);
87  fPol2DSigma.resize(fNRingSeg);
88  for(Int_t bin=0; bin<fNRingSeg; bin++){
89  for(Int_t vertex=0; vertex<fNVertex; vertex++){
90  //Theta,Phi Range, + x: x is half step width of binning used for calculating theses values
91  fPol2DMean[bin].push_back( new TF2(Form("meanPol_%i_v%i",bin,vertex),"x*x*x*[0]+x*x*[1]+x*[2]+y*y*[3]+y*[4]+[5]+y*(x*x*[6]+x*[7])",20.+3.3,86.,0+7.51,60.));
92  fPol2DSigma[bin].push_back(new TF2(Form("sigmaPol_%i_v%i",bin,vertex),"TMath::Power(x,3)*[0]+TMath::Power(x,2)*[1]+x*[2]+TMath::Power(y,4)*[3]+TMath::Power(y,3)*[4]+TMath::Power(y,2)*[5]+y*[6]+[7]+y*(x*x*[8]+x*[9]+[10]) + x*(y*y*y*[11]+y*y*[12])",20.+3.3,86,8+7.51,60.));
93  for(Int_t par=0; par<fNParMean; par++)
94  fPol2DMean[bin][vertex] ->SetParameter(par, fBtPar->getTF2ParMean( bin, vertex, par));
95  for(Int_t par=0; par<fNParSigma; par++)
96  fPol2DSigma[bin][vertex]->SetParameter(par, fBtPar->getTF2ParSigma(bin, vertex, par));
97  }
98  fRad2Deg.push_back(TMath::DegToRad()*(bin*fNRingSegStep+fNRingSegOffset));
99  fRad2DegX.push_back(TMath::Sin(fRad2Deg[bin]));
100  fRad2DegY.push_back(-1*TMath::Cos(fRad2Deg[bin]));
101  }
102 
103  fFiredPads.resize( fNSector , vector<Int_t>( fNRichSeg , 0 ) );
104 
105  return kTRUE;
106 }
107 
108 
109 
110 //--------------------------------------------------------------------
111 // -- Helper functions
112 
113 void HParticleBtRingF::addressToColRow(const Int_t address, Int_t &sec, Int_t &row, Int_t &col)
114 {
115  //Converts richCal address to sector, column and row numbers
116 
117  sec = (Int_t)address/10000;
118  row = (Int_t)(address-sec*10000)/100;
119  col = address-sec*10000-row*100;
120  sec = sec==6 ? 0 : sec;
121 }
122 
123 Int_t HParticleBtRingF::correctPhi(const Int_t sec, const Float_t phi)
124 {
125  //Correct phi angle if phi angle disagrees with sector number
126  //Agreement is necessary for transformations from angle to RICH pad plane
127 
128  if(sec==0){
129  if(phi>120)
130  return 120;
131  else if(phi<60)
132  return 60;
133  else
134  return phi;
135  }else if(sec==1){
136  if(phi<120)
137  return 120;
138  else if(phi>180)
139  return 180;
140  else
141  return phi;
142  }else if(sec==2){
143  if(phi<180)
144  return 180;
145  else if(phi>240)
146  return 240;
147  else
148  return phi;
149  }else if(sec==3){
150  if(phi<240)
151  return 240;
152  else if(phi>300)
153  return 300;
154  else
155  return phi;
156  }else if(sec==4){
157  if(phi>360 || (phi>=0 && phi < 60))
158  return 360;
159  else if(phi<300)
160  return 300;
161  else
162  return phi;
163  }else{ //sec==5
164  if(phi>300 || phi<0)
165  return 0;
166  else if(phi >60 && phi<=300)
167  return 60;
168  else
169  return phi;
170  }
171 }
172 
173 void HParticleBtRingF::sortElements(Double_t &entry1 ,Double_t &entry2)
174 {
175  //Sorts 2 Double_t values by size (ascending)
176  if(entry1 >entry2){
177  Float_t tmp = entry1;
178  entry1 = entry2;
179  entry2 = tmp;
180  }
181 }
182 
183 
184 Int_t HParticleBtRingF::getVertexNum(const Float_t vertex)
185 {
186  //Returns vertex number to given z-vertex position
187 
188  for(Int_t i=0; i < fNVertex;i++){
189  if((vertex>-fVertexPosMin+(i*fVertexStep))&& (vertex<-fVertexPosMax+(i*fVertexStep))) return i;
190  }
191  if(vertex<=fVertexPosMin)
192  return 0;
193  else //v>-2.5
194  return 14;
195 }
196 
197 
198 
199 //--------------------------------------------------------------------
200 // -- Called once per event
201 
203 {
204  //Fills rich cal hit addresses and charges into vectors
205  //Bad hits and hits from bad events are exluded
206 
207  Int_t sizeRichCal = catRichCal->getEntries();
208  HRichCal* richCal;
209  Int_t sec;
210  Int_t col;
211  Int_t row;
212  for(Int_t l=0; l < sizeRichCal;l++){
213  richCal = HCategoryManager::getObject(richCal,catRichCal,l);
214  if(!richCal)
215  continue;
216  if(!richCal->getIsCleanedSector() && !richCal->getIsCleanedHigh()){
217  addressToColRow(richCal->getAddress(),sec, row, col);
218  if(richCal->getCharge() > fChargeLimit[sec]){
219  fRichHitAdd.push_back(richCal->getAddress());
220  fRichHitCharge.push_back(richCal->getCharge());
221  }
222  if(row<fRichSegBorderY){
223  fFiredPads[sec][0]++;
224  }else{
225  if(col<fRichSegBorderX)
226  fFiredPads[sec][1]++;
227  else
228  fFiredPads[sec][2]++;
229  }
230  }
231  }
232 }
233 
235 {
236  //Empties rich and track vectors
237 
238  for(UInt_t i = 0; i < fPrediction.size() ; i++ )
239  fPrediction[i].clear();
240  fPrediction.clear();
241  for(UInt_t i = 0; i < fRingMatrix.size() ; i++ )
242  fRingMatrix[i].clear();
243  fRingMatrix.clear();
244 
245  fRichHitAdd.clear();
246  fRichHitCharge.clear();
247  fTrackTheta.clear();
248  fTrackPhi.clear();
249  fTrackVertex.clear();
250  fTrackSec.clear();
251  fTrackPCandIdx.clear();
252  fIsGoodTrack.clear();
253  fPosXCenter.clear();
254  fPosYCenter.clear();
255 
256  for(Int_t i = 0; i < fNSector ; i++ ){
257  for(Int_t j = 0; j < fNRichSeg ; j++ ){
258  fFiredPads[i][j]=0;
259  }
260  }
261 
262 }
263 
264 
265 //--------------------------------------------------------------------
266 // -- Called once per track
267 
268 //Marks pads in area around ring center
269 void HParticleBtRingF::fillMatrix(Int_t xPad, Int_t yPad, Int_t sec)
270 {
271  //Marks area around ring center
272  //Address are stored in ringMatrix vector
273 
274  Int_t address = 0;
275 
276  vector <Int_t> ringMatrixVec;
277  xPad -= fSizeMatrix*0.5;
278  yPad -= fSizeMatrix*0.5;
279  address = 10000 * (sec ? sec : 6) + 100 * yPad + xPad;
280 
281 
282  for(Int_t posX=0; posX <fSizeMatrix; posX++){
283  for(Int_t posY=0; posY <fSizeMatrix; posY++){
284  if( TMath::Sqrt( TMath::Power(TMath::Abs(fSizeMatrix*0.5-posX),2) + TMath::Power(TMath::Abs(fSizeMatrix*0.5-posY),2) ) < (Float_t)fSizeMatrix/2. ){
285  ringMatrixVec.push_back(address+posY*100+posX);
286  }
287  }
288  }
289  fRingMatrix.push_back(ringMatrixVec);
290 }
291 
292 
293 void HParticleBtRingF::fillPrediction(const HParticleCand* cand, HVertex &vertex, Bool_t isGoodTrack, const Bool_t doAngleCorr)
294 {
295  //Theta and phi angles and vertex position is used to determine track position on pad plane
296  //Information about optical ring distortion is used to predict fired pads in defined sigma area
297  //Mean values with neighbouring sectors assure a more smooth ring prediction
298  //Predicted pads are stored in prediction vector
299 
300  HParticleBtAngleTrafo richAngles;
301 
302  Int_t address = 0;
303  Double_t theta = cand->getTheta();
304  Double_t phi = cand->getPhi();
305  Int_t sec = cand->getSector();
306  Float_t candZ = cand->getZ();
307  Float_t vertexZ = vertex.getZ();
308  Int_t vertexNum;
309  Double_t radius;
310  Double_t sigma;
311  Double_t sigmaX0;
312  Double_t sigmaY0;
313  Double_t radiusSeg0;
314  Double_t sigmaSeg0;
315  Double_t sigmaX0Seg0;
316  Double_t sigmaY0Seg0;
317  Double_t radiusNext;
318  Double_t sigmaNext;
319  Double_t sigmaX0Next;
320  Double_t sigmaY0Next;
321  Double_t sigNum;
322  vector <Int_t> predictionVec;
323 
324  phi = correctPhi(sec,phi);
325 
326  if(theta>fThetaAngleMin && theta < fThetaAngleMax)
327  {
328  //Cases if no vertex was reconstructed
329  if(vertexZ > -80. && vertexZ < 20.){
330  vertexNum = getVertexNum(vertexZ);
331  }else if(candZ > -80. && candZ < 20.){
332  vertexZ = candZ;
333  vertexNum = getVertexNum(candZ);
334  }else if(candZ <= -80.){
335  vertexZ = -80.;
336  vertexNum = getVertexNum(-80.);
337  }else{
338  vertexZ = 20.;
339  vertexNum = getVertexNum(20.);
340  }
341 
342 
343 
344  //Correct theta and phi angle
345  Double_t thetaCor;
346  Double_t phiCor;
347  if(doAngleCorr){
348  if(fAngleCor.alignRichRing(theta,phi, thetaCor, phiCor)){
349  theta = thetaCor;
350  phi = phiCor;
351  }
352  }
353 
354  thetaCor = richAngles.zTheta2dTheta(vertexZ,theta, -(phi-fPhiOff[sec]));
355  theta-=thetaCor;
356 
357 
358 
359  //Transform angles to x,y Padplane coordinates
360  Double_t xPad = richAngles.angles2xPad(theta,-(phi-fPhiOff[sec]));
361  Double_t yPad = richAngles.angles2yPad(theta,-(phi-fPhiOff[sec]));
362  Double_t posX = richAngles.angles2x(theta,-(phi-fPhiOff[sec]));
363  Double_t posY = richAngles.angles2y(theta,-(phi-fPhiOff[sec]));
364 
365 
366  //z vertex correction
367  Double_t yPadCorr = richAngles.zTheta2dYPad(vertexZ,theta,-(phi-fPhiOff2[sec]));
368  Double_t xPadCorr = richAngles.zTheta2dXPad();
369  Double_t posXCorr = richAngles.zTheta2dY(vertexZ,theta,-(phi-fPhiOff2[sec]));
370  Double_t posYCorr = richAngles.zTheta2dX();
371  posX += posXCorr;
372  posY += posYCorr;
373  xPad += xPadCorr;
374  yPad += yPadCorr;
375 
376 
377  //Coordinates for n sigma areas
378  Double_t sigmaX[2] = {0.,0.};
379  Double_t sigmaY[2] = {0.,0.};
380  Double_t padX[2] = {0.,0.};
381  Double_t padY[2] = {0.,0.};
382  Int_t padXRound[2] = {0,0};
383  Int_t padYRound[2] = {0,0};
384 
385  sigNum=fNSigma;
386 
387  //Loop over different phi angles of the ring
388  for( Int_t bin = 0; bin < fNRingSeg; bin++ ) {
389 
390  //Find neighbouring segments
391  Int_t binPrev;
392  Int_t binNext;
393  if(bin==0){
394  binPrev = fNRingSeg-1;
395  binNext = 2;
396  }
397  else if(bin==fNRingSeg-1){
398  binPrev = fNRingSeg-2;
399  binNext = 0;
400  }
401  else{
402  binPrev = bin-1;
403  binNext = bin+1;
404  }
405  radius = fPol2DMean[bin][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
406  sigma = fPol2DSigma[bin][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
407  sigmaX0 = fRad2DegX[bin]*sigNum*sigma;
408  sigmaY0 = fRad2DegY[bin]*sigNum*sigma;
409 
410 
411  //Smooth ring prediction area width neighbour sigma and radius
412  radiusSeg0 = fPol2DMean[binPrev][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
413  sigmaSeg0 = fPol2DSigma[binPrev][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
414  sigmaX0Seg0 = fRad2DegX[binPrev]*sigNum*sigmaSeg0;
415  sigmaY0Seg0 = fRad2DegY[binPrev]*sigNum*sigmaSeg0;
416 
417  radiusNext = fPol2DMean[binNext][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
418  sigmaNext = fPol2DSigma[binNext][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
419  sigmaX0Next = fRad2DegX[binNext]*sigNum*sigmaNext;
420  sigmaY0Next = fRad2DegY[binNext]*sigNum*sigmaNext;
421 
422 
423  radius = (radius + radiusSeg0 + radiusNext )/3.;
424  if(sigma<sigmaSeg0){
425  sigma = (sigma + sigmaSeg0 + sigmaNext )/3.;
426  sigmaX0 = (sigmaX0+ sigmaX0Seg0 + sigmaX0Next )/3.;
427  sigmaY0 = (sigmaY0+ sigmaY0Seg0 + sigmaY0Next )/3.;
428  }
429 
430  //Smooth Overlap region
431  if(bin==fNRingSeg-1 || bin==fNRingSeg-2 || bin==fNRingSeg-3){
432  radiusSeg0 = fPol2DMean[0][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
433  sigmaSeg0 = fPol2DSigma[0][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
434  sigmaX0Seg0 = fRad2DegX[0]*sigNum*sigmaSeg0;
435  sigmaY0Seg0 = fRad2DegY[0]*sigNum*sigmaSeg0;
436 
437  radius = (radius + radiusSeg0 )/2.;
438  if(sigma<sigmaSeg0){
439  sigma = (sigma + sigmaSeg0 )/2.;
440  sigmaX0 = (sigmaX0+ sigmaX0Seg0)/2.;
441  sigmaY0 = (sigmaY0+ sigmaY0Seg0)/2.;
442  sigma = sigmaSeg0 ;
443  sigmaX0 = sigmaX0Seg0;
444  sigmaY0 = sigmaY0Seg0;
445  }
446  }
447  if(bin==0 || bin==1 || bin==2){
448  radiusSeg0 = fPol2DMean[fNRingSeg-1][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
449  sigmaSeg0 = fPol2DSigma[fNRingSeg-1][vertexNum]->Eval(theta,-(phi-fPhiOff[sec])+fPhiOffsetPar);
450  sigmaX0Seg0 = fRad2DegX[fNRingSeg-1]*sigNum*sigmaSeg0;
451  sigmaY0Seg0 = fRad2DegY[fNRingSeg-1]*sigNum*sigmaSeg0;
452 
453  radius = (radius + radiusSeg0 )/2.;
454  if(sigma<sigmaSeg0){
455  sigma = (sigma + sigmaSeg0 )/2.;
456  sigmaX0 = (sigmaX0+ sigmaX0Seg0)/2.;
457  sigmaY0 = (sigmaY0+ sigmaY0Seg0)/2.;
458  sigma = sigmaSeg0 ;
459  sigmaX0 = sigmaX0Seg0;
460  sigmaY0 = sigmaY0Seg0;
461  }
462  }
463 
464 
465  sigmaX[0] = fRad2DegX[bin]*radius-sigmaX0;
466  sigmaY[0] = fRad2DegY[bin]*radius-sigmaY0;
467  sigmaX[1] = fRad2DegX[bin]*radius+sigmaX0;
468  sigmaY[1] = fRad2DegY[bin]*radius+sigmaY0;
469  sortElements(sigmaX[0],sigmaX[1]);
470  sortElements(sigmaY[0],sigmaY[1]);
471  padX[0] = richAngles.x2xPad(posX+sigmaX[0]);
472  padY[0] = richAngles.xy2yPad(posX+sigmaX[0],posY+sigmaY[0]);
473  padX[1] = richAngles.x2xPad(posX+sigmaX[1]);
474  padY[1] = richAngles.xy2yPad(posX+sigmaX[1],posY+sigmaY[1]);
475 
476 
477 
478  padXRound[0] = TMath::Floor(padX[0]);
479  padXRound[1] = TMath::Floor(padX[1]);
480  padYRound[0] = TMath::Floor(padY[0]);
481  padYRound[1] = TMath::Floor(padY[1]);
482 
483  //Convert pad position in address and store address in vector
484  Int_t padY0=padY[0];
485  while(padXRound[0] <= padXRound[1]){
486 
487  while(padYRound[0] <= padYRound[1]){
488  address = 10000 * (sec ? sec : 6) + 100 * padYRound[0] + padXRound[0];
489 
490  //Fill only if object is not yet stored in vector
491  Bool_t kFound=kFALSE;
492  UInt_t pred=0;
493  while(pred < predictionVec.size() && !kFound){
494  if(predictionVec[pred] == address)
495  kFound=kTRUE;
496  pred++;
497 
498  }
499  if(!kFound)
500  predictionVec.push_back(address);
501 
502  padYRound[0]++;
503  }
504  padYRound[0]=padY0;
505  padXRound[0]++;
506  }
507  }
508  fPrediction.push_back(predictionVec);
509  fTrackTheta.push_back(theta);
510  fTrackPhi.push_back(phi);
511  fTrackVertex.push_back(vertexNum);
512  fTrackSec.push_back(sec);
513  fTrackPCandIdx.push_back(cand->getIndex());
514  fIsGoodTrack.push_back(isGoodTrack);
515  fPosXCenter.push_back(xPad);
516  fPosYCenter.push_back(yPad);
517 
518  fillMatrix(TMath::Floor(xPad),TMath::Floor(yPad),sec);
519 
520  } else {
521  predictionVec.clear();
522  predictionVec.push_back(-1);
523  fPrediction.push_back(predictionVec);
524  fTrackTheta.push_back(-1);
525  fTrackPhi.push_back(-1);
526  fTrackVertex.push_back(-1);
527  fTrackSec.push_back(-1);
528  fTrackPCandIdx.push_back(-1);
529  fIsGoodTrack.push_back(kFALSE);
530  fRingMatrix.push_back(predictionVec);
531  fPosXCenter.push_back(-1.);
532  fPosYCenter.push_back(-1.);
533 
534  }
535 
536 }
537 
538 
539 
540 Float_t HParticleBtRingF::getRingMatrix(const Int_t trackNo)
541 {
542  //Returns fraction of pads fired on ring prediction compared to pads fired in ring matrix around ring center
543 
544  Int_t padsFired = 0;
545  Int_t padsFiredPred = 0;
546  Float_t chargeFired = 0;
547  Float_t chargeFiredPred = 0;
548 
549  for(UInt_t i=0; i<fRingMatrix[trackNo].size(); i++){
550  for(UInt_t j=0; j<fRichHitAdd.size(); j++){
551  if(fRingMatrix[trackNo][i]==fRichHitAdd[j]){
552  padsFired++;
553  chargeFired +=fRichHitCharge[j];
554  for(UInt_t k=0; k<fPrediction[trackNo].size(); k++){
555  if(fRingMatrix[trackNo][i]==fPrediction[trackNo][k]){
556  padsFiredPred++;
557  chargeFiredPred +=fRichHitCharge[j];
558  }
559  }
560  }
561  }
562  }
563  return (Float_t)chargeFiredPred/(Float_t)chargeFired;
564 }
565 
566 Float_t HParticleBtRingF::getTrackTheta(Int_t trackNo)
567 {
568  //Returns theta angle for given trackNo
569  if(trackNo<(Int_t)fTrackTheta.size()) {
570  return fTrackTheta[trackNo];
571  } else return -1;
572 }
573 
574 Float_t HParticleBtRingF::getTrackPhi(Int_t trackNo)
575 {
576  //Returns phi angle for given trackNo
577  if(trackNo<(Int_t)fTrackPhi.size()) {
578  return fTrackPhi[trackNo];
579  } else return -1;
580 }
581 
583 {
584  //Returns vertex number for given trackNo
585  if(trackNo<(Int_t)fTrackVertex.size()) {
586  return fTrackVertex[trackNo];
587  } else return -1;
588 }
589 
590 Int_t HParticleBtRingF::getTrackSec(Int_t trackNo)
591 {
592  //Returns sector for given trackNo
593  if(trackNo<(Int_t)fTrackSec.size()) {
594  return fTrackSec[trackNo];
595  } else return -1;
596 }
597 
598 Float_t HParticleBtRingF::getPosXCenter(Int_t trackNo)
599 {
600  //Returns phi angle for given trackNo
601  if(trackNo<(Int_t)fPosXCenter.size()) {
602  return fPosXCenter[trackNo];
603  } else return -1;
604 }
605 
606 Float_t HParticleBtRingF::getPosYCenter(Int_t trackNo)
607 {
608  //Returns phi angle for given trackNo
609  if(trackNo<(Int_t)fPosYCenter.size()) {
610  return fPosYCenter[trackNo];
611  } else return -1;
612 }
613 
614 Bool_t HParticleBtRingF::isGoodTrack(Int_t trackNo)
615 {
616  //Returns sector for given trackNo
617  if(trackNo<(Int_t)fTrackSec.size()) {
618  return fIsGoodTrack[trackNo];
619  } else return 0;
620 }
621 
623 {
624  //Stores ring,track and rich information in arrays
625  //Arrays are stored in HParticleBtRingFInfo for output
626  Bool_t kOverflow = kFALSE;
627 
628  Int_t prediction [128][128]; //tracks,predicted pads
629  Int_t ringMatrix [128][128];
630  Int_t richHitAdd [1024]; //fired pads
631  Float_t richHitCharge [1024];
632 
633  Float_t trackTheta [128];
634  Float_t trackPhi [128];
635  Int_t trackVertex [128];
636  Int_t trackSec [128];
637  Int_t trackPCandIdx [128];
638  Bool_t isGoodTrack [128];
639  Float_t posXCenter [128];
640  Float_t posYCenter [128];
641 
642 
643  //Initialization
644  for(Int_t i = 0; i < 128; i++ ){
645  for(Int_t j = 0; j < 128; j++ ){
646  prediction[i][j] = -1;
647  ringMatrix[i][j] = -1;
648  }
649  }
650 
651  for(Int_t i = 0; i < 1024; i++ ){
652  richHitAdd[i] = -1;
653  richHitCharge[i] = -1.;
654  }
655 
656  for(Int_t i = 0; i < 128; i++ ){
657  trackTheta[i] = -1.;
658  trackPhi[i] = -1.;
659  trackVertex[i] = -1;
660  trackSec[i] = -1;
661  trackPCandIdx[i] = -1;
662  isGoodTrack[i] = kFALSE;
663  posXCenter[i] = -1.;
664  posYCenter[i] = -1.;
665  }
666 
667  //Fill vector to array and check if vector size is too large
668  if(fPrediction.size() <= 128){
669  for(UInt_t i = 0; i < fPrediction.size(); i++ ){
670  if(fPrediction[i].size() <= 128){
671  for(UInt_t j = 0; j < fPrediction[i].size(); j++ ){
672  prediction[i][j] = fPrediction[i][j];
673  ringMatrix[i][j] = fRingMatrix[i][j];
674  }
675  }
676  else
677  kOverflow = kTRUE;
678  }
679  }else
680  kOverflow = kTRUE;
681 
682 
683  if(fRichHitAdd.size() <= 1024){
684  for(UInt_t i = 0; i < fRichHitAdd.size(); i++ ){
685  richHitAdd[i] = fRichHitAdd[i];
686  richHitCharge[i] = fRichHitCharge[i];
687  }
688  }else
689  kOverflow =kTRUE;
690  if(fTrackTheta.size()<=128){
691  for(UInt_t i = 0; i < fTrackTheta.size(); i++ ){
692  trackTheta[i] = fTrackTheta[i];
693  trackPhi[i] = fTrackPhi[i];
694  trackVertex[i] = fTrackVertex[i];
695  trackSec[i] = fTrackSec[i];
696  trackPCandIdx[i] = fTrackPCandIdx[i];
697  isGoodTrack[i] = fIsGoodTrack[i];
698  posXCenter[i] = fPosXCenter[i];
699  posYCenter[i] = fPosYCenter[i];
700  }
701  }else
702  kOverflow =kTRUE;
703 
704  btRingInfo->setPrediction ( prediction );
705  btRingInfo->setRingMatrix ( ringMatrix );
706  btRingInfo->setRichHitAdd ( richHitAdd );
707  btRingInfo->setRichHitCharge ( richHitCharge);
708 
709  btRingInfo->setTrackTheta ( trackTheta );
710  btRingInfo->setTrackPhi ( trackPhi );
711  btRingInfo->setTrackVertex ( trackVertex );
712  btRingInfo->setTrackSec ( trackSec );
713  btRingInfo->setTrackPCandIdx ( trackPCandIdx);
714  btRingInfo->setIsGoodTrack ( isGoodTrack );
715  btRingInfo->setPosXCenter ( posXCenter );
716  btRingInfo->setPosYCenter ( posYCenter );
717 
718  return kOverflow;
719 
720 }
721 
722 Int_t HParticleBtRingF::plotPrediction(Int_t trackNo = -1)
723 {
724  Int_t returnVal = 0 ;
725  for(UInt_t j = 0; j < fPrediction[trackNo].size(); j++ ){
726  Bool_t hasHit = kFALSE;
727  for(UInt_t k = 0; k < fRichHitAdd.size(); k++ ){
728  if(fRichHitAdd[k] == fPrediction[trackNo][j]){
729  hasHit = kTRUE;
730  returnVal++;
731  }
732  }
733  cout << fPrediction[trackNo][j] << " - " <<"["<< hasHit << "]" << endl;
734  }
735 
736 return returnVal;
737 }
738 
739 
740 void HParticleBtRingF::plotRichHit(Int_t trackNo = -1)
741 {
742  Int_t sec[2];
743  Int_t row[2];
744  Int_t col[2];
745  Int_t plotCounter = 0 ;
746  for(UInt_t i = 0; i < fRichHitAdd.size(); i++ ){
747  addressToColRow(fRichHitAdd[i] ,sec[0], row[0], col[0]);
748  addressToColRow(fPrediction[trackNo][1],sec[1], row[1], col[1]);
749  if(sec[0] == sec[1]){
750  cout << fRichHitAdd[i] << " -- " ;
751  plotCounter++;
752  if(plotCounter%5 == 0)
753  cout << endl;
754  }
755  }
756 
757 }
758 
759 
760 
761 Bool_t HParticleBtRingF::hasNoisyRichSeg(Bool_t *trackInSec)
762 {
763  Bool_t secUsed[6];
764  for(Int_t i=0;i<6;i++) secUsed[0+i] = trackInSec[i];
765  Bool_t isNoisy = kFALSE;
766  for(Int_t i = 0; i < fNSector; i++){
767  for(Int_t j = 0; j < fNRichSeg; j++){
768  if( fFiredPads[i][j] > 100 && secUsed[i])
769  isNoisy = kTRUE;
770  }
771  }
772  if(isNoisy)
773  cout << "hparticlebtringf: Noisy RICH segment detected and removed" << endl;
774  return isNoisy;
775 }
776 
777 
vector< Int_t > fTrackSec
vector< Int_t > fTrackVertex
Float_t getPhi() const
Definition: hvirtualcand.h:60
Float_t * getChargeThresMax()
vector< vector< Int_t > > fPrediction
Double_t getZ()
Definition: heventheader.h:22
Int_t getAddress(void) const
Definition: hrichcal.h:116
Float_t getSigmaRangeMax()
void fillPrediction(const HParticleCand *cand, HVertex &vertex, Bool_t isGoodTrack, const Bool_t doAngleCorr)
vector< vector< Int_t > > fRingMatrix
Int_t getTrackSec(Int_t trackNo)
vector< vector< Int_t > > fFiredPads
Float_t angles2x(const Float_t theta, const Float_t phi)
ClassImp(HParticleBtRingF) HParticleBtRingF
Float_t getVertexPosMin()
Float_t getThetaAngleMax()
void setPrediction(Int_t val[][128])
Float_t zTheta2dYPad(const Float_t z, const Float_t theta, const Float_t phi)
Float_t getThetaAngleMin()
vector< Float_t > fTrackTheta
Float_t getSigmaRange()
HRuntimeDb * getRuntimeDb(void)
Definition: hades.h:111
Int_t getRingSegOffset()
Int_t getRichSegBorderX()
vector< vector< TF2 * > > fPol2DSigma
Float_t angles2yPad(const Float_t theta, const Float_t phi)
vector< Float_t > fRichHitCharge
vector< Float_t > fRad2DegX
Float_t x2xPad(const Float_t x)
vector< Bool_t > fIsGoodTrack
Float_t getCharge(void) const
Definition: hrichcal.h:84
Float_t getVertexStep()
Int_t getNVertex()
Float_t getVertexPosMax()
Float_t getPosXCenter(Int_t trackNo)
Double_t theta
Int_t correctPhi(const Int_t sec, const Float_t phi)
static T * getObject(T *pout, Short_t num=-1, Int_t index=-1, Bool_t silent=kFALSE)
Float_t getOffsetPar()
void fillRichCal(HCategory *catRichCal)
vector< Int_t > fRichHitAdd
Float_t zTheta2dY(const Float_t z, const Float_t theta, const Float_t phi)
Short_t getIndex() const
Bool_t isGoodTrack(Int_t trackNo)
Float_t getPosYCenter(Int_t trackNo)
vector< Int_t > fTrackPCandIdx
Int_t getNParMean()
Float_t fChargeLimit[6]
Int_t getNRichSeg()
vector< vector< TF2 * > > fPol2DMean
vector< Float_t > fRad2DegY
HParticleBtPar * fBtPar
Float_t getTrackPhi(Int_t trackNo)
void setRichHitCharge(Float_t *val)
vector< Float_t > fTrackPhi
vector< Float_t > fRad2Deg
void setRingMatrix(Int_t val[][128])
Hades * gHades
Definition: hades.cc:1213
Float_t getTrackTheta(Int_t trackNo)
Float_t * getPhiOffset2()
void addressToColRow(const Int_t address, Int_t &sec, Int_t &row, Int_t &col)
Float_t getTheta() const
Definition: hvirtualcand.h:61
void setTrackVertex(Int_t *val)
vector< Float_t > fPosXCenter
void plotRichHit(Int_t trackNo)
HParSet * getContainer(const Text_t *)
Definition: hruntimedb.cc:124
void setTrackPhi(Float_t *val)
Int_t getNRingSegments()
Bool_t getIsCleanedHigh(void) const
Definition: hrichcal.h:128
Float_t xy2yPad(const Float_t x, const Float_t y)
void setPosXCenter(Float_t *val)
Bool_t getIsCleanedSector(void) const
Definition: hrichcal.h:132
void setTrackTheta(Float_t *val)
void sortElements(Double_t &entry1, Double_t &entry2)
vector< Float_t > fPosYCenter
Float_t * getChargeThres()
void setIsGoodTrack(Bool_t *val)
Float_t getRingMatrix(const Int_t trackNo)
void fillMatrix(Int_t xPad, Int_t yPad, Int_t sec)
Int_t getRichSegBorderY()
Int_t getVertexNum(const Float_t vertex)
Float_t angles2y(const Float_t theta, const Float_t phi)
void setPosYCenter(Float_t *val)
Float_t * getPhiOffset()
Float_t phi
Definition: drawAccCuts.C:15
void setTrackSec(Int_t *val)
Bool_t fillRingInfo(HParticleBtRingInfo *btRingInfo)
Float_t getZ() const
Definition: hvirtualcand.h:63
Float_t zTheta2dTheta(const Float_t z, const Float_t theta, const Float_t phi)
Int_t plotPrediction(Int_t trackNo)
Int_t getTrackVertex(Int_t trackNo)
Bool_t hasNoisyRichSeg(Bool_t *trackInSec)
Int_t getSizeMatrix()
Short_t getSector() const
static Bool_t alignRichRing(const Double_t theta, const Double_t phi, Double_t &thetaCor, Double_t &phiCor)
Double_t getTF2ParMean(Int_t ringSeg, Int_t vertex, Int_t par)
Int_t getRingSegStep()
HParticleAngleCor fAngleCor
Float_t angles2xPad(const Float_t theta, const Float_t phi)
Float_t fChargeLimitMaximum[6]
const Cat_t catRichCal
Definition: richdef.h:40
void setRichHitAdd(Int_t *val)
Double_t getTF2ParSigma(Int_t ringSeg, Int_t vertex, Int_t par)
Int_t getNParSigma()
void setTrackPCandIdx(Int_t *val)