// $Id$ // // File: DBCALTimeSpectrum_factory_FINE.cc // Created: Thu Sep 22 20:43:52 EDT 2011 // Creator: davidl (on Linux ifarm1102 2.6.18-128.7.1.el5 x86_64) // #include #include using namespace std; #include "DBCALTimeSpectrum_factory.h" #include "DBCALTimeSpectrum_factory_FINE.h" using namespace jana; // These are auto-generated from timewalk_calibrate_max.C for // the specific summing scheme implemented here. static double BCAL_TimeWalkUp(double fADC, int layer); static double BCAL_TimeWalkDn(double fADC, int layer); #include "timewalk_FINE.h" //------------------ // init //------------------ jerror_t DBCALTimeSpectrum_factory_FINE::init(void) { return NOERROR; } //------------------ // GetSummedLayer //------------------ int DBCALTimeSpectrum_factory_FINE::GetSummedLayer(int layer, int sector) { return layer; } //------------------ // GetSummedSector //------------------ int DBCALTimeSpectrum_factory_FINE::GetSummedSector(int layer, int sector) { return sector; } //------------------ // GetSummedCell //------------------ int DBCALTimeSpectrum_factory_FINE::GetSummedCell(int layer, int sector) { // Return the index of the summed cell given the layer // and sector. int summed_layer = GetSummedLayer(layer, sector); int summed_sector = GetSummedSector(layer, sector); return summed_layer*10 + summed_sector; } //------------------ // GetSummedLayerAndSectorFromCell //------------------ void DBCALTimeSpectrum_factory_FINE::GetSummedLayerAndSectorFromCell(int cell, int &summed_layer, int &summed_sector) { // Return the summed layer and summed sector based on the cell number summed_layer = cell/10; summed_sector = cell%10; } //------------------ // brun //------------------ jerror_t DBCALTimeSpectrum_factory_FINE::brun(jana::JEventLoop *eventLoop, int runnumber) { return NOERROR; } //------------------ // evnt //------------------ jerror_t DBCALTimeSpectrum_factory_FINE::evnt(JEventLoop *loop, int eventnumber) { // Get the single SiPM spectra vector spectra; // Jump through hoops to get to untagged factory DBCALTimeSpectrum_factory *fac = (DBCALTimeSpectrum_factory*)loop->GetFactory("DBCALTimeSpectrum","",false); fac->Get(spectra); // Loop over single SiPM spectra make a duplicate of // it using the DBCALTimeSpectrum constructor used for // summing SiPMs. We do this because the summing // includes code to add electronic noise. for(unsigned int i=0; ilayer; int summed_sector = spectrum_orig->sector; vector v; v.push_back(spectrum_orig); double thresh_mV = 44.7; DBCALTimeSpectrum *spectrum = new DBCALTimeSpectrum(thresh_mV, v, summed_layer, summed_sector); // Overwrite corrected times so we can apply timewalk // corrections for the summed cells // (n.b. these will be the same as were already applied, but // it keeps this code more consistent with the summed counterparts) spectrum->tup_corrected = spectrum->tup; if(spectrum->tup>-1000.0){ spectrum->tup_corrected -= BCAL_TimeWalkUp(spectrum->fADC_up, summed_layer); } spectrum->tdn_corrected = spectrum->tdn; if(spectrum->tdn>-1000.0){ spectrum->tdn_corrected -= BCAL_TimeWalkDn(spectrum->fADC_dn, summed_layer); } _data.push_back(spectrum); } return NOERROR; } //------------------ // erun //------------------ jerror_t DBCALTimeSpectrum_factory_FINE::erun(void) { return NOERROR; } //------------------ // fini //------------------ jerror_t DBCALTimeSpectrum_factory_FINE::fini(void) { return NOERROR; }