Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
g4hitshifthcal.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file g4hitshifthcal.cc
1 #include "g4hitshifthcal.h"
2 
3 // G4Hits includes
4 #include <g4main/PHG4Hit.h>
6 #include <g4main/PHG4HitDefs.h> // for hit_idbits
7 
9 
10 #include <phool/PHCompositeNode.h>
11 #include <phool/getClass.h>
12 
13 #include <cassert>
14 #include <sstream>
15 #include <string>
16 
17 //____________________________________________________________________________..
19  : SubsysReco(name)
20 {
21 }
22 
23 //____________________________________________________________________________..
25 {
26  PHG4HitContainer *hitsin = findNode::getClass<PHG4HitContainer>(topNode, "G4HIT_HCALIN");
27  if (hitsin)
28  {
29  //-----------------------------------------------------------------------
30  // Loop over G4Hits
31  //-----------------------------------------------------------------------
32  PHG4HitContainer::ConstRange hit_range = hitsin->getHits();
33  for (PHG4HitContainer::ConstIterator hit_iter = hit_range.first; hit_iter != hit_range.second; hit_iter++)
34  {
35  int introw = (hit_iter->second->get_hit_id() >> PHG4HitDefs::hit_idbits);
36 
37  // Get the original hit_id
38  PHG4HitDefs::keytype original_hit_id = hit_iter->second->get_hit_id();
39 
40  // Get the lowBits from the original hit_id
41  PHG4HitDefs::keytype lowBits = original_hit_id & ((1ULL << PHG4HitDefs::hit_idbits) - 1);
42  ;
43 
44  // shift row up by 4
45  int newrow = introw + 4;
46 
47  if (newrow >= 256)
48  {
49  newrow = newrow - 256;
50  }
51  // Clear the high-order bits of hit_id and set them to the new value
52  PHG4HitDefs::keytype new_hit_id = (static_cast<PHG4HitDefs::keytype>(newrow) << PHG4HitDefs::hit_idbits) | lowBits;
53 
54  hit_iter->second->set_hit_id(new_hit_id);
55  }
56  }
57  // for ohcal
58  PHG4HitContainer *hitsout = findNode::getClass<PHG4HitContainer>(topNode, "G4HIT_HCALOUT");
59  if (hitsout)
60  {
61  //-----------------------------------------------------------------------
62  // Loop over G4Hits
63  //-----------------------------------------------------------------------
64  PHG4HitContainer::ConstRange hit_range = hitsout->getHits();
65  for (PHG4HitContainer::ConstIterator hit_iter = hit_range.first; hit_iter != hit_range.second; hit_iter++)
66  {
67  int introw = (hit_iter->second->get_hit_id() >> PHG4HitDefs::hit_idbits);
68 
69  // Get the original hit_id
70  PHG4HitDefs::keytype original_hit_id = hit_iter->second->get_hit_id();
71 
72  // Get the lowBits from the original hit_id
73  PHG4HitDefs::keytype lowBits = original_hit_id & ((1ULL << PHG4HitDefs::hit_idbits) - 1);
74 
75  // shift row up by 5
76  int newrow = introw + 5;
77 
78  if (newrow >= 320)
79  {
80  newrow = newrow - 320;
81  }
82  // Clear the high-order bits of hit_id and set them to the new value
83  PHG4HitDefs::keytype new_hit_id = (static_cast<PHG4HitDefs::keytype>(newrow) << PHG4HitDefs::hit_idbits) | lowBits;
84 
85  hit_iter->second->set_hit_id(new_hit_id);
86  }
87  }
88 
90 }