/* * hitMuonDetector - registers hits for muon detector * * This is a part of the hits package for the * HDGeant simulation program for Hall D. * * version 1.0 -David Lawrence May 10, 2013 * */ #include #include #include #include #include using namespace std; extern "C" { #include #include #include "calibDB.h" } extern s_HDDM_t* thisInputEvent; static vector muonHits; /* register hits during tracking (from gustep) */ extern "C" void hitMuonDetector (float xin[4], float xout[4], float pin[5], float pout[5], float dEsum, int track, int stack, int ipart) { // Record hit at mid-point between entrance and exit s_MwpcTruthHit_t hit; hit.x = (xin[0]+xout[0])/2.0; hit.y = (xin[1]+xout[1])/2.0; hit.z = (xin[2]+xout[2])/2.0; hit.px = (pin[0]*pin[4]+pout[0]*pout[4])/2.0; hit.py = (pin[1]*pin[4]+pout[1]*pout[4])/2.0; hit.pz = (pin[2]*pin[4]+pout[2]*pout[4])/2.0; hit.t = 0.0; hit.dE = dEsum; hit.ptype = ipart; hit.track = track; hit.layer = getlayer_wrapper_(); muonHits.push_back(hit); } /* entry point from fortran */ extern "C" void hitmuondetector_(float* xin, float* xout, float* pin, float* pout, float* dEsum, int* track, int* stack, int* ipart) { hitMuonDetector(xin,xout,pin,pout,*dEsum,*track,*stack, *ipart); } /* pick and package the hits for shipping */ extern "C" s_ForwardMuonDetector_t* pickForwardMuonDetector () { unsigned int N = muonHits.size(); if(N == 0)return (s_ForwardMuonDetector_t*)HDDM_NULL; // Make HDDM structure to hold data s_ForwardMuonDetector_t *box = make_s_ForwardMuonDetector(); box->mwpcTruthHits = make_s_MwpcTruthHits((int)N); // Copy hits into HDDM structure box->mwpcTruthHits->mult = 0; for(unsigned int i=0; imwpcTruthHits->in[i] = muonHits[i]; box->mwpcTruthHits->mult++; } // reset hits container muonHits.clear(); return box; }