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

Functions

void ReconstructShowers_CA ()
 

Function Documentation

◆ ReconstructShowers_CA()

void ReconstructShowers_CA ( )
3 {
4  Log(2, "ShowRec.cpp", "--- void ReconstructShowers_CA() ---");
5 
6  //-----------------------------------------------------------------
7  // Main function for reconstruction of "ConeAdvanced" 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  cout << "GLOBAL_InBTArrayEntries = " << GLOBAL_InBTArrayEntries << endl;
29 
30 
31  //-----------------------------------------------------------------
32  // Since GLOBAL_InBTArray is filled in ascending ordering by zpositon
33  // We use the descending loop to begin with BT with lowest z first.
34  for (Int_t i=GLOBAL_InBTArrayEntries-1; i>=0; --i) {
35 
36  //-----------------------------------
37  // CounterOutPut
38  if (gEDBDEBUGLEVEL==2) if ((i%1)==0) cout << GLOBAL_InBTArrayEntries <<" InBT in total, still to do:"<<Form("%4d",i)<< "\r\r\r\r"<<flush;
39  if (gEDBDEBUGLEVEL==1) {
40  int modulo=GLOBAL_InBTArrayEntries/20;
41  if ((i%modulo)==0) cout << i <<" : 5% more done"<<endl;
42  }
43  //-----------------------------------
44 
45  //-----------------------------------
46  // Get InitiatorBT from GLOBAL_InBTArray
47  InBT=(EdbSegP*)GLOBAL_InBTArray->At(i);
48  //--------
49  GLOBAL_InBT_E=InBT->P();
50  GLOBAL_InBT_TanTheta=TMath::Sqrt(InBT->TX()*InBT->TX()+InBT->TY()*InBT->TY());
51  GLOBAL_InBT_Flag=InBT->Flag();
52  GLOBAL_InBT_MC=InBT->MCEvt();
53  //--------
54  Int_t local_NBT=0;
55  Int_t local_NBTMC=0;
56  Int_t local_NBTallMC=0;
57  Int_t local_NBTeMC=0;
58  float_t local_pure=-1;
59  float_t local_purall=-1;
60  Int_t npat_int=0;
61  Int_t npat_total=0;
62  Int_t npatN=0;
63  Int_t npat_Neff=0;
64  Int_t NBT_Neff=0;
65  Int_t NBTMC_Neff=0;
66  Int_t NBTMCe_Neff=0;
67  //--------
68 
69  if (gEDBDEBUGLEVEL>2) {
70  cout << endl << endl << "--- Starting Shower for Number " << i << " now: "<<endl;
71  InBT->PrintNice();
72  }
73  //-----------------------------------
74 
75  //-----------------------------------
76  // 1) Make local_gAli with cut parameters:
77  //-----------------------------------
78  local_gAli = TransformEdbPVRec(GLOBAL_gAli, InBT);
79  // Add InBT to GLOBAL_ShowerSegArray
80  GLOBAL_ShowerSegArray -> Add(InBT);
81  //-----------------------------------
82 
83 
84  //-----------------------------------
85  // 2) Loop over (whole) local_gAli, check BT for Cuts
86  //-----------------------------------
87  Int_t local_gAli_npat=local_gAli->Npatterns();
88  if (gEDBDEBUGLEVEL>2) cout << "--- local_gAli_npat= " << local_gAli_npat << endl;
89 
90  // Loop over all plates of local_gAli, since this is already
91  // extracted with the right numbers of plates...
92  for (Int_t patterloop_cnt=local_gAli_npat-1; patterloop_cnt>=0; --patterloop_cnt) {
93  if (gEDBDEBUGLEVEL>3) cout << "--- --- Doing patterloop_cnt= " << patterloop_cnt << endl;
94 
95  for (Int_t btloop_cnt=0; btloop_cnt<local_gAli->GetPattern(patterloop_cnt)->GetN(); ++btloop_cnt) {
96  seg = (EdbSegP*)local_gAli->GetPattern(patterloop_cnt)->GetSegment(btloop_cnt);
97  if (gEDBDEBUGLEVEL>3) seg->PrintNice();
98 
99  // Now apply cut conditions: CA ConeAdvanced Alg --------------------
100  if (!GetConeOrTubeDistanceToInBT(seg, InBT, CUT_PARAMETER[0], CUT_PARAMETER[1])) continue;
101  if (!FindPrecedingBTs(seg, InBT, local_gAli, GLOBAL_ShowerSegArray)) continue;
102  // end of cut conditions: CA ConeAdvanced Alg --------------------
103 
104  // If we arrive here, Basetrack seg has passed criteria
105  // and is then added to the shower array:
106  // Check if its not the InBT which is already added:
107  if (seg->X()==InBT->X()&&seg->Y()==InBT->Y()) {
108  ; // do nothing;
109  }
110  else {
111  GLOBAL_ShowerSegArray -> Add(seg);
112  }
113  }
114  // Calc BT density around shower:
115  EdbPattern* pat_interim=local_gAli->GetPattern(patterloop_cnt);
116  CalcTrackDensity(pat_interim,local_gAli_pat_interim_halfsize,npat_int,npat_total,npatN);
117 
118  // Calc TrackNumbers for plate for efficency numbers:
119  CalcEfficencyNumbers(pat_interim, InBT->MCEvt(), NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
120  }
121  // end of loop over all plates of local_gAli
123 
124 
125  //-----------------------------------
126  // 4) Calculate pur/eff/NBT numbers,
127  // not needed when only reconstruction
128  // done:
129  //-----------------------------------
130  if (cmd_OUTPUTLEVEL>=2 || cmd_OUTPUTLEVEL==0 ) {
131  Int_t NBT=0;
132  Int_t NBTMC=0;
133  Int_t NBTallMC=0;
134  Int_t NBTeMC=0;
135  Double_t eff, purall, pure;
136  CalcEffPurOfShower2(GLOBAL_ShowerSegArray, NBT, NBTMC, NBTallMC, NBTeMC, purall, pure, NBT_Neff, NBTMC_Neff,NBTMCe_Neff);
137 
138  // Fill only for MC Event:
139  if (GLOBAL_InBT_MC>0) {
144  }
146  }
147 
148 
149  //-----------------------------------
150  // 5) Fill Tree:
151  //-----------------------------------
152  TREE_ShowRecEff->Fill();
153  if (gEDBDEBUGLEVEL>3) TREE_ShowRecEff->Show(TREE_ShowRecEff->GetEntries()-1);
154 
155 
156  //-----------------------------------
157  // 6a) Transfer ShowerArray to treebranchTreeEntry:
158  //-----------------------------------
159  if (cmd_OUTPUTLEVEL>0) {
161  }
162 
163 
164  //------------------------------------
165  // Reset and delete important things:
166  // also to avoid memory problems ...
167  //-----------------------------------
168  GLOBAL_ShowerSegArray->Clear();
169  if (gEDBDEBUGLEVEL>3) cout << "--- ---GLOBAL_ShowerSegArray->GetEntries(): "<< GLOBAL_ShowerSegArray->GetEntries() << endl;
170  delete local_gAli;
171  local_gAli=0;
173  //------------------------------------
174  }
175  // end of loop over GLOBAL_InBTArrayEntries
176  //-----------------------------------------------------------------
177 
178  if (gEDBDEBUGLEVEL==2) cout << endl<<flush;
179  if (gEDBDEBUGLEVEL>3) cout << "---TREE_ShowRecEff->GetEntries() ... " << TREE_ShowRecEff->GetEntries() << endl;
180  if (gEDBDEBUGLEVEL>3) cout << "---GLOBAL_INBTSHOWERNR ... " << GLOBAL_INBTSHOWERNR<< endl;
181 
182 
183  return;
184 }
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
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
Bool_t FindPrecedingBTs(EdbSegP *s, EdbSegP *InBT, EdbPVRec *gAli, TObjArray *showersegarray)
Definition: ShowRec.cpp:6764
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