QwAnalysis
QwTreeEventBuffer.cc
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*//*!
2 
3  \file QwTreeEventBuffer.cc
4  \ingroup QwTracking
5 
6  \brief Implementation of the class that reads simulated QweakSimG4 events
7 
8 *//*-------------------------------------------------------------------------*/
9 
10 #include "QwTreeEventBuffer.h"
11 
12 // System headers
13 #include <string>
14 #include <cmath>
15 #include <cstring>
16 
17 // ROOT headers
18 #include <TVector3.h>
19 #include <TLeaf.h>
20 
21 // Qweak headers
22 #include "QwLog.h"
23 #include "QwUnits.h"
24 #include "QwHit.h"
25 #include "QwHitContainer.h"
26 #include "QwParameterFile.h"
27 #include "QwDetectorInfo.h"
28 #include "QwPartialTrack.h"
29 #include "QwEvent.h"
30 
31 #include "QwDriftChamberHDC.h"
32 
33 // Helper headers
34 #include "uv2xy.h"
35 
36 // Definitions
37 #define VECTOR_SIZE 100
38 #define COINCIDENCE_LEVEL_OF_R3_CHARGED_HITS 0 // choose 0 - 4 folder of coincidence for charged particle hits in VDCs
39 
40 bool is_R2WirePlane10_OK = true;
43 
44 double drop_off_R2_plane10_hits = 0; //90; // percent of dropped hits to total hits in plane 10 of Region 2, no drop-off if set to 0
45 
46 double drop_off_R2_hits = 0; // percent of dropped hits to total hits in Region 2, no drop-off if set to 0
47 double drop_off_R3_hits = 0; // percent of dropped hits to total hits in Region 3, no drop-off if set to 0
48 
49 double missing_drift_time = 0.0; // [ns], set to 0 if no missing drift time
50 
51 
52 // List of available cross section values
54 
55 //------------------------------------------------------------
56 /**
57  * Constructor with file name and spectrometer geometry
58  * @param detector_info Detector geometry information vector
59  */
61 : fCurrentEvent(0),fOriginalEvent(0),fDetectorInfo(detector_info),
62  fListCrossSections(false),fUseCrossSection(""),fCrossSection(0)
63 {
64  // Initialize
65  fCurrentRunNumber = -1;
66  fRunRange.first = -1;
67  fRunRange.second = 0;
69  fEventRange.first = -1;
70  fEventRange.second = 0;
71 
72  // Set the number of entries per event to 1
73  fNumberOfEvents = 0;
74  fNumberOfEntries = 0;
76 
77  // Allocate memory for the tree vectors
79  // Initialize the tree vectors
80  ClearVectors();
81 
82  fEnableR2Hits = true;
83  fEnableR3Hits = true;
84  fEnableResolution = true;
85 
95 
97 
98  // If fAvailableCrossSections hasn't been initialized, do it now
99  // (only C++11 has support for { } initializer lists, so this must be
100  // done explicitly)
101  if (fAvailableCrossSections.size() == 0) {
102  fAvailableCrossSections.push_back("BornTotal");
103  fAvailableCrossSections.push_back("BornInelastic");
104  fAvailableCrossSections.push_back("BornQE");
105  fAvailableCrossSections.push_back("RadTotal");
106  fAvailableCrossSections.push_back("RadElastic");
107  fAvailableCrossSections.push_back("RadQE");
108  fAvailableCrossSections.push_back("RadDIS");
109  fAvailableCrossSections.push_back("RadTotalIntOnly");
110  fAvailableCrossSections.push_back("RadElasticIntOnly");
111  fAvailableCrossSections.push_back("RadQEIntOnly");
112  fAvailableCrossSections.push_back("RadDISIntOnly");
113  fAvailableCrossSections.push_back("RadElasticPeak");
114  }
115 }
116 
117 
118 /**
119  * Destructor to close and delete the ROOT file
120  */
122 {
123  // Delete previous event
124  if (fCurrentEvent) {
125  delete fCurrentEvent;
126  fCurrentEvent = 0;
127  }
128  // Delete previous original event
129  if (fOriginalEvent) {
130  delete fOriginalEvent;
131  fOriginalEvent = 0;
132  }
133 }
134 
135 
136 /**
137  * Define the command line and config file options
138  * @param options Options object
139  */
141 {
142  options.AddOptions("SimTracking options")("QwSimTracking.enable-r2-hits",
143  po::value<bool>()->default_bool_value(true),
144  "enable R2 hit reconstruction");
145  options.AddOptions("SimTracking options")("QwSimTracking.enable-r3-hits",
146  po::value<bool>()->default_bool_value(true),
147  "enable R3 hit reconstruction");
148  options.AddOptions("SimTracking options")("QwSimTracking.enable-resolution",
149  po::value<bool>()->default_bool_value(true),
150  "enable drift chamber resolution");
151  options.AddOptions("SimTracking options")("QwSimTracking.reconstruct-all",
152  po::value<bool>()->default_bool_value(true),
153  "attempt reconstruction of all events, regardless of software trigger");
154  options.AddOptions("SimTracking options")("QwSimTracking.list-cross-sections",
155  po::value<bool>()->default_bool_value(false),
156  "list which cross sections are available for fCrossSection");
157  options.AddOptions("SimTracking options")("QwSimTracking.use-cross-section",
158  po::value<string>()->default_value(""),
159  "specify which cross section to fill into fCrossSection");
160 }
161 
162 /**
163  * Process the options contained in the QwOptions object
164  * @param options Options object
165  */
167 {
168  fRunRange = options.GetIntValuePair("run");
169  fEventRange = options.GetIntValuePair("event");
170 
171  fEnableR2Hits = options.GetValue<bool>("QwSimTracking.enable-r2-hits");
172  fEnableR3Hits = options.GetValue<bool>("QwSimTracking.enable-r3-hits");
173  fEnableResolution = options.GetValue<bool>("QwSimTracking.enable-resolution");
174  fReconstructAllEvents = options.GetValue<bool>("QwSimTracking.reconstruct-all");
175 
176  // Get the cross section to use
177  fUseCrossSection = options.GetValue<string>("QwSimTracking.use-cross-section");
178  if (fUseCrossSection.size()) AssignCrossSection();
179 
180  // List cross sections when requested
181  fListCrossSections = options.GetValue<bool>("QwSimTracking.list-cross-sections");
183 }
184 
185 
186 /**
187  * Open the event stream
188  * @return Status
189  */
191 {
192  // Get the run number
193  if (fCurrentRunNumber == -1)
194  fCurrentRunNumber = fRunRange.first - 1;
195 
196  // Find the next run number
197  unsigned int status = 1;
198  while (status != 0 && fCurrentRunNumber < fRunRange.second) {
199  // Next run
201  // Open the file
202  status = OpenFile();
203  }
204  return status;
205 }
206 
207 
208 /**
209  * Open the event stream
210  * @return Status
211  */
213 {
214  // Determine the file name
215  TString filename = Form(getenv_safe_TString("QW_DATA") + "/QwSim_%d.root", fCurrentRunNumber);
216 
217  // Open ROOT file
218  fFile = new TFile (filename);
219  if (! fFile) {
220  QwError << "Could not open file " << filename << " for reading!" << QwLog::endl;
221  return 1;
222  }
223 
224  // Get the ROOT tree
225  fTree = (TTree*) fFile->Get("QweakSimG4_Tree");
226  if (! fTree) {
227  QwError << "Could not find Geant4 Monte Carlo tree in file " << filename << QwLog::endl;
228  return 1;
229  }
230  fTree->SetMakeClass(1);
231 
232  // Get the number of entries
233  SetNumberOfEntries(fTree->GetEntries());
234  QwVerbose << "Entries in event file: " << GetNumberOfEntries() << QwLog::endl;
235 
236  // Reset event and entry numbers
237  fCurrentEventNumber = -1;
238  fCurrentEntryNumber = -1;
239 
240  // Attach branches to the tree vectors
241  AttachBranches();
242 
243  return 0;
244 }
245 
246 
247 /**
248  * Close the event stream
249  * @return Status
250  */
252 {
253  // Close file
254  if (fFile) {
255  fFile->Close();
256  delete fFile;
257  }
258  return 0;
259 }
260 
261 /**
262  * List the available cross sections
263  */
265  QwOut << "Available cross sections:" << QwLog::endl;
266  for (size_t i = 0; i < fAvailableCrossSections.size(); i++) {
268  }
269 }
270 
271 /**
272  * Assign the correct cross section pointer based on the setting in
273  * the flag fUseCrossSection
274  */
276 {
277  // Get cross section when the flag is specified
278  std::vector<string>::iterator iter =
280 
281  if (iter != fAvailableCrossSections.end()) {
282  QwMessage << "Using cross section " << fUseCrossSection << QwLog::endl;
283  if (fUseCrossSection == "BornTotal") {
285  }
286  if (fUseCrossSection == "BornInelastic") {
288  }
289  if (fUseCrossSection == "BornQE") {
291  }
292  if (fUseCrossSection == "RadTotal") {
294  }
295  if (fUseCrossSection == "RadElastic") {
297  }
298  if (fUseCrossSection == "RadQE") {
300  }
301  if (fUseCrossSection == "RadDIS") {
303  }
304  if (fUseCrossSection == "RadTotalIntOnly") {
306  }
307  if (fUseCrossSection == "RadElasticIntOnly") {
309  }
310  if (fUseCrossSection == "RadQEIntOnly") {
312  }
313  if (fUseCrossSection == "RadDISIntOnly") {
315  }
316  if (fUseCrossSection == "RadElasticPeak") {
318  }
319  } else {
320  QwMessage << "Using default cross section." << QwLog::endl;
322  }
323 }
324 
325 /**
326  * Return the dereferenced cross section pointer
327  */
329 {
330  if (fCrossSection) return *fCrossSection;
331  else return fPrimary_CrossSection;
332 }
333 
334 /**
335  * Read the next event
336  * @return Status (zero when succesful)
337  */
339 {
340 
341  // Find next event number in requested range
343  // But make sure it is not past the end of the range
344  if (fCurrentEventNumber > fEventRange.second) return 1;
345 
346  // Progress meter (this should probably produce less output in production)
347  if (fCurrentEventNumber > 0 && fCurrentEventNumber % 1000 == 0) {
348  QwMessage << "Processing event " << fCurrentEventNumber << QwLog::endl;
349  } else if (fCurrentEventNumber > 0 && fCurrentEventNumber % 100 == 0) {
350  QwVerbose << "Processing event " << fCurrentEventNumber << QwLog::endl;
351  }
352 
353  // Read the next event
355 }
356 
357 
358 /**
359  * Read the specified event
360  * @return Status (zero when succesful)
361  */
362 unsigned int QwTreeEventBuffer::GetSpecificEvent(const int eventnumber)
363 {
364  // Delete previous event
365  if (fCurrentEvent) {
366  delete fCurrentEvent;
367  fCurrentEvent = 0;
368  }
369  // Delete previous original event
370  if (fOriginalEvent) {
371  delete fOriginalEvent;
372  fOriginalEvent = 0;
373  }
374 
375 
376  // Assign the current event and entry number
377  fCurrentEventNumber = eventnumber;
379 
380  // Check the event number
381  if ((fCurrentEventNumber < fEventRange.first)
382  || (fCurrentEventNumber > fEventRange.second))
383  return 1;
385  return 1;
387  return 1;
388 
389 
390  /// Create the event header with the run and event number
392 
393  /// Create a new event
394  fCurrentEvent = new QwEvent();
395  fCurrentEvent->SetEventHeader(header);
396  fOriginalEvent = new QwEvent();
398 
399  // Stack entries to form event
400  while (fCurrentEntryNumber / fNumberOfEntriesPerEvent == fCurrentEventNumber
402 
403  // Get the next entry from the ROOT tree
404  if (GetEntry(fCurrentEntryNumber++) == false)
405  continue;
406 
407  // Add the smeared hit list
409  fCurrentEvent->AddHitContainer(smearedhitlist);
410  delete smearedhitlist;
411 
412  // Add the original hit list
413  QwHitContainer* originalhitlist = CreateHitList(fEnableResolution);
414  fOriginalEvent->AddHitContainer(originalhitlist);
415  delete originalhitlist;
416 
417  // Assign the kinematic variables
426 
427  // Assign some of the kinematic variables to the original event
437 
438  // Assign the kinematic variables in fKin
446 
447  // Assign the cross section to the reconstructed event for correct weighting
449 
450  for (size_t i=0; i<fCerenkov_PMT_PMTLeftNbOfPEs.size(); i++){
453  }
454 
455  for (size_t i=0; i<fCerenkov_PMT_PMTRightNbOfPEs.size(); i++){
458  }
459 
460  for (size_t i=0; i<fCerenkov_PMT_PMTTotalNbOfPEs.size(); i++){
463  }
464 
465  std::vector<boost::shared_ptr<QwTreeLine> > treelinelist;
466  treelinelist = CreateTreeLines(kRegionID2);
467  for (size_t i = 0; i < treelinelist.size(); i++)
468  fOriginalEvent->AddTreeLine(treelinelist[i].get());
469  treelinelist = CreateTreeLines(kRegionID3);
470  for (size_t i = 0; i < treelinelist.size(); i++)
471  fOriginalEvent->AddTreeLine(treelinelist[i].get());
472 
473  // Add the partial tracks
474  std::vector<boost::shared_ptr<QwPartialTrack> > partialtracklist;
475  partialtracklist = CreatePartialTracks(kRegionID2);
476  for (size_t i = 0; i < partialtracklist.size(); i++)
477  fOriginalEvent->AddPartialTrack(partialtracklist[i].get());
478  partialtracklist = CreatePartialTracks(kRegionID3);
479  for (size_t i = 0; i < partialtracklist.size(); i++)
480  fOriginalEvent->AddPartialTrack(partialtracklist[i].get());
481 
482  } // end of loop over entries
483  return 0;
484 }
485 
486 
487 /**
488  * Read the specified entry from the tree
489  * @param entry Entry to read from ROOT tree
490  */
491 bool QwTreeEventBuffer::GetEntry(const unsigned int entry)
492 {
493  // Read event
494  QwVerbose << "Reading entry " << entry << QwLog::endl;
495  fTree->GetEntry(entry);
496 
497  // Region 1
500 
501  // Region 2
502  bool is_charged_particle = true;
503  for (size_t i1 = 0; i1 < fRegion2_ChamberFront_WirePlane1_ParticleType.size(); i1++) {
505  if (abs(pdgcode) != 11) is_charged_particle = false;
506  }
507 
508  for (size_t i2 = 0; i2 < fRegion2_ChamberFront_WirePlane2_ParticleType.size(); i2++) {
510  if (abs(pdgcode) != 11) is_charged_particle = false;
511  }
512 
513  for (size_t i3 = 0; i3 < fRegion2_ChamberFront_WirePlane3_ParticleType.size(); i3++) {
515  if (abs(pdgcode) != 11) is_charged_particle = false;
516  }
517 
518  for (size_t i4 = 0; i4 < fRegion2_ChamberFront_WirePlane4_ParticleType.size(); i4++) {
520  if (abs(pdgcode) != 11) is_charged_particle = false;
521  }
522 
523  for (size_t i5 = 0; i5 < fRegion2_ChamberFront_WirePlane5_ParticleType.size(); i5++) {
525  if (abs(pdgcode) != 11) is_charged_particle = false;
526  }
527 
528  for (size_t i6 = 0; i6 < fRegion2_ChamberFront_WirePlane6_ParticleType.size(); i6++) {
530  if (abs(pdgcode) != 11) is_charged_particle = false;
531  }
532 
533  for (size_t i1 = 0; i1 < fRegion2_ChamberBack_WirePlane1_ParticleType.size(); i1++) {
535  if (abs(pdgcode) != 11) is_charged_particle = false;
536  }
537 
538  for (size_t i2 = 0; i2 < fRegion2_ChamberBack_WirePlane2_ParticleType.size(); i2++) {
540  if (abs(pdgcode) != 11) is_charged_particle = false;
541  }
542 
543  for (size_t i3 = 0; i3 < fRegion2_ChamberBack_WirePlane3_ParticleType.size(); i3++) {
545  if (abs(pdgcode) != 11) is_charged_particle = false;
546  }
547 
548  for (size_t i4 = 0; i4 < fRegion2_ChamberBack_WirePlane4_ParticleType.size(); i4++) {
550  if (abs(pdgcode) != 11) is_charged_particle = false;
551  }
552 
553  for (size_t i5 = 0; i5 < fRegion2_ChamberBack_WirePlane5_ParticleType.size(); i5++) {
555  if (abs(pdgcode) != 11) is_charged_particle = false;
556  }
557 
558  for (size_t i6 = 0; i6 < fRegion2_ChamberBack_WirePlane6_ParticleType.size(); i6++) {
560  if (abs(pdgcode) != 11) is_charged_particle = false;
561  }
562 
572  fRegion2_ChamberBack_WirePlane4_PlaneHasBeenHit == 5 && // non-functioning plane
575  is_charged_particle ;
576 
577  // Region 3
578  int charge_particle_coincidence_hits = 0;
579  bool FU = false, FV = false, BU = false, BV = false;
580 
581  for (size_t i1 = 0; i1 < fRegion3_ChamberFront_WirePlaneU_ParticleType.size(); i1++) {
583  if (abs(pdgcode) == 11) FU = true;
584  }
585 
586  for (size_t i2 = 0; i2 < fRegion3_ChamberFront_WirePlaneV_ParticleType.size(); i2++) {
588  if (abs(pdgcode) == 11) FV = true;
589  }
590 
591  for (size_t i3 = 0; i3 < fRegion3_ChamberBack_WirePlaneU_ParticleType.size(); i3++) {
593  if (abs(pdgcode) == 11) BU = true;
594  }
595 
596  for (size_t i4 = 0; i4 < fRegion3_ChamberBack_WirePlaneV_ParticleType.size(); i4++) {
598  if (abs(pdgcode) == 11) BV = true;
599  }
600 
601  charge_particle_coincidence_hits = (int) FU + (int) FV + (int) BU + (int) BV;
602 
607 
609  (charge_particle_coincidence_hits>=COINCIDENCE_LEVEL_OF_R3_CHARGED_HITS);
610 
611  if (fRegion3_HasBeenHit) {
612 
613  const QwDetectorInfo* detectorinfo = fDetectorInfo.in(kRegionID3).in(kPackage1).at(0);
614  double r3_half_length_x = 0.5*detectorinfo->GetActiveWidthX();
615  double r3_half_length_y = 0.5*detectorinfo->GetActiveWidthY();
616 
617  bool r3_geo_check_ok = true;
620  for (int j = 0; j < r3_min_hits && j < VECTOR_SIZE; j++) {
621  r3_geo_check_ok = r3_geo_check_ok &&
622  (fabs(fRegion3_ChamberFront_WirePlaneU_LocalPositionX.at(j))<r3_half_length_x &&
623  fabs(fRegion3_ChamberFront_WirePlaneV_LocalPositionX.at(j))<r3_half_length_x &&
624  fabs(fRegion3_ChamberBack_WirePlaneU_LocalPositionX.at(j))<r3_half_length_x &&
625  fabs(fRegion3_ChamberBack_WirePlaneV_LocalPositionX.at(j))<r3_half_length_x &&
626  fabs(fRegion3_ChamberFront_WirePlaneU_LocalPositionY.at(j))<r3_half_length_y &&
627  fabs(fRegion3_ChamberFront_WirePlaneV_LocalPositionY.at(j))<r3_half_length_y &&
628  fabs(fRegion3_ChamberBack_WirePlaneU_LocalPositionY.at(j))<r3_half_length_y &&
629  fabs(fRegion3_ChamberBack_WirePlaneV_LocalPositionY.at(j))<r3_half_length_y );
630 
631  }
632  fRegion3_HasBeenHit = (fRegion3_HasBeenHit && r3_geo_check_ok);
633  }
634 
635  // Trigger Scintillator
636  is_charged_particle = false;
637  for (size_t i = 0; i < fTriggerScintillator_Detector_ParticleType.size(); i++) {
638  int pdgcode = fTriggerScintillator_Detector_ParticleType.at(i);
639  if (abs(pdgcode) == 11) is_charged_particle = true;
640  }
641 
643 
644  // Cerenkov
646 
647 // std::cout<<"Detector number of hits: "<<fCerenkov_Detector_NbOfHits<<std::endl;
648 // for (int i = 0; i < fCerenkov_Detector_NbOfHits ; i++) {
649 //
650 // int octant = fDetectorInfo.in(kRegionID3).in(kPackage1).at(i)->GetOctant();
651 // //fCerenkov_HasBeenHit = fCerenkov_HasBeenHit && (fCerenkov_Detector_DetectorID.at(0) == octant);
652 //
653 // std::cout<<"detector ID="<<fCerenkov_Detector_DetectorID.at(i)<<", Octant: "<<octant<<std::endl;
654 // }
655 
656  fCerenkov_Light = false;
657  if(!fCerenkov_PMT_PMTTotalNbOfPEs.empty())
658  {
659  for(size_t i=0; i<fCerenkov_PMT_PMTTotalNbOfPEs.size(); i++)
660  {
662  }
663  }
664  else if (!fCerenkov_PMT_PMTTotalNbOfHits.empty())
665  {
666  for(size_t i=0; i<fCerenkov_PMT_PMTTotalNbOfHits.size(); i++)
667  {
669  }
670  }
671  else
672  fCerenkov_Light = true;
673 
674 
675 
678 
681  }
682 
685 
688  }
689 
692 
695 
698 
701 
702  //count as a valid track if the coincidence is satisfied
703  bool is_a_valid_track = fRegion2_HasBeenHit && fRegion3_HasBeenHit
706  if (is_a_valid_track)
708 
709 // std::cout<<"trigger: "<<fRegion2_HasBeenHit<<", "<<fRegion3_HasBeenHit<<", "
710 // <<fTriggerScintillator_HasBeenHit<<", "<<fTriggerScintillator_HasBeenHit<<", "
711 // <<fCerenkov_Light<<std::endl;
712 
714  fTree->GetEntry(entry);
715  } else {
716 
717  QwDebug << "Skipped event with missing hits: " << entry << QwLog::endl;
718  return false;
719  }
720  // Print info
721  QwDebug << "Region 1: "
724 
725  QwDebug << "Region 2: "
738 
739  QwDebug << "Region 3: "
744 
745  QwDebug << "Trigger Scintillator: "
747 
748  QwDebug << "Cerenkov: "
749  << fCerenkov_Detector_NbOfHits << " hit(s)." << QwLog::endl;
750 
751  return true;
752 
753 }
754 
755 
756 
757 /**
758  * Get the hit container
759  * @return Copy of the hit container
760  */
762 {
763  return fCurrentEvent->GetHitContainer();
764 }
765 
766 
767 /**
768  * Get the tree lines
769  * @param region Region of the tree lines
770  * @return Vector of tree lines
771  */
772 std::vector<boost::shared_ptr<QwTreeLine> > QwTreeEventBuffer::CreateTreeLines(EQwRegionID region) const
773 {
774  // List of tree lines
775  std::vector<boost::shared_ptr<QwTreeLine> > treelinelist;
776 
777  /// \todo Recreate tree lines from simulated hits in QwTreeEventBuffer
778 
779  return treelinelist;
780 }
781 
782 
783 /**
784  * Get the partial tracks
785  * @param region Region of the partial track
786  * @return Vector of partial tracks
787  */
788 std::vector<boost::shared_ptr<QwPartialTrack> > QwTreeEventBuffer::CreatePartialTracks(EQwRegionID region) const
789 {
790  // List of position and momentum, and of partial tracks
791  std::vector<TVector3> position, momentum;
792  std::vector<boost::shared_ptr<QwPartialTrack> > partialtracklist;
793 
794  // Depending on the region, get the position and momentum at the reference
795  // detector defined in the header file.
796  Double_t rx,ry,rz;
797  Double_t px,py,pz;
798  switch (region) {
799  case kRegionID1:
800  for (int hit = 0; hit < REGION1_DETECTOR(Front,NbOfHits); hit++) {
801  rx = REGION1_DETECTOR(Front,PlaneGlobalPositionX).at(hit) * Qw::cm;
802  ry = REGION1_DETECTOR(Front,PlaneGlobalPositionY).at(hit) * Qw::cm;
803  rz = REGION1_DETECTOR(Front,PlaneGlobalPositionZ).at(hit) * Qw::cm;
804  position.push_back(TVector3(rx,ry,rz));
805  px = REGION1_DETECTOR(Front,PlaneGlobalMomentumX).at(hit) * Qw::MeV;
806  py = REGION1_DETECTOR(Front,PlaneGlobalMomentumY).at(hit) * Qw::MeV;
807  pz = REGION1_DETECTOR(Front,PlaneGlobalMomentumZ).at(hit) * Qw::MeV;
808  momentum.push_back(TVector3(px,py,pz));
809  }
810  break;
811  case kRegionID2:
812  for (int hit = 0; hit < REGION2_DETECTOR(Front,1,NbOfHits); hit++) {
813  rx = REGION2_DETECTOR(Front,1,PlaneGlobalPositionX).at(hit) * Qw::cm;
814  ry = REGION2_DETECTOR(Front,1,PlaneGlobalPositionY).at(hit) * Qw::cm;
815  rz = REGION2_DETECTOR(Front,1,PlaneGlobalPositionZ).at(hit) * Qw::cm;
816  position.push_back(TVector3(rx,ry,rz));
817  px = REGION2_DETECTOR(Front,1,PlaneGlobalMomentumX).at(hit) * Qw::MeV;
818  py = REGION2_DETECTOR(Front,1,PlaneGlobalMomentumY).at(hit) * Qw::MeV;
819  pz = REGION2_DETECTOR(Front,1,PlaneGlobalMomentumZ).at(hit) * Qw::MeV;
820  momentum.push_back(TVector3(px,py,pz));
821  }
822  break;
823  case kRegionID3:
824  for (int hit = 0; hit < REGION3_DETECTOR(Front,U,NbOfHits); hit++) {
825  rx = REGION3_DETECTOR(Front,U,GlobalPositionX).at(hit) * Qw::cm;
826  ry = REGION3_DETECTOR(Front,U,GlobalPositionY).at(hit) * Qw::cm;
827  rz = REGION3_DETECTOR(Front,U,GlobalPositionZ).at(hit) * Qw::cm;
828  position.push_back(TVector3(rx,ry,rz));
829  px = REGION3_DETECTOR(Front,U,GlobalMomentumX).at(hit) * Qw::MeV;
830  py = REGION3_DETECTOR(Front,U,GlobalMomentumY).at(hit) * Qw::MeV;
831  pz = REGION3_DETECTOR(Front,U,GlobalMomentumZ).at(hit) * Qw::MeV;
832  momentum.push_back(TVector3(px,py,pz));
833  }
834  break;
835  default:
836  QwError << "Region not supported!" << QwLog::endl;
837  break;
838  }
839 
840  // Add the hits to the list of partial tracks
841  for (size_t hit = 0; hit < position.size(); hit++) {
842  QwPartialTrack* partialtrack = new QwPartialTrack(position.at(hit), momentum.at(hit));
843  partialtrack->SetRegion(region);
844  partialtracklist.push_back(boost::shared_ptr<QwPartialTrack>(partialtrack));
845  }
846 
847  // Return the list of partial tracks
848  return partialtracklist;
849 }
850 
851 
852 /**
853  * Get the hit list
854  * @param resolution_effects Flag to enable resolution effects (default is true)
855  * @return Hit list
856  */
857 QwHitContainer* QwTreeEventBuffer::CreateHitList(const bool resolution_effects) const
858 {
859  QwDebug << "Calling QwTreeEventBuffer::GetHitList ()" << QwLog::endl;
860 
861  // Flag to set hit numbers to non-zero values
862  const bool set_hit_numbers = false;
863 
864  // Create the hit list
865  int hitcounter = 0;
866  QwHitContainer* hitlist = new QwHitContainer;
867 
868  // Pointer to the detector info, this should be set before each detector section
869  const QwDetectorInfo* detectorinfo = 0;
870  if (fDetectorInfo.size() == 0) {
871  QwError << "No detector geometry defined: use SetDetectorInfo()." << QwLog::endl;
872  return 0;
873  }
874 
875  // Region 1 decoding provides hits in the usual QwHit format: strips with a
876  // hit are stored (zero-suppressed), and if the BONUS electronics with charge
877  // digitization are used that value is stored in the QwHit::fADC field (or
878  // whatever that will be called).
879  //
880  // Clustering of the region 1 hits is handled by a dedicated object, which
881  // can use the strip charge value to make a smarter decision. The result of
882  // the clustering is a QwGEMCluster. The clustering algorithm is implemented
883  // in the QwGEMClusterFinder.
884 
885  // Region 1 front chamber
886  QwDebug << "Processing Region1_ChamberFront_WirePlane: "
888  try {
889  detectorinfo = fDetectorInfo.in(kRegionID1).in(kPackage1).at(0);
890  for (int i1 = 0; i1 < fRegion1_ChamberFront_WirePlane_NbOfHits && i1 < VECTOR_SIZE; i1++) {
893  // Position in the Qweak frame
894  double x = yLocalMC;
895  double y = xLocalMC;
896  std::vector<QwHit> hits = CreateHitRegion1(detectorinfo,x,y,resolution_effects);
897  // Set the hit numbers
898  for (size_t i = 0; i < hits.size(); i++)
899  if (set_hit_numbers)
900  hits[i].SetHitNumber(hitcounter++);
901  // Add the hit to the hit list (it is copied)
902  hitlist->Append(hits);
903  }
904  } catch (std::exception&) {
905  QwDebug << "No detector in region 1, front plane, package up." << QwLog::endl;
906  }
907 
908  // Region 1 back chamber
909  QwDebug << "No code for processing Region1_ChamberBack_WirePlane: "
911  try {
912  detectorinfo = fDetectorInfo.in(kRegionID1).in(kPackage1).at(1);
913  for (int i2 = 0; i2 < fRegion1_ChamberBack_WirePlane_NbOfHits && i2 < VECTOR_SIZE; i2++) {
916  // Position in the Qweak frame
917  double x = yLocalMC;
918  double y = xLocalMC;
919  std::vector<QwHit> hits = CreateHitRegion1(detectorinfo,x,y,resolution_effects);
920  // Set the hit numbers
921  for (size_t i = 0; i < hits.size(); i++)
922  if (set_hit_numbers)
923  hits[i].SetHitNumber(hitcounter++);
924  // Add the hit to the hit list (it is copied)
925  hitlist->Append(hits);
926  }
927  } catch (std::exception&) {
928  QwDebug << "No detector in region 1, back plane, package up." << QwLog::endl;
929  }
930 
931 
932  if (fEnableR2Hits &&
935 
936  // Region 2 front chambers (x,u,v,x',u',v')
937  QwDebug << "Processing Region2_ChamberFront_WirePlane1: "
939 
940  try {
941  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
942  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(0);
943  for (int i1 = 0; i1 < fRegion2_ChamberFront_WirePlane1_NbOfHits && i1 < VECTOR_SIZE; i1++) {
944 
945  // Check if right package
948  continue;
949 
950  //double xLocalMC = fRegion2_ChamberFront_WirePlane1_PlaneLocalPositionX.at(i1);
951  //double yLocalMC = fRegion2_ChamberFront_WirePlane1_PlaneLocalPositionY.at(i1);
954  //double zGlobalMC = fRegion2_ChamberFront_WirePlane1_PlaneGlobalPositionZ.at(i1);
955 
956  // Convert global x-y to local x-y
957  double originX = detectorinfo->GetXPosition();
958  double originY = detectorinfo->GetYPosition();
959  //double originZ = detectorinfo->GetZPosition();
960  int octant = detectorinfo->GetOctant();
961 
962  // std::cout<<"\nHDC front #1, octant: "<<detectorinfo->GetOctant()<<"\n";
963  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
964  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
965  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
966 
967  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
968  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
969 
970  // Create the hit
971  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
972  if (hit) {
973  // Set the hit number
974  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
975  // Add the hit to the hit list (it is copied) and delete local instance
976  hitlist->push_back(*hit);
977  delete hit;
978  }
979  }
980  }
981  } catch (std::exception&) {
982  QwVerbose << "No detector in region 2, front plane 1." << QwLog::endl;
983  }
984 
985  QwDebug << "Processing Region2_ChamberFront_WirePlane2: "
987  try {
988  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
989  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(1);
990  for (int i1 = 0; i1 < fRegion2_ChamberFront_WirePlane2_NbOfHits && i1 < VECTOR_SIZE; i1++) {
991 
992  // Check if right package
995  continue;
996 
997  //double xLocalMC = fRegion2_ChamberFront_WirePlane2_PlaneLocalPositionX.at(i1);
998  //double yLocalMC = fRegion2_ChamberFront_WirePlane2_PlaneLocalPositionY.at(i1);
1001  //double zGlobalMC = fRegion2_ChamberFront_WirePlane2_PlaneGlobalPositionZ.at(i1);
1002 
1003  // Convert global x-y to local x-y
1004  double originX = detectorinfo->GetXPosition();
1005  double originY = detectorinfo->GetYPosition();
1006  //double originZ = detectorinfo->GetZPosition();
1007  int octant = detectorinfo->GetOctant();
1008 
1009  // std::cout<<"\nHDC front #2, octant: "<<detectorinfo->GetOctant()<<"\n";
1010  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1011  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1012  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1013 
1014  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1015  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1016 
1017  // Create the hit
1018  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1019  if (hit) {
1020  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1021  hitlist->push_back(*hit);
1022  delete hit;
1023  }
1024  }
1025  }
1026  } catch (std::exception&) {
1027  QwVerbose << "No detector in region 2, front plane 2." << QwLog::endl;
1028  }
1029 
1030  QwDebug << "Processing Region2_ChamberFront_WirePlane3: "
1032  try {
1033  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1034  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(2);
1035  for (int i1 = 0; i1 < fRegion2_ChamberFront_WirePlane3_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1036 
1037  // Check if right package
1040  continue;
1041 
1042  //double xLocalMC = fRegion2_ChamberFront_WirePlane3_PlaneLocalPositionX.at(i1);
1043  //double yLocalMC = fRegion2_ChamberFront_WirePlane3_PlaneLocalPositionY.at(i1);
1046  //double zGlobalMC = fRegion2_ChamberFront_WirePlane3_PlaneGlobalPositionZ.at(i1);
1047 
1048  // Convert global x-y to local x-y
1049  double originX = detectorinfo->GetXPosition();
1050  double originY = detectorinfo->GetYPosition();
1051  //double originZ = detectorinfo->GetZPosition();
1052  int octant = detectorinfo->GetOctant();
1053 
1054  // std::cout<<"\nHDC front #3, octant: "<<detectorinfo->GetOctant()<<"\n";
1055  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1056  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1057  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1058 
1059  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1060  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1061 
1062  // Create the hit
1063  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1064  if (hit) {
1065  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1066  hitlist->push_back(*hit);
1067  delete hit;
1068  }
1069  }
1070  }
1071  } catch (std::exception&) {
1072  QwVerbose << "No detector in region 2, front plane 3." << QwLog::endl;
1073  }
1074 
1075  QwDebug << "Processing Region2_ChamberFront_WirePlane4: "
1077  try {
1078  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1079  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(3);
1080  for (int i1 = 0; i1 < fRegion2_ChamberFront_WirePlane4_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1081 
1082  // Check if right package
1085  continue;
1086 
1087  //double xLocalMC = fRegion2_ChamberFront_WirePlane4_PlaneLocalPositionX.at(i1);
1088  //double yLocalMC = fRegion2_ChamberFront_WirePlane4_PlaneLocalPositionY.at(i1);
1091  //double zGlobalMC = fRegion2_ChamberFront_WirePlane4_PlaneGlobalPositionZ.at(i1);
1092 
1093  // Convert global x-y to local x-y
1094  double originX = detectorinfo->GetXPosition();
1095  double originY = detectorinfo->GetYPosition();
1096  //double originZ = detectorinfo->GetZPosition();
1097  int octant = detectorinfo->GetOctant();
1098 
1099  // std::cout<<"\nHDC front #4, octant: "<<detectorinfo->GetOctant()<<"\n";
1100  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1101  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1102  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1103 
1104  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1105  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1106 
1107  // Create the hit
1108  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1109  if (hit) {
1110  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1111  hitlist->push_back(*hit);
1112  delete hit;
1113  }
1114  }
1115  }
1116  } catch (std::exception&) {
1117  QwVerbose << "No detector in region 2, front plane 4." << QwLog::endl;
1118  }
1119 
1120  QwDebug << "Processing Region2_ChamberFront_WirePlane5: "
1122  try {
1123  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1124  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(4);
1125  for (int i1 = 0; i1 < fRegion2_ChamberFront_WirePlane5_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1126 
1127  // Check if right package
1130  continue;
1131 
1132  //double xLocalMC = fRegion2_ChamberFront_WirePlane5_PlaneLocalPositionX.at(i1);
1133  //double yLocalMC = fRegion2_ChamberFront_WirePlane5_PlaneLocalPositionY.at(i1);
1136  //double zGlobalMC = fRegion2_ChamberFront_WirePlane5_PlaneGlobalPositionZ.at(i1);
1137 
1138  // Convert global x-y to local x-y
1139  double originX = detectorinfo->GetXPosition();
1140  double originY = detectorinfo->GetYPosition();
1141  //double originZ = detectorinfo->GetZPosition();
1142  int octant = detectorinfo->GetOctant();
1143 
1144  // std::cout<<"\nHDC front #5, octant: "<<detectorinfo->GetOctant()<<"\n";
1145  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1146  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1147  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1148 
1149  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1150  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1151 
1152  // Create the hit
1153  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1154  if (hit) {
1155  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1156  hitlist->push_back(*hit);
1157  delete hit;
1158  }
1159  }
1160  }
1161  } catch (std::exception&) {
1162  QwVerbose << "No detector in region 2, front plane 5." << QwLog::endl;
1163  }
1164 
1165  QwDebug << "Processing Region2_ChamberFront_WirePlane6: "
1167  try {
1168  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1169  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(5);
1170  for (int i1 = 0; i1 < fRegion2_ChamberFront_WirePlane6_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1171 
1172  // Check if right package
1175  continue;
1176 
1177  //double xLocalMC = fRegion2_ChamberFront_WirePlane6_PlaneLocalPositionX.at(i1);
1178  //double yLocalMC = fRegion2_ChamberFront_WirePlane6_PlaneLocalPositionY.at(i1);
1181  //double zGlobalMC = fRegion2_ChamberFront_WirePlane6_PlaneGlobalPositionZ.at(i1);
1182 
1183  // Convert global x-y to local x-y
1184  double originX = detectorinfo->GetXPosition();
1185  double originY = detectorinfo->GetYPosition();
1186  //double originZ = detectorinfo->GetZPosition();
1187  int octant = detectorinfo->GetOctant();
1188 
1189  // std::cout<<"\nHDC front #6, octant: "<<detectorinfo->GetOctant()<<"\n";
1190  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1191  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1192  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1193 
1194  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1195  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1196 
1197  // Create the hit
1198  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1199  if (hit) {
1200  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1201  hitlist->push_back(*hit);
1202  delete hit;
1203  }
1204  }
1205  }
1206  } catch (std::exception&) {
1207  QwVerbose << "No detector in region 2, front plane 6." << QwLog::endl;
1208  }
1209 
1210  // Region 2 back chambers (x,u,v,x',u',v')
1211  QwDebug << "Processing Region2_ChamberBack_WirePlane1: "
1213  try {
1214  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1215  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(6);
1216  for (int i1 = 0; i1 < fRegion2_ChamberBack_WirePlane1_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1217 
1218  // Check if right package
1221  continue;
1222 
1223  //double xLocalMC = fRegion2_ChamberBack_WirePlane1_PlaneLocalPositionX.at(i1);
1224  //double yLocalMC = fRegion2_ChamberBack_WirePlane1_PlaneLocalPositionY.at(i1);
1225  double xGlobalMC = fRegion2_ChamberBack_WirePlane1_PlaneGlobalPositionX.at(i1);
1226  double yGlobalMC = fRegion2_ChamberBack_WirePlane1_PlaneGlobalPositionY.at(i1);
1227  //double zGlobalMC = fRegion2_ChamberBack_WirePlane1_PlaneGlobalPositionZ.at(i1);
1228 
1229  // Convert global x-y to local x-y
1230  double originX = detectorinfo->GetXPosition();
1231  double originY = detectorinfo->GetYPosition();
1232  //double originZ = detectorinfo->GetZPosition();
1233  int octant = detectorinfo->GetOctant();
1234 
1235  // std::cout<<"\nHDC back #1, octant: "<<detectorinfo->GetOctant()<<"\n";
1236  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1237  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1238  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1239 
1240  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1241  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1242 
1243  // Create the hit
1244  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1245  if (hit) {
1246  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1247  hitlist->push_back(*hit);
1248  delete hit;
1249  }
1250  }
1251  }
1252  } catch (std::exception&) {
1253  QwVerbose << "No detector in region 2, back plane 1." << QwLog::endl;
1254  }
1255 
1256  QwDebug << "Processing Region2_ChamberBack_WirePlane2: "
1258  try {
1259  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1260  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(7);
1261  for (int i1 = 0; i1 < fRegion2_ChamberBack_WirePlane2_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1262 
1263  // Check if right package
1266  continue;
1267 
1268  //double xLocalMC = fRegion2_ChamberBack_WirePlane2_PlaneLocalPositionX.at(i1);
1269  //double yLocalMC = fRegion2_ChamberBack_WirePlane2_PlaneLocalPositionY.at(i1);
1270  double xGlobalMC = fRegion2_ChamberBack_WirePlane2_PlaneGlobalPositionX.at(i1);
1271  double yGlobalMC = fRegion2_ChamberBack_WirePlane2_PlaneGlobalPositionY.at(i1);
1272  //double zGlobalMC = fRegion2_ChamberBack_WirePlane2_PlaneGlobalPositionZ.at(i1);
1273 
1274  // Convert global x-y to local x-y
1275  double originX = detectorinfo->GetXPosition();
1276  double originY = detectorinfo->GetYPosition();
1277  //double originZ = detectorinfo->GetZPosition();
1278  int octant = detectorinfo->GetOctant();
1279 
1280  // std::cout<<"\nHDC back #2, octant: "<<detectorinfo->GetOctant()<<"\n";
1281  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1282  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1283  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1284 
1285  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1286  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1287 
1288  // Create the hit
1289  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1290  if (hit) {
1291  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1292  hitlist->push_back(*hit);
1293  delete hit;
1294  }
1295  }
1296  }
1297  } catch (std::exception&) {
1298  QwVerbose << "No detector in region 2, back plane 2." << QwLog::endl;
1299  }
1300 
1301  QwDebug << "Processing Region2_ChamberBack_WirePlane3: "
1303  try {
1304  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1305  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(8);
1306  for (int i1 = 0; i1 < fRegion2_ChamberBack_WirePlane3_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1307 
1308  // Check if right package
1311  continue;
1312 
1313  //double xLocalMC = fRegion2_ChamberBack_WirePlane3_PlaneLocalPositionX.at(i1);
1314  //double yLocalMC = fRegion2_ChamberBack_WirePlane3_PlaneLocalPositionY.at(i1);
1315  double xGlobalMC = fRegion2_ChamberBack_WirePlane3_PlaneGlobalPositionX.at(i1);
1316  double yGlobalMC = fRegion2_ChamberBack_WirePlane3_PlaneGlobalPositionY.at(i1);
1317  //double zGlobalMC = fRegion2_ChamberBack_WirePlane3_PlaneGlobalPositionZ.at(i1);
1318 
1319  // Convert global x-y to local x-y
1320  double originX = detectorinfo->GetXPosition();
1321  double originY = detectorinfo->GetYPosition();
1322  //double originZ = detectorinfo->GetZPosition();
1323  int octant = detectorinfo->GetOctant();
1324 
1325  // std::cout<<"\nHDC back #3, octant: "<<detectorinfo->GetOctant()<<"\n";
1326  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1327  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1328  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1329 
1330  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1331  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1332 
1333  // Create the hit
1334  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1335  if (hit) {
1336  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1337  hitlist->push_back(*hit);
1338  delete hit;
1339  }
1340  }
1341  }
1342  } catch (std::exception&) {
1343  QwVerbose << "No detector in region 2, back plane 3." << QwLog::endl;
1344  }
1345 
1346  if (is_R2WirePlane10_OK==true)
1347  {
1348  QwDebug << "Processing Region2_ChamberBack_WirePlane4: "
1350 
1351  try {
1352  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1353  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(9);
1354  for (int i1 = 0; i1 < fRegion2_ChamberBack_WirePlane4_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1355 
1356  // Check if right package
1359  continue;
1360 
1361  //double xLocalMC = fRegion2_ChamberBack_WirePlane4_PlaneLocalPositionX.at(i1);
1362  //double yLocalMC = fRegion2_ChamberBack_WirePlane4_PlaneLocalPositionY.at(i1);
1363  double xGlobalMC = fRegion2_ChamberBack_WirePlane4_PlaneGlobalPositionX.at(i1);
1364  double yGlobalMC = fRegion2_ChamberBack_WirePlane4_PlaneGlobalPositionY.at(i1);
1365  //double zGlobalMC = fRegion2_ChamberBack_WirePlane4_PlaneGlobalPositionZ.at(i1);
1366 
1367  // Convert global x-y to local x-y
1368  double originX = detectorinfo->GetXPosition();
1369  double originY = detectorinfo->GetYPosition();
1370  //double originZ = detectorinfo->GetZPosition();
1371  int octant = detectorinfo->GetOctant();
1372 
1373  // std::cout<<"\nHDC back #4, octant: "<<detectorinfo->GetOctant()<<"\n";
1374  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1375  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1376  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1377 
1378  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1379  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1380 
1381  // Create the hit
1382  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1383 
1385  {
1386  boost::mt19937 rng;
1387  boost::uniform_real<double> u(0, 100);
1388  static boost::variate_generator<boost::mt19937, boost::uniform_real<double> > gen(rng, u);
1389  double random_percent = gen();
1390  if( random_percent < drop_off_R2_plane10_hits )
1391  {
1392  //std::cout<<"rand()="<<random_percent<<", drop_off_R2_plane10_hits="<<drop_off_R2_plane10_hits<<std::endl;
1393  hit = 0;
1394  }
1395  }
1396 
1397  if (hit) {
1398  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1399  hitlist->push_back(*hit);
1400  delete hit;
1401  }
1402  }
1403  }
1404  } catch (std::exception&) {
1405  QwVerbose << "No detector in region 2, back plane 4." << QwLog::endl;
1406  }
1407  } // end of if (is_R2WirePlane10_OK==true)
1408 
1409  QwDebug << "Processing Region2_ChamberBack_WirePlane5: "
1411  try {
1412  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1413  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(10);
1414  for (int i1 = 0; i1 < fRegion2_ChamberBack_WirePlane5_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1415 
1416  // Check if right package
1419  continue;
1420 
1421  //double xLocalMC = fRegion2_ChamberBack_WirePlane5_PlaneLocalPositionX.at(i1);
1422  //double yLocalMC = fRegion2_ChamberBack_WirePlane5_PlaneLocalPositionY.at(i1);
1423  double xGlobalMC = fRegion2_ChamberBack_WirePlane5_PlaneGlobalPositionX.at(i1);
1424  double yGlobalMC = fRegion2_ChamberBack_WirePlane5_PlaneGlobalPositionY.at(i1);
1425  //double zGlobalMC = fRegion2_ChamberBack_WirePlane5_PlaneGlobalPositionZ.at(i1);
1426 
1427  // Convert global x-y to local x-y
1428  double originX = detectorinfo->GetXPosition();
1429  double originY = detectorinfo->GetYPosition();
1430  //double originZ = detectorinfo->GetZPosition();
1431  int octant = detectorinfo->GetOctant();
1432 
1433  // std::cout<<"\nHDC back #5, octant: "<<detectorinfo->GetOctant()<<"\n";
1434  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1435  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1436  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1437 
1438  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1439  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1440 
1441  // Create the hit
1442  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1443  if (hit) {
1444  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1445  hitlist->push_back(*hit);
1446  delete hit;
1447  }
1448  }
1449  }
1450  } catch (std::exception&) {
1451  QwVerbose << "No detector in region 2, back plane 5." << QwLog::endl;
1452  }
1453 
1454  QwDebug << "Processing Region2_ChamberBack_WirePlane6: "
1456  try {
1457  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1458  detectorinfo = fDetectorInfo.in(kRegionID2).in(package).at(11);
1459  for (int i1 = 0; i1 < fRegion2_ChamberBack_WirePlane6_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1460 
1461  // Check if right package
1464  continue;
1465 
1466  //double xLocalMC = fRegion2_ChamberBack_WirePlane6_PlaneLocalPositionX.at(i1);
1467  //double yLocalMC = fRegion2_ChamberBack_WirePlane6_PlaneLocalPositionY.at(i1);
1468  double xGlobalMC = fRegion2_ChamberBack_WirePlane6_PlaneGlobalPositionX.at(i1);
1469  double yGlobalMC = fRegion2_ChamberBack_WirePlane6_PlaneGlobalPositionY.at(i1);
1470  //double zGlobalMC = fRegion2_ChamberBack_WirePlane6_PlaneGlobalPositionZ.at(i1);
1471 
1472  // Convert global x-y to local x-y
1473  double originX = detectorinfo->GetXPosition();
1474  double originY = detectorinfo->GetYPosition();
1475  //double originZ = detectorinfo->GetZPosition();
1476  int octant = detectorinfo->GetOctant();
1477 
1478  // std::cout<<"\nHDC back #6, octant: "<<detectorinfo->GetOctant()<<"\n";
1479  // std::cout<<" origin xyz: "<<originX<<","<<originY<<","<<originZ<<"\n"
1480  // <<" local xyz: "<<xLocalMC<<","<<yLocalMC<<"\n"
1481  // <<" global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1482 
1483  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1484  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1485 
1486  // Create the hit
1487  QwHit* hit = CreateHitRegion2(detectorinfo,x,y,resolution_effects);
1488  if (hit) {
1489  if (set_hit_numbers) hit->SetHitNumber(hitcounter++);
1490  hitlist->push_back(*hit);
1491  delete hit;
1492  }
1493  }
1494  }
1495  } catch (std::exception&) {
1496  QwVerbose << "No detector in region 2, back plane 6." << QwLog::endl;
1497  }
1498 
1499  } // end of if (r2_hit)
1500 
1501  // The local reference frame in which the region 3 hits are stored in the MC
1502  // file is centered at the wire plane center, has the z axis pointing towards
1503  // the target, the y axis pointing towards the beam pipe, and the x axis to
1504  // the left for the 'up' octant to form a right-handed frame.
1505  //
1506  // This is rather different from the global reference frame which has the z
1507  // axis pointing away from the target in the downstream direction, the y axis
1508  // away from the beam pipe (vertically upwards for the 'up' octant), and the
1509  // x axis to the left for the 'up' octant to form a right-handed frame.
1510  //
1511  // In addition, of course, the local frame is tilted around the x axis such
1512  // that the axis between the local xy (wire) plane and the global z axis is
1513  // approximately 65 degrees.
1514  //
1515  // The global momentum components are used because there seems to be a problem
1516  // with the local components in the MC file. For one event the following
1517  // values are stored (wdc, 2009-12-31, event 0 in QwSim_100.root):
1518  // local global (units: cm and MeV)
1519  // x = 6.80 6.80
1520  // y = -7.65 269.7
1521  // z = -0.00 439.6
1522  // Px = 12.13 12.13
1523  // Py = -3498 441.3
1524  // Pz = -2113 1067.3
1525  // |P| = 4086.5 1155.0
1526  // (for a beam energy of 1165.0 MeV)
1527  //
1528  // Detector rotation around the x axis: the Px, Py and Pz are given in the
1529  // lab reference frame, but the local detector plane coordinate system is
1530  // rotated around the lab x axis. We need to correct the slopes for this
1531  // rotation to obtain the slope with respect to the wire plane. This means
1532  // a rotation over -theta around x for z,y.
1533 
1534  if (fEnableR3Hits &&
1537 
1538  //double originX0, originY0, originZ0;
1539  // Region 3 front planes (u,v)
1540  QwDebug << "Processing Region3_ChamberFront_WirePlaneU: "
1542  try {
1543  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1544  detectorinfo = fDetectorInfo.in(kRegionID3).in(package).at(0);
1545  for (int i1 = 0; i1 < fRegion3_ChamberFront_WirePlaneU_NbOfHits && i1 < VECTOR_SIZE; i1++) {
1546 
1547  // Check if right package
1550  continue;
1551 
1552  QwDebug << "hit in " << *detectorinfo << QwLog::endl;
1553 
1554  // We don't care about nutral particles, such as gamma and neutron
1555  int pdgcode = fRegion3_ChamberFront_WirePlaneU_ParticleType.at(i1);
1556  if (abs(pdgcode) != 11) continue;
1557 
1558  // Get the position and momentum in the MC frame (local and global)
1559  //double xLocalMC = fRegion3_ChamberFront_WirePlaneU_LocalPositionX.at(i1);
1560  //double yLocalMC = fRegion3_ChamberFront_WirePlaneU_LocalPositionY.at(i1);
1561  //double zLocalMC = fRegion3_ChamberFront_WirePlaneU_LocalPositionZ.at(i1);
1562  double xGlobalMC = fRegion3_ChamberFront_WirePlaneU_GlobalPositionX.at(i1);
1563  double yGlobalMC = fRegion3_ChamberFront_WirePlaneU_GlobalPositionY.at(i1);
1564  double zGlobalMC = fRegion3_ChamberFront_WirePlaneU_GlobalPositionZ.at(i1);
1565  double pxGlobalMC = fRegion3_ChamberFront_WirePlaneU_GlobalMomentumX.at(i1);
1566  double pyGlobalMC = fRegion3_ChamberFront_WirePlaneU_GlobalMomentumY.at(i1);
1567  double pzGlobalMC = fRegion3_ChamberFront_WirePlaneU_GlobalMomentumZ.at(i1);
1568 
1569  // Convert global x-y to local x-y
1570  double originX = detectorinfo->GetXPosition();
1571  double originY = detectorinfo->GetYPosition();
1572  double originZ = detectorinfo->GetZPosition();
1573  int octant = detectorinfo->GetOctant();
1574  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1575  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1576  double z = zGlobalMC - originZ;
1577 
1578  // Detector rotation over theta around the x axis in the MC frame
1579  double cos_theta = detectorinfo->GetDetectorPitchCos();
1580  double sin_theta = detectorinfo->GetDetectorPitchSin();
1581 
1582  double xx = cos_theta*x - sin_theta*z;
1583  double yy = y; //no change in y
1584  double zz = sin_theta*x + cos_theta*z;
1585  x = xx; y = yy; z = zz;
1586 
1587  // x = x/cos_theta;
1588  //
1589  // std::cout<<"\nVDC front U, octant: "<<detectorinfo->GetOctant()<<", ";
1590  // std::cout<<"origin xyz: "<<originX<<","<<originY<<","<<originZ
1591  // <<", local xyz: "<<xLocalMC<<","<<yLocalMC<<","<<zLocalMC
1592  // <<", global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1593  //
1594  // std::cout<<"px: "<<pxGlobalMC<<", py: "<<pyGlobalMC<<", pz: "<<pzGlobalMC <<std::endl;
1595  //
1596 
1597  // rotation to octant 1 (local)
1598  double px = pxGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1599  double py = pyGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1600  double pz = pzGlobalMC;
1601 
1602  // Rotation over theta around y in octant 1 local frame
1603  double pxLocalMC = cos_theta * px - sin_theta * pz;
1604  double pyLocalMC = py; // no change in y
1605  double pzLocalMC = sin_theta * px + cos_theta * pz;
1606 
1607  // Slopes in the Qweak frame
1608  double mx = pxLocalMC / pzLocalMC;
1609  double my = pyLocalMC / pzLocalMC;
1610 
1611  // Fill a vector with the hits for this track
1612  std::vector<QwHit> hits = CreateHitRegion3(detectorinfo,x,y,mx,my,resolution_effects);
1613 
1614  // Set the hit numbers
1615  for (size_t i = 0; i < hits.size(); i++)
1616  if (set_hit_numbers)
1617  hits[i].SetHitNumber(hitcounter++);
1618 
1619  // Append this vector of hits to the QwHitContainer.
1620  hitlist->Append(hits);
1621  }
1622  } //end of loop over packages
1623  } catch (std::exception&) {
1624  QwVerbose << "No detector in region 3, front plane 0." << QwLog::endl;
1625  }
1626 
1627  QwDebug << "Processing Region3_ChamberFront_WirePlaneV: "
1629  try {
1630  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1631  detectorinfo = fDetectorInfo.in(kRegionID3).in(package).at(1);
1632  for (int i2 = 0; i2 < fRegion3_ChamberFront_WirePlaneV_NbOfHits && i2 < VECTOR_SIZE; i2++) {
1633 
1634  // Check if right package
1637 
1638  continue;
1639 
1640  QwDebug << "hit in " << *detectorinfo << QwLog::endl;
1641 
1642  // We don't care about nutral particles, such as gamma and neytron
1643  int pdgcode = fRegion3_ChamberFront_WirePlaneV_ParticleType.at(i2);
1644  if (abs(pdgcode) != 11) continue;
1645 
1646  // Get the position and momentum in the MC frame (local and global)
1647  //double xLocalMC = fRegion3_ChamberFront_WirePlaneV_LocalPositionX.at(i2);
1648  //double yLocalMC = fRegion3_ChamberFront_WirePlaneV_LocalPositionY.at(i2);
1649  //double zLocalMC = fRegion3_ChamberFront_WirePlaneV_LocalPositionZ.at(i2);
1650  double xGlobalMC = fRegion3_ChamberFront_WirePlaneV_GlobalPositionX.at(i2);
1651  double yGlobalMC = fRegion3_ChamberFront_WirePlaneV_GlobalPositionY.at(i2);
1652  double zGlobalMC = fRegion3_ChamberFront_WirePlaneV_GlobalPositionZ.at(i2);
1653  double pxGlobalMC = fRegion3_ChamberFront_WirePlaneV_GlobalMomentumX.at(i2);
1654  double pyGlobalMC = fRegion3_ChamberFront_WirePlaneV_GlobalMomentumY.at(i2);
1655  double pzGlobalMC = fRegion3_ChamberFront_WirePlaneV_GlobalMomentumZ.at(i2);
1656 
1657  // Convert global x-y to local x-y
1658  double originX = detectorinfo->GetXPosition();
1659  double originY = detectorinfo->GetYPosition();
1660  double originZ = detectorinfo->GetZPosition();
1661  int octant = detectorinfo->GetOctant();
1662  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1663  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1664  double z = zGlobalMC - originZ;
1665 
1666  // Detector rotation over theta around the x axis in the MC frame
1667  double cos_theta = detectorinfo->GetDetectorPitchCos();
1668  double sin_theta = detectorinfo->GetDetectorPitchSin();
1669 
1670  double xx = cos_theta*x - sin_theta*z;
1671  double yy = y; //no change in y
1672  double zz = sin_theta*x + cos_theta*z;
1673  x = xx; y = yy; z = zz;
1674 
1675  // x = x/cos_theta;
1676 
1677  // std::cout<<"VDC front V, octant: "<<octant <<", ";
1678  // std::cout<<"origin xyz: "<<originX<<","<<originY<<","<<originZ
1679  // <<", local xyz: "<<xLocalMC<<","<<yLocalMC<<","<<zLocalMC
1680  // <<", global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1681  //
1682  // std::cout<<"After rotation:"<<std::endl;
1683  // std::cout<<"origin xyz: "<<xGlobalToLocal(originX,originY,octant)<<","<<yGlobalToLocal(originX,originY,octant)<<","<<originZ
1684  // <<", local xyz: "<<x<<","<<y<<std::endl;
1685 
1686  // rotation to octant 1 (local)
1687  double px = pxGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1688  double py = pyGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1689  double pz = pzGlobalMC;
1690 
1691  // Rotation over theta around y in octant 1 local frame
1692  double pxLocalMC = cos_theta * px - sin_theta * pz;
1693  double pyLocalMC = py; // no change in y
1694  double pzLocalMC = sin_theta * px + cos_theta * pz;
1695 
1696  // Slopes in the Qweak frame
1697  double mx = pxLocalMC / pzLocalMC;
1698  double my = pyLocalMC / pzLocalMC;
1699 
1700  // Fill a vector with the hits for this track
1701  std::vector<QwHit> hits = CreateHitRegion3(detectorinfo,x,y,mx,my,resolution_effects);
1702 
1703  // Set the hit numbers
1704  for (size_t i = 0; i < hits.size(); i++)
1705  if (set_hit_numbers)
1706  hits[i].SetHitNumber(hitcounter++);
1707 
1708  // Append this vector of hits to the QwHitContainer.
1709  hitlist->Append(hits);
1710  }
1711  }
1712  } catch (std::exception&) {
1713  QwVerbose << "No detector in region 3, front plane 1." << QwLog::endl;
1714  }
1715 
1716  // Region 3 back planes (u',v')
1717  QwDebug << "Processing Region3_ChamberBack_WirePlaneU: "
1719  try {
1720  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1721  detectorinfo = fDetectorInfo.in(kRegionID3).in(package).at(2);
1722  for (int i3 = 0; i3 < fRegion3_ChamberBack_WirePlaneU_NbOfHits && i3 < VECTOR_SIZE; i3++) {
1723 
1724  // Check if right package
1727  continue;
1728 
1729  QwDebug << "hit in " << *detectorinfo << QwLog::endl;
1730 
1731  // We don't care about nutral particles, such as gamma and neytron
1732  int pdgcode = fRegion3_ChamberBack_WirePlaneU_ParticleType.at(i3);
1733  if (abs(pdgcode) != 11) continue;
1734 
1735  // Get the position and momentum in the MC frame (local and global)
1736  //double xLocalMC = fRegion3_ChamberBack_WirePlaneU_LocalPositionX.at(i3);
1737  //double yLocalMC = fRegion3_ChamberBack_WirePlaneU_LocalPositionY.at(i3);
1738  //double zLocalMC = fRegion3_ChamberBack_WirePlaneU_LocalPositionZ.at(i3);
1739  double xGlobalMC = fRegion3_ChamberBack_WirePlaneU_GlobalPositionX.at(i3);
1740  double yGlobalMC = fRegion3_ChamberBack_WirePlaneU_GlobalPositionY.at(i3);
1741  double zGlobalMC = fRegion3_ChamberBack_WirePlaneU_GlobalPositionZ.at(i3);
1742  double pxGlobalMC = fRegion3_ChamberBack_WirePlaneU_GlobalMomentumX.at(i3);
1743  double pyGlobalMC = fRegion3_ChamberBack_WirePlaneU_GlobalMomentumY.at(i3);
1744  double pzGlobalMC = fRegion3_ChamberBack_WirePlaneU_GlobalMomentumZ.at(i3);
1745 
1746  // Convert global x-y to local x-y
1747  double originX = detectorinfo->GetXPosition();
1748  double originY = detectorinfo->GetYPosition();
1749  double originZ = detectorinfo->GetZPosition();
1750  int octant = detectorinfo->GetOctant();
1751  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1752  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1753  double z = zGlobalMC - originZ;
1754 
1755  // Detector rotation over theta around the x axis in the MC frame
1756  double cos_theta = detectorinfo->GetDetectorPitchCos();
1757  double sin_theta = detectorinfo->GetDetectorPitchSin();
1758 
1759  double xx = cos_theta*x - sin_theta*z;
1760  double yy = y; //no change in y
1761  double zz = sin_theta*x + cos_theta*z;
1762  x = xx; y = yy; z = zz;
1763 
1764  // x = x/cos_theta;
1765 
1766  // std::cout<<"VDC back U, octant: "<<detectorinfo->GetOctant()<<", ";
1767  // std::cout<<"origin xyz: "<<originX<<","<<originY<<","<<originZ
1768  // <<", local xyz: "<<xLocalMC<<","<<yLocalMC<<","<<zLocalMC
1769  // <<", global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1770  //
1771  // std::cout<<"After rotation:"<<std::endl;
1772  // std::cout<<"origin xyz: "<<xGlobalToLocal(originX,originY,octant)<<","<<yGlobalToLocal(originX,originY,octant)<<","<<originZ
1773  // <<", local xyz: "<<x<<","<<y<<std::endl;
1774 
1775  // rotation to octant 1 (local)
1776  double px = pxGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1777  double py = pyGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1778  double pz = pzGlobalMC;
1779 
1780  // Rotation over theta around y in octant 1 local frame
1781  double pxLocalMC = cos_theta * px - sin_theta * pz;
1782  double pyLocalMC = py; // no change in y
1783  double pzLocalMC = sin_theta * px + cos_theta * pz;
1784 
1785  // Slopes in the Qweak frame
1786  double mx = pxLocalMC / pzLocalMC;
1787  double my = pyLocalMC / pzLocalMC;
1788 
1789  // Fill a vector with the hits for this track
1790  std::vector<QwHit> hits = CreateHitRegion3(detectorinfo,x,y,mx,my,resolution_effects);
1791 
1792  // Set the hit numbers
1793  for (size_t i = 0; i < hits.size(); i++)
1794  if (set_hit_numbers)
1795  hits[i].SetHitNumber(hitcounter++);
1796 
1797  // Append this vector of hits to the QwHitContainer.
1798  hitlist->Append(hits);
1799  }
1800  } //end of loop over package
1801  } catch (std::exception&) {
1802  QwVerbose << "No detector in region 3, back plane 0." << QwLog::endl;
1803  }
1804 
1805  QwDebug << "Processing Region3_ChamberBack_WirePlaneV: "
1807  try {
1808  for (EQwDetectorPackage package = kPackage1; package <= kPackage2; package++) {
1809  detectorinfo = fDetectorInfo.in(kRegionID3).in(package).at(3);
1810  for (int i4 = 0; i4 < fRegion3_ChamberBack_WirePlaneV_NbOfHits && i4 < VECTOR_SIZE; i4++) {
1811 
1812  // Check if right package
1815  continue;
1816 
1817  QwDebug << "hit in " << *detectorinfo << QwLog::endl;
1818 
1819  // We don't care about nutral particles, such as gamma and neytron
1820  int pdgcode = fRegion3_ChamberBack_WirePlaneV_ParticleType.at(i4);
1821  if (abs(pdgcode) != 11) continue;
1822 
1823  // Get the position and momentum in the MC frame (local and global)
1824  //double xLocalMC = fRegion3_ChamberBack_WirePlaneV_LocalPositionX.at(i4);
1825  //double yLocalMC = fRegion3_ChamberBack_WirePlaneV_LocalPositionY.at(i4);
1826  //double zLocalMC = fRegion3_ChamberBack_WirePlaneV_LocalPositionZ.at(i4);
1827  double xGlobalMC = fRegion3_ChamberBack_WirePlaneV_GlobalPositionX.at(i4);
1828  double yGlobalMC = fRegion3_ChamberBack_WirePlaneV_GlobalPositionY.at(i4);
1829  double zGlobalMC = fRegion3_ChamberBack_WirePlaneV_GlobalPositionZ.at(i4);
1830  double pxGlobalMC = fRegion3_ChamberBack_WirePlaneV_GlobalMomentumX.at(i4);
1831  double pyGlobalMC = fRegion3_ChamberBack_WirePlaneV_GlobalMomentumY.at(i4);
1832  double pzGlobalMC = fRegion3_ChamberBack_WirePlaneV_GlobalMomentumZ.at(i4);
1833 
1834  // Convert global x-y to local x-y
1835  double originX = detectorinfo->GetXPosition();
1836  double originY = detectorinfo->GetYPosition();
1837  double originZ = detectorinfo->GetZPosition();
1838  int octant = detectorinfo->GetOctant();
1839  double x = xGlobalToLocal(xGlobalMC,yGlobalMC,octant) - xGlobalToLocal(originX,originY,3);
1840  double y = yGlobalToLocal(xGlobalMC,yGlobalMC,octant) - yGlobalToLocal(originX,originY,3);
1841  double z = zGlobalMC - originZ;
1842 
1843  // Detector rotation over theta around the x axis in the MC frame
1844  double cos_theta = detectorinfo->GetDetectorPitchCos();
1845  double sin_theta = detectorinfo->GetDetectorPitchSin();
1846 
1847  double xx = cos_theta*x - sin_theta*z;
1848  double yy = y; //no change in y
1849  double zz = sin_theta*x + cos_theta*z;
1850  x = xx; y = yy; z = zz;
1851 
1852  // x = x/cos_theta;
1853 
1854  //
1855  // std::cout<<"VDC back V, octant: "<<detectorinfo->GetOctant()<<", ";
1856  // std::cout<<"origin xyz: "<<originX<<","<<originY<<","<<originZ
1857  // <<", local xyz: "<<xLocalMC<<","<<yLocalMC<<","<<zLocalMC
1858  // <<", global xyz:"<<xGlobalMC<<", "<<yGlobalMC<<", "<<zGlobalMC<<std::endl;
1859  //
1860 
1861  // rotation around z-axis to octant 1 (local)
1862  double px = pxGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1863  double py = pyGlobalToLocal(pxGlobalMC, pyGlobalMC, octant);
1864  double pz = pzGlobalMC;
1865 
1866  // Rotation over theta around y in octant 1 local frame
1867  double pxLocalMC = cos_theta * px - sin_theta * pz;
1868  double pyLocalMC = py; // no change in y
1869  double pzLocalMC = sin_theta * px + cos_theta * pz;
1870 
1871  // Slopes in the Qweak frame
1872  double mx = pxLocalMC / pzLocalMC;
1873  double my = pyLocalMC / pzLocalMC;
1874 
1875  // Fill a vector with the hits for this track
1876  std::vector<QwHit> hits = CreateHitRegion3(detectorinfo,x,y,mx,my,resolution_effects);
1877 
1878  // Set the hit numbers
1879  for (size_t i = 0; i < hits.size(); i++)
1880  if (set_hit_numbers)
1881  hits[i].SetHitNumber(hitcounter++);
1882 
1883  // Append this vector of hits to the QwHitContainer.
1884  hitlist->Append(hits);
1885  }
1886  } //end of loop over packages
1887  } catch (std::exception&) {
1888  QwVerbose << "No detector in region 3, back plane 1." << QwLog::endl;
1889  }
1890 
1891  } // end of if (r3_hit)
1892 
1893  QwDebug << "Processing Trigger Scintillator: "
1895  try {
1896  detectorinfo = fDetectorInfo.in(kRegionIDTrig).in(kPackage1).at(0);
1897  for (int i = 0; i < fTriggerScintillator_Detector_NbOfHits && i < 1; i++) {
1898  QwDebug << "hit in " << *detectorinfo << QwLog::endl;
1899 
1900  // Get the position
1903 
1904  // Fill a vector with the hits for this track
1905  std::vector<QwHit> hits = CreateHitCerenkov(detectorinfo,x,y);
1906 
1907  // Set the hit numbers
1908  for (size_t hit = 0; hit < hits.size(); hit++)
1909  if (set_hit_numbers)
1910  hits[hit].SetHitNumber(hitcounter++);
1911 
1912  // Append this vector of hits to the QwHitContainer.
1913  hitlist->Append(hits);
1914  }
1915  } catch (std::exception&) {
1916  QwVerbose << "No detector in trigger scintillator." << QwLog::endl;
1917  }
1918 
1919 
1920  QwDebug << "Processing Cerenkov: "
1921  << fCerenkov_Detector_NbOfHits << " hit(s)." << QwLog::endl;
1922  try {
1923  for (int i = 0; i < fCerenkov_Detector_NbOfHits; i++) {
1924 
1925  // Choose correct detector info to get the octant
1928  QwDebug << "hit in " << *detectorinfo << QwLog::endl;
1929 
1930  // Get the position
1933 
1934  // Fill a vector with the hits for this track
1935  std::vector<QwHit> hits = CreateHitCerenkov(detectorinfo,x,y);
1936 
1937  // Set the hit numbers
1938  for (size_t hit = 0; hit < hits.size(); hit++)
1939  if (set_hit_numbers)
1940  hits[hit].SetHitNumber(hitcounter++);
1941 
1942  // Append this vector of hits to the QwHitContainer.
1943  hitlist->Append(hits);
1944  }
1945  } catch (std::exception&) {
1946  QwVerbose << "No detector in cerenkov detector." << QwLog::endl;
1947  }
1948 
1949 
1950  // Now return the final hitlist
1951  QwDebug << "Leaving QwTreeEventBuffer::GetHitList ()" << QwLog::endl;
1952  return hitlist;
1953 }
1954 
1955 
1956 /*! Region 1 hit position determination
1957 
1958  In region 1 we have the simulated position at the GEM plane in x and y
1959  coordinates. We simply transfer the x and y into r and phi, which are
1960  then transformed in the particular r and phi strips that are hit. The
1961  track resolutions in r and phi are used to determine the number of r and
1962  phi strips that are activated.
1963 
1964  @param detectorinfo Detector information
1965  @param x_local X coordinate of the track in the wire plane
1966  @param y_local Y coordinate of the track in the wire plane
1967  @param resolution_effects Flag to enable resolution smearing
1968  @return Pointer to the created hit object (needs to be deleted by caller)
1969 
1970 */
1972  const QwDetectorInfo* detectorinfo,
1973  const double x_local, const double y_local,
1974  const bool resolution_effects) const
1975 {
1976  // Detector identification
1977  EQwRegionID region = detectorinfo->GetRegion();
1978  EQwDetectorPackage package = detectorinfo->GetPackage();
1979  EQwDirectionID direction = detectorinfo->GetDirection();
1980  int octant = detectorinfo->GetOctant();
1981  int plane = detectorinfo->GetPlane();
1982  double offset = detectorinfo->GetElementOffset();
1983  double spacing = detectorinfo->GetElementSpacing();
1984  int numberofelements = detectorinfo->GetNumberOfElements();
1985 
1986  // Detector geometry
1987  double x_detector = detectorinfo->GetXPosition();
1988  double y_detector = detectorinfo->GetYPosition();
1989 
1990  // Global r,y coordinates
1991  double x = x_local + x_detector;
1992  double y = y_local + y_detector;
1993  double r = sqrt(x * x + y * y);
1994 
1995  // Create a list for the hits (will be returned)
1996  std::vector<QwHit> hits;
1997 
1998  // Determine the strip range that was hit
1999  // TODO The effects of the resolution are hard-coded and cannot be disabled. Who cares? GEMs are dead!
2000  int strip1 = 0;
2001  int strip2 = 0;
2002  switch (direction) {
2003  case kDirectionR:
2004  strip1 = (int) floor ((r - offset) / spacing) - 2;
2005  strip2 = (int) floor ((r - offset) / spacing) + 2;
2006  break;
2007  case kDirectionY:
2008  strip1 = (int) floor ((y - offset) / spacing) - 2;
2009  strip2 = (int) floor ((y - offset) / spacing) + 2;
2010  break;
2011  default:
2012  QwError << "Direction " << direction << " not handled in CreateHitRegion1!" << QwLog::endl;
2013  return hits;
2014  }
2015 
2016  // Add the hit strips to the hit list
2017  for (int strip = strip1; strip <= strip2; strip++) {
2018 
2019  // Throw out unphysical hits
2020  if (strip <= 0 || strip > numberofelements) continue;
2021 
2022  // Create a new hit
2023  QwHit* hit = new QwHit(0,0,0,0, region, package, octant, plane, direction, strip, 0);
2024  hit->SetDetectorInfo(detectorinfo);
2025 
2026  // Add hit to the list for this detector plane and delete local instance
2027  hits.push_back(*hit);
2028  delete hit;
2029  }
2030 
2031  return hits;
2032 }
2033 
2034 
2035 /*! Region 2 wire position determination
2036 
2037  In region 2 we have the simulated position at the HDC plane in x and y
2038  coordinates. We simply find the wire closest to the position of the hit
2039  after appropriately transforming x and y in u and v. The distance in the
2040  plane between the wire and the tracks is the drift distance. No hits are
2041  discarded based on drift distance.
2042 
2043  For some reason we get hits in negative wires (e.g. -1, -2) which probably
2044  indicates a mismatch in the active volumes of the detector between the
2045  Monte Carlo simulation and tracking codes. For now there is no problem
2046  yet that has led us to fix this.
2047 
2048  @param detectorinfo Detector information
2049  @param x X coordinate of the track in the wire plane
2050  @param y Y coordinate of the track in the wire plane
2051  @param resolution_effects Flag to enable resolution smearing
2052  @return Pointer to the created hit object (needs to be deleted by caller)
2053 
2054 */
2056  const QwDetectorInfo* detectorinfo,
2057  const double x, const double y,
2058  const bool resolution_effects) const
2059 {
2060 
2061  if ( drop_off_R2_hits > 0.0 && drop_off_R2_hits < 100)
2062  {
2063  boost::mt19937 rng;
2064  boost::uniform_real<double> u(0, 100);
2065  static boost::variate_generator<boost::mt19937, boost::uniform_real<double> > gen(rng, u);
2066  double random_percent = gen();
2067  if( random_percent < drop_off_R2_hits )
2068  {
2069  //std::cout<<"rand()="<<random_percent<<", drop_off_R2_hits="<<drop_off_R2_hits<<std::endl;
2070  return 0;
2071  }
2072  }
2073 
2074  // Detector identification
2075  EQwRegionID region = detectorinfo->GetRegion();
2076  EQwDetectorPackage package = detectorinfo->GetPackage();
2077  EQwDirectionID direction = detectorinfo->GetDirection();
2078  int octant = detectorinfo->GetOctant();
2079  int plane = detectorinfo->GetPlane();
2080 
2081  // Detector geometry
2082  double angle = detectorinfo->GetElementAngle();
2083  double offset = detectorinfo->GetElementOffset();
2084  double spacing = detectorinfo->GetElementSpacing();
2085 
2086  // Determine angles for U and V, but we are really only interested in the
2087  // current direction, so the other one is arbitrarily set to angleU = -angleV,
2088  // which happens to be correct for region 2 and 3 drift chambers.
2089  double angleU = 0.0, angleV = Qw::pi/2.0; // default: UV == XY
2090  if (direction == kDirectionU) { angleU = -angle; angleV = angle; }
2091  if (direction == kDirectionV) { angleU = angle; angleV = -angle; }
2092  // Ensure correct handedness
2093  if (fmod(angleU,2.0*Qw::pi) - fmod(angleV,2.0*Qw::pi) < 0.0) angleU += Qw::pi;
2094  Uv2xy uv2xy (angleU, angleV);
2095 
2096  // Make the necessary transformations for the wires.
2097  // The wire coordinate is symbolized as w.
2098  double w = 0.0;
2099  switch (direction) {
2100  case kDirectionX:
2101  // Nothing needs to be done for direction X
2102  w = x;
2103  break;
2104  case kDirectionU:
2105  w = uv2xy.xy2u (x, y);
2106  break;
2107  case kDirectionV:
2108  w = uv2xy.xy2v (x, y);
2109  break;
2110  default:
2111  QwError << "Direction " << direction << " not handled in CreateHitRegion2!" << QwLog::endl;
2112  return 0;
2113  }
2114 
2115  // The wire number 1 corresponds to w from -0.5*dx to +0.5*dx around offset.
2116  int wire = (int) floor ((w - offset) / spacing + 0.5) + 1;
2117 
2118  // Check whether this wire is physical, return null if not possible
2119  if ((wire < 1) || (wire > detectorinfo->GetNumberOfElements())){
2120  return 0;
2121  }
2122 
2123  //check whether this wire is a dead wire (plane 1, wire 18)
2124  if (is_Plane10_Wire18_OK == false && plane == 1 && wire == num_of_dead_R2_wire)
2125  {
2126  //std::cout<<"Dropped a hit on wire 18 of R2 plane 1"<<std::endl;
2127  return 0;
2128  }
2129 
2130  // Calculate the actual position of this wire
2131  double w_wire = offset + (wire - 1) * spacing;
2132 
2133  // Calculate the drift distance
2134  double mean_distance = fabs(w - w_wire);
2135  double sigma_distance = detectorinfo->GetSpatialResolution();
2136  sigma_distance = 0.03;
2137  double distance = mean_distance;
2138  // If resolution effects are enables, we override the mean value
2139  if (resolution_effects) {
2140  // Using a normal distribution we take into account the resolution
2141  // (static to avoid creating the same random number for every hit)
2142  static boost::variate_generator
2143  < boost::mt19937, boost::normal_distribution<double> >
2145  // Another absolute value to avoid negative distances
2146  distance = fabs(mean_distance + sigma_distance * normal());
2147  }
2148 
2149  // taken into account the missing drift time
2150  if(missing_drift_time != 0)
2151  {
2152  double drift_time = GetR2DriftTimeFromDistance(distance);
2153  //std::cout<<"before: dist="<<distance<<", time="<<drift_time;
2154  drift_time = drift_time - missing_drift_time;
2155  if (drift_time<0)
2156  drift_time = 0;
2157  distance = GetR2DriftDistanceFromTime(drift_time);
2158  //std::cout<<", after: dist="<<distance<<", time="<<drift_time<<std::endl;
2159  }
2160 
2161  // Create a new hit
2162  QwHit* hit = new QwHit(0,0,0,0, region, package, octant, plane, direction, wire, 0);
2163  hit->SetDetectorInfo(detectorinfo);
2164  hit->SetDriftDistance(distance);
2165  hit->SetSpatialResolution(spacing);
2166 
2167  // Efficiency of this wire
2168  double efficiency = detectorinfo->GetElementEfficiency(wire);
2169  if (efficiency < 1.0 && double(rand() % 10000) / 10000.0 > efficiency) {
2170  delete hit;
2171  hit = 0;
2172  }
2173 
2174  return hit;
2175 }
2176 
2177 
2178 /*! Region 3 wire position determination
2179 
2180  In region 3 we have the simulated position and momentum at the VDC plane,
2181  but we want to construct the wires that are hit and the distance from
2182  those wires to the track. To first approximation the drift distance can
2183  be taken transverse to the plane. We calculate the position where the
2184  track enters the VDC and the position where it exits the VDC. For each
2185  position we determine the wire that was hit. The drift distance goes
2186  linearly from abs(+D/2) to abs(-D/2). If the drift distance is above
2187  a fraction 1/3 of the thickness the hit is discarded, otherwise we have
2188  too many hits compared with the data...
2189 
2190  @param detectorinfo Detector information
2191  @param x X coordinate of the track in the wire plane
2192  @param y Y coordinate of the track in the wire plane
2193  @param mx X slope of the track through the wire plane
2194  @param my Y slope of the track through the wire plane
2195  @param resolution_effects Flag to enable resolution smearing
2196  @return Standard list of hit objects
2197 
2198 */
2200  const QwDetectorInfo* detectorinfo,
2201  const double x, const double y,
2202  const double mx, const double my,
2203  const bool resolution_effects) const
2204 {
2205  // Detector identification
2206  EQwRegionID region = detectorinfo->GetRegion();
2207  EQwDetectorPackage package = detectorinfo->GetPackage();
2208  EQwDirectionID direction = detectorinfo->GetDirection();
2209  int octant = detectorinfo->GetOctant();
2210  int plane = detectorinfo->GetPlane();
2211 
2212  // Detector geometry: wirespacing, width, central wire
2213  double angle = detectorinfo->GetElementAngle();
2214  double offset = detectorinfo->GetElementOffset();
2215  double spacing = detectorinfo->GetElementSpacing();
2216  double dz = detectorinfo->GetActiveWidthZ();
2217 
2218 
2219  // Create a list for the hits (will be returned)
2220  std::vector<QwHit> hits;
2221  // randomly drop off some hits
2222  if ( drop_off_R3_hits > 0.0 && drop_off_R3_hits < 100)
2223  {
2224  boost::mt19937 rng;
2225  boost::uniform_real<double> u(0, 100);
2226  static boost::variate_generator<boost::mt19937, boost::uniform_real<double> > gen(rng, u);
2227  double random_percent = gen();
2228  if( random_percent < drop_off_R3_hits )
2229  {
2230  //std::cout<<"rand()="<<random_percent<<", drop_off_R3_hits="<<drop_off_R3_hits<<std::endl;
2231  return hits;
2232  }
2233  }
2234 
2235  // Determine angles for U and V, but we are really only interested in the
2236  // current direction, so the other one is arbitrarily set to angleU = -angleV,
2237  // which happens to be correct for region 2 and 3 drift chambers.
2238  double angleU = 0.0, angleV = Qw::pi/2.0; // default: UV == XY
2239 
2240  if (direction == kDirectionU) { angleU = -angle; angleV = angle; }
2241  if (direction == kDirectionV) { angleU = angle; angleV = -angle; }
2242 
2243  // Ensure correct handedness
2244  // if (fmod(angleV,2.0*Qw::pi) - fmod(angleU,2.0*Qw::pi) < 0.0) angleV += Qw::pi;
2245  Uv2xy uv2xy (angleU, angleV);
2246 
2247  // Make the necessary transformations for the wires
2248  double x1 = 0.0, x2 = 0.0;
2249  switch (direction) {
2250  case kDirectionU:
2251  x1 = uv2xy.xy2u (x - mx * dz/2, y - my * dz/2);
2252  x2 = uv2xy.xy2u (x + mx * dz/2, y + my * dz/2);
2253  break;
2254  case kDirectionV:
2255  x1 = uv2xy.xy2v (x - mx * dz/2, y - my * dz/2);
2256  x2 = uv2xy.xy2v (x + mx * dz/2, y + my * dz/2);
2257  break;
2258  default:
2259  QwError << "Direction " << direction << " not handled in CreateHitRegion3!" << QwLog::endl;
2260  return hits;
2261  }
2262  // Ensure correct ordering
2263  if (x1 > x2) { double _x1 = x1; x1 = x2; x2 = _x1; }
2264  // From here we only work with the coordinate x, it is understood that for
2265  // the u and v planes this is equivalent (by virtue of the previous switch
2266  // statement) to the u and v coordinates.
2267 
2268  // We store the position where the track actually crosses the wire plane
2269  // for the calculation of the drift distances.
2270  double x0 = (x1 + x2) / 2.0;
2271 
2272  // The wire number 1 corresponds to x from -0.5*dx to +0.5*dx around offset.
2273  int wire1 = (int) floor ((x1 - offset) / spacing + 0.5) + 1;
2274  int wire2 = (int) floor ((x2 - offset) / spacing + 0.5) + 1;
2275 
2276  // Find all wire hits for this detector plane
2277  for (int wire = wire1; wire <= wire2; wire++) {
2278 
2279  // Check whether this wire is physical, skip if not possible
2280  if ((wire < 1) || (wire > detectorinfo->GetNumberOfElements())) {
2281 
2282 // std::cout<<"skiped unphysical wire "<<wire<<", where wire1="<<wire1<<", wire2="<<wire2
2283 // <<", detectorinfo->GetNumberOfElements()="<<detectorinfo->GetNumberOfElements()<<std::endl;
2284  continue;
2285  }
2286 
2287  // Calculate the actual position of this wire
2288  // NOTE: off-one-wire for pkg1 and pkg2, need check
2289  double x_wire;
2290  if (package==1)
2291  x_wire = offset + (wire - 1) * spacing;
2292  else
2293  x_wire = offset + wire * spacing;
2294 
2295  // The drift distance is just the transverse (with respect to wire plane)
2296  // distance from the wire to the track, i.e. no angular dependence is
2297  // included here (it could be done, though, mx and mz are available).
2298  double mean_distance = dz * fabs(x0 - x_wire) / (x2 - x1);
2299  double sigma_distance = detectorinfo->GetSpatialResolution();
2300  sigma_distance = 0.028;
2301  double distance = mean_distance;
2302  // If resolution effects are active, we override the mean value
2303  if (resolution_effects) {
2304  // Using a normal distribution we take into account the resolution
2305  // (static to avoid creating the same random number for every hit)
2306  static boost::variate_generator
2307  < boost::mt19937, boost::normal_distribution<double> >
2309  // Another absolute value to avoid negative distances
2310  distance = fabs(mean_distance + sigma_distance * normal());
2311  }
2312 
2313  // Skip the hit if is outside of the chamber
2314  if (distance > dz/2) {
2315  //std::cout<<"skiped a outside hit: distance ("<<distance<<") > dz/2 ("<<dz/2<<")"<<std::endl;
2316  continue;
2317  }
2318 
2319  // Create a new hit
2320  QwHit* hit = new QwHit(0,0,0,0, region, package, octant, plane, direction, wire, 0);
2321  hit->SetDriftDistance(distance);
2322  hit->SetDetectorInfo(detectorinfo);
2323 
2324 // std::cout<<"add a hit===>> region, package, octant, plane, direction, wire, distance: \n\t"
2325 // <<region<<", "<<package<<", "<<octant<<", "<<plane<<", "<<direction<<", "<<wire<<", "<<distance<<std::endl;
2326 
2327  // Efficiency of this wire
2328  double efficiency = detectorinfo->GetElementEfficiency(wire);
2329  if (efficiency == 1.0 || double(rand() % 10000) / 10000.0 < efficiency) {
2330  // Add hit to the list for this detector plane and delete local instance
2331  hits.push_back(*hit);
2332 
2333  }
2334 
2335  delete hit;
2336  }
2337 
2338  // Return the short list of hits in this VDC plane
2339  return hits;
2340 }
2341 
2342 
2343 /*! Cerenkov and trigger scintillator hit position determination
2344 
2345  @param detectorinfo Detector information
2346  @param x_local X coordinate of the track in the wire plane
2347  @param y_local Y coordinate of the track in the wire plane
2348  @return Pointer to the created hit object (needs to be deleted by caller)
2349 
2350 */
2352  const QwDetectorInfo* detectorinfo,
2353  const double x_local, const double y_local) const
2354 {
2355  // Detector identification
2356  EQwRegionID region = detectorinfo->GetRegion();
2357  EQwDetectorPackage package = detectorinfo->GetPackage();
2358  EQwDirectionID direction = detectorinfo->GetDirection();
2359  int octant = detectorinfo->GetOctant();
2360  int plane = detectorinfo->GetPlane();
2361 
2362  // Detector geometry
2363  double x_detector = detectorinfo->GetXPosition();
2364  double x_min = - detectorinfo->GetActiveWidthX() / 2.0;
2365  double x_max = detectorinfo->GetActiveWidthX() / 2.0;
2366 
2367  // Minimum and maximum yield (for hit closest and furthest away)
2368  UInt_t yield; // stored as raw data
2369  double y_min = 10.0;
2370  double y_max = 100.0;
2371 
2372  // Global x coordinates
2373  double x = x_local + x_detector;
2374 
2375  // Create a list for the hits (will be returned)
2376  std::vector<QwHit> hits;
2377 
2378  // Add the left and right hits to the hit list
2379  QwHit* hit = 0;
2380 
2381  // Calculate light yield of left hit (element 1)
2382  yield = static_cast<int>((y_max - y_min) * (x - x_min) / (x_max - x_min) * (x - x_min) / (x_max - x_min) + y_min);
2383 
2384  // Create a new hit
2385  hit = new QwHit(0,0,0,0, region, package, octant, plane, direction, 1, 0);
2386  hit->SetDetectorInfo(detectorinfo);
2387  hit->SetRawTime(yield);
2388 
2389  // Add hit to the list for this detector plane and delete local instance
2390  hits.push_back(*hit);
2391  delete hit;
2392 
2393 
2394  // Calculate light yield of right hit (element 2)
2395  yield = static_cast<int>((y_max - y_min) * (-x - x_min) / (x_max - x_min) * (-x - x_min) / (x_max - x_min) + y_min);
2396 
2397  // Create a new hit
2398  hit = new QwHit(0,0,0,0, region, package, octant, plane, direction, 2, 0);
2399  hit->SetDetectorInfo(detectorinfo);
2400  hit->SetRawTime(yield);
2401 
2402  // Add hit to the list for this detector plane and delete local instance
2403  hits.push_back(*hit);
2404  delete hit;
2405 
2406 
2407  return hits;
2408 }
2409 
2410 /**
2411  * Reserve space for the vectors of tree variables
2412  */
2414 {
2415 
2416  // Region1 WirePlane
2429 
2442 
2443  // Region2 WirePlane1
2458 
2473 
2474  // Region2 WirePlane2
2489 
2504 
2505  // Region2 WirePlane3
2520 
2535 
2536  // Region2 WirePlane4
2551 
2566 
2567  // Region2 WirePlane5
2582 
2597 
2598  // Region2 WirePlane6
2613 
2628 
2629  // Region3
2647 
2662 
2677 
2692 
2694 // fTriggerScintillator_Detector_HitLocalPositionX.reserve(VECTOR_SIZE);
2695 // fTriggerScintillator_Detector_HitLocalPositionY.reserve(VECTOR_SIZE);
2696 // fTriggerScintillator_Detector_HitLocalPositionX.reserve(VECTOR_SIZE);
2697 // fTriggerScintillator_Detector_HitLocalExitPositionY.reserve(VECTOR_SIZE);
2698 // fTriggerScintillator_Detector_HitLocalExitPositionZ.reserve(VECTOR_SIZE);
2699 // fTriggerScintillator_Detector_HitLocalExitPositionZ.reserve(VECTOR_SIZE);
2700 // fTriggerScintillator_Detector_HitGlobalPositionX.reserve(VECTOR_SIZE);
2701 // fTriggerScintillator_Detector_HitGlobalPositionY.reserve(VECTOR_SIZE);
2702 // fTriggerScintillator_Detector_HitGlobalPositionZ.reserve(VECTOR_SIZE);
2703 
2718 
2719 
2720 }
2721 
2722 /**
2723  * Clear the vectors of tree variables
2724  */
2726 {
2727 
2728  // Region1 WirePlane
2743 
2758 
2759  // Region2 WirePlane1
2775 
2792 
2793  // Region2 WirePlane2
2810 
2827 
2828  // Region2 WirePlane3
2845 
2862 
2863  // Region2 WirePlane4
2880 
2897 
2898  // Region2 WirePlane5
2915 
2932 
2933  // Region2 WirePlane6
2950 
2967 
2968  // Region3
2988 
3005 
3022 
3039 
3052 
3060 
3070 }
3071 
3072 /**
3073  * Attach the vectors of tree variables to the branches
3074  */
3076 {
3077 
3078  /// Attach to the primary branches
3079  fTree->SetBranchAddress("Primary.PrimaryQ2",
3081  fTree->SetBranchAddress("Primary.CrossSection",
3083  fTree->SetBranchAddress("Primary.CrossSectionWeight",
3085  fTree->SetBranchAddress("Primary.CrossSectionBornTotal",
3087  fTree->SetBranchAddress("Primary.CrossSectionBornInelastic",
3089  fTree->SetBranchAddress("Primary.CrossSectionBornQE",
3091  fTree->SetBranchAddress("Primary.CrossSectionRadTotal",
3093  fTree->SetBranchAddress("Primary.CrossSectionRadElastic",
3095  fTree->SetBranchAddress("Primary.CrossSectionRadQE",
3097  fTree->SetBranchAddress("Primary.CrossSectionRadDIS",
3099  fTree->SetBranchAddress("Primary.CrossSectionRadTotalIntOnly",
3101  fTree->SetBranchAddress("Primary.CrossSectionRadElasticIntOnly",
3103  fTree->SetBranchAddress("Primary.CrossSectionRadQEIntOnly",
3105  fTree->SetBranchAddress("Primary.CrossSectionRadDISIntOnly",
3107  fTree->SetBranchAddress("Primary.CrossSectionRadElasticPeak",
3109  fTree->SetBranchAddress("Primary.OriginVertexPositionX",
3111  fTree->SetBranchAddress("Primary.OriginVertexPositionY",
3113  fTree->SetBranchAddress("Primary.OriginVertexPositionZ",
3115  fTree->SetBranchAddress("Primary.OriginVertexTotalEnergy",
3117  fTree->SetBranchAddress("Primary.OriginVertexKineticEnergy",
3119  fTree->SetBranchAddress("Primary.OriginVertexMomentumDirectionX",
3121  fTree->SetBranchAddress("Primary.OriginVertexMomentumDirectionY",
3123  fTree->SetBranchAddress("Primary.OriginVertexMomentumDirectionZ",
3125 
3126  fTree->SetBranchAddress("Primary.OriginVertexThetaAngle",
3128  fTree->SetBranchAddress("Primary.PreScatteringKineticEnergy",
3130 
3131  /// Attach to the region 1 branches
3132  // Region1 WirePlane
3133  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneHasBeenHit",
3135  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.NbOfHits",
3137  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneLocalPositionX",
3139  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneLocalPositionY",
3141  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneLocalPositionZ",
3143  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneLocalMomentumX",
3145  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneLocalMomentumY",
3147  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneLocalMomentumZ",
3149  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneGlobalPositionX",
3151  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneGlobalPositionY",
3153  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneGlobalPositionZ",
3155  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneGlobalMomentumX",
3157  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneGlobalMomentumY",
3159  fTree->SetBranchAddress("Region1.ChamberFront.WirePlane.PlaneGlobalMomentumZ",
3161 
3162  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneHasBeenHit",
3164  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.NbOfHits",
3166  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneLocalPositionX",
3168  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneLocalPositionY",
3170  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneLocalPositionZ",
3172  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneLocalMomentumX",
3174  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneLocalMomentumY",
3176  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneLocalMomentumZ",
3178  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneGlobalPositionX",
3180  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneGlobalPositionY",
3182  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneGlobalPositionZ",
3184  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneGlobalMomentumX",
3186  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneGlobalMomentumY",
3188  fTree->SetBranchAddress("Region1.ChamberBack.WirePlane.PlaneGlobalMomentumZ",
3190 
3191 
3192  /// Attach to the region 2 branches
3193  // WirePlane1
3194  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneHasBeenHit",
3196  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.NbOfHits",
3198  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane1.ParticleType"))
3199  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.ParticleType",
3201  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane1.PackageID"))
3202  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PackageID",
3204  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneLocalPositionX",
3206  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneLocalPositionY",
3208  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneLocalPositionZ",
3210  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneLocalMomentumX",
3212  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneLocalMomentumY",
3214  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneLocalMomentumZ",
3216  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneGlobalPositionX",
3218  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneGlobalPositionY",
3220  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneGlobalPositionZ",
3222  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneGlobalMomentumX",
3224  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneGlobalMomentumY",
3226  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane1.PlaneGlobalMomentumZ",
3228 
3229  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneHasBeenHit",
3231  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.NbOfHits",
3233  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane1.ParticleType"))
3234  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.ParticleType",
3236  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane1.PackageID"))
3237  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PackageID",
3239  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneLocalPositionX",
3241  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneLocalPositionY",
3243  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneLocalPositionZ",
3245  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneLocalMomentumX",
3247  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneLocalMomentumY",
3249  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneLocalMomentumZ",
3251  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneGlobalPositionX",
3253  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneGlobalPositionY",
3255  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneGlobalPositionZ",
3257  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneGlobalMomentumX",
3259  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneGlobalMomentumY",
3261  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane1.PlaneGlobalMomentumZ",
3263 
3264  // WirePlane2
3265  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneHasBeenHit",
3267  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.NbOfHits",
3269  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane2.ParticleType"))
3270  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.ParticleType",
3272  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane2.PackageID"))
3273  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PackageID",
3275  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneLocalPositionX",
3277  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneLocalPositionY",
3279  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneLocalPositionZ",
3281  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneLocalMomentumX",
3283  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneLocalMomentumY",
3285  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneLocalMomentumZ",
3287  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneGlobalPositionX",
3289  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneGlobalPositionY",
3291  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneGlobalPositionZ",
3293  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneGlobalMomentumX",
3295  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneGlobalMomentumY",
3297  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane2.PlaneGlobalMomentumZ",
3299 
3300  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneHasBeenHit",
3302  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.NbOfHits",
3304  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane2.ParticleType"))
3305  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.ParticleType",
3307  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane2.PackageID"))
3308  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PackageID",
3310  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneLocalPositionX",
3312  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneLocalPositionY",
3314  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneLocalPositionZ",
3316  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneLocalMomentumX",
3318  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneLocalMomentumY",
3320  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneLocalMomentumZ",
3322  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneGlobalPositionX",
3324  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneGlobalPositionY",
3326  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneGlobalPositionZ",
3328  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneGlobalMomentumX",
3330  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneGlobalMomentumY",
3332  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane2.PlaneGlobalMomentumZ",
3334 
3335  // WirePlane3
3336  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneHasBeenHit",
3338  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.NbOfHits",
3340  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane3.ParticleType"))
3341  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.ParticleType",
3343  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane3.PackageID"))
3344  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PackageID",
3346  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneLocalPositionX",
3348  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneLocalPositionY",
3350  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneLocalPositionZ",
3352  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneLocalMomentumX",
3354  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneLocalMomentumY",
3356  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneLocalMomentumZ",
3358  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneGlobalPositionX",
3360  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneGlobalPositionY",
3362  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneGlobalPositionZ",
3364  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneGlobalMomentumX",
3366  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneGlobalMomentumY",
3368  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane3.PlaneGlobalMomentumZ",
3370 
3371  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneHasBeenHit",
3373  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.NbOfHits",
3375  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane3.ParticleType"))
3376  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.ParticleType",
3378  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane3.PackageID"))
3379  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PackageID",
3381  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneLocalPositionX",
3383  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneLocalPositionY",
3385  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneLocalPositionZ",
3387  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneLocalMomentumX",
3389  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneLocalMomentumY",
3391  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneLocalMomentumZ",
3393  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneGlobalPositionX",
3395  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneGlobalPositionY",
3397  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneGlobalPositionZ",
3399  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneGlobalMomentumX",
3401  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneGlobalMomentumY",
3403  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane3.PlaneGlobalMomentumZ",
3405 
3406  // WirePlane4
3407  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneHasBeenHit",
3409  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.NbOfHits",
3411  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane4.ParticleType"))
3412  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.ParticleType",
3414  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane4.PackageID"))
3415  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PackageID",
3417  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneLocalPositionX",
3419  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneLocalPositionY",
3421  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneLocalPositionZ",
3423  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneLocalMomentumX",
3425  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneLocalMomentumY",
3427  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneLocalMomentumZ",
3429  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneGlobalPositionX",
3431  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneGlobalPositionY",
3433  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneGlobalPositionZ",
3435  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneGlobalMomentumX",
3437  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneGlobalMomentumY",
3439  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane4.PlaneGlobalMomentumZ",
3441 
3442  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneHasBeenHit",
3444  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.NbOfHits",
3446  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane4.ParticleType"))
3447  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.ParticleType",
3449  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane4.PackageID"))
3450  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PackageID",
3452  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneLocalPositionX",
3454  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneLocalPositionY",
3456  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneLocalPositionZ",
3458  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneLocalMomentumX",
3460  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneLocalMomentumY",
3462  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneLocalMomentumZ",
3464  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneGlobalPositionX",
3466  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneGlobalPositionY",
3468  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneGlobalPositionZ",
3470  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneGlobalMomentumX",
3472  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneGlobalMomentumY",
3474  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane4.PlaneGlobalMomentumZ",
3476 
3477  // WirePlane5
3478  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneHasBeenHit",
3480  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.NbOfHits",
3482  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane5.ParticleType"))
3483  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.ParticleType",
3485  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane5.PackageID"))
3486  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PackageID",
3488  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneLocalPositionX",
3490  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneLocalPositionY",
3492  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneLocalPositionZ",
3494  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneLocalMomentumX",
3496  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneLocalMomentumY",
3498  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneLocalMomentumZ",
3500  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneGlobalPositionX",
3502  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneGlobalPositionY",
3504  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneGlobalPositionZ",
3506  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneGlobalMomentumX",
3508  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneGlobalMomentumY",
3510  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane5.PlaneGlobalMomentumZ",
3512 
3513  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneHasBeenHit",
3515  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.NbOfHits",
3517  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane5.ParticleType"))
3518  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.ParticleType",
3520  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane5.PackageID"))
3521  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PackageID",
3523  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneLocalPositionX",
3525  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneLocalPositionY",
3527  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneLocalPositionZ",
3529  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneLocalMomentumX",
3531  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneLocalMomentumY",
3533  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneLocalMomentumZ",
3535  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneGlobalPositionX",
3537  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneGlobalPositionY",
3539  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneGlobalPositionZ",
3541  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneGlobalMomentumX",
3543  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneGlobalMomentumY",
3545  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane5.PlaneGlobalMomentumZ",
3547 
3548  // WirePlane6
3549  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneHasBeenHit",
3551  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.NbOfHits",
3553  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane6.ParticleType"))
3554  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.ParticleType",
3556  if(fTree->FindLeaf("Region2.ChamberFront.WirePlane6.PackageID"))
3557  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PackageID",
3559  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneLocalPositionX",
3561  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneLocalPositionY",
3563  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneLocalPositionZ",
3565  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneLocalMomentumX",
3567  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneLocalMomentumY",
3569  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneLocalMomentumZ",
3571  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneGlobalPositionX",
3573  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneGlobalPositionY",
3575  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneGlobalPositionZ",
3577  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneGlobalMomentumX",
3579  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneGlobalMomentumY",
3581  fTree->SetBranchAddress("Region2.ChamberFront.WirePlane6.PlaneGlobalMomentumZ",
3583 
3584  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneHasBeenHit",
3586  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.NbOfHits",
3588  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane6.ParticleType"))
3589  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.ParticleType",
3591  if(fTree->FindLeaf("Region2.ChamberBack.WirePlane6.PackageID"))
3592  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PackageID",
3594  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneLocalPositionX",
3596  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneLocalPositionY",
3598  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneLocalPositionZ",
3600  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneLocalMomentumX",
3602  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneLocalMomentumY",
3604  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneLocalMomentumZ",
3606  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneGlobalPositionX",
3608  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneGlobalPositionY",
3610  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneGlobalPositionZ",
3612  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneGlobalMomentumX",
3614  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneGlobalMomentumY",
3616  fTree->SetBranchAddress("Region2.ChamberBack.WirePlane6.PlaneGlobalMomentumZ",
3618 
3619 
3620  /// Attach to the region 3 branches
3621  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.HasBeenHit",
3623  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.NbOfHits",
3625  if(fTree->FindLeaf("Region3.ChamberFront.WirePlaneU.ParticleType"))
3626  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.ParticleType",
3628  if(fTree->FindLeaf("Region3.ChamberFront.WirePlaneU.PackageID"))
3629  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.PackageID",
3631  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.LocalPositionX",
3633  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.LocalPositionY",
3635  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.LocalPositionZ",
3637  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalPositionX",
3639  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalPositionY",
3641  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalPositionZ",
3643  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.LocalMomentumX",
3645  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.LocalMomentumY",
3647  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.LocalMomentumZ",
3649  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalPositionX",
3651  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalPositionY",
3653  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalPositionZ",
3655  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalMomentumX",
3657  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalMomentumY",
3659  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneU.GlobalMomentumZ",
3661 
3662  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.HasBeenHit",
3664  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.NbOfHits",
3666  if(fTree->FindLeaf("Region3.ChamberFront.WirePlaneV.ParticleType"))
3667  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.ParticleType",
3669  if(fTree->FindLeaf("Region3.ChamberFront.WirePlaneV.PackageID"))
3670  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.PackageID",
3672  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.LocalPositionX",
3674  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.LocalPositionY",
3676  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.LocalPositionZ",
3678  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.LocalMomentumX",
3680  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.LocalMomentumY",
3682  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.LocalMomentumZ",
3684  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.GlobalPositionX",
3686  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.GlobalPositionY",
3688  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.GlobalPositionZ",
3690  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.GlobalMomentumX",
3692  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.GlobalMomentumY",
3694  fTree->SetBranchAddress("Region3.ChamberFront.WirePlaneV.GlobalMomentumZ",
3696 
3697  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.HasBeenHit",
3699  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.NbOfHits",
3701  if(fTree->FindLeaf("Region3.ChamberBack.WirePlaneU.ParticleType"))
3702  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.ParticleType",
3704  if(fTree->FindLeaf("Region3.ChamberBack.WirePlaneU.PackageID"))
3705  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.PackageID",
3707  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.LocalPositionX",
3709  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.LocalPositionY",
3711  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.LocalPositionZ",
3713  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.LocalMomentumX",
3715  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.LocalMomentumY",
3717  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.LocalMomentumZ",
3719  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.GlobalPositionX",
3721  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.GlobalPositionY",
3723  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.GlobalPositionZ",
3725  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.GlobalMomentumX",
3727  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.GlobalMomentumY",
3729  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneU.GlobalMomentumZ",
3731 
3732  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.HasBeenHit",
3734  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.NbOfHits",
3736  if(fTree->FindLeaf("Region3.ChamberBack.WirePlaneV.ParticleType"))
3737  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.ParticleType",
3739  if(fTree->FindLeaf("Region3.ChamberBack.WirePlaneV.PackageID"))
3740  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.PackageID",
3742  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.LocalPositionX",
3744  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.LocalPositionY",
3746  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.LocalPositionZ",
3748  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.LocalMomentumX",
3750  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.LocalMomentumY",
3752  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.LocalMomentumZ",
3754  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.GlobalPositionX",
3756  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.GlobalPositionY",
3758  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.GlobalPositionZ",
3760  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.GlobalMomentumX",
3762  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.GlobalMomentumY",
3764  fTree->SetBranchAddress("Region3.ChamberBack.WirePlaneV.GlobalMomentumZ",
3766 
3767 
3768  /// Attach to the trigger scintillator branches
3769  fTree->SetBranchAddress("TriggerScintillator.Detector.HasBeenHit",
3771  fTree->SetBranchAddress("TriggerScintillator.Detector.NbOfHits",
3773  if(fTree->FindLeaf("TriggerScintillator.Detector.ParticleType"))
3774  fTree->SetBranchAddress("TriggerScintillator.Detector.ParticleType",
3776  fTree->SetBranchAddress("TriggerScintillator.Detector.HitLocalPositionX",
3778  fTree->SetBranchAddress("TriggerScintillator.Detector.HitLocalPositionY",
3780  fTree->SetBranchAddress("TriggerScintillator.Detector.HitLocalPositionZ",
3782  fTree->SetBranchAddress("TriggerScintillator.Detector.HitLocalExitPositionX",
3784  fTree->SetBranchAddress("TriggerScintillator.Detector.HitLocalExitPositionY",
3786  fTree->SetBranchAddress("TriggerScintillator.Detector.HitLocalExitPositionZ",
3788  fTree->SetBranchAddress("TriggerScintillator.Detector.HitGlobalPositionX",
3790  fTree->SetBranchAddress("TriggerScintillator.Detector.HitGlobalPositionY",
3792  fTree->SetBranchAddress("TriggerScintillator.Detector.HitGlobalPositionZ",
3794 
3795 
3796  /// Attach to the cerenkov branches
3797  fTree->SetBranchAddress("Cerenkov.Detector.DetectorID",
3799  fTree->SetBranchAddress("Cerenkov.Detector.HasBeenHit",
3801  fTree->SetBranchAddress("Cerenkov.Detector.NbOfHits",
3803  if (strcmp(fTree->FindLeaf("Cerenkov.PMT.PMTTotalNbOfHits")->GetTypeName(),"vector<Int_t>") == 0)
3804  fTree->SetBranchAddress("Cerenkov.PMT.PMTTotalNbOfHits",
3806  if (strcmp(fTree->FindLeaf("Cerenkov.PMT.PMTTotalNbOfPEs")->GetTypeName(),"vector<Int_t>") == 0)
3807  fTree->SetBranchAddress("Cerenkov.PMT.PMTTotalNbOfPEs",
3809  if (strcmp(fTree->FindLeaf("Cerenkov.PMT.PMTLeftNbOfPEs")->GetTypeName(),"vector<Int_t>") == 0)
3810  fTree->SetBranchAddress("Cerenkov.PMT.PMTLeftNbOfPEs",
3812  if (strcmp(fTree->FindLeaf("Cerenkov.PMT.PMTRightNbOfPEs")->GetTypeName(),"vector<Int_t>") == 0)
3813  fTree->SetBranchAddress("Cerenkov.PMT.PMTRightNbOfPEs",
3815  fTree->SetBranchAddress("Cerenkov.Detector.HitLocalPositionX",
3817  fTree->SetBranchAddress("Cerenkov.Detector.HitLocalPositionY",
3819  fTree->SetBranchAddress("Cerenkov.Detector.HitLocalPositionZ",
3821  fTree->SetBranchAddress("Cerenkov.Detector.HitLocalExitPositionX",
3823  fTree->SetBranchAddress("Cerenkov.Detector.HitLocalExitPositionY",
3825  fTree->SetBranchAddress("Cerenkov.Detector.HitLocalExitPositionZ",
3827  fTree->SetBranchAddress("Cerenkov.Detector.HitGlobalPositionX",
3829  fTree->SetBranchAddress("Cerenkov.Detector.HitGlobalPositionY",
3831  fTree->SetBranchAddress("Cerenkov.Detector.HitGlobalPositionZ",
3833 
3834 }
3835 
3836 // Set track counters
3846 
3847 void QwTreeEventBuffer::PrintStatInfo(int r2good=0,int r3good=0, int ngoodtracks=0)
3848 {
3849  QwMessage<<"\nNumber of Geant4-simulated tracks:"<<QwLog::endl;
3850  QwMessage<<"Hit MD: "<<QwTreeEventBuffer::fNumOfSimulated_MD_Tracks<<QwLog::endl;
3851  QwMessage<<"Hit TS: "<< QwTreeEventBuffer::fNumOfSimulated_TS_Tracks<<QwLog::endl;
3852  QwMessage<<"Hit TS & MD: "<<QwTreeEventBuffer::fNumOfSimulated_TS_MD_Tracks<<QwLog::endl;
3853 
3854  QwMessage<<"Hit R2: "<<QwTreeEventBuffer::fNumOfSimulated_R2_PartialTracks<<QwLog::endl;
3855  QwMessage<<"Hit R2 & TS & MD: "<<QwTreeEventBuffer::fNumOfSimulated_R2_TS_MD_Tracks<<QwLog::endl;
3856  QwMessage<<"Hit R3: "<<QwTreeEventBuffer::fNumOfSimulated_R3_PartialTracks<<QwLog::endl;
3857  QwMessage<<"Hit R3 & TS & MD: "<<QwTreeEventBuffer::fNumOfSimulated_R3_TS_MD_Tracks<<QwLog::endl;
3858 
3859  QwMessage<<"Hit R2 & R3 & TS & MD: "<<QwTreeEventBuffer::fNumOfSimulated_ValidTracks<<"\n"<<QwLog::endl;
3860 
3861  QwMessage << "Number of good partial tracks found: "<< r2good+r3good << QwLog::endl;
3862  QwMessage << "Region 2: " << r2good << QwLog::endl;
3863  QwMessage << "Region 3: " << r3good << QwLog::endl;
3864 
3865  QwMessage << "\nNumber of bridged tracks: "<< ngoodtracks << QwLog::endl;
3866 
3867  if (QwTreeEventBuffer::fNumOfSimulated_R2_TS_MD_Tracks>0)
3868  QwMessage << "\nRegion 2 partial track finding efficiency: "
3869  << r2good<<"/"<<QwTreeEventBuffer::fNumOfSimulated_R2_TS_MD_Tracks<<" = "
3870  <<(float)r2good/QwTreeEventBuffer::fNumOfSimulated_R2_TS_MD_Tracks*100<<" \%"<<QwLog::endl;
3871  if (QwTreeEventBuffer::fNumOfSimulated_R3_TS_MD_Tracks>0)
3872  QwMessage << "Region 3 partial track finding efficiency: "
3873  << r3good<<"/"<<QwTreeEventBuffer::fNumOfSimulated_R3_TS_MD_Tracks<<" = "
3874  <<(float)r3good/QwTreeEventBuffer::fNumOfSimulated_R3_TS_MD_Tracks*100<<" \%"<<QwLog::endl;
3875 
3876  if (TMath::Min(r2good,r3good)>0)
3877  QwMessage << "Bridging efficiency: "
3878  << ngoodtracks<<"/"<<TMath::Min(r2good,r3good)<<" = "
3879  <<(float)ngoodtracks/TMath::Min(r2good,r3good)*100<<" \%"<<QwLog::endl;
3880 
3881  if (QwTreeEventBuffer::fNumOfSimulated_ValidTracks>0)
3882  QwMessage << "Overall efficiency : "
3883  << ngoodtracks<<"/"<<QwTreeEventBuffer::fNumOfSimulated_ValidTracks<<" = "
3884  <<(float)ngoodtracks/QwTreeEventBuffer::fNumOfSimulated_ValidTracks*100<<" \%\n"<<QwLog::endl;
3885 }
3886 
3888 {
3889  TString TtoD_MapFile = getenv_safe_string("QWANALYSIS")+"/Tracking/prminput/R2_TtoDTable.12164-14000.map";
3890  std::ifstream mapfile (TtoD_MapFile, std::ifstream::in);
3891 
3892  int line = 0;
3893  int time;
3894  double dist;
3895  while (line<131 && mapfile.good()) {
3896  mapfile >> time >> dist;
3897  //std::cout<<time <<"\t"<< dist<<std::endl;
3898  fDriftTimeDistance[time] = dist;
3899  line++;
3900  }
3901 
3902  mapfile.close();
3903 }
3904 
3905 // Get drift distance from drift time
3907 {
3908  int t = time-0.5; // [ns]
3909  if(t<0)
3910  t=0;
3911  if(t>=129)
3912  t=129;
3913 
3914  double dist;
3915  if (fDriftTimeDistance[t+1] > fDriftTimeDistance[t])
3916  dist = fDriftTimeDistance[t]+(fDriftTimeDistance[t+1]-fDriftTimeDistance[t])/(t+1-t)*(time-t);
3917  else
3918  dist = fDriftTimeDistance[t];
3919 
3920  return dist/10.0; // [cm]
3921 }
3922 
3923 // Get drift time from drift distance
3925 {
3926  int t;
3927 
3928  for (t=1; t<=130; t++)
3929  {
3930  if(GetR2DriftDistanceFromTime(t) > dist)
3931  break;
3932  }
3933 
3934  // interpolation
3935  double time;
3937  time=(t-1) + (dist-GetR2DriftDistanceFromTime(t-1))/(GetR2DriftDistanceFromTime(t)-GetR2DriftDistanceFromTime(t-1))*(t-(t-1));
3938  else
3939  time = t-1;
3940 
3941  return time; // [ns]
3942 }
3943 
3944 double QwTreeEventBuffer::xGlobalToLocal(double x, double y, int octant) const
3945 {
3946  double angle = (octant-1)*(-45.0*Qw::deg);
3947  return x*cos(angle)-y*sin(angle);
3948 }
3949 
3950 double QwTreeEventBuffer::yGlobalToLocal(double x, double y, int octant) const
3951 {
3952  double angle = (octant-1)*(-45.0*Qw::deg);
3953  return x*sin(angle)+y*cos(angle);
3954 }
3955 
3956 double QwTreeEventBuffer::pxGlobalToLocal(double px, double py, int octant) const
3957 {
3958  double angle = (octant-1)*(-45.0*Qw::deg);
3959  return px*cos(angle)-py*sin(angle);
3960 }
3961 
3962 double QwTreeEventBuffer::pyGlobalToLocal(double px, double py, int octant) const
3963 {
3964  double angle = (octant-1)*(-45.0*Qw::deg);
3965  return px*sin(angle)+py*cos(angle);
3966 }
3967 
void PrintStatInfo(int r2good, int r3good, int ngoodtracks)
Print statistical information.
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_GlobalMomentumZ
vector< Float_t > fCerenkov_Detector_HitLocalExitPositionY
static const double pi
Angles: base unit is radian.
Definition: QwUnits.h:102
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_LocalPositionX
Double_t fPrimaryQ2
&lt; Momentum transfer Q^2 assuming elastic scattering with hydrogen energy loss
Definition: QwEvent.h:355
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_LocalMomentumY
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneGlobalMomentumX
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneGlobalMomentumX
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneLocalPositionX
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneLocalPositionZ
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_GlobalPositionY
vector< Int_t > fRegion2_ChamberBack_WirePlane4_PackageID
Int_t fRegion2_ChamberFront_WirePlane6_NbOfHits
Int_t fRegion2_ChamberBack_WirePlane3_NbOfHits
static int fNumOfSimulated_R3_TS_MD_Tracks
Int_t fRegion3_ChamberFront_WirePlaneV_NbOfHits
Int_t fRegion3_ChamberBack_WirePlaneV_HasBeenHit
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneLocalPositionZ
Int_t fRegion2_ChamberFront_WirePlane1_NbOfHits
vector< Float_t > fCerenkov_Detector_HitLocalPositionY
int fNumberOfEntriesPerEvent
Number of entries to combine for each event (stacking)
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneLocalPositionY
double xy2u(double x, double y)
Transform from [x,y] to u.
Definition: uv2xy.cc:149
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneLocalPositionZ
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneGlobalMomentumX
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneLocalMomentumX
void AddTreeLine(const QwTreeLine *treeline)
Add an existing tree line as a copy.
Definition: QwEvent.cc:354
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_GlobalMomentumZ
Float_t fTriggerScintillator_Detector_HitGlobalPositionZ
#define QwOut
Predefined log drain for explicit output.
Definition: QwLog.h:35
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_LocalMomentumZ
Float_t fPrimary_CrossSectionRadDISIntOnly
std::vector< float > fMD_TotalNbOfPEs
Definition: QwEvent.h:330
virtual ~QwTreeEventBuffer()
Destructor.
vector< Int_t > fRegion2_ChamberFront_WirePlane6_ParticleType
static int fNumOfSimulated_R2_R3_Tracks
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneLocalPositionZ
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneLocalMomentumZ
vector< Int_t > fRegion3_ChamberBack_WirePlaneU_ParticleType
double GetDetectorPitchSin() const
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneLocalMomentumX
Float_t fPrimary_OriginVertexPositionZ
Float_t fTriggerScintillator_Detector_HitLocalExitPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneGlobalMomentumZ
#define default_bool_value(b)
Definition: QwOptions.h:51
void ReserveVectors()
Reserve space for the branch vectors.
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneGlobalPositionX
vector< Int_t > fRegion2_ChamberFront_WirePlane3_PackageID
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_GlobalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneGlobalMomentumY
std::vector< float > fMD_RightNbOfPEs
Definition: QwEvent.h:329
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneLocalMomentumY
QwHitContainer * CreateHitList(const bool resolution_effects) const
Create the hit list for this entry.
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_LocalMomentumY
double drop_off_R2_plane10_hits
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneGlobalMomentumY
static int fNumOfSimulated_TS_MD_Tracks
bool GetEntry(const unsigned int entry)
Read the specified entry from the tree.
std::vector< QwHit > CreateHitRegion1(const QwDetectorInfo *detectorinfo, const double x, const double y, const bool resolution_effects) const
Create a set of hits for one track in region 1.
static const double in
Definition: QwUnits.h:66
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneGlobalMomentumZ
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneGlobalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneLocalPositionZ
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_GlobalMomentumY
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneGlobalPositionZ
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_LocalMomentumX
const QwGeometry in(const EQwRegionID &r) const
Get detectors in given region.
Definition: QwGeometry.h:92
Int_t fRegion1_ChamberBack_WirePlane_PlaneHasBeenHit
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneGlobalPositionY
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneGlobalMomentumY
bool fEnableR2Hits
Flags.
Int_t fRegion2_ChamberFront_WirePlane4_NbOfHits
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneLocalPositionX
Float_t fPrimary_PreScatteringKineticEnergy
Float_t fTriggerScintillator_Detector_HitGlobalPositionY
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneLocalMomentumY
vector< Int_t > fRegion2_ChamberFront_WirePlane4_PackageID
double GetSpatialResolution() const
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneLocalPositionY
void AddHitContainer(const QwHitContainer *hitlist)
Add the hits in a hit container as a copy.
Definition: QwEvent.cc:322
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneGlobalMomentumY
An options class.
Definition: QwOptions.h:133
vector< Int_t > fRegion2_ChamberFront_WirePlane2_PackageID
Float_t fTriggerScintillator_Detector_HitLocalExitPositionX
int GetNumberOfEntries() const
Get the number of entries in the loaded run.
QwHit * CreateHitRegion2(const QwDetectorInfo *detectorinfo, const double x, const double y, const bool resolution_effects) const
Create a hit for one track in region 2.
const TString getenv_safe_TString(const char *name)
Definition: QwOptions.h:40
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_LocalMomentumY
TVector3 fVertexPosition
Vertex position.
Definition: QwEvent.h:342
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneLocalPositionY
Int_t fRegion2_ChamberBack_WirePlane1_NbOfHits
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneLocalPositionX
#define VECTOR_SIZE
void SetEventHeader(const QwEventHeader &eventheader)
Definition: QwEvent.h:193
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneLocalMomentumZ
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneGlobalMomentumZ
Float_t fPrimary_CrossSectionRadDIS
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneLocalMomentumY
boost::normal_distribution< double > fNormalDistribution
int GetPlane() const
void SetHitNumber(const Int_t hitcount)
Definition: QwHit.h:113
int fNumberOfEntries
Number of entries in the tree.
Contains header information of a tracked event.
Definition: QwEvent.h:37
void SetRegion(EQwRegionID region)
Set the region.
int fCurrentEventNumber
Current event number.
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneLocalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneLocalPositionX
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneLocalPositionZ
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneLocalPositionX
double fScatteringAngle
Scattering angle.
Definition: QwEvent.h:336
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneGlobalMomentumZ
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_LocalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneGlobalPositionY
QwEvent * fOriginalEvent
The original event from simulation.
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneLocalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneGlobalPositionY
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneGlobalMomentumZ
vector< Int_t > fRegion2_ChamberBack_WirePlane4_ParticleType
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneGlobalPositionZ
Float_t fPrimary_OriginVertexTotalEnergy
void ListCrossSections()
List the available cross sections.
static const double deg
Definition: QwUnits.h:106
int GetNumberOfEvents() const
Get the number of events in the run.
void LoadDriftTimeDistance()
Get drift distance from drift time or vice versa.
unsigned int OpenNextFile()
Open the next event file.
double fW2
Invariant mass squared of the recoiling target system.
Definition: QwEvent.h:138
std::vector< boost::shared_ptr< QwTreeLine > > CreateTreeLines(EQwRegionID region) const
Get the tree lines.
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneLocalMomentumX
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneGlobalPositionZ
Definition of the class that reads simulated QweakSimG4 events.
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_GlobalPositionY
double fScatteringVertexR
Scattering vertex radial distance.
Definition: QwEvent.h:338
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneGlobalPositionX
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneLocalMomentumX
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_GlobalPositionZ
QwEvent * fCurrentEvent
The event to be reconstructed.
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneGlobalMomentumY
bool is_R2WirePlane10_OK
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneLocalPositionZ
Int_t fRegion2_ChamberFront_WirePlane6_PlaneHasBeenHit
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneGlobalPositionZ
TTree * fTree
ROOT tree.
Float_t fPrimary_CrossSectionBornTotal
double fCrossSection
Definition: QwEvent.h:339
QwHitContainer * GetHitContainer() const
Get the hit list.
double GetActiveWidthY() const
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneLocalMomentumX
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_LocalPositionY
double drop_off_R2_hits
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_LocalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneLocalPositionZ
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneGlobalPositionZ
static int fNumOfSimulated_R2_TS_MD_Tracks
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneLocalPositionY
void SetNumberOfEntries(const unsigned int n)
Get the number of entries in the loaded run.
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_LocalMomentumX
EQwRegionID GetRegion() const
Int_t fRegion2_ChamberBack_WirePlane5_PlaneHasBeenHit
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneGlobalPositionX
#define QwVerbose
Predefined log drain for verbose messages.
Definition: QwLog.h:55
vector< Int_t > fRegion3_ChamberFront_WirePlaneV_PackageID
EQwDirectionID GetDirection() const
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_GlobalMomentumY
QwKinematics fKin
Inclusive scattering.
Definition: QwEvent.h:348
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneLocalPositionX
vector< Int_t > fRegion3_ChamberFront_WirePlaneU_ParticleType
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneLocalPositionY
TVector3 fVertexMomentum
Vertex momentum.
Definition: QwEvent.h:343
bool is_Plane10_Wire18_OK
Int_t fRegion2_ChamberFront_WirePlane3_NbOfHits
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneGlobalMomentumX
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneLocalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneGlobalPositionY
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneGlobalPositionX
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneLocalMomentumZ
EQwDetectorPackage
Definition: QwTypes.h:70
vector< Int_t > fRegion2_ChamberBack_WirePlane1_ParticleType
int fNumberOfEvents
Number of events in the tree (after combining entries)
Int_t fRegion2_ChamberFront_WirePlane1_PlaneHasBeenHit
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneGlobalPositionX
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneGlobalPositionY
Definition of the partial track class.
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_GlobalMomentumY
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneLocalPositionX
Int_t fRegion2_ChamberBack_WirePlane4_NbOfHits
Int_t fRegion3_ChamberBack_WirePlaneV_NbOfHits
double GetDetectorPitchCos() const
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_LocalMomentumZ
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneLocalMomentumY
Float_t fPrimary_OriginVertexMomentumDirectionZ
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneLocalPositionY
vector< Int_t > fRegion2_ChamberFront_WirePlane1_PackageID
static int fNumOfSimulated_MD_Tracks
vector< Float_t > fCerenkov_Detector_HitLocalExitPositionX
std::vector< QwHit > CreateHitRegion3(const QwDetectorInfo *detectorinfo, const double x, const double y, const double mx, const double my, const bool resolution_effects) const
Create a set of hits for one track in region 3.
double fP0
Incoming momentum .
Definition: QwEvent.h:133
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneGlobalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneLocalPositionX
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_LocalPositionX
static int fNumOfSimulated_ValidTracks
Set track counters.
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_GlobalPositionZ
int fCurrentRunNumber
Current run number.
double fDriftTimeDistance[131]
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition: QwOptions.h:164
Float_t fTriggerScintillator_Detector_HitLocalPositionX
double GetElementOffset() const
Float_t fPrimary_OriginVertexKineticEnergy
vector< Float_t > fCerenkov_PMT_PMTLeftNbOfPEs
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneLocalPositionY
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneGlobalPositionY
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneLocalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneGlobalPositionZ
vector< Float_t > fCerenkov_Detector_HitGlobalPositionX
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneGlobalPositionX
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneGlobalMomentumZ
double fQ2
Four-momentum transfer squared .
Definition: QwEvent.h:137
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneGlobalMomentumZ
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneLocalMomentumX
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneGlobalPositionX
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneGlobalPositionZ
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneGlobalPositionZ
Float_t fPrimary_CrossSectionRadQEIntOnly
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneLocalMomentumX
Int_t fTriggerScintillator_Detector_HasBeenHit
T GetValue(const std::string &key)
Get a templated value.
Definition: QwOptions.h:240
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_GlobalPositionZ
Contains a tracked event, i.e. all information from hits to tracks.
Definition: QwEvent.h:156
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneGlobalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneLocalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneGlobalMomentumX
Int_t fRegion3_ChamberBack_WirePlaneU_NbOfHits
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneLocalMomentumY
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneGlobalMomentumZ
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneGlobalMomentumY
Bool_t fTriggerScintillator_HasBeenHit
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneGlobalMomentumY
std::pair< int, int > GetIntValuePair(const std::string &key)
Get a pair of integer values.
Definition: QwOptions.cc:332
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneGlobalPositionY
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_LocalPositionZ
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_GlobalPositionX
vector< Int_t > fRegion2_ChamberBack_WirePlane3_ParticleType
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneLocalPositionX
static void DefineOptions(QwOptions &options)
Define command line and config file options.
double pyGlobalToLocal(double px, double py, int octant) const
EQwRegionID
Definition: QwTypes.h:16
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
vector< Int_t > fRegion2_ChamberFront_WirePlane5_ParticleType
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneLocalMomentumX
vector< Int_t > fRegion3_ChamberBack_WirePlaneU_PackageID
Float_t fPrimary_CrossSectionRadElasticIntOnly
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneGlobalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneLocalMomentumZ
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneGlobalPositionX
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneGlobalMomentumX
A logfile class, based on an identical class in the Hermes analyzer.
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneLocalMomentumZ
double fNu
Energy loss of the electron .
Definition: QwEvent.h:139
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneGlobalPositionY
Draft skeleton for the decoding-to-QTR interface class.
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneGlobalPositionY
void AttachBranches()
Attache the branch vectors.
vector< Float_t > fCerenkov_Detector_HitLocalExitPositionZ
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneLocalMomentumY
#define COINCIDENCE_LEVEL_OF_R3_CHARGED_HITS
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneLocalPositionY
double fPp
Outgoing momentum .
Definition: QwEvent.h:136
unsigned int OpenFile()
Open the event file.
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneLocalMomentumX
double drop_off_R3_hits
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_LocalPositionX
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneGlobalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneGlobalMomentumY
static const double GeV2
Definition: QwUnits.h:97
double fScatteringVertexZ
Scattering vertex z position.
Definition: QwEvent.h:337
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_LocalPositionY
void AddPartialTrack(const QwPartialTrack *partialtrack)
Add an existing partial track as a copy.
Definition: QwEvent.cc:442
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneLocalPositionZ
Int_t fRegion2_ChamberFront_WirePlane4_PlaneHasBeenHit
double GetElementEfficiency(int element) const
vector< Float_t > fCerenkov_Detector_HitLocalPositionX
vector< Int_t > fRegion2_ChamberBack_WirePlane5_PackageID
unsigned int GetNextEvent()
Read the next event.
boost::mt19937 fRandomnessGenerator
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneLocalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneGlobalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneLocalMomentumZ
unsigned int GetSpecificEvent(const int eventnumber)
Read the specified event.
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneGlobalPositionZ
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_LocalPositionX
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneLocalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneGlobalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneLocalMomentumX
vector< Int_t > fCerenkov_PMT_PMTTotalNbOfHits
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_LocalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneGlobalMomentumY
double GetR2DriftTimeFromDistance(double dist) const
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneGlobalMomentumZ
Float_t fPrimary_OriginVertexThetaAngle
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneGlobalMomentumZ
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneLocalPositionY
Int_t fRegion2_ChamberBack_WirePlane4_PlaneHasBeenHit
Float_t fPrimary_CrossSectionRadQE
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_GlobalPositionY
double GetR2DriftDistanceFromTime(double time) const
Int_t fRegion2_ChamberFront_WirePlane2_NbOfHits
Float_t fTriggerScintillator_Detector_HitLocalPositionY
double xGlobalToLocal(double x, double y, int octant) const
Get local coordinate from global coordinates and octant number.
double fY
Fractional energy loss .
Definition: QwEvent.h:141
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneGlobalMomentumY
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneLocalPositionX
Int_t fRegion3_ChamberFront_WirePlaneU_HasBeenHit
void SetDriftDistance(const Double_t distance)
Definition: QwHit.h:126
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneLocalPositionZ
const QwGeometry fDetectorInfo
List of detector info objects (geometry information)
double xy2v(double x, double y)
Transform from [x,y] to v.
Definition: uv2xy.cc:155
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneGlobalPositionX
double yGlobalToLocal(double x, double y, int octant) const
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_LocalPositionY
void AssignCrossSection()
Assign the correct cross section pointer.
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneLocalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneLocalPositionY
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneLocalPositionY
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneLocalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneLocalPositionX
vector< Int_t > fRegion2_ChamberBack_WirePlane5_ParticleType
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneLocalMomentumX
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneLocalPositionX
Float_t fTriggerScintillator_Detector_HitGlobalPositionX
double fOriginVertexEnergy
Definition: QwEvent.h:341
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_LocalMomentumX
Float_t fPrimary_CrossSectionRadTotal
A helper object for transformation between [u,v] and [x,y] frames.
TFile * fFile
ROOT file.
double fPreScatteringEnergy
Definition: QwEvent.h:340
Converts between (u,v) and (x,y) coordinates.
Definition: uv2xy.h:52
void SetDetectorInfo(const QwDetectorInfo *detectorinfo)
Set the detector info pointer.
std::vector< float > fMD_LeftNbOfPEs
Definition: QwEvent.h:328
vector< Float_t > fRegion2_ChamberFront_WirePlane2_PlaneGlobalMomentumX
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_GlobalMomentumY
vector< Float_t > fRegion2_ChamberFront_WirePlane5_PlaneGlobalPositionX
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_GlobalPositionY
vector< Float_t > fCerenkov_Detector_HitLocalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneGlobalPositionZ
Int_t fRegion2_ChamberFront_WirePlane5_NbOfHits
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneLocalMomentumY
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneGlobalPositionX
static const double GeV
Definition: QwUnits.h:95
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_GlobalPositionX
vector< Int_t > fRegion2_ChamberBack_WirePlane3_PackageID
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_LocalMomentumX
vector< Int_t > fRegion2_ChamberFront_WirePlane1_ParticleType
Int_t fTriggerScintillator_Detector_NbOfHits
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneGlobalMomentumX
static const double Mp
Mass of the proton.
Definition: QwUnits.h:119
#define REGION2_DETECTOR(chamber, plane, var)
double GetYPosition() const
QwHitContainer * GetHitContainer()
Get the list of hits as a hit container.
Definition: QwEvent.cc:332
vector< Int_t > fRegion2_ChamberBack_WirePlane6_ParticleType
Int_t fRegion1_ChamberFront_WirePlane_NbOfHits
vector< Int_t > fRegion2_ChamberBack_WirePlane2_ParticleType
vector< Float_t > fRegion2_ChamberFront_WirePlane4_PlaneGlobalPositionY
Float_t * fCrossSection
Cross section flags.
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneGlobalPositionX
QwTreeEventBuffer(const QwGeometry &detector_info)
Constructor with file name and spectrometer geometry.
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneGlobalPositionY
double GetActiveWidthZ() const
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
double GetElementSpacing() const
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneLocalPositionX
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneGlobalPositionY
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneGlobalPositionY
unsigned int CloseFile()
Close the event file.
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneGlobalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneGlobalMomentumX
vector< Int_t > fRegion2_ChamberFront_WirePlane4_ParticleType
std::vector< boost::shared_ptr< QwPartialTrack > > CreatePartialTracks(EQwRegionID region) const
Get the partial tracks.
Int_t fRegion2_ChamberBack_WirePlane2_PlaneHasBeenHit
#define REGION1_DETECTOR(chamber, var)
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneLocalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneGlobalMomentumY
double pxGlobalToLocal(double px, double py, int octant) const
EQwDirectionID
Definition: QwTypes.h:41
vector< Float_t > fCerenkov_PMT_PMTTotalNbOfPEs
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneLocalMomentumZ
const std::string getenv_safe_string(const char *name)
Definition: QwOptions.h:37
vector< Int_t > fRegion2_ChamberFront_WirePlane6_PackageID
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_LocalMomentumZ
Collection of QwDetectorInfo pointers that specifies an experimental geometry.
Definition: QwGeometry.h:27
Int_t fRegion2_ChamberFront_WirePlane5_PlaneHasBeenHit
Int_t fRegion2_ChamberBack_WirePlane6_NbOfHits
Float_t GetCrossSection()
Return the dereferenced cross section pointer.
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_GlobalMomentumZ
int fCurrentEntryNumber
Current entry number.
vector< Int_t > fTriggerScintillator_Detector_ParticleType
double fX
Bjorken-x scaling variable .
Definition: QwEvent.h:140
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_GlobalPositionX
static const double MeV
Definition: QwUnits.h:94
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneLocalPositionY
Int_t fRegion2_ChamberBack_WirePlane5_NbOfHits
static std::vector< string > fAvailableCrossSections
vector< Float_t > fCerenkov_Detector_HitGlobalPositionZ
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_GlobalMomentumX
Float_t fPrimary_OriginVertexPositionX
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneGlobalMomentumX
Hit structure uniquely defining each hit.
Definition: QwHit.h:43
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneGlobalMomentumX
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneGlobalMomentumY
std::pair< int, int > fEventRange
Requested event range.
Int_t fRegion2_ChamberFront_WirePlane2_PlaneHasBeenHit
vector< Float_t > fCerenkov_PMT_PMTRightNbOfPEs
Float_t fPrimary_CrossSectionRadTotalIntOnly
std::pair< int, int > fRunRange
Requested run range.
Int_t fRegion1_ChamberFront_WirePlane_PlaneHasBeenHit
#define REGION3_DETECTOR(chamber, plane, var)
double GetZPosition() const
double GetElementAngle() const
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_GlobalMomentumX
vector< Float_t > fRegion2_ChamberBack_WirePlane3_PlaneLocalPositionY
Int_t fRegion2_ChamberBack_WirePlane3_PlaneHasBeenHit
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneGlobalMomentumX
vector< Int_t > fRegion3_ChamberFront_WirePlaneV_ParticleType
static int fNumOfSimulated_TS_Tracks
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_GlobalMomentumX
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneLocalMomentumY
Float_t fPrimary_OriginVertexMomentumDirectionY
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_GlobalMomentumX
Int_t fRegion2_ChamberBack_WirePlane6_PlaneHasBeenHit
double GetXPosition() const
vector< Float_t > fRegion2_ChamberBack_WirePlane2_PlaneLocalPositionZ
vector< Int_t > fRegion2_ChamberFront_WirePlane2_ParticleType
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_GlobalPositionX
void ClearVectors()
Clear the branch vectors.
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneGlobalMomentumX
void ProcessOptions(QwOptions &options)
Process command line and config file options.
double missing_drift_time
std::vector< QwHit > CreateHitCerenkov(const QwDetectorInfo *detectorinfo, const double x, const double y) const
Create a pair of hits for one track in the cerenkov or trigger scintillator.
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneLocalMomentumX
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneLocalPositionX
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneLocalMomentumZ
vector< Float_t > fRegion2_ChamberFront_WirePlane6_PlaneLocalMomentumZ
vector< Float_t > fRegion1_ChamberFront_WirePlane_PlaneLocalMomentumX
int num_of_dead_R2_wire
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneGlobalMomentumX
vector< Int_t > fRegion3_ChamberFront_WirePlaneU_PackageID
Float_t fPrimary_CrossSectionWeight
void Append(const QwHitContainer &mylist)
vector< Float_t > fCerenkov_Detector_HitGlobalPositionY
vector< Float_t > fRegion2_ChamberBack_WirePlane4_PlaneLocalMomentumZ
vector< Int_t > fRegion3_ChamberBack_WirePlaneV_PackageID
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneGlobalMomentumY
int GetNumberOfElements() const
vector< Float_t > fRegion2_ChamberBack_WirePlane5_PlaneLocalPositionZ
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneGlobalMomentumZ
Int_t fRegion2_ChamberBack_WirePlane2_NbOfHits
void SetEntriesPerEvent(const unsigned int n)
Set the number of entries per event.
vector< Int_t > fCerenkov_Detector_DetectorID
static int fNumOfSimulated_R3_PartialTracks
vector< Float_t > fRegion2_ChamberFront_WirePlane1_PlaneLocalPositionY
vector< Int_t > fRegion2_ChamberFront_WirePlane3_ParticleType
Contains the straight part of a track in one region only.
Float_t fPrimary_OriginVertexPositionY
vector< Int_t > fRegion2_ChamberFront_WirePlane5_PackageID
Int_t fRegion2_ChamberBack_WirePlane1_PlaneHasBeenHit
Float_t fPrimary_CrossSectionRadElasticPeak
Int_t fRegion3_ChamberBack_WirePlaneU_HasBeenHit
Int_t fRegion3_ChamberFront_WirePlaneU_NbOfHits
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneLocalMomentumY
Float_t fPrimary_CrossSectionBornQE
Int_t fRegion1_ChamberBack_WirePlane_NbOfHits
Float_t fPrimary_OriginVertexMomentumDirectionX
vector< Int_t > fRegion2_ChamberBack_WirePlane6_PackageID
vector< Float_t > fRegion1_ChamberBack_WirePlane_PlaneLocalMomentumZ
vector< Float_t > fRegion3_ChamberFront_WirePlaneU_LocalPositionZ
vector< Int_t > fRegion3_ChamberBack_WirePlaneV_ParticleType
static int fNumOfSimulated_R2_PartialTracks
vector< Float_t > fRegion2_ChamberFront_WirePlane3_PlaneLocalMomentumX
vector< Float_t > fRegion3_ChamberFront_WirePlaneV_LocalPositionZ
Float_t fTriggerScintillator_Detector_HitLocalExitPositionY
Float_t fPrimary_CrossSectionRadElastic
vector< Int_t > fRegion2_ChamberBack_WirePlane2_PackageID
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneGlobalPositionY
vector< Float_t > fRegion3_ChamberBack_WirePlaneV_LocalPositionY
Int_t fRegion2_ChamberFront_WirePlane3_PlaneHasBeenHit
vector< Int_t > fRegion2_ChamberBack_WirePlane1_PackageID
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40
Float_t fPrimary_CrossSectionBornInelastic
int GetOctant() const
Float_t fTriggerScintillator_Detector_HitLocalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane1_PlaneGlobalPositionX
vector< Float_t > fRegion3_ChamberBack_WirePlaneU_GlobalPositionZ
vector< Float_t > fRegion2_ChamberBack_WirePlane6_PlaneGlobalPositionX
static const double cm
Length units: base unit is mm.
Definition: QwUnits.h:61
double GetActiveWidthX() const
Int_t fRegion3_ChamberFront_WirePlaneV_HasBeenHit