#include #include #include using namespace std; #include "HDDM/hddm_s.h" #include "particleType.h" char *INPUT_FILE=NULL; char OUTPUT_FILE[] = "pi0.hddm"; void ParseCommandLineArguments(int narg,char *argv[]); int Str2GeantParticleID(char *str); void Usage(void); double randm(double, double); float vertex[4]={0.0, 0.0, 65.0, 65.0}; Particle_t targetType = Proton; Particle_t beamType = Gamma; #define SQR(X) ((X)*(X)) time_t now; //------------------------------- // 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=1, eventNumber=Nevents+1, nParticles=1; // Start a new event s_PhysicsEvents_t* pes; s_Reactions_t* rs; s_Target_t* ta; s_Beam_t* be; 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].target = ta = make_s_Target(); ta->type = targetType; ta->properties = make_s_Properties(); ta->properties->charge = ParticleCharge(targetType); ta->properties->mass = ParticleMass(targetType); ta->momentum = make_s_Momentum(); ta->momentum->px = 0; ta->momentum->py = 0; ta->momentum->pz = 0; ta->momentum->E = ParticleMass(targetType); rs->in[0].beam = be = make_s_Beam(); be->type = beamType; be->properties = make_s_Properties(); be->properties->charge = ParticleCharge(beamType); be->properties->mass = ParticleMass(beamType); be->momentum = make_s_Momentum(); be->momentum->px = -ta->momentum->px; be->momentum->py = -ta->momentum->py; be->momentum->pz = -ta->momentum->pz; be->momentum->E = -ta->momentum->E; 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]; if(vertex[2]vz = randm(vertex[2],vertex[3]); } else { origin->vz = vertex[2]; } for(int i=0;imult++){ int N, charge=0.0, type=7; // type=7 for pi0 char typestr[256]; float px, py, pz; (*file) >> px >> py >> pz; float mass = 0.1349766; float p2 = px*px + py*py + pz*pz; float E2 = p2 + mass*mass; float E = sqrt(E2); 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; be->momentum->px += px; be->momentum->py += py; be->momentum->pz += pz; be->momentum->E += E; } be->momentum->E = sqrt(SQR(be->properties->mass)+ SQR(be->momentum->px)+ SQR(be->momentum->py)+ SQR(be->momentum->pz) ); 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 "< vertex[3]){ cerr<<"Invalid parameter: z_min > z_max"<< endl; exit(-1); } break; case 'b': beamType = (Particle_t)Str2GeantParticleID(&ptr[1]); break; case 't': targetType = (Particle_t)Str2GeantParticleID(&ptr[1]); break; default: cerr<<"Unknown option \""<