AMSDST
myTrdK.cxx
Go to the documentation of this file.
1 // Authors: M.Duranti - INFN di Perugia
2 #include "myTrdK.h"
3 #include "debug.h"
4 #include "TClass.h"
5 
6 using namespace std;
7 
8 //--------------------------------------------------------------------
9 
11 #ifdef _WITHGBATCH_
12 //ClassImp(template<class SeedType> myTrdKFiller)
13 #endif
14 
15 //--------------------------------------------------------------------
16 
18 #ifdef PDEBUG
19  printf("In myTrdK::myTrdK\n");
20 #endif
21  PRINTDEBUG;
22  init();
23  PRINTDEBUG;
24 }
25 
27 #ifdef PDEBUG
28  printf("In myTrdK::~myTrdK\n");
29 #endif
30  PRINTDEBUG;
31  Clear();
32 }
33 
34 void myTrdK::Clear(Option_t* option){
35 #ifdef PDEBUG
36  printf("In myTrdK::Clear\n");
37 #endif
38  PRINTDEBUG;
39  IsReadAlignmentOK = -10;
40  IsReadCalibOK = -10;
41  LHRValid = false;
42  LHRValidCorr = false;
43  fill_n(LHR, 3, (int)(-10));
44  fill_n(LHRCorr, 3, (int)(-10));
45  fill_n(LH, 3, (int)(-10));
46  fill_n(LHCorr, 3, (int)(-10));
47  NHitsUsedInLH = -10;
48  NHitsUsedInLHCorr = -10;
49  OffTrackNHits = -10;
50  OffTrackAmps = -10;
51  LHRrefitValid = LHRrefitCorrValid = false;
52  NHitsUsedInLHrefit = NHitsUsedInLHrefitCorr = -1;
53  fill_n(LHRrefit, 3, -2);
54  fill_n(LHrefit, 3, -2);
55  fill_n(LHRrefitCorr, 3, -2);
56  fill_n(LHrefitCorr, 3, -2);
57  PRINTDEBUG;
58  TRDCharge = -10;
59  TRDChargeError = -10;
60  QTRDHitCollectionNucleiSize = -10;
61  PRINTDEBUG;
62  return;
63 }
64 
65 void myTrdK::init(){
66 #ifdef PDEBUG
67  printf("In myTrdK::init\n");
68 #endif
69  PRINTDEBUG;
70  Clear();
71  PRINTDEBUG;
72  return;
73 }
74 
75 //-----------------------------------------------------------------------------
76 
77 #ifdef _WITHGBATCH_
78 
79 template<class SeedType>
80 myTrdKFiller<SeedType>::myTrdKFiller(){
81 #ifdef PDEBUG
82  printf("In template<class SeedType> myTrdKFiller::myTrdKFromTrTrackFiller\n");
83 #endif
84  PRINTDEBUG;
85  init();
86  PRINTDEBUG;
87 }
88 
89 template<class SeedType>
90 myTrdKFiller<SeedType>::~myTrdKFiller(){
91 #ifdef PDEBUG
92  printf("In template<class SeedType> myTrdKFiller::~myTrdKFromTrTrackFiller\n");
93 #endif
94  PRINTDEBUG;
95  Clear();
96 }
97 
98 template<class SeedType>
99 void myTrdKFiller<SeedType>::Clear(Option_t* option){
100 #ifdef PDEBUG
101  printf("In template<class SeedType> myTrdKFiller::Clear\n");
102 #endif
103  PRINTDEBUG;
104  return;
105 }
106 
107 template<class SeedType>
108 void myTrdKFiller<SeedType>::init(){
109 #ifdef PDEBUG
110  printf("In template<class SeedType> myTrdKFiller::init\n");
111 #endif
112  PRINTDEBUG;
113  Clear();
114  PRINTDEBUG;
115  return;
116 }
117 
118 template<class SeedType>
119 void myTrdKFiller<SeedType>::Fill(short int i_track, SeedType* track, float Energy, float kDef){
120 #ifdef PDEBUG
121  printf("In template<class SeedType> myTrdKFiller::Fill\n");
122 #endif
123  PRINTDEBUG;
124 
125  AMSEventR* pev = AMSEventR::Head();
126 
127  int NTrdRawHits = pev->nTrdRawHit();
128 
129 #if !defined _B524_ && !defined _B550_ && !defined _B572_
130 
131  if (kDef>=0 && track && NTrdRawHits>0) {
132 
133  TrdKCluster trdkclu(pev, track, kDef);
134 
135  IsReadAlignmentOK= trdkclu.IsReadAlignmentOK; // 0: Alignment not performed, 1: Static Alignment of Layer level, 2: Dynamic Alignment for entire TRD
136  IsReadCalibOK= trdkclu.IsReadCalibOK; // 0: Gain Calibration not performed, 1: Gain Calibration Succeeded
137 
138  if (IsReadAlignmentOK && IsReadCalibOK) {
139  LHRValid = trdkclu.GetLikelihoodRatio_TrTrack(trdkADCth, LHR, NHitsUsedInLH, 0, LH);
140  LHRValidCorr = trdkclu.GetLikelihoodRatio_TrTrack(trdkADCth, LHRCorr, NHitsUsedInLHCorr, Energy, LHCorr);
141  //Get Number of surrounding fired tubes, excluding the ones crossed by the current TrTrack prediction
142  trdkclu.GetOffTrackHit_TrTrack(OffTrackNHits, OffTrackAmps);
143  // printf("Likelihood = {%f, %f %f}\n", LHR[0], LHR[1], LHR[2]);//only for debug
144  LHRrefitValid = trdkclu.GetLikelihoodRatio_TRDRefit(trdkADCth, LHRrefit, NHitsUsedInLHrefit, 0, LHrefit);
145  LHRrefitCorrValid = trdkclu.GetLikelihoodRatio_TRDRefit(trdkADCth, LHRrefitCorr, NHitsUsedInLHrefitCorr, Energy, LHrefitCorr);
146 
147 #if !defined _B524_ && !defined _B530_ && !defined _B538_ && !defined _B550_ && !defined _B572_ && !defined _B580_ && !defined _B584_ && !defined _B594_ && !defined _B598_ && !defined _B610_ && !defined _B620_
148  //Calculate TRD charge, this automatically call a new Trd Refit according to "charge nuclei" hypothesis
149  trdkclu.CalculateTRDCharge();
150  //Get value of TRD charge, suggest discarding events with QTRD=0
151  TRDCharge = trdkclu.GetTRDCharge();
152  //Get one sigma error of TRD charge
153  TRDChargeError = trdkclu.GetTRDChargeError();
154  //Number of hits used in likelihood calculation, suggest discarding events with NHits<15
155  QTRDHitCollectionNucleiSize = trdkclu.GetQTRDHitCollectionNuclei().size();
156  }
157 #endif //after B630
158 
159  PRINTDEBUG;
160 
161  }
162 
163 #endif //#if !defined _B524_ && !defined _B550_ && !defined _B572_ //both for TRDK and TRDQT
164 
165  PRINTDEBUG;
166 
167  return;
168 }
169 
170 /* explicit instantiation */
171 template class myTrdKFiller<TrTrackR>;
172 template class myTrdKFiller<TrdTrackR>;
173 
174 #endif