// $Id: mcsmear.cc 2388 2007-01-10 16:46:03Z davidl $ // // Created June 22, 2005 David Lawrence #include #include #include using namespace std; #include #include #include "HDDM/hddm_s.h" void Smear(s_HDDM_t *hddm_s); void ParseCommandLineArguments(int narg, char* argv[]); void Usage(void); void ctrlCHandle(int x); char *INFILENAME = NULL; char *OUTFILENAME = NULL; int QUIT = 0; int Nevents_to_merge=2; s_HDDM_t *merged_event=NULL; void AddEvent(s_HDDM_t *new_event); void AddCDCHits(s_HDDM_t *new_event); void AddFDCHits(s_HDDM_t *new_event); void AddThrowns(s_HDDM_t *new_event); #define _DBG_ cout<<__FILE__<<":"<<__LINE__<<" " #define _DBG__ cout<<__FILE__<<":"<<__LINE__<physicsEvents == HDDM_NULL)merged_event->physicsEvents = make_s_PhysicsEvents(1); s_HitView_t* &old_hits = merged_event->physicsEvents->in[0].hitView; s_HitView_t* &new_hits = new_event->physicsEvents->in[0].hitView; if(old_hits == HDDM_NULL)old_hits = make_s_HitView(); if(old_hits->centralDC==HDDM_NULL)old_hits->centralDC = make_s_CentralDC(); if(old_hits->centralDC->cdcStraws==HDDM_NULL)old_hits->centralDC->cdcStraws = make_s_CdcStraws(0); if(old_hits->centralDC->cdcTruthPoints==HDDM_NULL)old_hits->centralDC->cdcTruthPoints = make_s_CdcTruthPoints(0); if(new_hits->centralDC==HDDM_NULL)return; if(new_hits->centralDC->cdcStraws==HDDM_NULL)return; if(new_hits->centralDC->cdcTruthPoints==HDDM_NULL)return; s_CdcStraws_t* &old_cdcStraws = old_hits->centralDC->cdcStraws; s_CdcStraws_t* &new_cdcStraws = new_hits->centralDC->cdcStraws; s_CdcTruthPoints_t* &old_cdcTruthPoints = old_hits->centralDC->cdcTruthPoints; s_CdcTruthPoints_t* &new_cdcTruthPoints = new_hits->centralDC->cdcTruthPoints; int Nold = old_cdcStraws->mult; int Nnew = new_cdcStraws->mult; if(Nnew>0){ s_CdcStraws_t *cdcStraws = make_s_CdcStraws(Nold+Nnew); for(int i=0; iin[cdcStraws->mult++] = old_cdcStraws->in[i]; } for(int i=0; iin[cdcStraws->mult++] = new_cdcStraws->in[i]; } // Here we need to replace the new_fdcChambers structure // so when new_event is freed, the underlying structures // are not. free(new_cdcStraws); new_cdcStraws = (s_CdcStraws_t*)HDDM_NULL; free(old_cdcStraws); old_cdcStraws = cdcStraws; } Nold = old_cdcTruthPoints->mult; Nnew = new_cdcTruthPoints->mult; if(Nnew>0){ s_CdcTruthPoints_t *cdcTruthPoints = make_s_CdcTruthPoints(Nold+Nnew); for(int i=0; iin[cdcTruthPoints->mult++] = old_cdcTruthPoints->in[i]; } for(int i=0; iin[cdcTruthPoints->mult++] = new_cdcTruthPoints->in[i]; } // Here we need to replace the new_fdcChambers structure // so when new_event is freed, the underlying structures // are not. free(new_cdcTruthPoints); new_cdcTruthPoints = (s_CdcTruthPoints_t*)HDDM_NULL; free(old_cdcTruthPoints); old_cdcTruthPoints = cdcTruthPoints; } } //----------- // AddFDCHits //----------- void AddFDCHits(s_HDDM_t *new_event) { // Make sure structures exist in merged_event if(merged_event->physicsEvents == HDDM_NULL)merged_event->physicsEvents = make_s_PhysicsEvents(1); s_HitView_t* &old_hits = merged_event->physicsEvents->in[0].hitView; s_HitView_t* &new_hits = new_event->physicsEvents->in[0].hitView; if(old_hits == HDDM_NULL)old_hits = make_s_HitView(); if(old_hits->forwardDC==HDDM_NULL)old_hits->forwardDC = make_s_ForwardDC(); if(old_hits->forwardDC->fdcChambers==HDDM_NULL)old_hits->forwardDC->fdcChambers = make_s_FdcChambers(0); if(new_hits->forwardDC==HDDM_NULL)return; if(new_hits->forwardDC->fdcChambers==HDDM_NULL)return; s_FdcChambers_t* &old_fdcChambers = old_hits->forwardDC->fdcChambers; s_FdcChambers_t* &new_fdcChambers = new_hits->forwardDC->fdcChambers; int Nold = old_fdcChambers->mult; int Nnew = new_fdcChambers->mult; if(Nnew>0){ s_FdcChambers_t *fdcChambers = make_s_FdcChambers(Nold+Nnew); for(int i=0; iin[fdcChambers->mult++] = old_fdcChambers->in[i]; } for(int i=0; iin[fdcChambers->mult++] = new_fdcChambers->in[i]; } // Here we need to replace the new_fdcChambers structure // so when new_event is freed, the underlying structures // are not. free(new_fdcChambers); new_fdcChambers = (s_FdcChambers_t*)HDDM_NULL; free(old_fdcChambers); old_fdcChambers = fdcChambers; } } //----------- // AddThrowns //----------- void AddThrowns(s_HDDM_t *new_event) { // Make sure structures exist in merged_event if(merged_event->physicsEvents == HDDM_NULL)merged_event->physicsEvents = make_s_PhysicsEvents(1); s_Reactions_t* &old_reactions = merged_event->physicsEvents->in[0].reactions; s_Reactions_t* &new_reactions = new_event->physicsEvents->in[0].reactions; if(old_reactions == HDDM_NULL)old_reactions = make_s_Reactions(0); if(new_reactions==HDDM_NULL)return; int Nold = old_reactions->mult; int Nnew = new_reactions->mult; if(Nnew>0){ s_Reactions_t *reactions = make_s_Reactions(Nold+Nnew); for(int i=0; iin[reactions->mult++] = old_reactions->in[i]; } for(int i=0; iin[reactions->mult++] = new_reactions->in[i]; } // Here we need to replace the new_reactions structure // so when new_event is freed, the underlying structures // are not. free(new_reactions); new_reactions = (s_Reactions_t*)HDDM_NULL; free(old_reactions); old_reactions = reactions; } } //----------- // ParseCommandLineArguments //----------- void ParseCommandLineArguments(int narg, char* argv[]) { for(int i=1; i