#include #include #include using namespace std; #include "HDDM/hddm_s.h" #include "particleType.h" char *INPUT_FILE=NULL; char *OUTPUT_FILE = "output.hddm"; void ParseCommandLineArguments(int narg,char *argv[]); int Str2GeantParticleID(char *str); void Usage(void); float vertex[3]={0.0, 0.0, 65.0}; //------------------------------- // main //------------------------------- int main(int narg, char *argv[]) { ParseCommandLineArguments(narg,argv); if(!INPUT_FILE){ cerr<<"No input file!"<is_open()){ cerr<<"Unable to open file \""<eof()){ int runNumber=0, eventNumber=0, nParticles=0; (*file)>> runNumber >> eventNumber >> nParticles; if(runNumber==0 && eventNumber==0 && nParticles==0)break; // Start a new event s_PhysicsEvents_t* pes; s_Reactions_t* rs; s_Vertices_t* vs; s_Origin_t* origin; s_Products_t* ps; s_HDDM_t *thisOutputEvent = make_s_HDDM(); thisOutputEvent->physicsEvents = pes = make_s_PhysicsEvents(1); pes->mult = 1; pes->in[0].runNo = runNumber; pes->in[0].eventNo = eventNumber; pes->in[0].reactions = rs = make_s_Reactions(1); rs->mult = 1; rs->in[0].vertices = vs = make_s_Vertices(1); vs->mult = 1; vs->in[0].origin = origin = make_s_Origin(); vs->in[0].products = ps = make_s_Products(nParticles); ps->mult = 0; origin->t = 0.0; origin->vx = vertex[0]; origin->vy = vertex[1]; origin->vz = vertex[2]; for(int i=0;imult++){ int N, charge, type; char typestr[256]; float mass, px, py, pz, E; (*file)>> N >> typestr >> mass; (*file)>> charge >> px >> py >> pz >> E; type = Str2GeantParticleID(typestr); if(type<0)type = atoi(typestr); ps->in[ps->mult].type = (Particle_t)type; ps->in[ps->mult].pdgtype = 0; /* don't bother with the PDG type here */ ps->in[ps->mult].id = i+1; /* unique value for this particle within the event */ ps->in[ps->mult].parentid = 0; /* All internally generated particles have no parent */ ps->in[ps->mult].mech = 0; /* maybe this should be set to something? */ ps->in[ps->mult].momentum = make_s_Momentum(); ps->in[ps->mult].momentum->px = px; ps->in[ps->mult].momentum->py = py; ps->in[ps->mult].momentum->pz = pz; ps->in[ps->mult].momentum->E = E; } if(nParticles>0){ flush_s_HDDM(thisOutputEvent, thisOutputStream); if(eventNumber%1000 == 0)cout<<"Wrote event "<close(); // Close output file close_s_HDDM(thisOutputStream); cout<<"Processed "<