// $Id$ // // Created June 22, 2005 David Lawrence // The following flag can be used to switch from the classic mode where // the event loop is implemented in main() to a JANA based event-loop. #define USE_JANA 1 #include #include using namespace std; #include #include #include #include #include #include #if USE_JANA #include #include "MyProcessor.h" #endif #include "units.h" #include "HDDM/hddm_s.h" void Smear(s_HDDM_t *hddm_s); void ParseCommandLineArguments(int narg, char* argv[]); void Usage(void); #if ! USE_JANA void ctrlCHandleMCSmear(int x); #endif char *INFILENAME = NULL; char *OUTFILENAME = NULL; int QUIT = 0; bool ADD_NOISE = false; bool SMEAR_HITS = true; bool SMEAR_BCAL = true; bool FDC_ELOSS_OFF = false; bool IGNORE_SEEDS = false; // setup response parameters double BCAL_DARKRATE_GHZ = 0.;// 0.0176 (from calibDB BCAL/bcal_parms) for 4x4 array double BCAL_SIGMA_SIG_RELATIVE = 0.;// 0.105 (from calibDB BCAL/bcal_parms) double BCAL_SIGMA_PED_RELATIVE = 0.;// 0.139 (from calibDB BCAL/bcal_parms) double BCAL_SIPM_GAIN_VARIATION = 0.;// 0.04 (from calibDB BCAL/bcal_parms) double BCAL_XTALK_FRACT = 0.;// 0.157 (from calibDB BCAL/bcal_parms) double BCAL_INTWINDOW_NS = 0.;// 100 (from calibDB BCAL/bcal_parms) double BCAL_DEVICEPDE = 0.;// 0.21 (from calibDB BCAL/bcal_parms) double BCAL_SAMPLING_FRACT = 0.;// 0.095 (from calibDB BCAL/bcal_parms) double BCAL_PHOTONSPERSIDEPERMEV_INFIBER = 0.0;// 75 (from calibDB BCAL/bcal_parms) double BCAL_AVG_DARK_DIGI_VALS_PER_EVENT = 0.0; // 240 used to set thresholds double BCAL_SAMPLINGCOEFA = 0.0; // 0.042 (from calibDB BCAL/bcal_parms) double BCAL_SAMPLINGCOEFB = 0.0; // 0.013 (from calibDB BCAL/bcal_parms) double BCAL_TIMEDIFFCOEFA = 0.0; // 0.07 * sqrt( 2 ) (from calibDB BCAL/bcal_parms) double BCAL_TIMEDIFFCOEFB = 0.0; // 0.00 * sqrt( 2 ) (from calibDB BCAL/bcal_parms) bool NO_E_SMEAR = false; bool NO_T_SMEAR = false; bool NO_DARK_PULSES = false; bool NO_THRESHOLD_CUT = false; bool BCAL_DEBUG_HISTS = false; double FCAL_PHOT_STAT_COEF = 0.0; //0.035; double FCAL_BLOCK_THRESHOLD = 0.0; //20.0*k_MeV; double CDC_TDRIFT_SIGMA = 0.0; // 150.0/55.0*1E-9 seconds double CDC_TIME_WINDOW = 0.0; // 1000.0E-9 seconds double CDC_PEDESTAL_SIGMA = 0.0; // 0.06*k_keV double FDC_TDRIFT_SIGMA = 0.0; // 200.0/55.0*1.0E-9 seconds double FDC_CATHODE_SIGMA = 0.0; // 150.0 microns double FDC_PED_NOISE = 0.0; // in pC calculated in SmearFDC double FDC_HIT_DROP_FRACTION = 0.0; // 1000.0E-9 double FDC_TIME_WINDOW = 0.0; // 1000.0E-9 in seconds double START_SIGMA = 0.0; // 300ps double START_PHOTONS_PERMEV = 0.0; // used to be 8000 should be more like 200 // TOF parameters will be read from data base later double TOF_SIGMA = 100.*k_psec; double TOF_PHOTONS_PERMEV = 400.; #include using namespace jana; static JCalibration *jcalib=NULL; // histogram pthread_mutex_t root_mutex = PTHREAD_MUTEX_INITIALIZER; TH2F *fdc_drift_time_smear_hist; TH2F *fdc_drift_dist_smear_hist; TH2F *fdc_drift_time; TH2F *cdc_drift_time; TH1F *fdc_anode_mult; TH2F *cdc_drift_smear; //----------- // main //----------- int main(int narg,char* argv[]) { #if ! USE_JANA // Set up to catch SIGINTs for graceful exits signal(SIGINT,ctrlCHandleMCSmear); #endif ParseCommandLineArguments(narg, argv); // hist file TFile *hfile = new TFile("smear.root","RECREATE","smearing histograms"); fdc_drift_time_smear_hist=new TH2F("fdc_drift_time_smear_hist","Drift time smearing for FDC", 300,0.0,0.6,400,-200,200); fdc_drift_dist_smear_hist=new TH2F("fdc_drift_dist_smear_hist","Drift distance smearing for FDC", 100,0.0,0.6,400,-0.5,0.5); fdc_drift_time=new TH2F("fdc_drift_time","FDC drift distance vs. time",100,-20,380,100,0,1.); fdc_anode_mult = new TH1F("fdc_anode_mult","wire hit multiplicity",20,-0.5,19.5); cdc_drift_time = new TH2F("cdc_drift_time","CDC drift distance vs time",100,-20,800,100,0.,0.8); cdc_drift_smear = new TH2F("cdc_drift_smear","CDC drift smearing", 100,0.0,0.8,100,-0.8,0.8); // Create a JCalibration object using the JANA_CALIB_URL environment variable // Right now, we hardwire this to use JCalibrationFile. const char *url = getenv("JANA_CALIB_URL"); if(!url){ _DBG_<<"JANA_CALIB_URL environment not set."< tofparms; jcalib->Get("TOF/tof_parms", tofparms); TOF_SIGMA = tofparms["TOF_SIGMA"]; TOF_PHOTONS_PERMEV = tofparms["TOF_PHOTONS_PERMEV"]; } // get the BCAL parameters { cout<<"get BCAL/bcal_parms parameters from calibDB"< bcalparms; jcalib->Get("BCAL/bcal_parms", bcalparms); BCAL_DARKRATE_GHZ = bcalparms["BCAL_DARKRATE_GHZ"]; BCAL_SIGMA_SIG_RELATIVE = bcalparms["BCAL_SIGMA_SIG_RELATIVE"]; BCAL_SIGMA_PED_RELATIVE = bcalparms["BCAL_SIGMA_PED_RELATIVE"]; BCAL_SIPM_GAIN_VARIATION = bcalparms["BCAL_SIPM_GAIN_VARIATION"]; BCAL_XTALK_FRACT = bcalparms["BCAL_XTALK_FRACT"]; BCAL_INTWINDOW_NS = bcalparms["BCAL_INTWINDOW_NS"]; BCAL_DEVICEPDE = bcalparms["BCAL_DEVICEPDE"]; BCAL_SAMPLING_FRACT = bcalparms["BCAL_SAMPLING_FRACT"]; BCAL_AVG_DARK_DIGI_VALS_PER_EVENT = bcalparms["BCAL_AVG_DARK_DIGI_VALS_PER_EVENT"]; BCAL_PHOTONSPERSIDEPERMEV_INFIBER = bcalparms["BCAL_PHOTONSPERSIDEPERMEV_INFIBER"]; BCAL_SAMPLINGCOEFA = bcalparms["BCAL_SAMPLINGCOEFA"]; BCAL_SAMPLINGCOEFB = bcalparms["BCAL_SAMPLINGCOEFB"]; BCAL_TIMEDIFFCOEFA = bcalparms["BCAL_TIMEDIFFCOEFA"]; BCAL_TIMEDIFFCOEFB = bcalparms["BCAL_TIMEDIFFCOEFB"]; } { cout<<"get FCAL/fcal_parms parameters from calibDB"< fcalparms; jcalib->Get("FCAL/fcal_parms", fcalparms); if (FCAL_PHOT_STAT_COEF == 0.0) FCAL_PHOT_STAT_COEF = fcalparms["FCAL_PHOT_STAT_COEF"]; if (FCAL_BLOCK_THRESHOLD == 0.0) FCAL_BLOCK_THRESHOLD = fcalparms["FCAL_BLOCK_THRESHOLD"]; } { cout<<"get CDC/cdc_parms parameters from calibDB"< cdcparms; jcalib->Get("CDC/cdc_parms", cdcparms); if (CDC_TDRIFT_SIGMA == 0.0) CDC_TDRIFT_SIGMA = cdcparms["CDC_TDRIFT_SIGMA"]; if (CDC_TIME_WINDOW == 0.0) CDC_TIME_WINDOW = cdcparms["CDC_TIME_WINDOW"]; if (CDC_PEDESTAL_SIGMA == 0.0) CDC_PEDESTAL_SIGMA = cdcparms["CDC_PEDESTAL_SIGMA"]; } { cout<<"get FDC/fdc_parms parameters from calibDB"< fdcparms; jcalib->Get("FDC/fdc_parms", fdcparms); if (FDC_TDRIFT_SIGMA == 0.0) FDC_TDRIFT_SIGMA = fdcparms["FDC_TDRIFT_SIGMA"]; if (FDC_CATHODE_SIGMA ==0.0) FDC_CATHODE_SIGMA = fdcparms["FDC_CATHODE_SIGMA"]; FDC_PED_NOISE = fdcparms["FDC_PED_NOISE"]; if (FDC_TIME_WINDOW == 0.0) FDC_TIME_WINDOW = fdcparms["FDC_TIME_WINDOW"]; if (FDC_HIT_DROP_FRACTION == 0.0) FDC_HIT_DROP_FRACTION = fdcparms["FDC_HIT_DROP_FRACTION"]; } { cout<<"get START_COUNTER/start_parms parameters from calibDB"< startparms; jcalib->Get("START_COUNTER/start_parms", startparms); START_SIGMA = startparms["START_SIGMA"] ; START_PHOTONS_PERMEV = startparms["START_PHOTONS_PERMEV"]; } #if ! USE_JANA cout<<" input file: "<Write(); hfile->Close(); return 0; } //----------- // ParseCommandLineArguments //----------- void ParseCommandLineArguments(int narg, char* argv[]) { bool warn_obsolete = false; for(int i=1; i