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

Functions

void ReconstructShowers_OI ()
 void ReconstructShowers_CL() /// Still Missing in the Implementation !!! More...
 

Function Documentation

◆ ReconstructShowers_OI()

void ReconstructShowers_OI ( )

void ReconstructShowers_CL() /// Still Missing in the Implementation !!!

3 {
4  Log(2, "ShowRec.cpp", "--- void ReconstructShowers_OI() ---");
5 
6  //-----------------------------------------------------------------
7  // Main function for reconstruction of OFFICIAL IMPLEMENTATION 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  if (gEDBDEBUGLEVEL==1) {
38  int modulo=TMath::Max(GLOBAL_InBTArrayEntries/20,1);
39  if ((i%modulo)==0) cout << i <<" : 5% more done"<<endl;
40  }
41  //-----------------------------------
42 
43  //-----------------------------------
44  // Get InitiatorBT from GLOBAL_InBTArray
45  InBT=(EdbSegP*)GLOBAL_InBTArray->At(i);
46  //--------
47  GLOBAL_InBT_E=InBT->P();
48  GLOBAL_InBT_TanTheta=TMath::Sqrt(InBT->TX()*InBT->TX()+InBT->TY()*InBT->TY());
49  GLOBAL_InBT_Flag=InBT->Flag();
50  GLOBAL_InBT_MC=InBT->MCEvt();
51  //--------
52  Int_t local_NBT=0;
53  Int_t local_NBTMC=0;
54  Int_t local_NBTallMC=0;
55  Int_t local_NBTeMC=0;
56  float_t local_pure=-1;
57  float_t local_purall=-1;
58  Int_t npat_int=0;
59  Int_t npat_total=0;
60  Int_t npatN=0;
61  Int_t npat_Neff=0;
62  Int_t NBT_Neff=0;
63  Int_t NBTMC_Neff=0;
64  Int_t NBTMCe_Neff=0;
65  //--------
66 
67  if (gEDBDEBUGLEVEL>2) {
68  cout << endl << endl << "--- Starting Shower for Number " << i << " now: "<<endl;
69  InBT->PrintNice();
70  }
71  //-----------------------------------
72 
73  //-----------------------------------
74  // 1) Make local_gAli with cut parameters:
75  //-----------------------------------
76  local_gAli = TransformEdbPVRec(GLOBAL_gAli, InBT);
77 
78  /*
79  //-----------------------------------
80  // 1) BG Clean of local_gAli
81  // that maybe not necessary always , only for the large
82  // MC pasted Backgrounds...
83  //-----------------------------------
84  Float_t BGTargetDensity=0;
85  // cout << "--- \t\t : -CLEAN InputData BG Cleaning: 0: No, 1:20BT/mm2 2: 40BT/mm2 3:10BT/mm2 4:60BT/mm2 \n";
86  if (cmd_CLEAN==1) BGTargetDensity=20;
87  if (cmd_CLEAN==2) BGTargetDensity=40;
88  if (cmd_CLEAN==3) BGTargetDensity=10;
89  if (cmd_CLEAN==4) BGTargetDensity=60;
90  if (cmd_CLEAN==0) BGTargetDensity=1000;
91 
92  EdbPVRQuality* localPVRQualCheck = new EdbPVRQuality(local_gAli,BGTargetDensity);
93  EdbPVRec* new_local_gAli;
94  new_local_gAli = localPVRQualCheck->GetEdbPVRec(1);
95  localPVRQualCheck->Print();
96  local_gAli=new_local_gAli;
97  */
98 
99 // InBT->PrintNice();
100 // gSystem->Exit(1);
101 
102  //-----------------------------------
103  // Add InBT to GLOBAL_ShowerSegArray
104  GLOBAL_ShowerSegArray -> Add(InBT);
105  //-----------------------------------
106 
107 
108  //-----------------------------------
109  // 2) Loop over (whole) local_gAli, check BT for Cuts
110  //-----------------------------------
111  Int_t local_gAli_npat=local_gAli->Npatterns();
112  if (gEDBDEBUGLEVEL>2) cout << "--- local_gAli_npat= " << local_gAli_npat << endl;
113 
114  // Loop over all plates of local_gAli, since this is already
115  // extracted with the right numbers of plates...
116  for (Int_t patterloop_cnt=local_gAli_npat-1; patterloop_cnt>=0; --patterloop_cnt) {
117  if (gEDBDEBUGLEVEL>3) cout << "--- --- Doing patterloop_cnt= " << patterloop_cnt << endl;
118 
119  for (Int_t btloop_cnt=0; btloop_cnt<local_gAli->GetPattern(patterloop_cnt)->GetN(); ++btloop_cnt) {
120  seg = (EdbSegP*)local_gAli->GetPattern(patterloop_cnt)->GetSegment(btloop_cnt);
121  if (gEDBDEBUGLEVEL>3) seg->PrintNice();
122 
123  // Now apply cut conditions: OFFICIAL IMPLEMENTATION Alg --------------------
124  if (!GetConeOrTubeDistanceToInBT(seg, InBT, CUT_PARAMETER[0], CUT_PARAMETER[1])) continue;
125  if (!FindPrecedingBTsSingleThetaAngle(seg, InBT, local_gAli, GLOBAL_ShowerSegArray)) continue;
126  // end of cut conditions: OFFICIAL IMPLEMENTATION Alg --------------------
127 
128  // If we arrive here, Basetrack seg has passed criteria
129  // and is then added to the shower array:
130  // Check if its not the InBT which is already added:
131  if (seg->X()==InBT->X()&&seg->Y()==InBT->Y()) {
132  ; // do nothing;
133  }
134  else {
135  GLOBAL_ShowerSegArray -> Add(seg);
136  }
137  }
138  // Calc BT density around shower:
139  EdbPattern* pat_interim=local_gAli->GetPattern(patterloop_cnt);
140  CalcTrackDensity(pat_interim,local_gAli_pat_interim_halfsize,npat_int,npat_total,npatN);
141 
142  // Calc TrackNumbers for plate for efficency numbers:
143  CalcEfficencyNumbers(pat_interim, InBT->MCEvt(), NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
144  }
145  // end of loop over all plates of local_gAli
147 
148 
149  //-----------------------------------
150  // 4) Calculate pur/eff/NBT numbers,
151  // not needed when only reconstruction
152  // done:
153  //-----------------------------------
154  if (cmd_OUTPUTLEVEL>=2 || cmd_OUTPUTLEVEL==0 ) {
155  Int_t NBT=0;
156  Int_t NBTMC=0;
157  Int_t NBTallMC=0;
158  Int_t NBTeMC=0;
159  Double_t eff, purall, pure;
160  CalcEffPurOfShower2(GLOBAL_ShowerSegArray, NBT, NBTMC, NBTallMC, NBTeMC, purall, pure, NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
161 
162  // Fill only for MC Event:
163  if (GLOBAL_InBT_MC>0) {
168  }
170  }
171 
172 
173 
174  //-----------------------------------
175  // 5) Fill Tree:
176  //-----------------------------------
177  TREE_ShowRecEff->Fill();
178  if (gEDBDEBUGLEVEL>3) TREE_ShowRecEff->Show(TREE_ShowRecEff->GetEntries()-1);
179 
180 
181  //-----------------------------------
182  // 6a) Transfer ShowerArray to treebranchTreeEntry:
183  //-----------------------------------
184  if (cmd_OUTPUTLEVEL>0) {
186  }
187 
188 
189  //------------------------------------
190  // Reset and delete important things:
191  // also to avoid memory problems ...
192  //-----------------------------------
193  GLOBAL_ShowerSegArray->Clear();
194  if (gEDBDEBUGLEVEL>3) cout << "--- ---GLOBAL_ShowerSegArray->GetEntries(): "<< GLOBAL_ShowerSegArray->GetEntries() << endl;
195  delete local_gAli;
196  local_gAli=0;
198  //------------------------------------
199  }
200  // end of loop over GLOBAL_InBTArrayEntries
201  //-----------------------------------------------------------------
202 
203  if (gEDBDEBUGLEVEL==2) cout << endl<<flush;
204  if (gEDBDEBUGLEVEL>3) cout << "---TREE_ShowRecEff->GetEntries() ... " << TREE_ShowRecEff->GetEntries() << endl;
205  if (gEDBDEBUGLEVEL>3) cout << "---GLOBAL_INBTSHOWERNR ... " << GLOBAL_INBTSHOWERNR<< endl;
206 
207 
208  return;
209 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
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
Bool_t GetConeOrTubeDistanceToInBT(EdbSegP *sa, EdbSegP *InBT, Double_t CylinderRadius, Double_t ConeAngle)
Definition: ShowRec.cpp:6990
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
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 X() const
Definition: EdbSegP.h:170
Float_t P() const
Definition: EdbSegP.h:149
Float_t Y() const
Definition: EdbSegP.h:171
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
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
gEDBDEBUGLEVEL
Definition: energy.C:7