LBNEDataNtp_t.cc
Go to the documentation of this file.
1 //
2 // LBNEDataNtp_t.cc
3 //
4 // ADM, July 2005
5 // This is a class that defines the LBNEDataNtp_t object that is used to
6 // store the g4numi output in a root tree.
7 // $Id: LBNEDataNtp_t.cc,v 1.1 2011/07/13 16:20:52 loiacono Exp $
8 //------------------
9 
10 #include "globals.hh"
11 #include "G4ios.hh"
12 
13 #include "LBNEDataNtp_t.hh"
15 //------------------------------------------------------------------------------
17 {
18  Clear();
19 }
20 
21 
22 //----------------------------------------------------------------------
24 {
25  // LBNEDataNtp_t destructor
26 }
27 
28 //----------------------------------------------------------------------
30 {
31  run = -999;
32  evtno = -999;
33  protonN = -999;
34  beamHWidth = -99999.;
35  beamVWidth = -99999.;
36  beamX = -99999.;
37  beamY = -99999.;
38  protonX = -99999.;
39  protonY = -99999.;
40  protonZ = -99999.;
41  protonPx = -99999.;
42  protonPy = -99999.;
43  protonPz = -99999.;
44  nuTarZ = -99999.;
45  hornCurrent = -99999.;
46  Ndxdz = -99999.;
47  Ndydz = -99999.;
48  Npz = -99999.;
49  Nenergy = -99999.;
50  Norig = -999;
51  Ndecay = -999;
52  Ntype = -999;
53  Vx = -99999.;
54  Vy = -99999.;
55  Vz = -99999.;
56  pdPx = -99999.;
57  pdPy = -99999.;
58  pdPz = -99999.;
59  ppdxdz = -99999.;
60  ppdydz = -99999.;
61  pppz = -99999.;
62  ppenergy = -99999.;
63  ppmedium = -99999.;
64  ptype = -999;
65  ptrkid = -999;
66  ppvx = -99999.;
67  ppvy = -99999.;
68  ppvz = -99999.;
69  muparpx = -99999.;
70  muparpy = -99999.;
71  muparpz = -99999.;
72  mupare = -99999.;
73  Necm = -99999.;
74  Nimpwt = -99999.;
75  xpoint = -99999.;
76  ypoint = -99999.;
77  zpoint = -99999.;
78  tvx = -99999.;
79  tvy = -99999.;
80  tvz = -99999.;
81  tpx = -99999.;
82  tpy = -99999.;
83  tpz = -99999.;
84  tptype = -999;
85  tgen = -999;
86 
87 //Added By Amit Bashyal:
88 
89  h1posx =-99999.;
90  h1posy =-99999.;
91  h1posz =-99999.;
92  h2posx =-99999.;
93  h2posy =-99999.;
94  h2posz =-99999.;
95  h1trackid =-9999.;
96  h2trackid =-9999.;
97  h1momx =-9999.;
98  h1momy =-9999.;
99  h1momz =-9999.;
100  h2momx =-9999.;
101  h2momy =-9999.;
102  h2momz =-9999.;
103  //-------------------------------------------------
104  for( Int_t index=0; index<5; ++index)
105  {
106  NdxdzNear[index] = -99999.;
107  NdydzNear[index] = -99999.;
108  NenergyN[index] = -99999.;
109  NWtNear[index] = -99999.;
110  }
111 
112  for ( Int_t index=0; index<3; ++index)
113  {
114  NdxdzFar[index] = -99999.;
115  NdydzFar[index] = -99999.;
116  NenergyF[index] = -99999.;
117  NWtFar[index] = -99999.;
118  }
119 
120  fTrkPtMap.clear();
121 
122 
123 }
124 
125 //----------------------------------------------------------------------
127 {
128  /*std::cout << "LBNEDataNtp" << std::endl;
129  std::cout << "type = " << tp.type << std::endl;
130  std::cout << " x = " << tp.x << std::endl;
131  std::cout << " y = " << tp.y << std::endl;
132  std::cout << " z = " << tp.z << std::endl;
133  std::cout << " px = " << tp.px << std::endl;
134  std::cout << " py = " << tp.py << std::endl;
135  std::cout << " pz = " << tp.pz << std::endl;
136  */
137 
138  TrkPtMap::iterator tpit = fTrkPtMap.find(trkpt);
139  if(tpit == fTrkPtMap.end())
140  {
141  TrackPoint_t trackpoint;
142  tpit = fTrkPtMap.insert(TrkPtMap::value_type(trkpt, trackpoint)).first;
143  }
144 
145  TrackPoint_t &trackpoint = (tpit -> second);
146  trackpoint = tp;
147 
148 /*
149 std::cout << "LBNEDataNtp TrackPoint in G4LBNE data after assignment - " << std::endl;
150  std::cout << " type = " << trackpoint.type << std::endl;
151  std::cout << " x = " << trackpoint.x << std::endl;
152  std::cout << " y = " << trackpoint.y << std::endl;
153  std::cout << " z = " << trackpoint.z << std::endl;
154  std::cout << " px = " << trackpoint.px << std::endl;
155  std::cout << " py = " << trackpoint.py << std::endl;
156  std::cout << " pz = " << trackpoint.pz << std::endl;
157 
158  trackpoint.Print();
159 */
160 }
161 
162 
163 //----------------------------------------------------------------------
165 {
166 
168  TrkPtMap::iterator tpit = fTrkPtMap.find(trkpt);
169  if(tpit == fTrkPtMap.end())
170  {
171  TrackPoint_t trackpoint;
172  tpit = fTrkPtMap.insert(TrkPtMap::value_type(trkpt, trackpoint)).first;
173  }
174 
175  TrackPoint_t &trackpoint = (tpit -> second);
176  trackpoint = tp;
177 }
178 
179 //----------------------------------------------------------------------
181  int trkid, int gen, double impwt,
182  float x, float y, float z,
183  float px, float py, float pz)
184 {
185  /*std::cout << "LBNEDataNtp" << std::endl;
186  std::cout << "type = " << type << std::endl;
187  std::cout << " x = " << x << std::endl;
188  std::cout << " y = " << y << std::endl;
189  std::cout << " z = " << z << std::endl;
190  std::cout << " px = " << px << std::endl;
191  std::cout << " py = " << py << std::endl;
192  std::cout << " pz = " << pz << std::endl;
193  */
194 
195  TrkPtMap::iterator tpit = fTrkPtMap.find(trkpt);
196  if(tpit == fTrkPtMap.end())
197  {
198  TrackPoint_t trackpoint;
199  tpit = fTrkPtMap.insert(TrkPtMap::value_type(trkpt, trackpoint)).first;
200  }
201 
202  TrackPoint_t &trackpoint = (tpit -> second);
203  trackpoint.type = type;
204  trackpoint.trkid = trkid;
205  trackpoint.gen = gen;
206  trackpoint.impwt = impwt;
207  trackpoint.x = x;
208  trackpoint.y = y;
209  trackpoint.z = z;
210  trackpoint.px = px;
211  trackpoint.py = py;
212  trackpoint.pz = pz;
213 
214 /*
215  std::cout << "LBNEDataNtp TrackPoint in G4LBNE data after assignment - " << std::endl;
216  std::cout << " type = " << trackpoint.type << std::endl;
217  std::cout << " x = " << trackpoint.x << std::endl;
218  std::cout << " y = " << trackpoint.y << std::endl;
219  std::cout << " z = " << trackpoint.z << std::endl;
220  std::cout << " px = " << trackpoint.px << std::endl;
221  std::cout << " py = " << trackpoint.py << std::endl;
222  std::cout << " pz = " << trackpoint.pz << std::endl;
223 
224 
225  trackpoint.Print();
226 */
227 }
228 
229 //----------------------------------------------------------------------
231  int trkid, int gen, double impwt,
232  float x, float y, float z,
233  float px, float py, float pz)
234 {
236  TrkPtMap::iterator tpit = fTrkPtMap.find(trkpt);
237  if(tpit == fTrkPtMap.end())
238  {
239  TrackPoint_t trackpoint;
240  tpit = fTrkPtMap.insert(TrkPtMap::value_type(trkpt, trackpoint)).first;
241  }
242 
243  TrackPoint_t &trackpoint = (tpit -> second);
244  trackpoint.type = type;
245  trackpoint.trkid = trkid;
246  trackpoint.gen = gen;
247  trackpoint.impwt = impwt;
248  trackpoint.x = x;
249  trackpoint.y = y;
250  trackpoint.z = z;
251  trackpoint.px = px;
252  trackpoint.py = py;
253  trackpoint.pz = pz;
254 }
255 
256 /*
257 //----------------------------------------------------------------------
258 void LBNEDataNtp_t::AddTrkPointParticleType(TrkPoint::TrkPoint_t &trkpt, int type)
259 {
260 }
261 
262 //----------------------------------------------------------------------
263 void LBNEDataNtp_t::AddTrkPointTrackID(TrkPoint::TrkPoint_t &trkpt, int trkid)
264 {
265 }
266 
267 //----------------------------------------------------------------------
268 void LBNEDataNtp_t::AddTrkPointPosition(TrkPoint::TrkPoint_t &trkpt,
269  float x, float y, float z)
270 {
271 }
272 //----------------------------------------------------------------------
273 void LBNEDataNtp_t::AddTrkPointMomentum(TrkPoint::TrkPoint_t &trkpt,
274  float px, float py, float pz)
275 {
276 }
277 */
278 
279 
280 //********************************************************************
281 //********************************************************************
282 //Access to Track Point Map (see inlined functions too)
283 
284 //----------------------------------------------------------------------
286 {
287  //
288  // Return data at key, if key exits
289  //
290 
292  {
293  std::cout << "LBNEDataNtp_t::TrkPtDataAt() - PROBLEM: Key "
294  << key << " doesn't exist in the TrackPoint Map."
295  << " MUST call LBNEDataNtp_t::TrkPtKeyExists() before "
296  << "calling this function. GOING TO CRASH NOW." << std::endl;
297 
298  }
299 
300  TrkPtMapIter it = fTrkPtMap.find(key);
301 
302  //const TrkPtMapIter it = std::find(fTrkPtMap.begin(), fTrkPtMap.end(), key);
303 
304  return it -> second;
305 }
306 
307 
308 //----------------------------------------------------------------------
310 {
311  //
312  // Return data at key, if key exits
313  //
314 
316  {
317  std::cout << "LBNEDataNtp_t::GetTrkPtParticleTypeAt() - PROBLEM: Key "
318  << key << " doesn't exist in the TrackPoint Map."
319  << " MUST call LBNEDataNtp_t::TrkPtKeyExists() before "
320  << "calling this function. GOING TO CRASH NOW." << std::endl;
321 
322  }
323 
324  TrkPtMapIter it = fTrkPtMap.find(key);
325 
326  const TrackPoint_t& trackpoint = (it -> second);
327 
328  return trackpoint.GetParticleType();
329 }
330 
331 //----------------------------------------------------------------------
333 {
334  //
335  // Return data at key, if key exits
336  //
337 
339  {
340  std::cout << "LBNEDataNtp_t::GetTrkPtTrackIDAt() - PROBLEM: Key "
341  << key << " doesn't exist in the TrackPoint Map."
342  << " MUST call LBNEDataNtp_t::TrkPtKeyExists() before "
343  << "calling this function. GOING TO CRASH NOW." << std::endl;
344 
345  }
346 
347  TrkPtMapIter it = fTrkPtMap.find(key);
348 
349  const TrackPoint_t& trackpoint = (it -> second);
350 
351  return trackpoint.GetTrackID();
352 }
353 //----------------------------------------------------------------------
355 {
356  //
357  // Return data at key, if key exits
358  //
359 
361  {
362  std::cout << "LBNEDataNtp_t::GetTrkPtGenerationAt() - PROBLEM: Key "
363  << key << " doesn't exist in the TrackPoint Map."
364  << " MUST call LBNEDataNtp_t::TrkPtKeyExists() before "
365  << "calling this function. GOING TO CRASH NOW." << std::endl;
366 
367  }
368 
369  TrkPtMapIter it = fTrkPtMap.find(key);
370 
371  const TrackPoint_t& trackpoint = (it -> second);
372 
373  return trackpoint.GetGeneration();
374 }
375 //----------------------------------------------------------------------
377 {
378  //
379  // Return data at key, if key exits
380  //
381 
383  {
384  std::cout << "LBNEDataNtp_t::GetTrkPtImpWeightAt() - PROBLEM: Key "
385  << key << " doesn't exist in the TrackPoint Map."
386  << " MUST call LBNEDataNtp_t::TrkPtKeyExists() before "
387  << "calling this function. GOING TO CRASH NOW." << std::endl;
388 
389  }
390 
391  TrkPtMapIter it = fTrkPtMap.find(key);
392 
393  const TrackPoint_t& trackpoint = (it -> second);
394 
395  return trackpoint.GetImpWeight();
396 }
397 
398 //----------------------------------------------------------------------
400 {
401  //
402  // Return data at key, if key exits
403  //
404 
406  {
407  std::cout << "LBNEDataNtp_t::GetTrkPtPositionAt() - PROBLEM: Key "
408  << key << " doesn't exist in the TrackPoint Map."
409  << " MUST call LBNEDataNtp_t::TrkPtKeyExists() before "
410  << "calling this function. GOING TO CRASH NOW." << std::endl;
411 
412  }
413 
414  TrkPtMapIter it = fTrkPtMap.find(key);
415 
416  const TrackPoint_t& trackpoint = (it -> second);
417 
418  return trackpoint.GetPosition(pos);
419 }
420 
421 //----------------------------------------------------------------------
422 float LBNEDataNtp_t::GetTrkPtMomentumAt(int key, const std::string &mpos) const
423 {
424  //
425  // Return data at key, if key exits
426  //
427 
429  {
430  std::cout << "LBNEDataNtp_t::GetTrkPtMomentumAt() - PROBLEM: Key "
431  << key << " doesn't exist in the TrackPoint Map."
432  << " MUST call LBNEDataNtp_t::TrkPtKeyExists() before "
433  << "calling this function. GOING TO CRASH NOW." << std::endl;
434 
435  }
436 
437  TrkPtMapIter it = fTrkPtMap.find(key);
438 
439  const TrackPoint_t& trackpoint = (it -> second);
440 
441  return trackpoint.GetMomentum(mpos);
442 }
443 
444 //end Acess to TrackPoint Map
445 //********************************************************************
446 //********************************************************************
447 
448 
449 
450 
451 
452 
453 
454 
455 
456 
457 
458 
459 
460 
461 
462 
463 
464 //-------------------------------------------------------------------------------------
466 {
467  if (trkpt == TrkPoint::AsString(TrkPoint::kTarget) || trkpt == "kTarget") return kTarget;
468  else if (trkpt == TrkPoint::AsString(TrkPoint::kTargetExit) || trkpt == "kTargetExit") return kTargetExit;
469  else if (trkpt == TrkPoint::AsString(TrkPoint::kTargetEndPlane) || trkpt == "kTargetEndPlane") return kTargetEndPlane;
470  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn1Enter) || trkpt == "kHorn1Enter") return kHorn1Enter;
471  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn1NeckPlane) || trkpt == "kHorn1NeckPlane") return kHorn1NeckPlane;
472  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn1Exit) || trkpt == "kHorn1Exit") return kHorn1Exit;
473  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn1EndPlane) || trkpt == "kHorn1EndPlane") return kHorn1EndPlane;
474  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn2Enter) || trkpt == "kHorn2Enter") return kHorn2Enter;
475  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn2NeckPlane) || trkpt == "kHorn2NeckPlane") return kHorn2NeckPlane;
476  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn2Exit) || trkpt == "kHorn2Exit") return kHorn2Exit;
477  else if (trkpt == TrkPoint::AsString(TrkPoint::kHorn2EndPlane) || trkpt == "kHorn2EndPlane") return kHorn2EndPlane;
478  else if (trkpt == TrkPoint::AsString(TrkPoint::kDPipeEnter) || trkpt == "kDPipeEnter") return kDPipeEnter;
479  else if (trkpt == TrkPoint::AsString(TrkPoint::kDPipeExit) || trkpt == "kDPipeExit") return kDPipeExit;
480 
481  else if (trkpt == TrkPoint::AsString(TrkPoint::kUnknown) || trkpt == "kUnknown") return kUnknown;
482  else return kUnknown;
483 }
484 
485 //-------------------------------------------------------------------------------------
487 {
488 //returns enum
489  switch (trkpt)
490  {
491  case 1: return kTarget; break;
492  case 2: return kTargetExit; break;
493  case 3: return kTargetEndPlane; break;
494  case 11: return kHorn1Enter; break;
495  case 12: return kHorn1NeckPlane; break;
496  case 13: return kHorn1Exit; break;
497  case 14: return kHorn1EndPlane; break;
498  case 21: return kHorn2Enter; break;
499  case 22: return kHorn2NeckPlane; break;
500  case 23: return kHorn2Exit; break;
501  case 24: return kHorn2EndPlane; break;
502  case 31: return kDPipeEnter; break;
503  case 32: return kDPipeExit; break;
504  case -99: return kUnknown; break;
505  default: return kUnknown; break;
506  }
507 }
508 
509 //-------------------------------------------------------------------------------------
511 {
513 }
514 
515 //-------------------------------------------------------------------------------------
517 {
519 }
520 
521 //-------------------------------------------------------------------------------------
523 {
524  switch (trkpt)
525  {
526  case kTarget : return "Target"; break;
527  case kTargetExit : return "TargetExit"; break;
528  case kTargetEndPlane : return "TargetEndPlane"; break;
529  case kHorn1Enter : return "Horn1Enter"; break;
530  case kHorn1NeckPlane : return "Horn1NeckPlane"; break;
531  case kHorn1Exit : return "Horn1Exit"; break;
532  case kHorn1EndPlane : return "Horn1EndPlane"; break;
533  case kHorn2Enter : return "Horn2Enter"; break;
534  case kHorn2NeckPlane : return "Horn2NeckPlane"; break;
535  case kHorn2Exit : return "Horn2Exit"; break;
536  case kHorn2EndPlane : return "Horn2EndPlane"; break;
537  case kDPipeEnter : return "DPipeEnter"; break;
538  case kDPipeExit : return "DPipeExit"; break;
539  case kUnknown : return "Unknown"; break;
540  default : return "Unknown"; break;
541  }
542 }
543 
544 //-------------------------------------------------------------------------------------
546 {
547  switch (trkpt)
548  {
549  case kTarget : return "Target"; break;
550  case kTargetExit : return "TargetExit"; break;
551  case kTargetEndPlane : return "TargetEndPlane"; break;
552  case kHorn1Enter : return "Horn1Enter"; break;
553  case kHorn1NeckPlane : return "Horn1NeckPlane"; break;
554  case kHorn1Exit : return "Horn1Exit"; break;
555  case kHorn1EndPlane : return "Horn1EndPlane"; break;
556  case kHorn2Enter : return "Horn2Enter"; break;
557  case kHorn2NeckPlane : return "Horn2NeckPlane"; break;
558  case kHorn2Exit : return "Horn2Exit"; break;
559  case kHorn2EndPlane : return "Horn2EndPlane"; break;
560  case kDPipeEnter : return "DPipeEnter"; break;
561  case kDPipeExit : return "DPipeExit"; break;
562  case kUnknown : return "Unknown"; break;
563  default : return "Unknown"; break;
564  }
565 
566 }
567 
568 //-------------------------------------------------------------------------------------
570 {
571  switch (trkpt)
572  {
573  case kTarget : return 1; break;
574  case kTargetExit : return 2; break;
575  case kTargetEndPlane : return 3; break;
576  case kHorn1Enter : return 11; break;
577  case kHorn1NeckPlane : return 12; break;
578  case kHorn1Exit : return 13; break;
579  case kHorn1EndPlane : return 14; break;
580  case kHorn2Enter : return 21; break;
581  case kHorn2NeckPlane : return 22; break;
582  case kHorn2Exit : return 23; break;
583  case kHorn2EndPlane : return 24; break;
584  case kDPipeEnter : return 31; break;
585  case kDPipeExit : return 32; break;
586  case kUnknown : return -99; break;
587  default : return -99; break;
588  }
589 }
590 
591 //-------------------------------------------------------------------------------------
592 bool TrkPoint::Overlap(const TrkPoint_t lhs, const TrkPoint_t rhs)
593 {
594  if(lhs == kUnknown || rhs == kUnknown)
595  {
596  std::cout << "LBNEDataNtp_t.cxx: TrkPoint::Overlap - TrkPoint is kUnknown." << std::endl;
597  return false;
598  }
599 
600  if(lhs == rhs)
601  {
602  return true;
603  }
604  else
605  return false;
606 
607 }
intermediate_table::iterator iterator
Int_t GetParticleType() const
Definition: TrackPoint_t.hh:90
Float_t hornCurrent
Int_t GetTrackID() const
Definition: TrackPoint_t.hh:91
Float_t NdxdzNear[5]
Int_t GetGeneration() const
Definition: TrackPoint_t.hh:92
std::string string
Definition: nybbler.cc:12
Float_t beamVWidth
std::string AsString(TrkPoint_t trkpt)
TrkPtMap::const_iterator TrkPtMapIter
TrkPtMap fTrkPtMap
bool Overlap(const TrkPoint_t lhs, const TrkPoint_t rhs)
const TrackPoint_t & GetTrkPtAt(int key) const
virtual ~LBNEDataNtp_t()
double y
int AsInt(TrkPoint_t trkpt)
Double_t NWtFar[3]
int GetTrkPtTrackIDAt(int key) const
enum TrkPoint::ETrkPoint TrkPoint_t
Float_t GetMomentum(int i) const
Definition: TrackPoint_t.cc:69
Double_t impwt
Definition: TrackPoint_t.hh:51
double z
Float_t GetPosition(int i) const
Definition: TrackPoint_t.cc:41
int GetTrkPtParticleTypeAt(int key) const
TrkPoint_t StringToEnum(const std::string &trkpt)
Float_t NdxdzFar[3]
Float_t NdydzFar[3]
Float_t NenergyF[3]
float GetTrkPtPositionAt(int key, const std::string &pos) const
TrkPoint_t IntToEnum(int trkpt)
int StringToInt(const std::string &trkpt)
int GetTrkPtGenerationAt(int key) const
Double_t GetImpWeight() const
Definition: TrackPoint_t.hh:93
void AddTrkPoint(TrkPoint::TrkPoint_t trkpt, TrackPoint_t &tp)
static QCString type
Definition: declinfo.cpp:672
Float_t NdydzNear[5]
list x
Definition: train.py:276
double GetTrkPtImpWeightAt(int key) const
Float_t NenergyN[5]
std::string AsLabel(TrkPoint_t trkpt)
Double_t NWtNear[5]
bool TrkPtKeyExists(int key) const
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:79
float GetTrkPtMomentumAt(int key, const std::string &mpos) const
ClassImp(LBNEDataNtp_t) LBNEDataNtp_t
Float_t beamHWidth
QTextStream & endl(QTextStream &s)
std::string IntToString(int trkpt)