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

Functions

void ReconstructShowers_CT ()
 

Function Documentation

◆ ReconstructShowers_CT()

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