File indexing completed on 2025-08-05 08:17:38
0001 #include "g4hitshifthcal.h"
0002
0003
0004 #include <g4main/PHG4Hit.h>
0005 #include <g4main/PHG4HitContainer.h>
0006 #include <g4main/PHG4HitDefs.h> // for hit_idbits
0007
0008 #include <fun4all/Fun4AllReturnCodes.h>
0009
0010 #include <phool/PHCompositeNode.h>
0011 #include <phool/getClass.h>
0012
0013 #include <cassert>
0014 #include <sstream>
0015 #include <string>
0016
0017
0018 g4hitshifthcal::g4hitshifthcal(const std::string &name)
0019 : SubsysReco(name)
0020 {
0021 }
0022
0023
0024 int g4hitshifthcal::process_event(PHCompositeNode *topNode)
0025 {
0026 PHG4HitContainer *hitsin = findNode::getClass<PHG4HitContainer>(topNode, "G4HIT_HCALIN");
0027 if (hitsin)
0028 {
0029
0030
0031
0032 PHG4HitContainer::ConstRange hit_range = hitsin->getHits();
0033 for (PHG4HitContainer::ConstIterator hit_iter = hit_range.first; hit_iter != hit_range.second; hit_iter++)
0034 {
0035 int introw = (hit_iter->second->get_hit_id() >> PHG4HitDefs::hit_idbits);
0036
0037
0038 PHG4HitDefs::keytype original_hit_id = hit_iter->second->get_hit_id();
0039
0040
0041 PHG4HitDefs::keytype lowBits = original_hit_id & ((1ULL << PHG4HitDefs::hit_idbits) - 1);
0042 ;
0043
0044
0045 int newrow = introw + 4;
0046
0047 if (newrow >= 256)
0048 {
0049 newrow = newrow - 256;
0050 }
0051
0052 PHG4HitDefs::keytype new_hit_id = (static_cast<PHG4HitDefs::keytype>(newrow) << PHG4HitDefs::hit_idbits) | lowBits;
0053
0054 hit_iter->second->set_hit_id(new_hit_id);
0055 }
0056 }
0057
0058 PHG4HitContainer *hitsout = findNode::getClass<PHG4HitContainer>(topNode, "G4HIT_HCALOUT");
0059 if (hitsout)
0060 {
0061
0062
0063
0064 PHG4HitContainer::ConstRange hit_range = hitsout->getHits();
0065 for (PHG4HitContainer::ConstIterator hit_iter = hit_range.first; hit_iter != hit_range.second; hit_iter++)
0066 {
0067 int introw = (hit_iter->second->get_hit_id() >> PHG4HitDefs::hit_idbits);
0068
0069
0070 PHG4HitDefs::keytype original_hit_id = hit_iter->second->get_hit_id();
0071
0072
0073 PHG4HitDefs::keytype lowBits = original_hit_id & ((1ULL << PHG4HitDefs::hit_idbits) - 1);
0074
0075
0076 int newrow = introw + 5;
0077
0078 if (newrow >= 320)
0079 {
0080 newrow = newrow - 320;
0081 }
0082
0083 PHG4HitDefs::keytype new_hit_id = (static_cast<PHG4HitDefs::keytype>(newrow) << PHG4HitDefs::hit_idbits) | lowBits;
0084
0085 hit_iter->second->set_hit_id(new_hit_id);
0086 }
0087 }
0088
0089 return Fun4AllReturnCodes::EVENT_OK;
0090 }