CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DTTMax Class Reference

#include <DTTMax.h>

Classes

struct  InfoLayer
 
struct  TMax
 Information on each of the four TMax values in a SL. More...
 

Public Types

typedef dttmaxenums::SegDir SegDir
 
typedef dttmaxenums::SigmaFactor SigmaFactor
 
typedef dttmaxenums::TMaxCells TMaxCells
 

Public Member Functions

 DTTMax (const std::vector< DTRecHit1D > &hits, const DTSuperLayer &isl, GlobalVector dir, GlobalPoint pos, const DTTTrigBaseSync &sync)
 Constructor. More...
 
InfoLayer *& getInfoLayer (int layer)
 
std::vector< const TMax * > getTMax (const DTWireId &idWire)
 
std::vector< const TMax * > getTMax (const DTSuperLayerId &isl)
 
const TMaxgetTMax (TMaxCells cCase)
 
virtual ~DTTMax ()
 Destructor. More...
 

Private Member Functions

 DTTMax ()
 

Private Attributes

bool debug
 
std::vector< InfoLayer * > theInfoLayers
 
SegDir theSegDir
 
std::string theSegType
 
std::vector< TMax * > theTMaxes
 

Detailed Description

Class to calculate the different TMax values according to the track path

Author
Marina Giunta

Definition at line 31 of file DTTMax.h.

Member Typedef Documentation

Definition at line 34 of file DTTMax.h.

Definition at line 35 of file DTTMax.h.

Definition at line 33 of file DTTMax.h.

Constructor & Destructor Documentation

DTTMax::DTTMax ( const std::vector< DTRecHit1D > &  hits,
const DTSuperLayer isl,
GlobalVector  dir,
GlobalPoint  pos,
const DTTTrigBaseSync sync 
)

Constructor.

Definition at line 42 of file DTTMax.cc.

References dttmaxenums::c123, dttmaxenums::c124, dttmaxenums::c134, dttmaxenums::c234, gather_cfg::cout, debug, dumpMFGeometry_cfg::delta, getInfoLayer(), hT123Bad, hT123LLR, hT123LRL, hT123LRR, hT124Bad, hT124LLLL, hT124LLLR, hT124LLR, hT124LRLL, hT124LRLR, hT124LRR1gt4, hT124LRR1lt4, hT134Bad, hT134LLLL, hT134LLLR, hT134LLR1gt4, hT134LLR1lt4, hT134LRLL, hT134LRLR, hT134LRR, hT234Bad, hT234LLR, hT234LRL, hT234LRR, DTTMax::InfoLayer::idWire, dttmaxenums::L, DTLayerId::layer(), dttmaxenums::noR, dttmaxenums::notInit, dttmaxenums::R, dttmaxenums::r32, dttmaxenums::r72, dttmaxenums::r78, OrderedSet::t, RandomServiceHelper::t1, RandomServiceHelper::t2, RandomServiceHelper::t3, theInfoLayers, theSegDir, theSegType, theTMaxes, DTTMax::InfoLayer::time, GeomDet::toLocal(), DTTMax::InfoLayer::wireX, PV3DBase< T, PVType, FrameType >::x(), testProducerWithPsetDescEmpty_cfi::x1, and testProducerWithPsetDescEmpty_cfi::x2.

47  : theInfoLayers(4, (InfoLayer*)nullptr), //FIXME
48  theTMaxes(4, (TMax*)nullptr) {
49  // debug parameter for verbose output
50  debug = "true";
51 
52  // Collect all information using InfoLayer
53  for (vector<DTRecHit1D>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
54  // cout << "Hit Pos " << (*hit).localPosition() << endl;
55 
56  InfoLayer* layInfo = new InfoLayer((*hit), isl, dir, pos, sync);
57  int ilay = layInfo->idWire.layer();
58  if (getInfoLayer(ilay) == nullptr) {
59  getInfoLayer(ilay) = layInfo;
60  } else {
61  // FIXME: in case there is > 1 hit/layer, the first is taken and the others are IGNORED.
62  delete layInfo;
63  }
64  }
65 
66  // Get the segment direction
67  theSegDir = ((isl.toLocal(dir).x() < 0) ? L : R);
68 
69  int layersIn = 0;
70  int nGoodHits = 0;
71  for (vector<InfoLayer*>::const_iterator ilay = theInfoLayers.begin(); ilay != theInfoLayers.end(); ++ilay) {
72  if ((*ilay) == nullptr) {
73  theSegType += "X";
74  continue;
75  }
76  DTEnums::DTCellSide lOrR = (*ilay)->lr;
77  if (lOrR == Left)
78  theSegType += "L";
79  else if (lOrR == Right)
80  theSegType += "R";
81  else
82  theSegType += "X";
83 
84  // layersIn : 6 = layers 1,2,3
85  // 7 = 1,2,4
86  // 8 = 1,3,4
87  // 9 = 2,3,4
88  // 10= 1,2,3,4
89  layersIn += (*ilay)->idWire.layer();
90  nGoodHits++;
91  }
92 
93  if (nGoodHits >= 3 && (theSegType != "RRRR" && theSegType != "LLLL")) {
94  float t1 = 0.;
95  float t2 = 0.;
96  float t3 = 0.;
97  float t4 = 0.;
98  float x1 = 0.;
99  float x2 = 0.;
100  float x3 = 0.;
101  float x4 = 0.;
102 
103  if (layersIn <= 8 || layersIn == 10) {
104  t1 = getInfoLayer(1)->time;
105  x1 = getInfoLayer(1)->wireX;
106  }
107  if (layersIn <= 7 || layersIn >= 9) {
108  t2 = getInfoLayer(2)->time;
109  x2 = getInfoLayer(2)->wireX;
110  }
111  if (layersIn == 6 || layersIn >= 8) {
112  t3 = getInfoLayer(3)->time;
113  x3 = getInfoLayer(3)->wireX;
114  }
115  if (layersIn >= 7) {
116  t4 = getInfoLayer(4)->time;
117  x4 = getInfoLayer(4)->wireX;
118  }
119 
120  float t = 0.;
121  TMaxCells cGroup = notInit;
122  string type;
123  SigmaFactor sigma = noR; // Return the factor relating the width of the TMax distribution and the cell resolution
124  float halfCell = 2.1; // 2.1 is the half cell length in cm
125  float delta = 0.5; // (diff. wire pos.) < delta, halfCell+delta, .....
126  unsigned t0Factor = 99; // "quantity" of Delta(t0) included in the tmax formula
127 
128  //Debug
129  if (debug) {
130  cout << "seg. type: " << theSegType << " and dir: " << theSegDir << endl;
131  cout << "t1, t2, t3, t4: " << t1 << " " << t2 << " " << t3 << " " << t4 << endl;
132  cout << "x1, x2, x3, x4: " << x1 << " " << x2 << " " << x3 << " " << x4 << endl;
133  }
134 
135  //different t0 hists (if you have at least one hit within a certain distance from the wire)
136  unsigned hSubGroup = 99; //
137  if (t1 == 0. || t2 == 0. || t3 == 0. || t4 == 0.)
138  hSubGroup = 0; //if only 3 hits
139  else if (t1 <= 5. || t2 <= 5. || t3 <= 5. || t4 <= 5.)
140  hSubGroup = 1; //if distance of one hit from wire < 275um (v_drift=55um/ns)
141  else if (t1 <= 10. || t2 <= 10. || t3 <= 10. || t4 <= 10.)
142  hSubGroup = 2;
143  else if (t1 <= 20. || t2 <= 20. || t3 <= 20. || t4 <= 20.)
144  hSubGroup = 3;
145  else if (t1 <= 50. || t2 <= 50. || t3 <= 50. || t4 <= 50.)
146  hSubGroup = 4;
147 
148  if ((layersIn == 6 || layersIn == 10) && (fabs(x1 - x3) < delta)) {
149  cGroup = c123;
150  ((type += theSegType[0]) += theSegType[1]) += theSegType[2];
151  sigma = r32;
152  if (type == "LRL" || type == "RLR") {
153  t0Factor = 2;
154  t = (t1 + t3) / 2. + t2;
155  hT123LRL->Fill(t);
156  } else if ((type == "LLR" && theSegDir == R) || (type == "RRL" && theSegDir == L)) {
157  t0Factor = 1;
158  t = (t3 - t1) / 2. + t2;
159  hT123LLR->Fill(t);
160  } else if ((type == "LRR" && theSegDir == R) || (type == "RLL" && theSegDir == L)) {
161  t0Factor = 1;
162  t = (t1 - t3) / 2. + t2;
163  hT123LRR->Fill(t);
164  } else {
165  t = -1.;
166  sigma = noR;
167  hT123Bad->Fill(t);
168  }
169  theTMaxes[cGroup] = new TMax(t, cGroup, type, sigma, t0Factor, hSubGroup);
170  if (debug)
171  cout << "tmax123 " << t << " " << type << endl;
172  }
173  if (layersIn == 7 || layersIn == 10) {
174  cGroup = c124;
175  type.clear();
176  sigma = r72;
177  ((type += theSegType[0]) += theSegType[1]) += theSegType[3];
178  if ((theSegType == "LRLR" && type == "LRR" && x1 > x4) || (theSegType == "RLRL" && type == "RLL" && x1 < x4)) {
179  t0Factor = 2;
180  t = 1.5 * t2 + t1 - t4 / 2.;
181  hT124LRR1gt4->Fill(t);
182  } else if ((type == "LLR" && theSegDir == R && (fabs(x2 - x4) < delta) && x1 < x2) ||
183  (type == "RRL" && theSegDir == L && (fabs(x2 - x4) < delta) && x1 > x2)) {
184  t0Factor = 1;
185  t = 1.5 * t2 - t1 + t4 / 2.;
186  hT124LLR->Fill(t);
187  } else if ((type == "LLL" && theSegDir == R && (fabs(x2 - x4) < delta) && x1 < x2) ||
188  (type == "RRR" && theSegDir == L && (fabs(x2 - x4) < delta) && x1 > x2)) {
189  t0Factor = 0;
190  t = 1.5 * t2 - t1 - t4 / 2.;
191  hT124LLLR->Fill(t);
192  } else if ((type == "LLL" && theSegDir == L && (fabs(x2 - x4) < delta)) ||
193  (type == "RRR" && theSegDir == R && (fabs(x2 - x4) < delta))) {
194  t0Factor = 0;
195  t = -1.5 * t2 + t1 + t4 / 2.;
196  hT124LLLL->Fill(t);
197  } else if ((type == "LRL" && theSegDir == L && (fabs(x2 - x4) < delta)) ||
198  (type == "RLR" && theSegDir == R && (fabs(x2 - x4) < delta))) {
199  t0Factor = 3;
200  t = 1.5 * t2 + t1 + t4 / 2.;
201  hT124LRLL->Fill(t);
202  } else if ((type == "LRL" && theSegDir == R && (fabs(x1 - x4) < (halfCell + delta))) ||
203  (type == "RLR" && theSegDir == L && (fabs(x1 - x4) < (halfCell + delta)))) {
204  t0Factor = 99; // it's actually 1.5, but this value it's not used
205  t = 3. / 4. * t2 + t1 / 2. + t4 / 4.;
206  sigma = r78;
207  hT124LRLR->Fill(t);
208  } else if ((type == "LRR" && theSegDir == R && x1 < x4 && (fabs(x1 - x4) < (halfCell + delta))) ||
209  (type == "RLL" && theSegDir == L && x1 > x4 && (fabs(x1 - x4) < (halfCell + delta)))) {
210  t0Factor = 1;
211  t = 3. / 4. * t2 + t1 / 2. - t4 / 4.;
212  sigma = r78;
213  hT124LRR1lt4->Fill(t);
214  } else {
215  t = -1.;
216  sigma = noR;
217  hT124Bad->Fill(t);
218  }
219  theTMaxes[cGroup] = new TMax(t, cGroup, type, sigma, t0Factor, hSubGroup);
220  if (debug)
221  cout << "tmax124 " << t << " " << t0Factor << " " << type << endl;
222  }
223  if (layersIn == 8 || layersIn == 10) {
224  cGroup = c134;
225  type.clear();
226  ((type += theSegType[0]) += theSegType[2]) += theSegType[3];
227  sigma = r72;
228  if ((type == "LLR" && x1 > x4 && theSegType == "LRLR") || (type == "RRL" && x1 < x4 && theSegType == "RLRL")) {
229  t0Factor = 2;
230  t = 1.5 * t3 + t4 - t1 / 2.;
231  hT134LLR1gt4->Fill(t);
232  } else if ((type == "LLR" && x1 < x4 && (fabs(x1 - x4) < (halfCell + delta))) ||
233  (type == "RRL" && x1 > x4 && (fabs(x1 - x4) < (halfCell + delta)))) {
234  t0Factor = 1;
235  t = 3. / 4. * t3 + t4 / 2. - t1 / 4.;
236  sigma = r78;
237  hT134LLR1lt4->Fill(t);
238  } else if ((type == "LRR" && theSegDir == R && x1 < x4 && (fabs(x1 - x3) < delta)) ||
239  (type == "RLL" && theSegDir == L && x1 > x4 && (fabs(x1 - x3) < delta))) {
240  t0Factor = 1;
241  t = 1.5 * t3 - t4 + t1 / 2.;
242  hT134LRR->Fill(t);
243  } else if ((type == "LRL" && theSegDir == R && (fabs(x1 - x3) < delta)) ||
244  (type == "RLR" && theSegDir == L && (fabs(x1 - x3) < delta))) {
245  t0Factor = 3;
246  t = 1.5 * t3 + t4 + t1 / 2.;
247  hT134LRLR->Fill(t);
248  } else if ((type == "LRL" && theSegDir == L && (fabs(x1 - x3) < (2. * halfCell + delta))) ||
249  (type == "RLR" && theSegDir == R && (fabs(x1 - x3) < (2. * halfCell + delta)))) {
250  t0Factor = 99; // it's actually 1.5, but this value it's not used
251  t = 3. / 4. * t3 + t4 / 2. + t1 / 4.;
252  sigma = r78;
253  hT134LRLL->Fill(t);
254  } else if ((type == "LLL" && theSegDir == L && x1 > x4 && (fabs(x1 - x3) < delta)) ||
255  (type == "RRR" && theSegDir == R && x1 < x4 && (fabs(x1 - x3) < delta))) {
256  t0Factor = 0;
257  t = 1.5 * t3 - t4 - t1 / 2.;
258  hT134LLLL->Fill(t);
259  } else if ((type == "LLL" && theSegDir == R && (fabs(x1 - x3) < delta)) ||
260  (type == "RRR" && theSegDir == L && (fabs(x1 - x3) < delta))) {
261  t0Factor = 0;
262  t = -1.5 * t3 + t4 + t1 / 2.;
263  hT134LLLR->Fill(t);
264  } else {
265  t = -1;
266  sigma = noR;
267  hT134Bad->Fill(t);
268  }
269  theTMaxes[cGroup] = new TMax(t, cGroup, type, sigma, t0Factor, hSubGroup);
270  if (debug)
271  cout << "tmax134 " << t << " " << t0Factor << " " << type << endl;
272  }
273  if ((layersIn == 9 || layersIn == 10) && (fabs(x2 - x4) < delta)) {
274  cGroup = c234;
275  type.clear();
276  ((type += theSegType[1]) += theSegType[2]) += theSegType[3];
277  sigma = r32;
278  if ((type == "LRL") || (type == "RLR")) {
279  t0Factor = 2;
280  t = (t2 + t4) / 2. + t3;
281  hT234LRL->Fill(t);
282  } else if ((type == "LRR" && theSegDir == R) || (type == "RLL" && theSegDir == L)) {
283  t0Factor = 1;
284  t = (t2 - t4) / 2. + t3;
285  hT234LRR->Fill(t);
286  } else if ((type == "LLR" && theSegDir == R) || (type == "RRL" && theSegDir == L)) {
287  t0Factor = 1;
288  t = (t4 - t2) / 2. + t3;
289  hT234LLR->Fill(t);
290  } else {
291  t = -1;
292  sigma = noR;
293  hT234Bad->Fill(t);
294  }
295  theTMaxes[cGroup] = new TMax(t, cGroup, type, sigma, t0Factor, hSubGroup);
296  if (debug)
297  cout << "tmax234 " << t << " " << type << endl;
298  }
299  }
300 }
SegDir theSegDir
Definition: DTTMax.h:92
TH1F * hT124LLR
Definition: Histogram.h:15
type
Definition: HCALResponse.h:21
TH1F * hT123Bad
Definition: Histogram.h:8
TH1F * hT123LRL
Definition: Histogram.h:9
TH1F * hT134LRLL
Definition: Histogram.h:25
TH1F * hT124LRLR
Definition: Histogram.h:19
TH1F * hT124LLLR
Definition: Histogram.h:16
TH1F * hT134LLR1lt4
Definition: Histogram.h:22
DTCellSide
Which side of the DT cell.
Definition: DTEnums.h:15
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
TH1F * hT124LLLL
Definition: Histogram.h:17
TH1F * hT134LLLR
Definition: Histogram.h:27
TH1F * hT134LRLR
Definition: Histogram.h:24
TH1F * hT124LRR1lt4
Definition: Histogram.h:14
bool debug
Definition: DTTMax.h:85
TH1F * hT124LRR1gt4
Definition: Histogram.h:13
TH1F * hT123LRR
Definition: Histogram.h:11
TH1F * hT124LRLL
Definition: Histogram.h:18
TH1F * hT234Bad
Definition: Histogram.h:28
TH1F * hT134LRR
Definition: Histogram.h:23
TH1F * hT234LRR
Definition: Histogram.h:31
InfoLayer *& getInfoLayer(int layer)
Definition: DTTMax.h:82
TH1F * hT234LRL
Definition: Histogram.h:29
TH1F * hT234LLR
Definition: Histogram.h:30
TH1F * hT134LLLL
Definition: Histogram.h:26
std::vector< TMax * > theTMaxes
Definition: DTTMax.h:91
TH1F * hT124Bad
Definition: Histogram.h:12
TH1F * hT134LLR1gt4
Definition: Histogram.h:21
TH1F * hT134Bad
Definition: Histogram.h:20
TH1F * hT123LLR
Definition: Histogram.h:10
T x() const
Definition: PV3DBase.h:59
std::vector< InfoLayer * > theInfoLayers
Definition: DTTMax.h:90
std::string theSegType
Definition: DTTMax.h:93
DTTMax::~DTTMax ( )
virtual

Destructor.

Definition at line 341 of file DTTMax.cc.

References theInfoLayers, and theTMaxes.

341  {
342  for (vector<InfoLayer*>::const_iterator ilay = theInfoLayers.begin(); ilay != theInfoLayers.end(); ++ilay) {
343  delete (*ilay);
344  }
345 
346  for (vector<TMax*>::const_iterator iTmax = theTMaxes.begin(); iTmax != theTMaxes.end(); ++iTmax) {
347  delete (*iTmax);
348  }
349 }
std::vector< TMax * > theTMaxes
Definition: DTTMax.h:91
std::vector< InfoLayer * > theInfoLayers
Definition: DTTMax.h:90
DTTMax::DTTMax ( )
inlineprivate

Definition at line 85 of file DTTMax.h.

References debug.

85 {}; // Hide default constructor

Member Function Documentation

InfoLayer*& DTTMax::getInfoLayer ( int  layer)
inline

Definition at line 82 of file DTTMax.h.

Referenced by DTTMax().

82 { return theInfoLayers[layer - 1]; }
std::vector< InfoLayer * > theInfoLayers
Definition: DTTMax.h:90
vector< const DTTMax::TMax * > DTTMax::getTMax ( const DTWireId idWire)

Definition at line 302 of file DTTMax.cc.

References dttmaxenums::c123, dttmaxenums::c124, dttmaxenums::c134, dttmaxenums::c234, DTLayerId::layer(), and findQualityFiles::v.

Referenced by DTVDriftCalibration::analyze(), and getTMax().

302  {
303  vector<const TMax*> v;
304  if (idWire.layer() == 1) {
305  v.push_back(getTMax(c123)); //FIXME: needs pointer
306  v.push_back(getTMax(c124));
307  v.push_back(getTMax(c134));
308  } else if (idWire.layer() == 2) {
309  v.push_back(getTMax(c123));
310  v.push_back(getTMax(c124));
311  v.push_back(getTMax(c234));
312  } else if (idWire.layer() == 3) {
313  v.push_back(getTMax(c123));
314  v.push_back(getTMax(c134));
315  v.push_back(getTMax(c234));
316  } else {
317  v.push_back(getTMax(c124));
318  v.push_back(getTMax(c134));
319  v.push_back(getTMax(c234));
320  }
321  return v;
322 }
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
std::vector< const TMax * > getTMax(const DTWireId &idWire)
Definition: DTTMax.cc:302
vector< const DTTMax::TMax * > DTTMax::getTMax ( const DTSuperLayerId isl)

Definition at line 324 of file DTTMax.cc.

References dttmaxenums::c123, dttmaxenums::c124, dttmaxenums::c134, dttmaxenums::c234, getTMax(), and findQualityFiles::v.

324  {
325  vector<const TMax*> v;
326  // add TMax* to the vector only if it really exists
327  if (getTMax(c123))
328  v.push_back(getTMax(c123));
329  if (getTMax(c124))
330  v.push_back(getTMax(c124));
331  if (getTMax(c134))
332  v.push_back(getTMax(c134));
333  if (getTMax(c234))
334  v.push_back(getTMax(c234));
335  return v;
336 }
std::vector< const TMax * > getTMax(const DTWireId &idWire)
Definition: DTTMax.cc:302
const DTTMax::TMax * DTTMax::getTMax ( TMaxCells  cCase)

Definition at line 338 of file DTTMax.cc.

References theTMaxes.

338 { return theTMaxes[cCase]; }
std::vector< TMax * > theTMaxes
Definition: DTTMax.h:91

Member Data Documentation

bool DTTMax::debug
private
std::vector<InfoLayer*> DTTMax::theInfoLayers
private

Definition at line 90 of file DTTMax.h.

Referenced by DTTMax(), and ~DTTMax().

SegDir DTTMax::theSegDir
private

Definition at line 92 of file DTTMax.h.

Referenced by DTTMax().

std::string DTTMax::theSegType
private

Definition at line 93 of file DTTMax.h.

Referenced by DTTMax().

std::vector<TMax*> DTTMax::theTMaxes
private

Definition at line 91 of file DTTMax.h.

Referenced by DTTMax(), getTMax(), and ~DTTMax().