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

Functions

void ReconstructShowers_AG ()
 

Function Documentation

◆ ReconstructShowers_AG()

void ReconstructShowers_AG ( )
3 {
4  Log(2, "ShowRec.cpp", "--- void ReconstructShowers_AG() ---");
5 
6  //-----------------------------------------------------------------
7  // Main function for reconstruction of "Advanced Gamma" 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  //-----------------------------------
79  // 2) Loop over (whole) local_gAli, check InitiatorBT
80  // 2) compatible with a segment forming a e+e- pair:
81  //-----------------------------------
82  Int_t NPairs=0,PIDDIFF=0,minPIDDIFF=0;
83 
84  Int_t local_gAli_npat=local_gAli->Npatterns();
85  Int_t btloop_cnt_N=0;
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  if (local_gAli->GetPattern(patterloop_cnt)->Z()<InBT->Z()) continue;
90  if (TMath::Abs(local_gAli->GetPattern(patterloop_cnt)->Z()-InBT->Z())>3000) continue;
91  if (local_gAli->GetPattern(patterloop_cnt)->Z()<InBT->Z()) continue;
92  for (Int_t btloop_cnt=0; btloop_cnt<btloop_cnt_N; ++btloop_cnt) {
93  seg = (EdbSegP*)local_gAli->GetPattern(patterloop_cnt)->GetSegment(btloop_cnt);
94  if (gEDBDEBUGLEVEL>3) seg->PrintNice();
95  if (IsSameSegment(seg,InBT)) continue;
96  PIDDIFF=TMath::Abs(seg->PID()-InBT->PID());
97  if (GetMinimumDist(InBT,seg)>50) continue;
98  if (GetdR(InBT,seg)>200) continue;
99  if (GetdeltaThetaSingleAngles(InBT,seg)>0.5) continue;
100  if (PIDDIFF>minPIDDIFF) continue;
101  // cout << " GetMinimumDist(InBT,seg); " << GetMinimumDist(InBT,seg) << "PIDDIFF "<< PIDDIFF<< endl;
102 
104  minPIDDIFF=PIDDIFF;
105  }
106  }
108  // return;
109 
110  //-----------------------------------
111  // 2) Loop over (whole) local_gAli, check BT for Cuts
112  //-----------------------------------
113  if (gEDBDEBUGLEVEL>2) cout << "--- local_gAli_npat= " << local_gAli_npat << endl;
114 
115  // Loop over all plates of local_gAli, since this is already
116  // extracted with the right numbers of plates...
117  for (Int_t patterloop_cnt=local_gAli_npat-1; patterloop_cnt>=0; --patterloop_cnt) {
118  if (gEDBDEBUGLEVEL>3) cout << "--- --- Doing patterloop_cnt= " << patterloop_cnt << endl;
119  btloop_cnt_N=local_gAli->GetPattern(patterloop_cnt)->GetN();
120 
121  // if pattern is before the Initiator BT->Z() position we just go on:
122  if (local_gAli->GetPattern(patterloop_cnt)->Z()<InBT->Z()) continue;
123 
124  for (Int_t btloop_cnt=0; btloop_cnt<btloop_cnt_N; ++btloop_cnt) {
125  seg = (EdbSegP*)local_gAli->GetPattern(patterloop_cnt)->GetSegment(btloop_cnt);
126  if (gEDBDEBUGLEVEL>3) seg->PrintNice();
127 
128  // Now apply cut conditions: Advanced Gamma Alg --------------------
130  if (!FindPrecedingBTsSingleThetaAngle(seg, InBT, local_gAli, GLOBAL_ShowerSegArray)) continue;
131  // end of cut conditions: Advanced Gamma Alg --------------------
132 
133  // If we arrive here, Basetrack seg has passed criteria
134  // and is then added to the shower array:
135  // Check if its not the InBT which is already added:
136  // if (IsSameSegment(seg,InBT)) { ; } // do nothing;
137  // else {GLOBAL_ShowerSegArray -> Add(seg);}
139  }
140 
141 
142  // Calc BT density around shower:
143  EdbPattern* pat_interim=local_gAli->GetPattern(patterloop_cnt);
144  CalcTrackDensity(pat_interim,local_gAli_pat_interim_halfsize,npat_int,npat_total,npatN);
145 
146  // Calc TrackNumbers for plate for efficency numbers:
147  CalcEfficencyNumbers(pat_interim, InBT->MCEvt(), NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
148  }
149  // end of loop over all plates of local_gAli
150 
152 
153 
154 
155 
156  Int_t s_NBT=0;
157  Int_t s_NBTMC=0;
158  Int_t s_NBTallMC=0;
159  Int_t s_NBTeMC=0;
160  Double_t s_eff=0;
161  Double_t s_purall=0;
162  Double_t s_pure=0;
163  CalcEffPurOfShower(GLOBAL_ShowerSegArray, s_NBT, s_NBTMC, s_NBTallMC, s_NBTeMC, s_purall, s_pure);
164 
165  //-----------------------------------
166  // 4) Calculate pur/eff/NBT numbers,
167  // not needed when only reconstruction
168  // done:
169  //-----------------------------------
170  if (cmd_OUTPUTLEVEL>=2 || cmd_OUTPUTLEVEL==0 ) {
171  Int_t NBT=0;
172  Int_t NBTMC=0;
173  Int_t NBTallMC=0;
174  Int_t NBTeMC=0;
175  Double_t eff, purall, pure;
176  CalcEffPurOfShower2(GLOBAL_ShowerSegArray, NBT, NBTMC, NBTallMC, NBTeMC, purall, pure, NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
177 
178  // Fill only for MC Event:
179  if (GLOBAL_InBT_MC>0) {
184  }
186  }
187 
188 
189  //-----------------------------------
190  // 5) Fill Tree:
191  //-----------------------------------
192  TREE_ShowRecEff->Fill();
193  if (gEDBDEBUGLEVEL>3) TREE_ShowRecEff->Show(TREE_ShowRecEff->GetEntries()-1);
194 
195 
196  //-----------------------------------
197  // 6a) Transfer ShowerArray to treebranchTreeEntry:
198  //-----------------------------------
199  if (cmd_OUTPUTLEVEL>0) {
201  }
202 
203 
204  //------------------------------------
205  // Reset and delete important things:
206  // also to avoid memory problems ...
207  //-----------------------------------
208  GLOBAL_ShowerSegArray->Clear();
209  if (gEDBDEBUGLEVEL>3) cout << "--- ---GLOBAL_ShowerSegArray->GetEntries(): "<< GLOBAL_ShowerSegArray->GetEntries() << endl;
210  delete local_gAli;
211  local_gAli=0;
213  //------------------------------------
214  }
215  // end of loop over GLOBAL_InBTArrayEntries
216  //-----------------------------------------------------------------
217 
218  if (gEDBDEBUGLEVEL==2) cout << endl<<flush;
219  if (gEDBDEBUGLEVEL>3) cout << "---TREE_ShowRecEff->GetEntries() ... " << TREE_ShowRecEff->GetEntries() << endl;
220  if (gEDBDEBUGLEVEL>3) cout << "---GLOBAL_INBTSHOWERNR ... " << GLOBAL_INBTSHOWERNR<< endl;
221 
222 
223  return;
224 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
Double_t GetdeltaThetaSingleAngles(EdbSegP *s1, EdbSegP *s2)
Definition: ShowRec.cpp:7258
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 IsSameSegment(EdbSegP *seg1, EdbSegP *seg2)
Definition: ShowRec.cpp:8857
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
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
Double_t GetMinimumDist(EdbSegP *seg1, EdbSegP *seg2)
Definition: ShowRec.cpp:8581
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 GetdR(EdbSegP *s1, EdbSegP *s2)
Definition: ShowRec.h:167
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
Int_t PID() const
Definition: EdbSegP.h:145
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