StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEventHelper.cxx
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <assert.h>
4 #include "TROOT.h"
5 #include "TClass.h"
6 #if ROOT_VERSION_CODE < 331013
7 #include "TCL.h"
8 #else
9 #include "TCernLib.h"
10 #endif
11 #include "TMath.h"
12 #include "TBaseClass.h"
13 #include "TDataMember.h"
14 #include "TMethod.h"
15 #include "TMethodArg.h"
16 #include "TDataType.h"
17 #include "TMemberInspector.h"
18 #include "TExMap.h"
19 #include "TCollection.h"
20 #include "TRegexp.h"
21 #include "TRandom.h"
22 #include "TError.h"
23 #include "TPoints3DABC.h"
24 #include "TSystem.h"
25 #include "TPad.h"
26 #include "TView.h"
27 
28 #include "StEvent.h"
29 #include "StObject.h"
30 #include "StHit.h"
31 #include "StTrack.h"
32 #include "StGlobalTrack.h"
33 #include "StTrackNode.h"
34 #include "StVertex.h"
35 #include "StTrackGeometry.h"
36 #include "StTrackDetectorInfo.h"
37 // For L3 filter
38 #if 0
39 #include "StarClassLibrary/BetheBloch.h"
40 #else
41 #include "StBichsel/Bichsel.h"
42 #endif
43 #include "StEvent/StDedxPidTraits.h"
44 // For coloring filter
45 #include "StEventTypes.h"
46 #include "StProbPidTraits.h"
47 #include "StTpcDedxPidAlgorithm.h"
48 #include "THelixTrack.h"
49 
50 #define __EVENTHELPER_ONLY__
51 #include "StEventHelper.h"
52 #include "StEventHitIter.h"
53 #undef __EVENTHELPER_ONLY__
54 #include <map>
55 
56 #include "StRnDHitCollection.h"
57 #include "StEtrHitCollection.h"
58 
59 void Break(){printf("InBreak\n");}
60 
61 std::map<long,long> myMap;
62 typedef std::pair <long,long> MyPair;
63 std::map <long,long> :: const_iterator myFinder;
64 
65 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,34,29)
66 typedef TMemberInspector StEventInspector;
67 #else
68 
69 class StEventInspector : public TMemberInspector {
70 public:
71 StEventInspector(TExMap *map,Int_t &count,const char *opt="");
72 virtual ~StEventInspector(){delete fSkip;};
73 virtual void Inspect(TClass* cl, const char* parent, const char* name, const void* addr);
74  void CheckIn(TObject *obj,const char *bwname="");
75 
76 Int_t &fCount;
77 TExMap *fMap;
78 TRegexp *fSkip;
79 TString fOpt;
80 
81 };
82 //______________________________________________________________________________
83 StEventInspector::StEventInspector(TExMap *map,Int_t &count,const char *opt):fCount(count)
84 {
85  fMap = map;
86  fSkip = 0;
87  fOpt = opt;
88  if (fOpt.Length()) fSkip = new TRegexp(fOpt.Data());
89 }
90 //______________________________________________________________________________
91 void StEventInspector::Inspect(TClass* kl, const char* tit , const char* name, const void* addr)
92 {
93  if(tit && strchr(tit,'.')) return ;
94 
95  TString ts;
96 
97  if (!kl) return;
98  if (name[0] == '*') name++;
99  int ln = strcspn(name,"[ ");
100  TString iname(name,ln);
101  const char *iName=iname.Data();
102  if (iName[1]=='P' && strcmp(iName,"fParent" )==0) return;
103  if (iName[0]=='G' && strcmp(iName,"G__virtualinfo")==0) return;
104 
105  G__ClassInfo *classInfo = (G__ClassInfo *)kl->GetClassInfo();
106  if (!classInfo) return;
107  G__ClassInfo &cl = *classInfo;
108 
109 
110 // Browse data members
111  G__DataMemberInfo m(cl);
112  int found=0;
113  const char *mName=0;
114  while (m.Next()) { // MemberLoop
115  mName = m.Name();
116  if (mName[1] != iName[1]) continue;
117  if (strcmp(mName,iName) ) continue;
118  found = 1; break;
119  }
120  assert(found);
121 
122  // we skip: non TObjects
123  // - the member G__virtualinfo inserted by the CINT RTTI system
124 
125  long prop = m.Property() | m.Type()->Property();
126  if (prop & G__BIT_ISFUNDAMENTAL) return;
127  if (prop & G__BIT_ISSTATIC) return;
128  if (prop & G__BIT_ISENUM) return;
129  if (strcmp(m.Type()->Fullname(),"TObject") && !m.Type()->IsBase("TObject"))
130  return;
131 
132  int size = sizeof(void*);
133  if (!(prop&G__BIT_ISPOINTER)) size = m.Type()->Size();
134 
135  int nmax = 1;
136  if (prop & G__BIT_ISARRAY) {
137  for (int dim = 0; dim < m.ArrayDim(); dim++) nmax *= m.MaxIndex(dim);
138  }
139 
140  for(int i=0; i<nmax; i++) {
141  char *ptr = (char*)addr + i*size;
142  TObject *obj = (prop&G__BIT_ISPOINTER) ? *((TObject**)ptr) : (TObject*)ptr;
143  if (!obj) continue;
144  const char *bwname = obj->ClassName();
145  if (!bwname[0] || strcmp(bwname,obj->ClassName())==0) {
146  bwname = name;
147  int l = strcspn(bwname,"[ ");
148  if (bwname[l]=='[') {
149  char cbuf[12]; sprintf(cbuf,"[%02d]",i);
150  ts.Replace(0,999,bwname,l);
151  ts += cbuf;
152  bwname = (const char*)ts;
153  }
154  }
155 
156  CheckIn(obj,bwname);
157 
158  }
159 
160 }
161 //______________________________________________________________________________
162 void StEventInspector::CheckIn(TObject *obj,const char *bwname)
163 {
164  if (!obj) return;
165  TObject *inobj=0;
166  if (obj->InheritsFrom(StRefArray::Class())) return;
167  if (obj->InheritsFrom( StObjLink::Class())) return;
168  int n;
169  if (fSkip && (fSkip->Index(obj->ClassName(),&n)>=0)) return;
170 
171  if (obj->InheritsFrom(TCollection::Class())){
172  TCollection *tcol = (TCollection*)obj;
173  TIter next(tcol);
174  while ((inobj=next())) {CheckIn(inobj);}
175  return;
176  }
177 
178  if (obj->InheritsFrom(StXRef::Class())){
179  LongKey_t &inmap = (*fMap)(TMath::Hash(&obj,sizeof(void*)),(Long_t)obj);
180  myFinder = myMap.find((long)obj);
181  assert((inmap==0) == (myFinder==myMap.end()));
182 
183  if (inmap) return;
184  myMap.insert(MyPair((long)obj,1));
185  inmap = 1;fCount++;
186  }
187 
188  if (obj->InheritsFrom(StStrArray::Class())){
189 // if (obj->IsA()==StSPtrVecTrackNode::Class()) Break();
190  if (((StStrArray*)obj)->size()) {
191 
192 
193  LongKey_t &inmap = (*fMap)(TMath::Hash(&obj,sizeof(void*)),(Long_t)obj);
194  myFinder = myMap.find((long)obj);
195  assert((inmap==0) == (myFinder==myMap.end()));
196  if (inmap) return;
197  myMap.insert(MyPair((long)obj,2));
198 
199  inmap = 2; fCount++;
200  int vecobj = ( obj->IsA() == StSPtrVecObject::Class());
201  // printf("%8d %p %s::%s\n",fLevel,(void*)obj,obj->GetName(),bwname);
202  StStrArray *arr = (StStrArray*)obj;
203  int sz = arr->size();
204  for (int idx=0;idx<sz; idx++) {
205  inobj = arr->at(idx);
206  Int_t count = fCount;
207  CheckIn(inobj);
208  if (count==fCount && !vecobj) break; //if no action was made, no sense to continue
209  }
210  return;
211  } }
212  StEventInspector insp(fMap,fCount);
213 #if ROOT_VERSION_CODE < 334597
214  char cbuf[1000];*cbuf=0;
215  obj->ShowMembers(insp,cbuf);
216 #else
217  obj->ShowMembers(insp);
218 #endif
219 }
220 #endif /* ROOT_VERSION_CODE >= ROOT_VERSION(5,34,29) */
221 //______________________________________________________________________________
222 ClassImp(StEventHelper)
223 //______________________________________________________________________________
224 StEventHelper::StEventHelper(const TObject *evt,const char *opt)
225 {
226  fMap = new TExMap(10000);
227  myMap.clear();
228  fObject = 0;
229  Reset(evt,opt);
230 }
231 //______________________________________________________________________________
232 StEventHelper::~StEventHelper()
233 {
234  myMap.clear();
235  delete fMap; fMap=0;
236  Clear();
237 }
238 //______________________________________________________________________________
239 void StEventHelper::Clear(Option_t *opt)
240 {
241 }
242 //______________________________________________________________________________
243 void StEventHelper::Reset(const TObject *evt,const char *opt)
244 {
245  fObject = (TObject *)evt;
246  Clear();
247  myMap.clear();
248  fMap->Delete();
249 #if ROOT_VERSION_CODE < ROOT_VERSION(5,34,29)
250  if (!fObject) return;
251  int kount=0;
252  StEventInspector insp(fMap,kount,opt);
253 #if ROOT_VERSION_CODE < 334597
254  char cbuf[1024];
255  fObject->ShowMembers(insp,cbuf);
256 #else
257  fObject->ShowMembers(insp);
258 #endif
259 #endif
260 }
261 //______________________________________________________________________________
262 int StEventHelper::Kind(const TObject *to)
263 {
264  static TClass *klass=0;
265  static int who=0;
266  int kind = 0;
267  TClass *myClass=to->IsA();
268  if (myClass!=klass) {
269  klass = myClass; who = 0;
270  if (klass->InheritsFrom( StHit::Class())) { who=kHIT;}
271  else if (klass->InheritsFrom( StTrack::Class())) { who=kTRK;}
272  else if (klass->InheritsFrom(StPtrVecHit::Class())) { who=kHRR;}
273  else if (klass->InheritsFrom( StVertex::Class())) { who=kVTX;}
274  else if (klass->InheritsFrom( TObjArray::Class())) { who=kTRR;}
275  }
276  kind = who;
277  if (kind==kHIT) {
278  StHitHelper hh((StHit*)to);
279  if (hh.IsUsed()) {kind|=kUSE;} else {kind|=kUNU;}
280  if (hh.IsFit ()) kind|=kFIT;
281  return kind;
282  }
283  return kind;
284 }
285 
286 //______________________________________________________________________________
287 void StEventHelper::ls(Option_t* option) const
288 {
289  typedef struct { int nb; int sz; const char *tenant; } QWE;
290  QWE *qwe=0;
291 
292  TExMap map;
293  TExMapIter it(fMap);
294  LongKey_t key,val;
295  while( it.Next(key,val) ) {
296  if (val != 2) continue;
297  StStrArray *a = (StStrArray *)(key);
298  LongKey_t &cnt = map((Long_t)a->IsA());
299 // printf("%s %p\n",a->ClassName(),(void*)a);
300  if (!cnt) {
301  qwe = new QWE;
302  cnt = (Long_t)qwe;
303  qwe->nb=0; qwe->sz=0;qwe->tenant=0;
304  }
305  qwe = (QWE*)cnt;
306  qwe->nb++; qwe->sz += a->size();
307  if (qwe->tenant==0 && a->size()) {
308  TObject *to = a->front();
309  if (to) qwe->tenant = to->ClassName();
310  }
311 
312  }
313  TExMapIter itt(&map);
314  printf("\n StEvent(%p)\n",(void*)fObject);
315 
316  while( itt.Next(key,val) ) {
317  TObject *kl = (TObject *)key;
318  qwe = (QWE*)val;
319  printf ("%8d(%8d) - %s (%s)\n",qwe->nb,qwe->sz,kl->GetName(),qwe->tenant);
320  delete qwe;
321  }
322  printf("\n");
323 
324 }
325 //______________________________________________________________________________
326 TObjArray *StEventHelper::SelConts(const char *sel)
327 {
328  TObjArray *tarr = new TObjArray;
329  TRegexp reg(sel);
330 
331  TExMapIter it(fMap);
332  LongKey_t key,val;
333  while( it.Next(key,val) ) {
334  if (val == 1) continue;
335  StStrArray *a = (StStrArray *)(key);
336  if(a->size()==0) continue;
337  int n =0;
338  if (reg.Index(a->ClassName(),&n)<0) continue;
339  tarr->Add(a);
340  }
341  return tarr;
342 }
343 //______________________________________________________________________________
344 TObjArray *StEventHelper::SelTracks(const char*,int flag)
345 {
346 int trackTypes[]= {global, primary, tpt, secondary, estGlobal, estPrimary,-1};
347 
348  TObjArray *conts = SelConts("^StSPtrVecTrackNode$");
349  TObjArray *traks = new TObjArray();
350  Int_t ilast = conts->GetLast();
351  for (int idx=0;idx<=ilast;idx++) {
352  StObjArray *arr = (StObjArray *)conts->At(idx);
353  if (!arr) continue;
354  int ntrk = arr->size();
355  if (!ntrk) continue;
356  for (int itrk=0;itrk<ntrk;itrk++) {
357  StTrackNode *tn = (StTrackNode*)arr->at(itrk);
358  if (!tn) continue;
359  StTrack *trk = 0;int ity; int bty=kTGB;
360  for (int jty=0;(ity=trackTypes[jty])>=0;jty++,bty<<=1){
361  if (!(flag&bty)) continue;
362  trk=(StTrack *)tn->track(ity);
363  if (!trk) continue;
364  if (trk->IsZombie()) continue;
365  // See: StRoot/St_base/StObject.h also
366  if ((flag&kMark2Draw) && !trk->TestBit(kMark2Draw)) continue;
367  traks->Add(trk);
368  }//end track types
369  }//end StTrackNode's
370  }// end StSPtrVecTrackNode's
371  delete conts;
372  return traks;
373 }
374 //______________________________________________________________________________
375 TObjArray *StEventHelper::SelHits(const char *RegEx, Int_t un, Int_t flag)
376 {
377 // un == used +2*nonused
378 
379  TObjArray *conts = SelConts(RegEx);
380  TObjArray *hits = new TObjArray();
381  Int_t ilast = conts->GetLast();
382 
383  for (int idx=0;idx<=ilast;idx++) {
384  StObjArray *arr = (StObjArray *)conts->At(idx);
385  if (!arr) continue;
386  int sz = arr->size();
387  if (!sz) continue;
388  if (!arr->at(0)->InheritsFrom(StHit::Class())) continue;
389  for(int ih=0;ih<sz; ih++) {
390  StHit *hit = (StHit*)arr->at(ih);
391  if (!hit) continue;
392  if (hit->IsZombie()) continue;
393  // See: StRoot/St_base/StObject.h also
394  if ((flag&kMark2Draw) && !hit->TestBit(kMark2Draw)) continue;
395  int used = (hit->trackReferenceCount()!=0);
396  int take = 0;
397  if ( used && (un&kUSE)) take++;
398  if (!used && (un&kUNU)) take++;
399  if (take) hits->Add(hit);
400  }
401  }
402  delete conts;
403  return hits;
404 }
405 //______________________________________________________________________________
406 TObjArray *StEventHelper::SelVertex(const char *sel,Int_t flag)
407 {
408 
409  TObjArray *conts = SelConts(sel);
410  TObjArray *verts = new TObjArray();
411  Int_t ilast = conts->GetLast();
412  int nvtx =0;
413  for (int idx=0;idx<=ilast;idx++) {
414  StObjArray *arr = (StObjArray *)conts->At(idx);
415  if (!arr) continue;
416  int sz = arr->size();
417  if (!sz) continue;
418  for (int ivx=0; ivx<sz; ivx++) {
419  StVertex *vx = (StVertex*)arr->at(ivx);
420  if (!vx) continue;
421  if (vx->IsZombie()) continue;
422  // See: StRoot/St_base/StObject.h also
423  if ((flag&kMark2Draw) && !vx->TestBit(kMark2Draw)) continue;
424  verts->Add(vx);nvtx++;
425  }
426  }
427  delete conts;
428  return verts;
429 }
430 //______________________________________________________________________________
431 TObjArray *StEventHelper::ExpandAndFilter(const TObject *eObj, int flag, TObjArray *out)
432 {
433  // eobj - TObject of StEvent objects (StHit,StTrack,StVertex or TObjArray of above)
434  if (!out) {out = new TObjArray;}
435  TObject *eobj = (TObject*)eObj;
436 
437  int kind = Kind(eobj);
438  if (kind&kHIT) {// input StHit
439  if (!(flag&kHIT)) return out;
440  int take=kind & (kUSE|kUNU|kFIT) &flag;
441  if (take) out->Add(eobj);
442  return out;
443  }//endif StHit
444 
445 //-------------------------------------------------------------
446  if (kind&kTRK) {// input StTrack
447  if (flag&kTRK) out->Add(eobj);
448  if (!(flag&kHRR)) return out;
449  StTrack *trk = (StTrack*)eobj;
450  StTrackHelper trkh(trk);
451  out->Add((TObject*)trkh.GetHits());
452  return out;
453  }//endif StTrack
454 
455 //-------------------------------------------------------------
456  if (kind&kVTX) {// input StVertex
457  if (flag&kVTX) out->Add(eobj);
458  StVertex *vtx = (StVertex*)eobj;
459  if (!(flag&(kTRK|kHRR))) return out;
460  StVertexHelper vtxh(vtx);
461  int n = vtxh.GetNTracks();
462  for (int i=-1;i<n;i++) {
463  const TObject *to = vtxh.GetTrack(i);
464  if (!to) continue;
465  ExpandAndFilter(to,flag,out);
466  }
467  return out;
468  }//endif StVertex
469 //-------------------------------------------------------------
470 
471  if (kind&kTRR) { // input TObjArray
472  TObjArray *inp = (TObjArray *)eobj;
473  inp->Compress();
474  int nbjs = inp->GetLast()+1;
475  if (!nbjs) return 0;
476  for (int i=0;i<nbjs;i++) {
477  ExpandAndFilter(inp->At(i),flag,out);
478  }
479  return out;
480  }// endif TObjArray
481 
482 //-------------------------------------------------------------
483  if (kind&kHRR) { // input HitsArray
484  if (!(flag&kHRR)) return out;
485  out->Add(eobj);
486  return out;
487  }// endif HitsArray
488  return 0;
489 }
490 //______________________________________________________________________________
491 TObjArray *StEventHelper::MakePoints(TObjArray *inp, int flag)
492 {
493 static const Color_t plitra[]={kRed,kGreen,kBlue,kMagenta, kCyan};
494 static const int nlitra = sizeof(plitra)/sizeof(Color_t);
495  int ilitra=0;
496  inp->Compress();
497  int nbjs = inp->GetLast()+1;
498  if (!nbjs) return 0;
499  TObjArray *out = new TObjArray;out->SetOwner();
500  StPoints3DABC *p[3] ; int np=0;
501  for (int i=0;i<nbjs;i++) {
502  TObject *to = inp->At(i);
503  int kind = Kind(to);
504  if (!(kind&kHRR)) { ilitra++; ilitra = ilitra%nlitra; }
505  int take = (kind&flag);
506  if (!take) continue;
507 //?? if (take&kHIT) take -=kHIT;
508  if (!take) continue;
509 
510  np = 0;
511  if (kind&kHIT) {np=1;p[0] = new StHitPoints ((StHit *)to );}
512  else if (kind&kHRR && ((StPtrVecHit*)to)->size())
513  {np=1;p[0] = new StHitPoints ((StPtrVecHit*)to );}
514 
515  else if (kind&kTRK) {np=3;p[0] = new StTrackPoints ((StTrack *)to );
516  p[1] = new StInnOutPoints((StTrack *)to,0);
517  p[2] = new StInnOutPoints((StTrack *)to,1);}
518 
519  else if (kind&kVTX) {np=1;p[0] = new StVertexPoints((StVertex *)to );}
520 
521  for (int j=0;j<np;j++){p[j]->SetUniqueID(plitra[ilitra]); out->Add(p[j]);}
522  }//
523 
524  return out;
525 }
526 //______________________________________________________________________________
527 void StEventHelper::Break(int kase)
528 {
529  fprintf(stderr,"Break(%d)\n",kase);
530 }
531 //______________________________________________________________________________
532 void StEventHelper::Remove(StEvent *ev,const char *className)
533 {
534 StSPtrVecObject& V = ev->content();
535  int n = V.size();
536  for (int i=0; i<n; i++) {
537  StObject *to = V[i];
538  if (!to) continue;
539  if (!strstr(to->ClassName(),className)) continue;
540  V[i] = 0; delete to;
541  }
542 }
543 
544 //______________________________________________________________________________
545 ClassImp(StPoints3DABC)
546 void StPoints3DABC::Add(StPoints3DABC *add)
547 {
548  int n = add->fSize + fSize;
549  if (n > fN) {
550  if (n < fN*2) n = fN*2;
551  Float_t *arr = new Float_t[n*3];
552  memcpy(arr, fXYZ, fSize*3*sizeof(Float_t));
553  delete [] fXYZ; fXYZ = arr; fN = n;
554  }
555  memcpy(fXYZ+fSize*3,add->fXYZ,add->fSize*3*sizeof(Float_t));
556  fSize+=add->fSize;
557 }
558 //______________________________________________________________________________
559 ClassImp(StTrackPoints)
560 //______________________________________________________________________________
561 StTrackPoints::StTrackPoints(const StTrack *st,const char *name,const char *title)
562 :StPoints3DABC(name,title,st)
563 {
564  Init();
565 }
566 //______________________________________________________________________________
567 void StTrackPoints::Init()
568 {
569  if (fXYZ) return;
570  StTrack *trk = ((StTrack*)fObj);
571  StTrackHelper th(trk);
572  fXYZ = th.GetPoints(fSize);
573  fN = fSize;
574  if (!fSize) { MakeZombie(); return;}
575 }
576 //______________________________________________________________________________
577  Int_t StTrackPoints::DistancetoPrimitive(Int_t px, Int_t py)
578 {
579 //*-*-*-*-*-*-*Compute distance from POINT px,py to a 3-D points *-*-*-*-*-*-*
580 //*-* =====================================================
581 //*-*
582 //*-* Compute the closest distance of approach from POINT px,py to each SEGMENT
583 //*-* of the polyline.
584 //*-* Returns when the distance found is below DistanceMaximum.
585 //*-* The distance is computed in pixels units.
586 //*-*
587 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
588 
589  enum {inaxis = 7,mindist=10};
590  Float_t dist = 999999;
591 
592  Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
593  Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
594  Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
595  Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
596 
597  TView *view = 0;
598 //*-*- return if POINT is not in the user area
599  if (px < puxmin - inaxis) goto END;
600  if (py > puymin + inaxis) goto END;
601  if (px > puxmax + inaxis) goto END;
602  if (py < puymax - inaxis) goto END;
603 
604  view = gPad->GetView();
605  if (!view) goto END;
606 
607  {Int_t i;
608  Float_t /*dpoint,*/alfa;
609  Float_t xndc[3];
610  Int_t x1,y1,x0,y0;
611  Int_t pointSize = fN*3;
612  view->WCtoNDC(fXYZ, xndc);
613  x0 = gPad->XtoAbsPixel(xndc[0]);
614  y0 = gPad->YtoAbsPixel(xndc[1]);
615 
616  float dif[2],difdif,cur[2],curcur,difcur;
617  for (i=3;i<pointSize;i+=3) {
618  view->WCtoNDC(fXYZ+i, xndc);
619  x1 = gPad->XtoAbsPixel(xndc[0]);
620  y1 = gPad->YtoAbsPixel(xndc[1]);
621  dif[0] = x1-x0; dif[1]=y1-y0;
622  cur[0] = x0-px; cur[1]=y0-py;
623  difdif = (dif[0]*dif[0]+dif[1]*dif[1]);
624  difcur = (dif[0]*cur[0]+dif[1]*cur[1]);
625  curcur = cur[0]*cur[0]+cur[1]*cur[1];
626  if (difdif<mindist*mindist) {
627  if ((i+3)<pointSize) continue;
628  dist = curcur; break;
629  }
630  alfa = -difcur/difdif;
631 
632  if (alfa<0.) {dist = curcur; break;}
633 
634  x0=x1; y0=y1;
635  if (alfa > 1.) {
636  if (i+3 < pointSize) continue;
637  dist = (px-x1)*(px-x1) + (py-y1)*(py-y1); break;
638  }
639  dist = curcur+alfa*(2*difcur+difdif*alfa);
640  break;
641  }}
642 END:
643  dist = TMath::Sqrt(dist);
644 //VP if (dist <= mindist) { dist = 0; gPad->SetSelected(fObj);}
645  if (dist <= mindist) { dist = 0; gPad->SetSelected(this);}
646 
647  return Int_t(dist);
648 }
649 
650 
651 //______________________________________________________________________________
652 ClassImp(StVertexPoints)
653 //______________________________________________________________________________
654 StVertexPoints::StVertexPoints(const StVertex *sv,const char *name,const char *title)
655 :StPoints3DABC(name,title,sv)
656 {
657  SetBit(1);
658  fSize = 1; fN =1;
659  fXYZ = new Float_t[3];
660  fXYZ[0] = ((StVertex*)fObj)->position().x();
661  fXYZ[1] = ((StVertex*)fObj)->position().y();
662  fXYZ[2] = ((StVertex*)fObj)->position().z();
663 }
664 //______________________________________________________________________________
665 ClassImp(StVertexPoints)
666 //______________________________________________________________________________
667 StInnOutPoints::StInnOutPoints(const StTrack *st,int innout,const char *name,const char *title)
668 :StPoints3DABC(name,title,st)
669 {
670  fSize = 1; fN =1; fInnOut=innout;
671  const StTrackGeometry *geo = (fInnOut==0) ? st->geometry():st->outerGeometry();
672  fXYZ = new Float_t[3];
673  fXYZ[0] = geo->origin().x();
674  fXYZ[1] = geo->origin().y();
675  fXYZ[2] = geo->origin().z();
676 }
677 
678 
679 ClassImp(StHitPoints)
680 //______________________________________________________________________________
681 StHitPoints::StHitPoints(const StHit *sh,const char *name,const char *title)
682 :StPoints3DABC(name,title,sh)
683 {
684  fSize = 1; fN =1;
685  Init();
686 }
687 //______________________________________________________________________________
688 StHitPoints::StHitPoints(const StRefArray *ar,const char *name,const char *title)
689 :StPoints3DABC(name,title,ar)
690 {
691  fSize = ar->size();
692  fN = fSize;
693  if (!fSize) return;
694  fObj = (fSize==1) ? ar->front() : ar;
695  Init();
696 }
697 //______________________________________________________________________________
698 void StHitPoints::Init()
699 {
700  if (fXYZ) return;
701  fXYZ = new Float_t[fN*3];
702 
703  int n=0;
704  for (int i =0;i<fSize;i++)
705  {
706  StHit *hit= (fSize==1) ? (StHit*)fObj: (StHit*)((StRefArray*)fObj)->at(i);
707  if (fSize>1 && !hit->trackReferenceCount()) continue;
708  if (fSize>1 && !hit->usedInFit()) continue;
709  StThreeVectorF v3 = hit->position();
710  fXYZ[n*3+0] = v3.x();
711  fXYZ[n*3+1] = v3.y();
712  fXYZ[n*3+2] = v3.z();
713  n++;
714  }
715  fN=n; fSize=n;
716 }
717 
718 //______________________________________________________________________________
719 ClassImp(StFilterABC)
720 
721 int StFilterABC::fgDial=0;
722 //______________________________________________________________________________
723 StFilterABC::StFilterABC(const char *name,bool active):TNamed(name,""),fActive(active)
724 {
725 }
726 //______________________________________________________________________________
727 void StFilterABC::SetDefs()
728 {
729  for (int i=0;GetNams() && GetNams()[i]; i++) {GetPars()[i]=GetDefs()[i];}
730 }
731 
732 //______________________________________________________________________________
733 ClassImp(StFilterDef)
734 StFilterDef::StFilterDef(const char *name,bool active):StFilterABC(name,active)
735 {
736  SetDefs();
737 
738 }
739 //______________________________________________________________________________
740 const char **StFilterDef::GetNams() const
741 {
742  static const char *nams[] = {
743  " RandomSelect ",
744  " RxyMin ",
745  " RxyMax ",
746  " ZMin ",
747  " ZMax ",
748  " PhiMin ",
749  " PhiMax ",
750  " LenMin ",
751  " LenMax ",
752  " PtMin ",
753  " PtMax ",
754  " PseudoMin ",
755  " PseudoMax ",
756  " QMin ",
757  " QMax ",
758  " EncodedMethod",
759  0};
760  return nams;
761 }
762 //______________________________________________________________________________
763 const float *StFilterDef::GetDefs() const
764 {
765  static const float defs[] = {
766  /* RandomSelect=*/ 1.00,
767  /* RxyMin =*/ 0.00,
768  /* RxyMax =*/ 900.00,
769  /* ZMin =*/ -900.00,
770  /* ZMax =*/ +900.00,
771  /* PhiMin =*/ -180.01,
772  /* PhiMax =*/ +181.01,
773  /* LenMin =*/ +0.00,
774  /* LenMax =*/ +999.00,
775  /* PtMin =*/ 0.00,
776  /* PtMax =*/ 999.00,
777  /* PseudoMin =*/ -999.00,
778  /* PseudoMax =*/ 999.00,
779  /* QMin =*/ -1 ,
780  /* QMax =*/ +1 ,
781  /* Encoded method*/ -1 , // The default value -1 menas all
782 
783  0};
784  return defs;
785 }
786 
787 //______________________________________________________________________________
788 Int_t StFilterDef::Accept(StPoints3DABC *pnt,Color_t &color, Size_t&, Style_t&)
789 {
790  static TRandom rrr;
791  float x,y,z,r2xy,phid,len,pt,ps,q;
792  const TObject *to;
793  const StTrack *trk;
794  // set default color for tracks
795  color = (((color-kRed)+1)%6)+kRed;
796 
797  int cut = 1;
798  if (fRandomSelect < 1. && fRandomSelect < rrr.Rndm())return 0;
799 
800  z = pnt->GetZ(0);
801  cut++;
802  if (fZMin >z || z > fZMax) goto SKIP;
803 
804  x = pnt->GetX(0);
805  y = pnt->GetY(0);
806  r2xy = x*x+y*y;
807  cut++;
808  if (fRxyMin*fRxyMin > r2xy || r2xy > fRxyMax*fRxyMax)goto SKIP;
809  phid = atan2(y,x)*(180./M_PI);
810  cut++;
811  if (fPhiMin > phid || phid > fPhiMax) goto SKIP;
812  to = pnt->GetObject();
813  if (!to) return 1;
814  if (!to->InheritsFrom(StTrack::Class())) return 1;
815 
816  // set default color for tracks
817  // color = (((color-kRed)+1)%6)+kRed;
818 
819  trk = (StTrack*)to;
820  len = trk->length();
821  cut++;
822  if (fLenMin >len || len > fLenMax) goto SKIP;
823  pt = trk->geometry()->momentum().perp();
824  cut++;
825  if (fPtMin >pt || pt > fPtMax) goto SKIP;
826  ps = trk->geometry()->momentum().pseudoRapidity();
827  cut++;
828  if (fPsMin >ps || ps > fPsMax) goto SKIP;
829  q = trk->geometry()->charge();
830  cut++;
831  if (fQMin >q || q > fQMax) goto SKIP;
832  cut++;
833  if ( (int(fEncodedMethod) != -1) && (trk->encodedMethod() != int(fEncodedMethod)) )
834  goto SKIP;
835  return 1;
836 
837 SKIP: return 0;
838 
839 }
840 
841 
842 //______________________________________________________________________________
843 ClassImp(StMuDstFilterHelper)
844 StMuDstFilterHelper::StMuDstFilterHelper(const char *name,bool active):StFilterABC(name,active)
845 {
846 #if 0
847  mBB = new BetheBloch();
848 #endif
849  SetDefs();
850 
851 }
852 //______________________________________________________________________________
853 StMuDstFilterHelper::~StMuDstFilterHelper()
854 #if 0
855 { delete mBB;}
856 #else
857 {}
858 #endif
859 //______________________________________________________________________________
860 const char **StMuDstFilterHelper::GetNams() const
861 {
862  static const char *nams[] = {
863  " pCutHigh ",
864  " nHitsCutHighP ",
865  " pCutLow ",
866  " nHitsCutLowP ",
867  " chargeForLowP ",
868  " dEdxMassCutHigh ",
869  " dEdxFractionCutHigh ",
870  " dEdxMassCutLow ",
871  " dEdxFractionCutLow ",
872  0
873  };
874  return nams;
875 }
876 //______________________________________________________________________________
877 const float *StMuDstFilterHelper::GetDefs() const
878 {
879  static const float defs[] = {
880  /* pCutHigh */ 2.0, // high momentum cut for RICH/Upsilon candidates
881  /* nHitsCutHighP */ 10, // nHits cut for all tracks
882  /* pCutLow */ 0.2, // low momentum cut
883  /* nHitsCutLowP */ 15,
884  /* chargeForLowP */ -1, // charge for tracks with pCutLow < p < pCutHigh, set to 0 for all tracks
885  /* dEdxMassCutHigh */ 0.939, // cut below BetheBloch(p/dEdxMassCutHigh), e.g. proton-band
886  /* dEdxFractionCutHigh */ 0.6, // cut fraction of dEdx-band, i.e. dEdxFractionCut * BetheBloch(p/dEdxMassCut)
887  /* dEdxMassCutLow */ 0.494, // cut above BetheBloch(p/dEdxMassCutLow), e.g. kaon-band
888  /* dEdxFractionCutLow */ 1.1,
889  0
890  };
891  return defs;
892 }
893 //______________________________________________________________________________
894 Int_t StMuDstFilterHelper::Accept(const StTrack* track) {
895 
896  float pCutHigh = fpCutHigh; // high momentum cut for RICH/Upsilon candidates
897  int nHitsCutHighP = int(fnHitsCutHighP); // nHits cut for all tracks
898 
899  // following cuts apply only for tracks with pCutLow < p <pHigh
900  float pCutLow = fpCutLow; // low momentum cut
901  int nHitsCutLowP = int(fnHitsCutLowP);
902  int chargeForLowP = int(fchargeForLowP); // charge for tracks with pCutLow < p < fpCutHigh, set to 0 for all tracks
903  float dEdxMassCutHigh = fdEdxMassCutHigh; // cut below BetheBloch(p/dEdxMassCutHigh), e.g. proton-band
904  float dEdxFractionCutHigh = fdEdxFractionCutHigh;// cut fraction of dEdx-band, i.e. dEdxFractionCut * BetheBloch(p/dEdxMassCut)
905  float dEdxMassCutLow = fdEdxMassCutLow; // cut above BetheBloch(p/dEdxMassCutLow), e.g. kaon-band
906  float dEdxFractionCutLow = fdEdxFractionCutLow;
907 
908  int iret = 0;
909  int chargeOK = 0;
910  int dedxOK = 0;
911 
912  float magnitude = track->geometry()->momentum().magnitude();
913  int nPoints = track->detectorInfo()->numberOfPoints();
914 
915  if ( magnitude > pCutHigh && nPoints >= nHitsCutHighP) iret = 1;
916  else {
917  if ( magnitude > pCutLow && nPoints >= nHitsCutLowP )
918  {
919  // check charge
920  if (chargeForLowP==0)
921  chargeOK = 1;
922  else if (track->geometry()->charge() == chargeForLowP)
923  chargeOK = 1;
924 #if 0
925  // check dEdx
926  // if (mBB==0) mBB = new BetheBloch();
927  float dedxHigh = dEdxFractionCutHigh * mBB->Sirrf(magnitude/dEdxMassCutHigh);
928  float dedxLow = dEdxFractionCutLow * mBB->Sirrf(magnitude/dEdxMassCutLow);
929 #else
930  float dedxHigh = dEdxFractionCutHigh * Bichsel::Instance()->GetI70M(TMath::Log10(magnitude/dEdxMassCutHigh));
931  float dedxLow = dEdxFractionCutLow * Bichsel::Instance()->GetI70M(TMath::Log10(magnitude/dEdxMassCutLow));
932 #endif
933  float dedx = 0;
934 
935  // get track dEdx
936  const StSPtrVecTrackPidTraits& traits = track->pidTraits();
937  StDedxPidTraits* dedxPidTr;
938  for (unsigned int itrait = 0; itrait < traits.size(); itrait++){
939  dedxPidTr = 0;
940  if (traits[itrait]->detector() == kTpcId) {
941  StTrackPidTraits* thisTrait = traits[itrait];
942  dedxPidTr = dynamic_cast<StDedxPidTraits*>(thisTrait);
943  if (dedxPidTr && dedxPidTr->method() == kTruncatedMeanId) {
944  // adjust L3 dE/dx by a factor of 2 to match offline
945  dedx = 2 * dedxPidTr->mean();
946  }
947  }
948  }
949  if (dedx > dedxHigh && dedx > dedxLow)
950  dedxOK = 1;
951  // final answer
952  iret = chargeOK * dedxOK;
953  } // if (pCutLow && nHitsCutLowP)
954  }
955  return iret;
956 }
957 
958 //______________________________________________________________________________
959 Int_t StMuDstFilterHelper::Accept(StPoints3DABC *pnt)
960 {
961  const TObject *to;
962  const StTrack *trk;
963  to = pnt->GetObject();
964  if (!to) return 1;
965  if (!to->InheritsFrom(StTrack::Class())) return 1;
966  trk = (StTrack*)to;
967  return Accept(trk);
968 }
969 
970 //______________________________________________________________________________
971 ClassImp(StColorFilterHelper)
972 StColorFilterHelper::StColorFilterHelper(const char *name,bool active):StFilterABC(name,active)
973 {
974  fPidAlgorithm = new StTpcDedxPidAlgorithm();;
975  fElectron = StElectron::instance();
976  fPion = StPionPlus::instance();
977  fKaon = StKaonPlus::instance();
978  fProton = StProton::instance();
979 
980  SetDefs();
981 
982 }
983 //______________________________________________________________________________
984 StColorFilterHelper::~StColorFilterHelper()
985 { delete fPidAlgorithm;}
986 //______________________________________________________________________________
987 const char **StColorFilterHelper::GetNams() const
988 {
989  static const char *nams[] = {
990  " Electron sigma ",
991  " Electron color ",
992  " Pion sigma ",
993  " Pion color ",
994  " Kaon sigma ",
995  " Kaon color ",
996  " Proton sigma ",
997  " Proton color ",
998  " others sigma ",
999  " others color ",
1000  0
1001  };
1002  return nams;
1003 }
1004 //______________________________________________________________________________
1005 const float *StColorFilterHelper::GetDefs() const
1006 {
1007  static const float defs[] = {
1008  /* fNSigmaElectron*/ 1 , // nSigma cut for electron
1009  /* fNColorElectron*/ 2 , // the color index for electron
1010  /* fNSigmaPion */ 1 , // nSigma cut for electron
1011  /* fNColorPion */ 3 , // the color index for pion
1012  /* fNSigmaKaon */ 1 , // nSigma cut for pion
1013  /* fNColorKaon */ 4 , // the color index for kaon
1014  /* fNSigmaProton */ 1 , // nSigma cut for kaon
1015  /* fNColorProton */ 6 , // the color index kaon
1016 
1017  /* fNSigmaOther*/ -1, // nSigma cut for other types
1018  /* fNColorOther*/ 0, // the color index for other types
1019  0
1020  };
1021  return defs;
1022 }
1023 //______________________________________________________________________________
1024 Int_t StColorFilterHelper::Accept(const StTrack* track, Color_t &color, Size_t&size, Style_t&) {
1025 
1026 float sigmaElectron = fNSigmaElectron ; // nSigna cut for electron
1027 Color_t colorElectron = (Color_t)fNColorElectron ; // the color index for electron
1028 
1029 float sigmaPion = fNSigmaPion ; // nSigna cut for electron
1030 Color_t colorPion = (Color_t)fNColorPion ; // the color index for pion
1031 
1032 float sigmaKaon = fNSigmaKaon ; // nSigna cut for pion
1033 Color_t colorKaon = (Color_t)fNColorKaon ; // the color index for kaon
1034 
1035 float sigmaProton = fNSigmaProton ; // nSigna cut for kaon
1036 Color_t colorProton = (Color_t)fNColorProton ; // the color index kaon
1037 
1038 // float sigmaOther = fNSigmaOther ; // nSigna cut for other types
1039 Color_t colorOther = (Color_t)fNColorOther ; // the color index for other types
1040 
1041 // Fisyak's color schema
1042 
1043 /* const StParticleDefinition* pd = */ track->pidTraits(*fPidAlgorithm);
1044 
1045  color = colorOther;
1046  size = 1;
1047 
1048  if (TMath::Abs(fPidAlgorithm->numberOfSigma(fElectron)) < sigmaElectron)
1049  { color = colorElectron; size = 2; }
1050 
1051  if (TMath::Abs(fPidAlgorithm->numberOfSigma(fKaon)) < sigmaKaon)
1052  { color = colorKaon; size = 4; }
1053 
1054  if (TMath::Abs(fPidAlgorithm->numberOfSigma(fPion)) < sigmaPion)
1055  { color = colorPion; size = 5; }
1056 
1057  if (TMath::Abs(fPidAlgorithm->numberOfSigma(fProton)) < sigmaProton)
1058  { color = colorProton; size = 3; }
1059 
1060  return 1;
1061 }
1062 
1063 //______________________________________________________________________________
1064 Int_t StColorFilterHelper::Accept(StPoints3DABC *pnt, Color_t&color, Size_t&size, Style_t&style)
1065 {
1066  const TObject *to;
1067  const StTrack *trk;
1068  to = pnt->GetObject();
1069  if (!to) return 1;
1070  if (!to->InheritsFrom(StTrack::Class())) return 1;
1071  trk = (StTrack*)to;
1072  return Accept(trk,color,size,style);
1073 }
1074 //______________________________________________________________________________
1075 //______________________________________________________________________________
1076 //______________________________________________________________________________
1077 ClassImp(StVertexHelper)
1079 { SetVertex(vtx);}
1080 StVertexHelper::StVertexHelper(const StEvent *evt)
1081 { SetVertex(evt->primaryVertex(0));}
1082 //______________________________________________________________________________
1083 void StVertexHelper::SetVertex(const StVertex *vtx){fVtx = vtx;}
1084 int StVertexHelper::GetType() {return (int)fVtx->type();}
1085 int StVertexHelper::GetFlag() {return fVtx->flag();};
1086 int StVertexHelper::GetNTracks() {return fVtx->numberOfDaughters();}
1087 //______________________________________________________________________________
1088 const StThreeVectorF &StVertexHelper::GetPoint()
1089 {
1090  return fVtx->position();
1091 }
1092 //______________________________________________________________________________
1093 const StTrack *StVertexHelper::GetTrack(int idx) // -1=parent track
1094 {
1095  if (idx==-1) return (const StTrack *) fVtx->parent();
1096  if (idx>= GetNTracks()) return 0;
1097  return (const StTrack *) fVtx->daughter((UInt_t)idx);
1098 }
1099 //______________________________________________________________________________
1101 {
1103 
1104  StMatrixF mxF = fVtx->covariantMatrix();
1105  int jj=0;
1106  for (int i=0;i< 3;i++) {
1107  for (int j=0;j<=i;j++) {
1108  fErrMtx[jj++] = mxF(i+1,j+1);}}
1109  return fErrMtx;
1110 }
1111 //______________________________________________________________________________
1112 //______________________________________________________________________________
1113 //______________________________________________________________________________
1114 ClassImp(StTrackHelper)
1115 StTrackHelper::StTrackHelper(const StTrack *trk) :
1116  StHelixHelper(trk->geometry()->helix(),
1117  trk->outerGeometry()->helix(),trk->length())
1118  , fTrk(trk), fHits(0)
1119 { GetNHits(); }
1120 StTrackHelper::StTrackHelper(const StGlobalTrack *trk) :
1121  StHelixHelper(trk->dcaGeometry()->helix(),
1122  trk->outerGeometry()->helix(),trk->length())
1123  , fTrk(trk), fHits(0)
1124 { GetNHits(); }
1125 
1126 StTrackHelper::~StTrackHelper()
1127 { }
1128 int StTrackHelper::GetType() const {return fTrk->type();}
1129  int StTrackHelper::GetFlag() const {return fTrk->flag();}
1130  int StTrackHelper::GetCharge() const {return fTrk->geometry()->charge();}
1131 const StVertex *StTrackHelper::GetParent() const {return fTrk->vertex();}
1132  float StTrackHelper::GetImpact() const {return fTrk->impactParameter();}
1133  float StTrackHelper::GetCurv() const {return GetTHelix(0)->GetRho() ;}
1134 const StThreeVectorF &StTrackHelper::GetFirstPoint() const {return fTrk->geometry()->origin();}
1135 const StThreeVectorF &StTrackHelper::GetLastPoint() const {return fTrk->outerGeometry()->origin();}
1136 const StThreeVectorF &StTrackHelper::GetMom() const {return fTrk->geometry()->momentum();}
1137 
1138 //______________________________________________________________________________
1139 const StPtrVecHit *StTrackHelper::GetHits() const
1140 {
1141  if (fHits) return fHits;
1142  const StTrackDetectorInfo *tdi = fTrk->detectorInfo();
1143  if (!tdi) return 0;
1144  fHits = &tdi->hits();
1145  return fHits;
1146 }
1147 //______________________________________________________________________________
1148 int StTrackHelper::GetNHits() const
1149 {
1150  if (fHits) return fHits->size();
1151  GetHits();
1152  return (fHits)? fHits->size():0;
1153 }
1154 //______________________________________________________________________________
1155 const StHit *StTrackHelper::GetHit(int idx) const
1156 {
1157  if (idx<0) return 0;
1158  if (idx>=GetNHits()) return 0;
1159  if (!fHits) return 0;
1160  return fHits->at(idx);
1161 }
1162 //______________________________________________________________________________
1163 int StTrackHelper::numberOfFitPoints(int det) const
1164 {
1165  const StTrackFitTraits& trait = fTrk->fitTraits();
1166  return (det)? trait.numberOfFitPoints((StDetectorId)det): trait.numberOfFitPoints();
1167 }
1168 //______________________________________________________________________________
1169 StMCTruth StTrackHelper::GetTruth(int byNumb,double rXYMin,double rXYMax) const
1170 {
1171  StMCPivotTruth pivo(1);
1172  int nHits = GetNHits();
1173  int nUsed=0;
1174  for (int jh=0;jh<nHits;jh++) {
1175  const StHit *hit = GetHit(jh);
1176  double r = sqrt(pow(hit->position().x(),2)+pow(hit->position().y(),2));
1177  if (r<rXYMin) continue;
1178  if (r>rXYMax) continue;
1179  int idTruth=hit->idTruth();
1180  int wtTruth=hit->qaTruth();
1181  if (!wtTruth) wtTruth=1;
1182 // if (!idTruth || !wtTruth) {
1183 // Warning("GetTruth","idTruth,wtTruth= %d %d",idTruth,wtTruth);
1184 // continue;}
1185  nUsed++; pivo.Add(idTruth,wtTruth);
1186  }
1187  if (!nUsed) return 0;
1188  return pivo.Get(byNumb);
1189 }
1190 
1191 //______________________________________________________________________________
1192 //______________________________________________________________________________
1193 //______________________________________________________________________________
1194 ClassImp(StHitHelper)
1195  StHitHelper::StHitHelper(const StHit *hit){fHit = hit;}
1196 void StHitHelper::SetHit(const StHit *hit) {fHit = hit;}
1197 int StHitHelper::GetDetId() {return fHit->detector();}
1198 int StHitHelper::GetFlag() {return fHit->flag();}
1199 float StHitHelper::GetCharge() {return fHit->charge();}
1200 int StHitHelper::IsUsed() {return fHit->trackReferenceCount();}
1201 int StHitHelper::IsFit() {return fHit->usedInFit();}
1202 const StThreeVectorF &StHitHelper::GetPoint() {return fHit->position();}
1203 //______________________________________________________________________________
1204 //______________________________________________________________________________
1205 //______________________________________________________________________________
1206 
1207 ClassImp(StErrorHelper)
1208 //_____________________________________________________________________________
1210 {
1211  fNErr=0; fNTot=0; fKErr=0;
1212  fMap = new TExMap;
1213  fArr = new TArrayI;
1214 }
1215 //_____________________________________________________________________________
1216 StErrorHelper::~StErrorHelper()
1217 {
1218  delete fMap;
1219  delete fArr;
1220 }
1221 //_____________________________________________________________________________
1222 void StErrorHelper::Add(int errn)
1223 {
1224  fNTot++;
1225  if(!errn) return;
1226  fNErr++;
1227  (*fMap)(errn)++;
1228 }
1229 //_____________________________________________________________________________
1230 void StErrorHelper::MakeArray()
1231 {
1232  if (!fNErr) return;
1233  fKErr = fMap->GetSize();
1234  fArr->Set(fKErr*3);
1235  TExMapIter it(fMap);
1236  LongKey_t lerr,lnum;
1237 
1238  int idx=0;
1239  while(it.Next(lerr,lnum)) {
1240  (*fArr)[idx+ 0] = lnum;
1241  (*fArr)[idx+fKErr] = lerr;
1242  idx++;
1243  }
1244 
1245  TMath::Sort(fKErr, fArr->GetArray(), fArr->GetArray()+2*fKErr);
1246 }
1247 //_____________________________________________________________________________
1248 void StErrorHelper::Print(const char* txt) const
1249 {
1250  StErrorHelper *This = (StErrorHelper *)this;
1251  This->MakeArray();
1252  if (!txt) txt="";
1253  printf("StEvent Error Summary:%s\n",txt);
1254 
1255  printf("%4d -%8d(%4d)\n",0,0,fNTot-fNErr);
1256  int *nrr=fArr->GetArray();
1257  int *krr=nrr+fKErr;
1258  int *idx=krr+fKErr;
1259  for (int i=0;i<fKErr;i++) {
1260  int j = idx[i];
1261  printf("%4d -%8d(%4d) //%s\n",i+1,krr[j],nrr[j],Say(krr[j]).Data());
1262  }
1263 }
1264 //_____________________________________________________________________________
1265 
1266 TString StErrorHelper::Say(int ierr,const char *klass)
1267 {
1268  static const char *TabErr[] =
1269  {
1270  "StTrack" ,"mFlag" ,"1","2","is Negative",
1271  "StTrack" ,"mFlag" ,"1","3","is Zero",
1272 
1273  "StTrack" ,"mImpactParameter" ,"2","1","is NaN",
1274  "StTrack" ,"mImpactParameter" ,"2","2","is huge",
1275 
1276  "StTrack" ,"mLength" ,"3","1","is NaN",
1277  "StTrack" ,"mLength" ,"3","2","is huge",
1278  "StTrack" ,"mLength" ,"3","3","is too small",
1279  "StTrack" ,"mLength" ,"3","4","contradicts to In/Out distance",
1280  "StTrack" ,"mLength" ,"3","5","helix out of Zmax",
1281  "StTrack" ,"mLength" ,"3","6","helix out of Rmax",
1282 
1283  "StTrack" ,"mGeometry" ,"4","2","iz zero",
1284  "StTrack" ,"mGeometry" ,"4","0","StTrackGeometry",
1285 
1286  "StTrack" ,"mOuterGeometry" ,"5","2","iz zero",
1287  "StTrack" ,"mOuterGeometry" ,"5","0","StTrackGeometry",
1288 
1289  "StTrack" ,"mDetectorInfo" ,"6","2","iz zero",
1290  "StTrack" ,"mDetectorInfo" ,"6","0","StTrackDetectorInfo",
1291 
1292  "StTrackGeometry" ,"Helix" ,"1","0","StPhysicalHelixD",
1293  "StTrackGeometry" ,"Helix" ,"1","2","out of zMax",
1294  "StTrackGeometry" ,"Helix" ,"1","3","out of rMax",
1295 
1296  "StTrackDetectorInfo" ,"mFirstPoint" ,"1","0","StThreeVectorF",
1297  "StTrackDetectorInfo" ,"mFirstPoint" ,"1","2","out of zMax",
1298  "StTrackDetectorInfo" ,"mFirstPoint" ,"1","3","out of rMax",
1299 
1300  "StTrackDetectorInfo" ,"mLastPoint" ,"2","0","StThreeVectorF",
1301  "StTrackDetectorInfo" ,"mLastPoint" ,"2","2","out of zMax",
1302  "StTrackDetectorInfo" ,"mFLastPoint" ,"2","3","out of rMax",
1303 
1304 
1305  "StPhysicalHelixD" ,"mDipAngle" ,"1","1","is NaN",
1306  "StPhysicalHelixD" ,"mDipAngle" ,"1","2","> Py/2",
1307  "StPhysicalHelixD" ,"mDipAngle" ,"1","3","== Py/2",
1308 
1309  "StPhysicalHelixD" ,"mCurvature" ,"2","1","is NaN",
1310  "StPhysicalHelixD" ,"mCurvature" ,"2","2","too big",
1311  "StPhysicalHelixD" ,"mCurvature" ,"2","3","is Negaive",
1312 
1313  "StPhysicalHelixD" ,"mOrigin" ,"3","0","StThreeVectorD",
1314  "StPhysicalHelixD" ,"mH" ,"4","2","!= 1 or -1",
1315 
1316  "StThreeVectorD" ,"mX1" ,"1","1","is NaN",
1317  "StThreeVectorD" ,"mX1" ,"1","2","too big",
1318  "StThreeVectorD" ,"mX2" ,"2","1","is NaN",
1319  "StThreeVectorD" ,"mX2" ,"2","2","too big",
1320  "StThreeVectorD" ,"mX3" ,"3","1","is NaN",
1321  "StThreeVectorD" ,"mX3" ,"3","2","too big",
1322 
1323 
1324  "StThreeVectorF" ,"mX1" ,"1","1","is NaN",
1325  "StThreeVectorF" ,"mX1" ,"1","2","too big",
1326  "StThreeVectorF" ,"mX2" ,"2","1","is NaN",
1327  "StThreeVectorF" ,"mX2" ,"2","2","too big",
1328  "StThreeVectorF" ,"mX3" ,"3","1","is NaN",
1329  "StThreeVectorF" ,"mX3" ,"3","2","too big",
1330  0};
1331 TString ts;
1332 
1333  int jmm = ierr%10;
1334  int jrr = (ierr/10)%10;
1335  for (const char **jt=TabErr;*jt;jt+=5) {
1336  if (strcmp(klass,*jt) ) continue;
1337  if (atoi(jt[2]) != jmm) continue;
1338  if (atoi(jt[3]) != jrr) continue;
1339  ts+=jt[1];
1340  if (jrr) { ts+=": "; ts+=jt[4];}
1341  else { ts+="."; ts+=Say(ierr/100,jt[4]);}
1342  return ts;
1343  }
1344  ts="***Unknown***";
1345  return ts;
1346 }
Definition: StHit.h:125
const float * GetErrMtx()