// $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 0 #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 CDC_USE_PARAMETERIZED_SIGMA = true; bool FDC_USE_PARAMETERIZED_SIGMA = true; // setup response parameters float BCAL_DARKRATE_GHZ = 0.;// 0.041; float BCAL_XTALK_FRACT = 0.;//0.03; float BCAL_INTWINDOW_NS = 0.;//100; float BCAL_DEVICEPDE = 0.;//0.12; float BCAL_SAMPLING_FRACT = 0.;//0.15; float BCAL_MAXOCCUPANCY_FRACT = 0.;//0.05; float BCAL_PHOTONSPERSIDEPERMEV_INFIBER = 0.0;//75; float BCAL_SAMPLINGCOEFA = 0.0; //0.042; float BCAL_SAMPLINGCOEFB = 0.0; //.013; float BCAL_TIMEDIFFCOEFA = 0.0; //0.07 * sqrt( 2 ); float BCAL_TIMEDIFFCOEFB = 0.0; //0.0 * sqrt( 2 ); float BCAL_CELLOUTERTHRESHOLD = 0.0;//1 * k_MeV; float Bcal_CellInnerThreshold = 0.0; 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.; vector >fdc_smear_parms; TF1 *fdc_smear_function; #include using namespace jana; static JCalibration *jcalib=NULL; // histogram TH2F *fdc_drift_time_smear_hist; TH2F *fdc_drift_dist_smear_hist; TH2F *fdc_drift_time; //----------- // 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.); // 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."< > tvals; jcalib->Get("FDC/drift_smear_parms", tvals); // Notify user cout<<"Read "<::iterator iter; for(iter=tvals[0].begin(); iter!=tvals[0].end(); iter++)cout<first<<" "; cout< &row = tvals[i]; vectordummy; dummy.push_back(row["h0"]); dummy.push_back(row["m0"]); dummy.push_back(row["s0"]); dummy.push_back(row["h1"]); dummy.push_back(row["m1"]); dummy.push_back(row["s1"]); dummy.push_back(row["h2"]); dummy.push_back(row["m2"]); dummy.push_back(row["s2"]); fdc_smear_parms.push_back(dummy); dummy.clear(); } } // get the TOF parameters { cout<<"get TOF/tof_parms parameters from calibDB"< 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_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_MAXOCCUPANCY_FRACT = bcalparms["BCAL_MAXOCCUPANCY_FRACT"]; 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"]; BCAL_CELLOUTERTHRESHOLD = bcalparms["BCAL_CELLOUTERTHRESHOLD"]; Bcal_CellInnerThreshold = bcalparms["Bcal_CellInnerThreshold"]; } { 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(); return 0; } //----------- // ParseCommandLineArguments //----------- void ParseCommandLineArguments(int narg, char* argv[]) { bool warn_obsolete = false; for(int i=1; i