#include <DTFineDelayCorr.h>
Public Member Functions | |
DTFineDelayCorr (const edm::ParameterSet &ps) | |
Constructor. | |
virtual | ~DTFineDelayCorr () |
Destructor. | |
Protected Member Functions | |
void | beginJob () |
Begin Job. | |
void | beginRun (const edm::Run &run, const edm::EventSetup &evSU) |
Begin Run. | |
void | endJob () |
End Job. | |
void | runClientDiagnostic () |
DQM Client Diagnostic. | |
void | writeConsts (const std::string &outputFileName) const |
Private Attributes | |
std::map< DTChamberId, std::vector< float > > | delayMap |
edm::ESHandle< DTConfigManager > | dtConfig |
bool | gaussMean |
int | minEntries |
int | nEvents |
std::map< DTChamberId, std::pair< int, float > > | oldDelayMap |
std::string | oldDelaysInputFile |
std::string | outputFileName |
bool | readOldFromDb |
std::string | t0MeanHistoTag |
std::string | trSource |
edm::ESHandle< DTTPGParameters > | worstPhaseMap |
bool | writeDB |
* Class to calculate corrections to the fine delays loaded in DT MiniCrates
Definition at line 28 of file DTFineDelayCorr.h.
DTFineDelayCorr::DTFineDelayCorr | ( | const edm::ParameterSet & | ps | ) |
Constructor.
Definition at line 45 of file DTFineDelayCorr.cc.
{ setConfig(ps,"DTFineDelayCorr"); // sets parameter values and name used in log file baseFolderDCC = "DT/90-LocalTriggerSynch/"; baseFolderDDU = "DT/90-LocalTriggerSynch/"; }
DTFineDelayCorr::~DTFineDelayCorr | ( | ) | [virtual] |
void DTFineDelayCorr::beginJob | ( | void | ) | [protected, virtual] |
Begin Job.
Reimplemented from DTLocalTriggerBaseTest.
Definition at line 59 of file DTFineDelayCorr.cc.
References dumpDBToFile_GT_ttrig_cfg::outputFileName, and Parameters::parameters.
{ // Tag for Hardware Source (DDU or DCC) hwSource = parameters.getParameter<string>("hwSource"); // Tag for the t0Mean Histograms t0MeanHistoTag = parameters.getParameter<string>("t0MeanHistoTag"); // Read old delays from file or from Db readOldFromDb = parameters.getParameter<bool>("readOldFromDb"); // Input file name for old delays oldDelaysInputFile = parameters.getParameter<string>("oldDelaysInputFile"), // Write new delays to file or to Db writeDB = parameters.getParameter<bool>("writeDB"); // Output File Name outputFileName = parameters.getParameter<string>("outputFile"); // Choose to use Hist Mean or Gaussian Fit Mean gaussMean = parameters.getParameter<bool>("gaussMean"); // Require Minimum Number Of Entries in the t0Mean Histogram minEntries = parameters.getUntrackedParameter<int>("minEntries",5); }
void DTFineDelayCorr::beginRun | ( | const edm::Run & | run, |
const edm::EventSetup & | evSU | ||
) | [protected, virtual] |
Begin Run.
Reimplemented from DTLocalTriggerBaseTest.
Definition at line 80 of file DTFineDelayCorr.cc.
References DTLocalTriggerBaseTest::beginRun(), and edm::EventSetup::get().
{ DTLocalTriggerBaseTest::beginRun(run,evSU); evSU.get< DTConfigManagerRcd >().get(dtConfig); evSU.get< DTTPGParametersRcd >().get(worstPhaseMap); }
void DTFineDelayCorr::endJob | ( | void | ) | [protected, virtual] |
End Job.
Reimplemented from DTLocalTriggerBaseTest.
Definition at line 190 of file DTFineDelayCorr.cc.
References filterCSVwithJSON::copy, DTLocalTriggerBaseTest::endJob(), and dumpDBToFile_GT_ttrig_cfg::outputFileName.
{ DTLocalTriggerBaseTest::endJob(); if (writeDB) { // to be added if needed } else { // write txt file // ** Open output file ** ofstream outFile(outputFileName.c_str()); for(map< DTChamberId, vector<float> >::const_iterator iter = delayMap.begin(); iter != delayMap.end() ; iter++) { // writing ostream_iterator<float> oit(outFile, " "); copy((*iter).second.begin(), (*iter).second.end(), oit); outFile << endl; } outFile.close(); } }
void DTFineDelayCorr::runClientDiagnostic | ( | ) | [protected, virtual] |
DQM Client Diagnostic.
Implements DTLocalTriggerBaseTest.
Definition at line 88 of file DTFineDelayCorr.cc.
References category(), gather_cfg::cout, DTChamberId, DTLayerId, DTTopology::firstChannel(), DTConfigPedestals::getOffset(), DTLayer::id(), geometryCSVtoXML::line, plotscripts::mean(), DTTimeUnits::ns, DetId::rawId(), DTChamberId::sector(), DTLayer::specificTopology(), relativeConstraints::station, DTChamberId::station(), and DTChamberId::wheel().
{ int coarseDelay = -999; float oldFineDelay = -999; if(!readOldFromDb) { // read old delays from txt file // ** Open and read old delays input file ** ifstream oldDelaysFile(oldDelaysInputFile.c_str()); string line; while (getline(oldDelaysFile, line)) { if( line == "" || line[0] == '#' ) continue; stringstream linestr; int wheelKey,sectorKey, stationKey; linestr << line; linestr >> wheelKey >> sectorKey >> stationKey >> coarseDelay >> oldFineDelay; pair<int,float> oldDelays = make_pair(coarseDelay,oldFineDelay); DTChamberId oldDelayKey = DTChamberId(wheelKey,stationKey,sectorKey); oldDelayMap.insert(make_pair(oldDelayKey,oldDelays)); } } // ** Loop over the chambers ** vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin(); vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end(); for (; chambIt!=chambEnd; ++chambIt) { DTChamberId chId = (*chambIt)->id(); uint32_t indexCh = chId.rawId(); int wheel = chId.wheel(); int sector = chId.sector(); int station = chId.station(); // ** Compute corrected values and write them to file or database ** vector<float> newDelays; // ** Retrieve Delays Loaded in MiniCrates ** if(readOldFromDb) { // read from db DTConfigPedestals *pedestals = dtConfig->getDTConfigPedestals(); const DTLayer *layer = muonGeom->layer(DTLayerId(chId,1,1)); float delay = pedestals->getOffset(DTWireId(layer->id(),layer->specificTopology().firstChannel())); coarseDelay = int(delay/25.); oldFineDelay = delay - coarseDelay * 25.; } else { // read from map created from txt file coarseDelay = oldDelayMap[chId].first; oldFineDelay = oldDelayMap[chId].second; } // ** Retrieve t0Mean histograms ** TH1F *t0H = getHisto<TH1F>(dbe->get(getMEName(t0MeanHistoTag,"", chId))); float newFineDelay = -999; // initialize to dummy number cout <<"MG: " << getMEName(t0MeanHistoTag,"", chId) << " entries: " << t0H->GetEntries() << endl; if (t0H->GetEntries() > minEntries) { Double_t mean; Double_t sigma; // ** Find Mean Value of the distribution ** if(gaussMean) { TF1 *funct = t0H->GetFunction("gaus"); mean = funct->GetParameter(1); sigma = funct->GetParameter(2); } else { mean = t0H->GetMean(); sigma = t0H->GetRMS(); } // ** Retrieve Worst Phase values ** int wpCoarseDelay; float wpFineDelay; worstPhaseMap->get(chId, wpCoarseDelay, wpFineDelay, DTTimeUnits::ns); // cout << "wpFineDelay, oldFineDelay, mean: " << wpFineDelay << " " // << oldFineDelay << " " << mean << endl; float bpFineDelay = (wpFineDelay < 12.5)? (wpFineDelay + 12.5) : (wpFineDelay - 12.5); // Best Phase: half BX far from the worst phase // ** Calculate correction ** float diffFineDelays = oldFineDelay + (mean - bpFineDelay); // positive mean shift implies positive delay correction int bxDiff = (int) (diffFineDelays / 25); coarseDelay += bxDiff; newFineDelay = fmodf(diffFineDelays, 25); // cout << "diffFineDelays, newFineDelay, bxDiff, coarseDelay: " << diffFineDelays // << " "<< newFineDelay << " " << bxDiff << " " << coarseDelay << endl; } else { LogProblem(category()) << "[" << testName << "Test]: Not enough entries in hist for Chamber " << indexCh << endl; } newDelays.push_back(wheel); newDelays.push_back(sector); newDelays.push_back(station); newDelays.push_back(coarseDelay); newDelays.push_back(newFineDelay); pair< DTChamberId, vector<float> > chDelays; chDelays.first = chId; chDelays.second = newDelays; delayMap.insert(chDelays); } }
void DTCalibrationMap::writeConsts | ( | const std::string & | outputFileName | ) | const [protected] |
Definition at line 215 of file DTCalibrationMap.cc.
References filterCSVwithJSON::copy, and dbtoconf::out.
{ ofstream out(outputFileName.c_str()); for(map<Key,CalibConsts>::const_iterator iter = theMap.begin(); iter != theMap.end() ; iter++) { out << (*iter).first.wheel() << ' ' << (*iter).first.station() << ' ' << (*iter).first.sector() << ' ' << (*iter).first.superlayer() << ' ' << (*iter).first.layer() << ' ' << (*iter).first.wire() << ' '; copy((*iter).second.begin(), (*iter).second.end(), ostream_iterator<float>(out, " ")); out << endl; } }
std::map< DTChamberId, std::vector<float> > DTFineDelayCorr::delayMap [private] |
Definition at line 72 of file DTFineDelayCorr.h.
edm::ESHandle< DTConfigManager > DTFineDelayCorr::dtConfig [private] |
Definition at line 65 of file DTFineDelayCorr.h.
bool DTFineDelayCorr::gaussMean [private] |
Definition at line 62 of file DTFineDelayCorr.h.
int DTFineDelayCorr::minEntries [private] |
Definition at line 63 of file DTFineDelayCorr.h.
int DTFineDelayCorr::nEvents [private] |
Definition at line 64 of file DTFineDelayCorr.h.
std::map< DTChamberId, std::pair<int,float> > DTFineDelayCorr::oldDelayMap [private] |
Definition at line 69 of file DTFineDelayCorr.h.
std::string DTFineDelayCorr::oldDelaysInputFile [private] |
Definition at line 58 of file DTFineDelayCorr.h.
std::string DTFineDelayCorr::outputFileName [private] |
Definition at line 57 of file DTFineDelayCorr.h.
bool DTFineDelayCorr::readOldFromDb [private] |
Definition at line 60 of file DTFineDelayCorr.h.
std::string DTFineDelayCorr::t0MeanHistoTag [private] |
Definition at line 56 of file DTFineDelayCorr.h.
std::string DTFineDelayCorr::trSource [private] |
Definition at line 59 of file DTFineDelayCorr.h.
edm::ESHandle< DTTPGParameters > DTFineDelayCorr::worstPhaseMap [private] |
Definition at line 66 of file DTFineDelayCorr.h.
bool DTFineDelayCorr::writeDB [private] |
Definition at line 61 of file DTFineDelayCorr.h.