FEDRA emulsion software from the OPERA Collaboration
ShowRec_Alg_RC.cpp File Reference
This graph shows which files directly or indirectly include this file:

Functions

void ReconstructShowers_RC ()
 

Function Documentation

◆ ReconstructShowers_RC()

void ReconstructShowers_RC ( )

last to variables are dummyvariabes.

if this is in, it doesnt work for iteratet ShowerAxisCenterGravityBT

3 {
4  Log(2, "ShowRec.cpp", "--- void ReconstructShowers_RC() ---");
5 
6  //-----------------------------------------------------------------
7  // Main function for reconstruction of "Recursive Cone" Algorithm
8  //-----------------------------------------------------------------
9 
10  //-----------------------------------
11  // For each InitiatorBT this is
12  // divided in several small parts:
13  //
14  // 1) Make local_gAli with cut parameters, Make GetPID of InBT and corresponding of plates
15  // 3) Loop over (whole) local_gAli, check BT for Cuts
16  // 4) Calculate pur/eff/NBT numbers
17  // 5) Fill Trees
18  //-----------------------------------
19 
20  // Define Helper Variables:
21  EdbPVRec* local_gAli;
22  EdbSegP* InBT;
23  EdbSegP* seg;
24  Float_t local_gAli_pat_interim_halfsize=0;
25 
28 
29  //-----------------------------------------------------------------
30  // Since GLOBAL_InBTArray is filled in ascending ordering by zpositon
31  // We use the descending loop to begin with BT with lowest z first.
32  for (Int_t i=GLOBAL_InBTArrayEntries-1; i>=0; --i) {
33 
34  //-----------------------------------
35  // CounterOutPut
36  if (gEDBDEBUGLEVEL==2) if ((i%1)==0) cout << GLOBAL_InBTArrayEntries <<" InBT in total, still to do:"<<Form("%4d",i)<< "\r\r\r\r"<<flush;
37  //-----------------------------------
38 
39  //-----------------------------------
40  // Get InitiatorBT from GLOBAL_InBTArray
41  InBT=(EdbSegP*)GLOBAL_InBTArray->At(i);
42  //--------
43  GLOBAL_InBT_E=InBT->P();
44  GLOBAL_InBT_TanTheta=TMath::Sqrt(InBT->TX()*InBT->TX()+InBT->TY()*InBT->TY());
45  GLOBAL_InBT_Flag=InBT->Flag();
46  GLOBAL_InBT_MC=InBT->MCEvt();
47  //--------
48  Int_t local_NBT=0;
49  Int_t local_NBTMC=0;
50  Int_t local_NBTallMC=0;
51  Int_t local_NBTeMC=0;
52  float_t local_pure=-1;
53  float_t local_purall=-1;
54  Int_t npat_int=0;
55  Int_t npat_total=0;
56  Int_t npatN=0;
57  Int_t npat_Neff=0;
58  Int_t NBT_Neff=0;
59  Int_t NBTMC_Neff=0;
60  Int_t NBTMCe_Neff=0;
61  //--------
62 
63  if (gEDBDEBUGLEVEL>2) {
64  cout << endl << endl << "--- Starting Shower for Number " << i << " now: "<<endl;
65  InBT->PrintNice();
66  }
67  //-----------------------------------
68 
69  //-----------------------------------
70  // 1) Make local_gAli with cut parameters:
71  //-----------------------------------
72  local_gAli = TransformEdbPVRec(GLOBAL_gAli, InBT);
73  // Add InBT to GLOBAL_ShowerSegArray
74  GLOBAL_ShowerSegArray -> Add(InBT);
75  //-----------------------------------
76 
77  //-----------------------------------
78  // 2) Loop over (whole) local_gAli, check BT for Cuts
79  //-----------------------------------
80  Int_t local_gAli_npat=local_gAli->Npatterns();
81  Int_t btloop_cnt_N=0;
82  if (gEDBDEBUGLEVEL>2) cout << "--- local_gAli_npat= " << local_gAli_npat << endl;
83 
84  // Loop over all plates of local_gAli, since this is already
85  // extracted with the right numbers of plates...
86  for (Int_t patterloop_cnt=local_gAli_npat-1; patterloop_cnt>=0; --patterloop_cnt) {
87  if (gEDBDEBUGLEVEL>3) cout << "--- --- Doing patterloop_cnt= " << patterloop_cnt << endl;
88  btloop_cnt_N=local_gAli->GetPattern(patterloop_cnt)->GetN();
89 
90  // if pattern is before the Initiator BT->Z() position we just go on:
91  if (local_gAli->GetPattern(patterloop_cnt)->Z()<InBT->Z()) continue;
92 
93  for (Int_t btloop_cnt=0; btloop_cnt<btloop_cnt_N; ++btloop_cnt) {
94  seg = (EdbSegP*)local_gAli->GetPattern(patterloop_cnt)->GetSegment(btloop_cnt);
95  if (gEDBDEBUGLEVEL>3) seg->PrintNice();
96 
97  // Now apply cut conditions: RECURSIVE CONE Alg --------------------
99  if (!FindPrecedingBTsSingleThetaAngle(seg, InBT, local_gAli, GLOBAL_ShowerSegArray)) continue;
100  // end of cut conditions: RECURSIVE CONE Alg --------------------
101 
102  // If we arrive here, Basetrack seg has passed criteria
103  // and is then added to the shower array:
104  // Check if its not the InBT which is already added:
106  }
107 
108  // Calc BT density around shower:
109  EdbPattern* pat_interim=local_gAli->GetPattern(patterloop_cnt);
110  CalcTrackDensity(pat_interim,local_gAli_pat_interim_halfsize,npat_int,npat_total,npatN);
111 
112  // Calc TrackNumbers for plate for efficency numbers:
113  CalcEfficencyNumbers(pat_interim, InBT->MCEvt(), NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
114  }
115  // end of loop over all plates of local_gAli
116 
118 
119  Int_t f_NBT=0;
120  Int_t f_NBTMC=0;
121  Int_t f_NBTallMC=0;
122  Int_t f_NBTeMC=0;
123  Double_t f_eff=0;
124  Double_t f_purall=0;
125  Double_t f_pure=0;
126  CalcEffPurOfShower(GLOBAL_ShowerSegArray, f_NBT, f_NBTMC, f_NBTallMC, f_NBTeMC, f_purall, f_pure);
128 
129  //-----------------------------------
130  // 3) Try RE-ITERATION over (whole) local_gAli!!
131  // 3) Using the iterated shower Gravity Center!
132  // 3)
133  // 3) WILL NOT WORK FOR ELECTRONS ... CAUSE FISRT POSITION IS SHIFTED AFTER ITERATION !!!
134  // 3) DEPRECIAPTED
135  // 3) DEPRECIAPTED .... DO NOT USE IT NOW!!!!!!!!!!!!!!
136  // 3) DEPRECIAPTED (even if it works we dont need to reevaluate the
137  // 3) efficency numbers anymore, since calculated above)
138  //-----------------------------------
139 
140  Bool_t DoIteration=kFALSE;
141  // Bool_t DoIteration=kTRUE// 3) DEPRECIAPTED .... DO NOT USE IT NOW!!!!!!!!!!!!!!
142 
143  if (DoIteration) {
144 
145  cout << "-------------------------------------------"<<endl;
146  EdbSegP* ShowerAxisCenterGravityBT = BuildShowerAxis(GLOBAL_ShowerSegArray);
147  GLOBAL_ShowerSegArray->Clear();
148  //-----------------------------------
149  // 3) Loop again over (whole) local_gAli, check BT for Cuts
150  //-----------------------------------
151  local_gAli_npat=local_gAli->Npatterns();
152  btloop_cnt_N=0;
153  if (gEDBDEBUGLEVEL>2) cout << "--- local_gAli_npat= " << local_gAli_npat << endl;
154 
155  // Loop over all plates of local_gAli, since this is already
156  // extracted with the right numbers of plates...
157  for (Int_t patterloop_cnt=local_gAli_npat-1; patterloop_cnt>=0; --patterloop_cnt) {
158  if (gEDBDEBUGLEVEL>3) cout << "--- --- Doing patterloop_cnt= " << patterloop_cnt << endl;
159  btloop_cnt_N=local_gAli->GetPattern(patterloop_cnt)->GetN();
160 
161  for (Int_t btloop_cnt=0; btloop_cnt<btloop_cnt_N; ++btloop_cnt) {
162  seg = (EdbSegP*)local_gAli->GetPattern(patterloop_cnt)->GetSegment(btloop_cnt);
163  if (gEDBDEBUGLEVEL>3) seg->PrintNice();
164 
165  // Now apply cut conditions: RECURSIVE CONE Alg --------------------
166  // if (!GetConeOrTubeDistanceToBTOfShowerArray(seg, ShowerAxisCenterGravityBT, GLOBAL_ShowerSegArray, CUT_PARAMETER[0], CUT_PARAMETER[1])) continue;
168  if (!FindPrecedingBTsSingleThetaAngle(seg, ShowerAxisCenterGravityBT, local_gAli, GLOBAL_ShowerSegArray)) continue;
169  // end of cut conditions: RECURSIVE CONE Alg --------------------
170 
171  // If we arrive here, Basetrack seg has passed criteria
172  // and is then added to the shower array:
173  // Check if its not the InBT which is already added:
174  // if (seg->X()==ShowerAxisCenterGravityBT->X()&&seg->Y()==ShowerAxisCenterGravityBT->Y()) { ; } // do nothing;
175  // else {GLOBAL_ShowerSegArray -> Add(seg);}
177  }
178  }
179  // end of loop over all plates of local_gAli
181  cout << "-------------------------------------------"<<endl;
182 
183 
184  } // of if (DoIteration)
185 
186  Int_t s_NBT=0;
187  Int_t s_NBTMC=0;
188  Int_t s_NBTallMC=0;
189  Int_t s_NBTeMC=0;
190  Double_t s_eff=0;
191  Double_t s_purall=0;
192  Double_t s_pure=0;
193  CalcEffPurOfShower(GLOBAL_ShowerSegArray, s_NBT, s_NBTMC, s_NBTallMC, s_NBTeMC, s_purall, s_pure);
194 
195  //-----------------------------------
196  // 4) Calculate pur/eff/NBT numbers,
197  // not needed when only reconstruction
198  // done:
199  //-----------------------------------
200  if (cmd_OUTPUTLEVEL>=2 || cmd_OUTPUTLEVEL==0 ) {
201  Int_t NBT=0;
202  Int_t NBTMC=0;
203  Int_t NBTallMC=0;
204  Int_t NBTeMC=0;
205  Double_t eff, purall, pure;
206  CalcEffPurOfShower2(GLOBAL_ShowerSegArray, NBT, NBTMC, NBTallMC, NBTeMC, purall, pure, NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
207 
208  // Fill only for MC Event:
209  if (GLOBAL_InBT_MC>0) {
214  }
216  }
217 
218 
219  //-----------------------------------
220  // 5) Fill Tree:
221  //-----------------------------------
222  TREE_ShowRecEff->Fill();
223  if (gEDBDEBUGLEVEL>3) TREE_ShowRecEff->Show(TREE_ShowRecEff->GetEntries()-1);
224 
225 
226  //-----------------------------------
227  // 6a) Transfer ShowerArray to treebranchTreeEntry:
228  //-----------------------------------
229  if (cmd_OUTPUTLEVEL>0) {
231  }
232 
233 
234  //-----------------------------------
235  // 7) cout some numbers from shower reco:
236  //-----------------------------------
237  if (gEDBDEBUGLEVEL>2) {
238  cout << "------------------------------- _NUMBERS ----------------------"<<endl;
239  cout << "ITERATION 0 : --- NBT = " << f_NBT << endl;
240  cout << "ITERATION 0 : --- NBTMC = " << f_NBTMC << endl;
241  cout << "ITERATION 0 : --- purall = " << f_purall << endl;
242  cout << "------------"<<endl;
243  cout << "ITERATION 1 : --- NBT = " << s_NBT << endl;
244  cout << "ITERATION 1 : --- NBTMC = " << s_NBTMC << endl;
245  cout << "ITERATION 1 : --- purall = " << s_purall << endl;
246  cout << "NUMBERS " << f_NBT << " " << f_NBTMC << " " << f_purall << " " << s_NBT << " " << s_NBTMC << " " << s_purall << " " << endl;
247  }
248 
249  //------------------------------------
250  // Reset and delete important things:
251  // also to avoid memory problems ...
252  //-----------------------------------
253  GLOBAL_ShowerSegArray->Clear();
254  if (gEDBDEBUGLEVEL>3) cout << "--- ---GLOBAL_ShowerSegArray->GetEntries(): "<< GLOBAL_ShowerSegArray->GetEntries() << endl;
255  delete local_gAli;
256  local_gAli=0;
258  //------------------------------------
259  }
260  // end of loop over GLOBAL_InBTArrayEntries
261  //-----------------------------------------------------------------
262 
263  if (gEDBDEBUGLEVEL==2) cout << endl<<flush;
264  if (gEDBDEBUGLEVEL>3) cout << "---TREE_ShowRecEff->GetEntries() ... " << TREE_ShowRecEff->GetEntries() << endl;
265  if (gEDBDEBUGLEVEL>3) cout << "---GLOBAL_INBTSHOWERNR ... " << GLOBAL_INBTSHOWERNR<< endl;
266 
267 
268  return;
269 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
void CalcEffPurOfShower(TObjArray *arr, Int_t &NBT, Int_t &NBTMC, Int_t &NBTallMC, Int_t &NBTeMC, Double_t &purall, Double_t &pure)
Definition: ShowRec.cpp:7597
Bool_t AddBTToArrayWithCeck(EdbSegP *tryAttachedSegment, TObjArray *GLOBAL_ShowerSegArray)
Definition: ShowRec.cpp:5939
void CalcTrackDensity(EdbPattern *pat_interim, Float_t pat_interim_halfsize, Int_t &npat_int, Int_t &npat_total, Int_t &npatN)
Definition: ShowRec.cpp:8749
void TransferShowerObjectArrayIntoEntryOfTreebranchShowerTree(TTree *treebranchtree, TObjArray *segarray)
Definition: ShowRec.cpp:7940
Bool_t FindPrecedingBTsSingleThetaAngle(EdbSegP *s, EdbSegP *InBT, EdbPVRec *gAli, TObjArray *showersegarray)
Definition: ShowRec.cpp:6825
EdbPVRec * TransformEdbPVRec(EdbPVRec *gAli, EdbSegP *InitiatorBT)
DEBUG OPENMP TEST!!!!!!!
Definition: ShowRec.cpp:6299
void CalcEffPurOfShower2(TObjArray *arr, Int_t &NBT, Int_t &NBTMC, Int_t &NBTallMC, Int_t &NBTeMC, Double_t &purall, Double_t &pure, Int_t NBT_Neff, Int_t NBTMC_Neff, Int_t NBTMCe_Neff)
Definition: ShowRec.cpp:7631
EdbSegP * BuildShowerAxis(TObjArray *ShowerSegArray)
Definition: ShowRec.cpp:8629
void PrintShowerObjectArray(TObjArray *segarray)
Definition: ShowRec.cpp:6967
Bool_t GetConeOrTubeDistanceToBTOfShowerArray(EdbSegP *sa, EdbSegP *InBT, TObjArray *showersegarray, Double_t CylinderRadius, Double_t ConeAngle)
Definition: ShowRec.cpp:7072
void CalcEfficencyNumbers(EdbPattern *pat_interim, Int_t MCCheck, Int_t &NBT_Neff, Int_t &NBTMC_Neff, Int_t &NBTMCe_Neff)
Definition: ShowRec.cpp:8771
Int_t GLOBAL_INBTSHOWERNR
Definition: ShowRec.h:80
Double_t GLOBAL_trckdens
Definition: ShowRec.h:39
EdbPVRec * GLOBAL_gAli
Definition: ShowRec.h:73
Int_t cmd_OUTPUTLEVEL
Definition: ShowRec.h:33
Int_t GLOBAL_EvtBT_FlagArray[99999]
Definition: ShowRec.h:51
TObjArray * GLOBAL_ShowerSegArray
Definition: ShowRec.h:76
Int_t GLOBAL_InBT_MC
Definition: ShowRec.h:43
Double_t GLOBAL_EvtBT_EArray[99999]
Definition: ShowRec.h:52
Int_t GLOBAL_EvtBT_MCArray[99999]
Definition: ShowRec.h:51
TTree * TREE_ShowRecEff
Definition: ShowRec.h:62
Float_t shower_trackdensb
Definition: ShowRec.h:395
Int_t GLOBAL_InBT_Flag
Definition: ShowRec.h:43
Double_t GLOBAL_EvtBT_E
Definition: ShowRec.h:50
Double_t GLOBAL_InBT_TanTheta
Definition: ShowRec.h:44
Double_t GLOBAL_InBT_E
Definition: ShowRec.h:44
Double_t CUT_PARAMETER[10]
Definition: ShowRec.h:78
Int_t GLOBAL_EvtBT_MC
Definition: ShowRec.h:49
Int_t GLOBAL_InBTArrayEntries
Definition: ShowRec.h:75
Double_t GLOBAL_EvtBT_TanThetaArray[99999]
Definition: ShowRec.h:52
Double_t GLOBAL_EvtBT_TanTheta
Definition: ShowRec.h:50
TTree * TREE_ShowShower
Definition: ShowRec.h:68
Int_t GLOBAL_EvtBT_Flag
Definition: ShowRec.h:49
TObjArray * GLOBAL_InBTArray
Definition: ShowRec.h:74
Definition: EdbPVRec.h:148
Definition: EdbPattern.h:280
Int_t Npatterns() const
Definition: EdbPattern.h:380
EdbPattern * GetPattern(int id) const
Definition: EdbPattern.cxx:1887
Definition: EdbSegP.h:18
Float_t TX() const
Definition: EdbSegP.h:172
Float_t Z() const
Definition: EdbSegP.h:150
Float_t P() const
Definition: EdbSegP.h:149
void PrintNice() const
Definition: EdbSegP.cxx:418
Float_t TY() const
Definition: EdbSegP.h:173
Int_t MCEvt() const
Definition: EdbSegP.h:142
Int_t Flag() const
Definition: EdbSegP.h:146
Float_t Z() const
Definition: EdbPattern.h:87
Int_t GetN() const
Definition: EdbPattern.h:65
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
gEDBDEBUGLEVEL
Definition: energy.C:7