Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:30

0001 #pragma once
0002 /**
0003 U4HitGet.h
0004 =================
0005 
0006 See: u4/tests/U4HitTest.cc
0007 
0008 
0009 **/
0010 
0011 #include "scuda.h"
0012 #include "sphoton.h"
0013 #include "sphit.h"
0014 
0015 #include "SEvt.hh"
0016 #include "U4Hit.h"
0017 #include "U4ThreeVector.h"
0018 
0019 struct U4HitGet
0020 {
0021     static void ConvertFromPhoton(U4Hit& hit, const sphoton& global, const sphoton& local, const sphit& ht );
0022     static void FromEvt_EGPU(U4Hit& hit, unsigned idx );
0023     static void FromEvt_ECPU(U4Hit& hit, unsigned idx );
0024     static void FromEvt(U4Hit& hit, unsigned idx, int eidx );
0025 };
0026 
0027 
0028 /**
0029 U4HitGet::ConvertFromPhoton
0030 ----------------------------
0031 
0032 **/
0033 
0034 
0035 inline void U4HitGet::ConvertFromPhoton(U4Hit& hit,  const sphoton& global, const sphoton& local, const sphit& ht )
0036 {
0037     hit.zero();
0038 
0039     U4ThreeVector::FromFloat3( hit.global_position,      global.pos );
0040     U4ThreeVector::FromFloat3( hit.global_direction,     global.mom );
0041     U4ThreeVector::FromFloat3( hit.global_polarization,  global.pol );
0042 
0043     hit.time = double(global.time) ;
0044     hit.weight = 1. ;
0045     hit.wavelength = double(global.wavelength);
0046 
0047     U4ThreeVector::FromFloat3( hit.local_position,      local.pos );
0048     U4ThreeVector::FromFloat3( hit.local_direction,     local.mom );
0049     U4ThreeVector::FromFloat3( hit.local_polarization,  local.pol );
0050 
0051     hit.sensorIndex = ht.sensor_index ;
0052     hit.sensor_identifier = ht.sensor_identifier ;
0053     hit.nodeIndex = -1 ;
0054 
0055     hit.boundary = global.boundary() ;
0056     hit.photonIndex = global.get_index() ;
0057     hit.flag_mask = global.flagmask ;
0058     hit.is_cerenkov = global.is_cerenkov() ;
0059     hit.is_reemission = global.is_reemit() ;
0060 }
0061 
0062 
0063 inline void U4HitGet::FromEvt_EGPU(U4Hit& hit, unsigned idx ){ FromEvt(hit, idx, SEvt::EGPU); }
0064 inline void U4HitGet::FromEvt_ECPU(U4Hit& hit, unsigned idx ){ FromEvt(hit, idx, SEvt::ECPU); }
0065 
0066 
0067 /**
0068 U4HitGet::FromEvt
0069 ------------------
0070 
0071 HMM: this is awkward for Opticks-as-a-service as do not want to return both global and local ?
0072 Better to define a composite hit array serialization that can be formed on the server,
0073 to avoid doubling the size of hit array that needs to be returned.
0074 
0075 The Opticks-client will be receiving global hit(sphoton)
0076 from which it needs to do something like SEvt::getLocalHit
0077 to apply the appropriate transforms to get the local hit.
0078 
0079 **/
0080 
0081 inline void U4HitGet::FromEvt(U4Hit& hit, unsigned idx, int eidx )
0082 {
0083     sphoton global ;
0084     sphoton local ;
0085 
0086     SEvt* sev = SEvt::Get(eidx);
0087     sev->getHit( global, idx);    // gets *idx* item from the hit array
0088 
0089     sphit ht ;  // extra hit info, just 3 ints : iindex, sensor_identifier, sensor_index
0090     sev->getLocalHit( ht, local,  idx);
0091 
0092     ConvertFromPhoton(hit, global, local, ht );
0093 }
0094 
0095 
0096