FEDRA emulsion software from the OPERA Collaboration
EdbShowAlgClean Class Reference

#include <EdbShowAlgClean.h>

Inheritance diagram for EdbShowAlgClean:
Collaboration diagram for EdbShowAlgClean:

Public Member Functions

void CheckClassType ()
 
void CheckClassTypeEntries ()
 
 ClassDef (EdbShowAlgClean, 1)
 
Bool_t CompareSegmentsByPosition (EdbSegP *s1, EdbSegP *s2, Int_t type)
 
 EdbShowAlgClean ()
 
 EdbShowAlgClean (TObjArray *Source)
 
 EdbShowAlgClean (TObjArray *Source, TObjArray *Dirt)
 
 EdbShowAlgClean (TObjArray *Source, TObjArray *Dirt, TObjArray *Target)
 
void Execute ()
 
TObjArray * GetDirt () const
 
TObjArray * GetSource () const
 
TObjArray * GetTarget () const
 
void Help ()
 
void Print ()
 
void RemovePassingDirtFromSource ()
 
void RemoveStoppingDirtFromSource ()
 
void SetCleaningType (Int_t CleaningType, Int_t Value)
 
void SetDirt (EdbTrackP *DirtTrack)
 
void SetDirt (TObjArray *Dirt)
 
void SetSource (EdbShowerP *SourceShower)
 
void SetSource (TObjArray *Source)
 
void SetTarget (EdbShowerP *TargetShower)
 
void SetTarget (TObjArray *Target)
 
void SimpleRemoveBGSegmentsFromShower ()
 
Int_t SimpleRemoveBGSegmentsFromShower (EdbShowerP *shower)
 
void SimpleRemoveDoubleBTViewOverlap ()
 
Int_t SimpleRemoveDoubleBTViewOverlap (EdbShowerP *shower)
 
void SimpleRemoveTrackSegmentsFromShower ()
 
Int_t SimpleRemoveTrackSegmentsFromShower (EdbShowerP *shower, EdbTrackP *track)
 
virtual ~EdbShowAlgClean ()
 

Private Member Functions

void Init ()
 
void Set0 ()
 

Private Attributes

TArrayI * eCleaningType
 
TObjArray * eDirt
 
Int_t eDirtClassType
 
Bool_t eIsSet [3]
 
TObjArray * eSource
 
Int_t eSourceClassType
 
TObjArray * eTarget
 
Int_t eTargetClassType
 

Constructor & Destructor Documentation

◆ EdbShowAlgClean() [1/4]

EdbShowAlgClean::EdbShowAlgClean ( )

◆ EdbShowAlgClean() [2/4]

EdbShowAlgClean::EdbShowAlgClean ( TObjArray *  Source)
18 {
19  Init();
20  Set0();
21  eSource=Source;
22 }
void Init()
Definition: EdbShowAlgClean.cxx:89
TObjArray * eSource
Definition: EdbShowAlgClean.h:36
void Set0()
Definition: EdbShowAlgClean.cxx:100

◆ EdbShowAlgClean() [3/4]

EdbShowAlgClean::EdbShowAlgClean ( TObjArray *  Source,
TObjArray *  Dirt 
)
26 {
27  Init();
28  Set0();
29  eSource=Source;
30  eDirt=Dirt;
31 }
TObjArray * eDirt
Definition: EdbShowAlgClean.h:39

◆ EdbShowAlgClean() [4/4]

EdbShowAlgClean::EdbShowAlgClean ( TObjArray *  Source,
TObjArray *  Dirt,
TObjArray *  Target 
)
35 {
36  Init();
37  Set0();
38  eSource=Source;
39  eDirt=Dirt;
40  eTarget=Target;
41 }
TObjArray * eTarget
Definition: EdbShowAlgClean.h:42

◆ ~EdbShowAlgClean()

EdbShowAlgClean::~EdbShowAlgClean ( )
virtual
46 {
47  // Default Destructor
48  cout << "EdbShowAlgClean::~EdbShowAlgClean()"<<endl;
49 }

Member Function Documentation

◆ CheckClassType()

void EdbShowAlgClean::CheckClassType ( )
117 {
118  cout << "EdbShowAlgClean::CheckClassType()"<<endl;
119 
120  TString eSourceClassName="";
121  TString eDirtClassName="";
122 
123  cout << "EdbShowAlgClean::CheckClassType() Now checking eSource= " << eSource << endl;
124 
125  if (!eIsSet[0] || eSource->GetEntries()==0) return;
126  eSourceClassName=eSource->At(0)->ClassName();
127  if (eSource->At(0)->ClassName()=="EdbShowerP") eSourceClassType=0;
128  if (eSource->At(0)->ClassName()=="EdbTrackP") eSourceClassType=1;
129  if (eSource->At(0)->ClassName()=="EdbSegP") eSourceClassType=2;
130 
131  cout << "EdbShowAlgClean::CheckClassType() eSourceClassType= " << eSourceClassType << endl;
132  cout << "EdbShowAlgClean::CheckClassType() eSourceClassName= " << eSourceClassName << endl;
133 
134  cout << "EdbShowAlgClean::CheckClassType() Now checking eDirt= " << eDirt << endl;
135 
136  if (!eIsSet[1] || eDirt->GetEntries()==0) return;
137  eDirtClassName=eDirt->At(0)->ClassName();
138  if (eDirt->At(0)->ClassName()=="EdbShowerP") eDirtClassType=0;
139  if (eDirt->At(0)->ClassName()=="EdbTrackP") eDirtClassType=1;
140  if (eDirt->At(0)->ClassName()=="EdbSegP") eDirtClassType=2;
141 
142  cout << "EdbShowAlgClean::CheckClassType() eDirtClassType= " << eDirtClassType << endl;
143  cout << "EdbShowAlgClean::CheckClassType() eDirtClassName= " << eDirtClassName << endl;
144 
145  cout << "EdbShowAlgClean::CheckClassType()...done."<<endl;
146 }
Bool_t eIsSet[3]
Definition: EdbShowAlgClean.h:49
Int_t eSourceClassType
Definition: EdbShowAlgClean.h:37
Int_t eDirtClassType
Definition: EdbShowAlgClean.h:40

◆ CheckClassTypeEntries()

void EdbShowAlgClean::CheckClassTypeEntries ( )
152 {
153  cout << " EdbShowAlgClean::CheckClassTypeEntries()"<<endl;
154 
155  if (!eIsSet[0] || eSource->GetEntries()==0) return;
156  Int_t eSourceClassTypeEntries=eSource->GetEntries();
157  cout << "eSourceClassTypeEntries= " << eSourceClassTypeEntries << endl;
158 
159  if (!eIsSet[1] || eDirt->GetEntries()==0) return;
160  Int_t eDirtClassTypeEntries=eDirt->GetEntries();
161  cout << "eDirtClassTypeEntries= " << eDirtClassTypeEntries << endl;
162 
163  cout << " EdbShowAlgClean::CheckClassTypeEntries()...done."<<endl;
164 }

◆ ClassDef()

EdbShowAlgClean::ClassDef ( EdbShowAlgClean  ,
 
)

◆ CompareSegmentsByPosition()

Bool_t EdbShowAlgClean::CompareSegmentsByPosition ( EdbSegP s1,
EdbSegP s2,
Int_t  type = 0 
)
254 {
255  // Cuts for "same segement" flag
256  Float_t positioncut=0.1;
257  Float_t anglecut=0.005;
258  // Cuts for the view Overlap
259  if (type==1) {
260  // These Cutvalues have beed adapted by running over our Backgrounds.
261  // A peak from View Overlap is seen as for these values:
262  positioncut=2;
263  anglecut=0.01; // Cuts for the view Overlap
264  }
265  if (type==99) {
266  // DEBUG values
267  positioncut=100;
268  anglecut=0.1;
269  }
270  if (TMath::Abs(s1->X()-s2->X())>positioncut) return kFALSE;
271  if (TMath::Abs(s1->Y()-s2->Y())>positioncut) return kFALSE;
272  if (TMath::Abs(s1->Z()-s2->Z())>positioncut) return kFALSE;
273  if (TMath::Abs(s1->TX()-s2->TX())>anglecut) return kFALSE;
274  if (TMath::Abs(s1->TY()-s2->TY())>anglecut) return kFALSE;
275  return kTRUE;
276 }
Float_t TX() const
Definition: EdbSegP.h:172
Float_t X() const
Definition: EdbSegP.h:170
Float_t Z() const
Definition: EdbSegP.h:150
Float_t Y() const
Definition: EdbSegP.h:171
Float_t TY() const
Definition: EdbSegP.h:173
Int_t type
Definition: testBGReduction_By_ANN.C:15
EdbSegP * s1
Definition: tlg2pattern.C:30
EdbSegP * s2
Definition: tlg2pattern.C:31

◆ Execute()

void EdbShowAlgClean::Execute ( )

Two options, to be separated later... a) Remove Track Segments if the track start is behind/same as first segment. b) Remove Track Segments if the track start is outside the cone that is defined by the first shower BT;

222 {
223 
224  // In this function all the interface methods to the different cleaning types
225  // are called, according to the flag value in eCleaningType.
226 
227  // Possible/Supported cleaning type methods will be:
228 
229  // a) Remove passing Dirt from Source:
230  // a) All Objects in Dirt which start _before_ the Source
231  // a) Source Objects are then removed from the specific Source object.
232  // a) Example: Source=EdbShowerP, Dirt=TObjArray filled with EdbTrackP.
233  // a) Example: Source=EdbShowerP, Dirt=EdbShowerP.
234 
235 
236  // b) Remove stopping Dirt From Source:
237  // -----
241 
242  //if (eCleaningType->At(0)==1) RemovePassingDirtFromSource();
243  //if (eCleaningType->At(1)==1) RemoveStoppingDirtFromSource();
244 
245 
246 
247 }

◆ GetDirt()

TObjArray* EdbShowAlgClean::GetDirt ( ) const
inline
69  {
70  return eDirt;
71  }

◆ GetSource()

TObjArray* EdbShowAlgClean::GetSource ( ) const
inline
66  {
67  return eSource;
68  }

◆ GetTarget()

TObjArray* EdbShowAlgClean::GetTarget ( ) const
inline
72  {
73  return eTarget;
74  }

◆ Help()

void EdbShowAlgClean::Help ( )
83 {
84  cout << " EdbShowAlgClean::Help()."<<endl;
85 }

◆ Init()

void EdbShowAlgClean::Init ( void  )
private
90 {
91  eSource=new TObjArray();
92  eDirt=new TObjArray();
93  eTarget=new TObjArray();
94  eCleaningType=new TArrayI(10);
95  cout << " EdbShowAlgClean::Init()...done."<<endl;
96 }
TArrayI * eCleaningType
Definition: EdbShowAlgClean.h:46

◆ Print()

void EdbShowAlgClean::Print ( )
54 {
55  cout << " EdbShowAlgClean::Print()."<<endl;
56  cout << " EdbShowAlgClean::Print().Possible options: SetSource(TObjArray*)"<<endl;
57  cout << " EdbShowAlgClean::Print().Possible options: SetDirt(TObjArray*)"<<endl;
58  cout << " EdbShowAlgClean::Print().Possible options: SetTarget(TObjArray*)"<<endl;
59  cout << " EdbShowAlgClean::Print().Possible options: CheckClassType()"<<endl;
60  cout << " EdbShowAlgClean::Print().Possible options: Execute()"<<endl;
61  cout << " EdbShowAlgClean::Print().Possible options: SimpleRemoveDoubleBTViewOverlap(EdbShowerP* shower)"<<endl;
62  cout << " EdbShowAlgClean::Print().Possible options: SimpleRemoveBGSegmentsFromShower(EdbShowerP* shower)"<<endl;
63  cout << " EdbShowAlgClean::Print().Possible options: SimpleRemovePassingDirtFromSource(EdbShowerP* shower, EdbTrackP* track)"<<endl;
64  cout << " EdbShowAlgClean::Print():"<<endl;
65  cout << " EdbShowAlgClean::Print() Source Is Set? "<< eIsSet[0] << endl;
66  cout << " EdbShowAlgClean::Print() Dirt Is Set? "<< eIsSet[1] << endl;
67  cout << " EdbShowAlgClean::Print() Target Is Set? "<< eIsSet[2] << endl;
68 
69  cout << " EdbShowAlgClean::Print() Source ClassType? "<< eSourceClassType << endl;
70  cout << " EdbShowAlgClean::Print() Dirt ClassType? "<< eDirtClassType << endl;
71  cout << " EdbShowAlgClean::Print() Target ClassType? "<< eTargetClassType << endl;
72 
73  cout << " EdbShowAlgClean::Print() Source Entries? " << eSource->GetEntries() << endl;
74  cout << " EdbShowAlgClean::Print() Dirt Entries? " << eDirt->GetEntries() << endl;
75  cout << " EdbShowAlgClean::Print() Target Entries? " << eTarget->GetEntries() << endl;
76 
77  cout << " EdbShowAlgClean::Print()...done."<<endl;
78 }
Int_t eTargetClassType
Definition: EdbShowAlgClean.h:43

◆ RemovePassingDirtFromSource()

void EdbShowAlgClean::RemovePassingDirtFromSource ( )

THE DYNAMIC CASTING DOEST WORK YET SOMEHOW!!!

668 {
670 
671  // Find from Dirt array the objects which are also present in the source object
672 
673  EdbSegP* source=0;
674 
675  // Loop over Source objects:
676  for (int n_source=0; n_source<eSource->GetEntriesFast(); ++n_source) {
677 
678  // Helping Trick To Identifiy the right class of the object:
679  cout << eSource->At(n_source)->ClassName() << endl;
680 
681  if (eSourceClassType==0) source=(EdbShowerP*)eSource->At(n_source);
682  if (eSourceClassType==1) source=(EdbTrackP*)eSource->At(n_source);
683  if (eSourceClassType==2) source=(EdbSegP*)eSource->At(n_source);
684 
685  source->PrintNice();
686 
687  TObject* dirt=0;
688  // Loop over Dirt objects:
689  for (int n_dirt=0; n_dirt<eDirt->GetEntriesFast(); ++n_dirt) {
690 
691  if (eDirtClassType==0) dirt=(EdbShowerP*)eDirt->At(n_dirt);
692  if (eDirtClassType==1) dirt=(EdbTrackP*)eDirt->At(n_dirt);
693  if (eDirtClassType==2) dirt=(EdbSegP*)eDirt->At(n_dirt);
694 
695  dirt->Print();
696 
697  }// Loop over Dirt objects:
698 
699  }// Loop over Source objects
700 
701  return;
702 }
Definition: EdbSegP.h:18
void PrintNice() const
Definition: EdbSegP.cxx:418
Definition: EdbShowerP.h:28
Definition: EdbPattern.h:118

◆ RemoveStoppingDirtFromSource()

void EdbShowAlgClean::RemoveStoppingDirtFromSource ( )
707 {
708  return;
709 }

◆ Set0()

void EdbShowAlgClean::Set0 ( )
private
101 {
102  eSource->Clear();
103  eDirt->Clear();
104  eTarget->Clear();
105  for (int i=0; i<3; ++i) eIsSet[i]=0;
106  for (int i=0; i<3; ++i) eCleaningType->SetAt(i,0);
108  eDirtClassType=0;
110  cout << " EdbShowAlgClean::Set0()...done."<<endl;
111 }

◆ SetCleaningType()

void EdbShowAlgClean::SetCleaningType ( Int_t  CleaningType,
Int_t  Value 
)
inline
84  {
85  eCleaningType[CleaningType]=Value;
86  return;
87  }

◆ SetDirt() [1/2]

void EdbShowAlgClean::SetDirt ( EdbTrackP DirtTrack)
199 {
200  cout << " EdbShowAlgClean::SetDirt()... NO CHEKCING YET FOR CORRECT CLASS TYPE.... (still to be done)"<<endl;
201  if (TString(DirtTrack->ClassName())!=TString("EdbTrackP")) {
202  cout << "EdbShowAlgClean::SetDirt(DirtTrack)... WRONG CLASS TYPE! Return." << endl;
203  return;
204  }
205  eDirt->Clear();
206  eDirt->Add(DirtTrack);
207  eDirtClassType=1;
208  eIsSet[1]=kTRUE;
209  return;
210 }

◆ SetDirt() [2/2]

void EdbShowAlgClean::SetDirt ( TObjArray *  Dirt)
191 {
192  cout << " EdbShowAlgClean::SetDirt()... NO CHEKCING YET FOR CORRECT CLASS TYPE.... (still to be done)"<<endl;
193  eDirt=Dirt;
194  eDirtClassType=1;
195  eIsSet[1]=kTRUE;
196  return;
197 }

◆ SetSource() [1/2]

void EdbShowAlgClean::SetSource ( EdbShowerP SourceShower)
178 {
179  cout << " EdbShowAlgClean::SetSource(SourceShower)... NO CHEKCING YET FOR CORRECT CLASS TYPE.... (still to be done)"<<endl;
180  if (TString(SourceShower->ClassName())!=TString("EdbShowerP")) {
181  cout << "EdbShowAlgClean::SetSource(SourceShower)... WRONG CLASS TYPE! Return." << endl;
182  return;
183  }
184  eSource->Clear();
185  eSource->Add(SourceShower);
187  eIsSet[0]=kTRUE;
188  return;
189 }

◆ SetSource() [2/2]

void EdbShowAlgClean::SetSource ( TObjArray *  Source)
170 {
171  cout << " EdbShowAlgClean::SetSource()... NO CHEKCING YET FOR CORRECT CLASS TYPE.... (still to be done)"<<endl;
172  eSource=Source;
174  eIsSet[0]=kTRUE;
175  return;
176 }

◆ SetTarget() [1/2]

void EdbShowAlgClean::SetTarget ( EdbShowerP TargetShower)

◆ SetTarget() [2/2]

void EdbShowAlgClean::SetTarget ( TObjArray *  Target)
212 {
213  cout << " EdbShowAlgClean::SetTarget()... NO CHEKCING YET FOR CORRECT CLASS TYPE.... (still to be done)"<<endl;
214  eTarget=Target;
215  eIsSet[2]=kTRUE;
216  return;
217 }

◆ SimpleRemoveBGSegmentsFromShower() [1/2]

void EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower ( )
594 {
595 
596  return;
597 }

◆ SimpleRemoveBGSegmentsFromShower() [2/2]

Int_t EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower ( EdbShowerP shower)

Cheating cleaning alg for test purposes: Simply remove BG basetracks from the shower: Remove also MCEvt basetracks which are not shower MC

602 {
603 
607 
608  cout << "void EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower(EdbShowerP* shower)" << endl;
609  //shower->PrintSegments();
610 
611  EdbSegP* s1=0;
612  Int_t n1=shower->N();
613  Int_t IsTrackRemoved=0;
614  Int_t showerMC=shower->MCEvt();
615  Bool_t IsShowerChanged=kFALSE;
616  TObjArray* InterimStorageArray = new TObjArray(n1);
617 
618  cout << showerMC << endl;
619  for (int i=0; i<n1; ++i) {
620  s1=shower->GetSegment(i);
621 
622  if (s1->MCEvt()==showerMC) continue;
623 
624  cout << "EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower() Segment at: " << i << " has different MCEvt(" << s1->MCEvt()<< ") (shower->MCEvt="<<showerMC <<"). Remove it." << endl;
625  //s1->PrintNice();
626 
627  InterimStorageArray->Add(s1);
628 
629  IsShowerChanged=kTRUE;
630  IsTrackRemoved=1;
631  } // of (int i=0; i<shower->N(); ++i)
632 
633 
634  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower() Loop Done."<<endl;
635  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower() InterimStorageArray->GetEntries() "<< InterimStorageArray->GetEntries() << endl;
636 
637  if (!IsShowerChanged) {
638  cout << "EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower() No change for shower. Return leaving shower unchanged."<<endl;
639  delete InterimStorageArray;
640  return IsTrackRemoved;
641  }
642 
643  // Now is the right time to remove the segments from the shower:
644  int nent=InterimStorageArray->GetEntries();
645  for (int n=0; n<nent; ++n) {
646  EdbSegP* showerseg=(EdbSegP*)InterimStorageArray->At(n);
647 // showerseg->PrintNice();
648  // No EdbShowerP* Update for all, except the last one
649  shower->RemoveSegment(showerseg,kFALSE);
650  }
651  shower->Update();
652 
653  // Clear InterimStorageArray:
654  InterimStorageArray->Clear();
655 
656  delete InterimStorageArray;
657 
658  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveBGSegmentsFromShower() New shower->N() = " << shower->N() << endl;
659  if (gEDBDEBUGLEVEL>2) shower->PrintSegments();
660  return IsTrackRemoved;
661 
662  return 0;
663 }
Int_t MCEvt() const
Definition: EdbSegP.h:142
Int_t N() const
Definition: EdbShowerP.h:412
EdbSegP * GetSegment(int i) const
Definition: EdbShowerP.h:435
void RemoveSegment(EdbSegP *s, Bool_t UpdateAll=kFALSE)
Definition: EdbShowerP.cxx:341
void PrintSegments()
Definition: EdbShowerP.cxx:2367
void Update()
Definition: EdbShowerP.cxx:975
gEDBDEBUGLEVEL
Definition: energy.C:7

◆ SimpleRemoveDoubleBTViewOverlap() [1/2]

void EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap ( )
494 {
495  // Using source : TObjArray of EdbShowerP...
496  cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap()" << endl;
497  cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap() Using source : TObjArray of EdbShowerP..." << endl;
498 
499  TObjArray* src = GetSource();
500 
501  for (int i=0; i<src->GetEntries(); ++i) {
502  EdbShowerP* sh = (EdbShowerP*)src->At(i);
504  }
505  return;
506 }
TObjArray * GetSource() const
Definition: EdbShowAlgClean.h:66
void SimpleRemoveDoubleBTViewOverlap()
Definition: EdbShowAlgClean.cxx:493

◆ SimpleRemoveDoubleBTViewOverlap() [2/2]

Int_t EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap ( EdbShowerP shower)

Looks for DoubleBT which are very close to each other (in TX,TY,X,Y) This is due to Sysal ViewCorrection of the objective view, since the correction function f(x,y)_view is not symmetric w.r.t f(x-300,y-300) 300=viewsize of the objective camera.

EdbTrackP::Remove is NOT CORRECTLY WORKING IN current fedra versions, BUG FIXING WAS DONE BY VALERI in svn rev1000 (at the moment I use 9xx so it is not yet corrected for this function here!!!

511 {
516 
517  // Cutvalues: deltaX,Y<5micron
518  // Cutvalues: deltaTX,TY<5micron
519  // Cutvalues: deltaZ==0 (same plate! only there the ViewOverlap occurs, of course...)
520  // (plots and cutvalues justified in the thesis...).
521 
525 
526  cout << "void EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap(EdbShowerP* shower)" << endl;
527  shower->PrintSegments();
528 
529  EdbSegP* s1=0;
530  EdbSegP* s2=0;
531  Int_t n1=shower->N();
532  cout << "void EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap(EdbShowerP* shower) Checking now N(N-1)/2 combinations: " << n1*(n1-1)/2 << endl;
533  TObjArray* InterimStorageArray = new TObjArray(n1);
534  Bool_t IsShowerChanged=kFALSE;
535  Int_t IsTrackRemoved=0;
536 
537  for (int i=0; i<n1-1; ++i) {
538  s1=shower->GetSegment(i);
539  for (int j=i+1; j<n1; ++j) {
540  s2=shower->GetSegment(j);
541 
542  //cout << "Checking Shower Segment Combination: " << i << " " << j << " : CompareSegmentsByPosition(EdbSegP* s1,EdbSegP* s2) " << CompareSegmentsByPosition(s1,s2) << endl;
543 
544 //if (!CompareSegmentsByPosition(s1,s2,99)) continue; /// DEBBUG PURPOSE ONLY
545  if (!CompareSegmentsByPosition(s1,s2,1)) continue;
546 
547  cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap() Checking Shower Segment Combination: " << i << " " << j << " : Could be two close segments caused by view overlap:"<< endl;
548  s1->PrintNice();
549  s2->PrintNice();
550  // If s1 has the worser Chi2 we add into the array which is to be taken out afterwards,...
551  if (s1->Chi2()>s2->Chi2()) {
552  InterimStorageArray->Add(s1);
553  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap() s1 has worse chi2, therefore added into InterimStorageArray" << endl;
554  }
555 
556  IsShowerChanged=kTRUE;
557  IsTrackRemoved=1;
558  } // of (int j=i+1; j<shower->N(); ++j)
559  } // of (int i=0; i<shower->N(); ++i)
560 
561 
562  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap() Loop Done."<<endl;
563  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap() InterimStorageArray->GetEntries() "<< InterimStorageArray->GetEntries() << endl;
564 
565  if (!IsShowerChanged) {
566  cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap() No change for shower. Return leaving shower unchanged."<<endl;
567  delete InterimStorageArray;
568  return IsTrackRemoved;
569  }
570 
571  // Now is the right time to remove the segments from the shower:
572  int nent=InterimStorageArray->GetEntries();
573  for (int n=0; n<nent; ++n) {
574  EdbSegP* showerseg=(EdbSegP*)InterimStorageArray->At(n);
575 // showerseg->PrintNice();
576  // No EdbShowerP* Update for all, except the last one
577  shower->RemoveSegment(showerseg,kTRUE);
578  }
579  shower->Update();
580 
581  // Clear InterimStorageArray:
582  InterimStorageArray->Clear();
583 
584  delete InterimStorageArray;
585 
586  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveDoubleBTViewOverlap() New shower->N() = " << shower->N() << endl;
587  if (gEDBDEBUGLEVEL>2) shower->PrintSegments();
588  return IsTrackRemoved;
589 }
Float_t Chi2() const
Definition: EdbSegP.h:154
Bool_t CompareSegmentsByPosition(EdbSegP *s1, EdbSegP *s2, Int_t type)
Definition: EdbShowAlgClean.cxx:253

◆ SimpleRemoveTrackSegmentsFromShower() [1/2]

void EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower ( )

DEBUG

283 {
284  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower()" << endl;
285  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Using source : TObjArray of EdbShowerP..." << endl;
286  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Using dirt : TObjArray of EdbTrackP..." << endl;
287 
288  // Short helper instance.
289  EdbShowAlg fEdbShowAlg;
290 
291  TObjArray* src = GetSource();
292  TObjArray* drt = GetDirt();
293 
294  Int_t Nbefore=0;
295  Int_t Nafter=0;
296  Int_t Nsrc=src->GetEntries();
297  Int_t Ndrt=drt->GetEntries();
298  if (gEDBDEBUGLEVEL>3) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() " << Nsrc << endl;
299  if (gEDBDEBUGLEVEL>3) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() " << Ndrt << endl;
300 // return;
301  Int_t NshowersChanged=0;
302  Int_t NsrcChanged=0;
303  Int_t NsrcStep=Nsrc/20;
304  if (NsrcStep<=2) NsrcStep=1;
305 
306  EdbSegP* showerstart=0;
307 
308  for (int i=0; i<src->GetEntries(); ++i) {
309  EdbShowerP* sh = (EdbShowerP*)src->At(i);
310  EdbSegP* showerstart=sh->GetSegment(0);
311  Nbefore=sh->N();
312  NshowersChanged=0;
313  int debug_cnt_0=0;
314  int debug_cnt_1=0;
315  int debug_cnt_2=0;
316  int debug_cnt_3=0;
317  Float_t shLastZ=sh->GetSegmentLastZ();
318  Float_t shFirstZ=sh->GetSegmentFirstZ();
319  Float_t trLastZ=0;
320  Float_t trFirstZ=0;
321 
322  for (int j=0; j<drt->GetEntries(); ++j) {
323  if (gEDBDEBUGLEVEL>3)
324  if (j%5==0) cout << "2% more done... j= "<< j << endl;
325 
326  EdbTrackP* tr = (EdbTrackP*)drt->At(j);
327  trFirstZ=tr->Z();
328  trLastZ=tr->GetSegment(tr->N()-1)->Z();
329  debug_cnt_0++;
330 
331  // Simple Cut statements here to tell which tracks should NOT be removed:
332  // These two should anyway be Not in the shower:
333 
334  if (gEDBDEBUGLEVEL>3) cout << "XXX:Cut0 sh:(i,Z0,Z1) "<< i <<" "<< shFirstZ << " "<< shLastZ << " tr (j,Z0,Z1) " << j << " "<< trFirstZ << " "<< trLastZ << " Cut0." << endl;
335 
336 
337 
338  // Dont check two by two tracks?
339  if (tr->N()<3) continue;
340 
341  // Tracks starting after the shower ending:
342  if (trFirstZ>shLastZ) continue;
343  debug_cnt_1++;
344  if (gEDBDEBUGLEVEL>3) cout << "XXX:XXX:Cut1 sh:(i,Z0,Z1) "<< i <<" "<< shFirstZ << " "<< shLastZ << " tr (j,Z0,Z1) " << j << " "<< trFirstZ << " "<< trLastZ << " Cut1." << endl;
345 
346 
347 
348  // Tracks ending before the shower starting
349  if (trLastZ<shFirstZ) continue;
350  debug_cnt_2++;
351  if (gEDBDEBUGLEVEL>3) cout << "XXX:XXX:XXX:Cut2 sh:(i,Z0,Z1) "<< i <<" "<< shFirstZ << " "<< shLastZ << " tr (j,Z0,Z1) " << j << " "<< trFirstZ << " "<< trLastZ << " Cut2." << endl;
352 
353 
354 
355  // Tracks starting within the shower Cone should also NOT be removed.
356  if (gEDBDEBUGLEVEL>3) cout << "Is this track within the cone w.r.t. the 1st segment of the shower???" << endl;
357  if (gEDBDEBUGLEVEL>3) cout << "IsInConeTube(EdbSegP* sTest, EdbSegP* sStart, Double_t CylinderRadius, Double_t ConeAngle)"<<endl;
358  Bool_t inConeTube = fEdbShowAlg.IsInConeTube(tr->GetSegment(0), showerstart, 1000 , 0.75);
359  if (inConeTube) continue;
360  debug_cnt_3++;
361 
362  if (gEDBDEBUGLEVEL>3) cout << "XXX:XXX:XXX:XXX:Cut3 sh:(i,Z0,Z1) "<< i <<" "<< shFirstZ << " "<< shLastZ << " tr (j,Z0,Z1) " << j << " "<< trFirstZ << " "<< trLastZ << " Cut3." << endl;
363  debug_cnt_3++;
364 
365  // Additional Safety Cut, for non removing tracks from different MC than shower.
366  // Normaly this shouldnt be necessary since the Reconstruction itsself shouldn
367  // avoid the MC-Mixing anyway.
368  if (sh->MCEvt()>0 && tr->MCEvt()>0 && (sh->MCEvt()-tr->MCEvt()!=0)) continue;
369  //cout << tr->MCEvt() << " " << sh->MCEvt() << endl;
370 
371 
372  NshowersChanged=SimpleRemoveTrackSegmentsFromShower(sh,tr);
373  if (NshowersChanged>0) cout << "SimpleRemoveTrackSegmentsFromShower("<<sh->ID()<<","<<tr->ID()<<") : YES. Removed" << NshowersChanged << " segments." << endl;
374 
375  } // for (int j=0; j<drt->GetEntries(); ++j)
376  Nafter=sh->N();
377 
378  // Now here we print message, in case it was changed:
379  if (Nbefore!=Nafter) {
380  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Shower has been modified! Show details: " << endl;
381  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Nbefore: " << Nbefore << endl;
382  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Nafter: " << Nafter << endl;
383  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() NRemoved: " << Nafter-Nbefore << endl;
384  NsrcChanged++;
385  }
386 
387  cout << debug_cnt_0 << endl;
388  cout << debug_cnt_1 << endl;
389  cout << debug_cnt_2 << endl;
390  cout << debug_cnt_3 << endl;
391 
392  } //for (int i=0; i<src->GetEntries(); ++i)
393 
394  cout << "RunStatistics: src->GetEntries() : " << src->GetEntries() << " src changed: " << NsrcChanged << endl;
395 
397  gEDBDEBUGLEVEL=2;
398  return;
399 }
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
Int_t ID() const
Definition: EdbSegP.h:144
void SimpleRemoveTrackSegmentsFromShower()
Definition: EdbShowAlgClean.cxx:282
TObjArray * GetDirt() const
Definition: EdbShowAlgClean.h:69
Definition: EdbShowAlg.h:40
Bool_t IsInConeTube(EdbSegP *sTest, EdbSegP *sStart, Double_t CylinderRadius, Double_t ConeAngle)
Definition: EdbShowAlg.cxx:248
Float_t GetSegmentFirstZ() const
Definition: EdbShowerP.h:439
Float_t GetSegmentLastZ() const
Definition: EdbShowerP.h:442
struct @8 Z

◆ SimpleRemoveTrackSegmentsFromShower() [2/2]

Int_t EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower ( EdbShowerP shower,
EdbTrackP track 
)
405 {
406  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower(EdbShowerP* shower, EdbTrackP* track)" << endl;
407  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Returns nseg of track if it was removed, else 0." << endl;
408 
409  if (gEDBDEBUGLEVEL>2) shower->PrintNice();
410  if (gEDBDEBUGLEVEL>2) track ->PrintNice();
411 
412  TObjArray* InterimStorageArray = new TObjArray();
413  Int_t IsTrackRemoved=0;
414 
415  // Remove _ALL_ track segments from the track which are in the shower.
416  // Comparison can be either done on adresses or on positions.
417  // Addresses might be unsafe, if track-segment doesnt come from shower-segment
418  // source. So it might be better to compare on positions....
419  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Old shower->N() = " << shower->N() << endl;
420 
421  for (int n_dirt=0; n_dirt<track->N(); ++n_dirt) {
422  if (gEDBDEBUGLEVEL>3) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Checking trackseg " << n_dirt <<" now" << endl;
423  EdbSegP* trackseg=track->GetSegment(n_dirt);
424 
425  for (int n_source=0; n_source<shower->N(); ++n_source) {
426  if (gEDBDEBUGLEVEL>3) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Checking showerseg " << n_source <<" now" << endl;
427  EdbSegP* showerseg=shower->GetSegment(n_source);
428 
429  if (!CompareSegmentsByPosition(trackseg,showerseg)) continue;
430  if (gEDBDEBUGLEVEL>3) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Possible Same Segments found (for source n="<< n_source << ") and dirt-n=" << n_dirt<< ")."<< endl;
431 
432  InterimStorageArray->Add(showerseg); // this shall be removed later.
433  ++IsTrackRemoved;
434 
435  // Now a tricky part: if we remove the BT inside this loop, we collaps because the Shower->N() doesnt correspond
436  // to the original one anymore.
437  // So instead we have to add this to a temporary array, and then remove it outside the loop.
438  // shower->RemoveSegment(trackseg);
439  // cout << "new shower->N() = " << shower->N() << endl;
440  // shower->PrintSegments();
441  // Update:: In ROOT the TObjArray::Remove does not automatically compress the array when you remove one object,
442  // so in principle you can Remove it without InterimStorageArray and no need of indexing everytime new.
443  // Though, now we keep it as it is.
444 
445  } //for (int n_source=0;
446  } //for (int n_dirt=0;
447 
448  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() Loop Done."<<endl;
449 
450  // Here we can check if we want remove more segments than there are still left...
451  // This is NOT a check whether the first shower basetrack is unchanged...
452  // This would be to implemnt somewhere else, actually one wants to keep always
453  // the first shower segment anyway...
454  if (shower->N()<=InterimStorageArray->GetEntries()) {
455  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower()... WARNING. I shall remove more tracks from the shower than the shower has segments. I wont do this: dont remove the track." << endl;
456  delete InterimStorageArray;
457  if (gEDBDEBUGLEVEL>1) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower(EdbShowerP* shower, EdbTrackP* track)...Done." << endl;
458  return IsTrackRemoved;
459  }
460 
461  if (InterimStorageArray->GetEntries()==0) {
462  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower()... INFORMATION. No segments from the track have been removed;" << endl;
463  delete InterimStorageArray;
464  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower(EdbShowerP* shower, EdbTrackP* track)...Done." << endl;
465  return IsTrackRemoved;
466  }
467 
468 
469  // Now is the right time to remove the segments from the shower:
470  int nent=InterimStorageArray->GetEntries();
471  for (int n=0; n<nent; ++n) {
472  EdbSegP* showerseg=(EdbSegP*)InterimStorageArray->At(n);
473  // No EdbShowerP* Update for all, except the last one
474  shower->RemoveSegment(showerseg,kTRUE);
475  }
476  shower->Update();
477 
478  // Clear InterimStorageArray:
479  InterimStorageArray->Clear();
480 
481  if (gEDBDEBUGLEVEL>2) {
482  cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower() New shower->N() = " << shower->N() << endl;
483  shower->PrintSegments();
484  }
485 
486  delete InterimStorageArray;
487  if (gEDBDEBUGLEVEL>2) cout << "EdbShowAlgClean::SimpleRemoveTrackSegmentsFromShower(EdbShowerP* shower, EdbTrackP* track)...Done." << endl;
488  return IsTrackRemoved;
489 }
void PrintNice()
Definition: EdbShowerP.cxx:2339
Definition: bitview.h:14

Member Data Documentation

◆ eCleaningType

TArrayI* EdbShowAlgClean::eCleaningType
private

◆ eDirt

TObjArray* EdbShowAlgClean::eDirt
private

◆ eDirtClassType

Int_t EdbShowAlgClean::eDirtClassType
private

◆ eIsSet

Bool_t EdbShowAlgClean::eIsSet[3]
private

◆ eSource

TObjArray* EdbShowAlgClean::eSource
private

◆ eSourceClassType

Int_t EdbShowAlgClean::eSourceClassType
private

◆ eTarget

TObjArray* EdbShowAlgClean::eTarget
private

◆ eTargetClassType

Int_t EdbShowAlgClean::eTargetClassType
private

The documentation for this class was generated from the following files: