StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPicoBEmcPidTraits.cxx
1 //
2 // StPicoBEmcPidTraits holds information about BEMC-matched tracks
3 //
4 
5 // C++ headers
6 #include <limits>
7 
8 // ROOT headers
9 #include "TMath.h"
10 
11 // PicoDst headers
12 #include "StPicoMessMgr.h"
13 #include "StPicoBEmcPidTraits.h"
14 
15 ClassImp(StPicoBEmcPidTraits)
16 
17 //_________________
19  mTrackIndex(-1),
20  mBemcId(-9999), mBemcAdc0(-9999), mBemcE0(-9999), mBemcE(-9999),
21  mBemcZDist(-9999), mBemcPhiDist(-9999),
22  mBemcSmdNEta(std::numeric_limits<unsigned char>::max()), mBemcSmdNPhi(std::numeric_limits<unsigned char>::max()),
23  mBtowId(-9999), mBtowId23(std::numeric_limits<unsigned char>::max()),
24  mBtowE(-9999), mBtowE2(-9999), mBtowE3(-9999),
25  mBtowEtaDist(-9999), mBtowPhiDist(-9999) {
26  /* emtpy */
27 }
28 
29 //_________________
30 StPicoBEmcPidTraits::StPicoBEmcPidTraits(Int_t index, Int_t id, Int_t adc0, const Float_t* e, const Float_t* dist,
31  const Int_t* nhit, const Int_t* ntow) : TObject() {
32 
33  mTrackIndex = (index > std::numeric_limits<short>::max()) ? -1 : (Short_t)index;
34 
35  auto getConstrainedShort = [](float x) {
36  return ( ( TMath::Abs(x) >= std::numeric_limits<short>::max() ) ?
37  std::numeric_limits<short>::max() : (short)(TMath::Nint(x)) );
38  };
39 
40  mBemcId = (id > std::numeric_limits<short>::max()) ? -1 : (Short_t)id;
41  mBemcAdc0 = ( (adc0 > std::numeric_limits<unsigned short>::max()) ?
42  std::numeric_limits<unsigned short>::max() : (UShort_t)adc0 );
43  mBemcE0 = getConstrainedShort(e[0] * 1000.);
44  mBemcE = getConstrainedShort(e[1] * 1000.);
45  mBemcZDist = getConstrainedShort(dist[0] * 100.);
46  mBemcPhiDist = getConstrainedShort(dist[1] * 10000.);
47  mBemcSmdNEta = ( (nhit[0] > std::numeric_limits<unsigned char>::max()) ?
48  std::numeric_limits<unsigned char>::max() : (UChar_t)(nhit[0]) );
49  mBemcSmdNPhi = ( (nhit[1] > std::numeric_limits<unsigned char>::max()) ?
50  std::numeric_limits<unsigned char>::max() : (UChar_t)(nhit[1]) );
51 
52  mBtowId = (ntow[0] <= 0 || ntow[0] > 4800) ? -1 : (Short_t)ntow[0];
53 
54  // Logic: If at least one closest to the mactched tower was
55  // found than we check the second one. The 1st and the 2nd
56  // digits of mBtowId23 represent Ids of the 1st and the 2nd highest
57  // towers that are the closest to the track-matched one, respectively.
58  if ( !(ntow[1] < 0 || ntow[1] >= 9) ) {
59  if ( !(ntow[2] < 0 || ntow[2] >= 9) ) { // If 2 towers were found
60  mBtowId23 = (Char_t)(ntow[1] * 10 + ntow[2]);
61  }
62  else { // If only 1 tower was found
63  mBtowId23 = (Char_t)(ntow[1] * 10 + 9);
64  }
65  }
66  else { // If none of the towers with energy>0.2 GeV were found near the matched tower
67  mBtowId23 = 99;
68  }
69 
70  mBtowE = getConstrainedShort(e[2] * 1000.);
71  mBtowE2 = getConstrainedShort(e[3] * 1000.);
72  mBtowE3 = getConstrainedShort(e[4] * 1000.);
73  mBtowEtaDist = getConstrainedShort(dist[2] * 10000.);
74  mBtowPhiDist = getConstrainedShort(dist[3] * 10000.);
75 }
76 
77 //_________________
79  mTrackIndex = traits.mTrackIndex;
80  mBemcId = traits.mBemcId;
81  mBemcAdc0 = traits.mBemcAdc0;
82  mBemcE0 = traits.mBemcE0;
83  mBemcE = traits.mBemcE;
84  mBemcZDist = traits.mBemcZDist;
85  mBemcPhiDist = traits.mBemcPhiDist;
86  mBemcSmdNEta = traits.mBemcSmdNEta;
87  mBemcSmdNPhi = traits.mBemcSmdNPhi;
88 
89  mBtowId = traits.mBtowId;
90  mBtowId23 = traits.mBtowId23;
91  mBtowE = traits.mBtowE;
92  mBtowE2 = traits.mBtowE2;
93  mBtowE3 = traits.mBtowE3;
94  mBtowEtaDist = traits.mBtowEtaDist;
95  mBtowPhiDist = traits.mBtowPhiDist;
96 }
97 
98 //_________________
100  /* empty */
101 }
102 
103 //_________________
104 void StPicoBEmcPidTraits::Print(const Char_t* option __attribute__((unused)) ) const {
105  LOG_INFO << "Matched track index = " << mTrackIndex << endm;
106  LOG_INFO << " BEMC Id = " << bemcId() << " BTOW Adc0 = " << bemcAdc0()
107  << " bemc E0 = " << bemcE0() << " e = " << bemcE() << endm;
108  LOG_INFO << " BEMC distz = " << bemcZDist() << " distphi = " << bemcPhiDist() << endm;
109  LOG_INFO << " BSMD nEta/nPhi = " << bemcSmdNEta() << "/" << bemcSmdNPhi() << endm;
110  LOG_INFO << " BTOW Id = " << btowId() << " tower Id 2/3 = " << btowId2() << " " << btowId3() << endm;
111  LOG_INFO << " BTOW energy = " << btowE() << " " << btowE2() << " " << btowE3() << endm;
112  LOG_INFO << " BTOW position to center = " << btowEtaDist() << " " << btowPhiDist() << endm;
113 }
114 
115 //_________________
116 void StPicoBEmcPidTraits::setEnergy(Float_t energy[5]) {
117  auto getConstrainedShort = [](float x) {
118  return fabs(x) >= std::numeric_limits<short>::max() ?
119  std::numeric_limits<short>::max() : (short)(TMath::Nint(x));
120  };
121  mBemcE0 = getConstrainedShort(energy[0] * 1000.);
122  mBemcE = getConstrainedShort(energy[1] * 1000.);
123  mBtowE = getConstrainedShort(energy[2] * 1000.);
124  mBtowE2 = getConstrainedShort(energy[3] * 1000.);
125  mBtowE3 = getConstrainedShort(energy[4] * 1000.);
126 }
127 
128 //_________________
129 void StPicoBEmcPidTraits::setDistances(Float_t dist[4]) {
130  auto getConstrainedShort = [](float x) {
131  return fabs(x) >= std::numeric_limits<short>::max() ?
132  std::numeric_limits<short>::max() : (short)(TMath::Nint(x));
133  };
134  mBemcZDist = getConstrainedShort(dist[0] * 100.);
135  mBemcPhiDist = getConstrainedShort(dist[1] * 10000.);
136  mBtowEtaDist = getConstrainedShort(dist[2] * 10000.);
137  mBtowPhiDist = getConstrainedShort(dist[3] * 10000.);
138 }
139 
140 //_________________
141 void StPicoBEmcPidTraits::setNHits(Int_t nhit[2]) {
142  mBemcSmdNEta = ( (nhit[0] > std::numeric_limits<unsigned char>::max()) ?
143  std::numeric_limits<unsigned char>::max() : (UChar_t)(nhit[0]) );
144  mBemcSmdNPhi = ( (nhit[1] > std::numeric_limits<unsigned char>::max()) ?
145  std::numeric_limits<unsigned char>::max() : (UChar_t)(nhit[1]) );
146 }
147 
148 //_________________
149 void StPicoBEmcPidTraits::setNTOW(Int_t ntow[3]) {
150  mBtowId = (ntow[0] <= 0 || ntow[0] > 4800) ? -1 : (Short_t)ntow[0];
151  // Logic: If at least one closest to the mactched tower was
152  // found than we check the second one. The 1st and the 2nd
153  // digits of mBtowId23 represent Ids of the 1st and the 2nd highest
154  // towers that are the closest to the track-matched one, respectively.
155  if ( !( ntow[1] < 0 || ntow[1] >= 9 ) ) {
156  if ( !(ntow[2] < 0 || ntow[2] >= 9) ) { // If 2 towers were found
157  mBtowId23 = (Char_t)(ntow[1] * 10 + ntow[2]);
158  }
159  else { // If only 1 tower was found
160  mBtowId23 = (Char_t)(ntow[1] * 10 + 9);
161  }
162  }
163  else { // If none of the towers with energy>0.2 GeV were found near the matched tower
164  mBtowId23 = 99;
165  }
166 }
Float_t btowE2() const
Energy of second closest tower.
Float_t bemcE() const
Associated bemc cluster energy (STAR standard clustering algorithm)
Float_t bemcE0() const
Associated bemc cluster highest tower energy (STAR standard clustering algorithm) ...
void setEnergy(Float_t energy[5])
Set energy.
Float_t btowE3() const
Energy of third closest tower.
StPicoBEmcPidTraits()
Default constructor.
Float_t btowEtaDist() const
Eta distance to matched tower (cm)
Int_t bemcAdc0() const
Associated bemc cluster highest tower adc (STAR standard clustering algorithm)
Float_t btowE() const
Matched tower energy.
Int_t bemcSmdNPhi() const
Associated bemc cluster number of fired SMD-phi wires (STAR standard clustering algorithm) ...
Int_t btowId2() const
Track second closest tower local id.
Int_t bemcSmdNEta() const
Associated bemc cluster number of fired SMD-eta wires (STAR standard clustering algorithm) ...
Float_t bemcZDist() const
Associated bemc cluster Z-distance (cm) (STAR standard clustering algorithm)
Int_t btowId() const
Track matched tower id (using StEmcPosition::projTrack())
Keep information about Barrel ElectroMagnetic Calorimeter (BEMC) matched tracks.
Float_t bemcPhiDist() const
Associated bemc cluster phi-distance (cm) (STAR standard clustering algorithm)
Int_t btowId3() const
Track third closest tower local id.
Float_t btowPhiDist() const
Phi distance to matched tower (cm)
void setNHits(Int_t nhit[2])
Set number of hits.
Int_t bemcId() const
Associated BEMC cluster id (STAR standard clustering algorithm)
void setDistances(Float_t dist[4])
Set distances.
virtual void Print(const Char_t *option="") const
Print BEMC PID traits information.
void setNTOW(Int_t ntow[3])
Set IDs of the towers.
virtual ~StPicoBEmcPidTraits()
Destructor.