Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:49

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  $Date: 2010/01/20 17:29:26 $
0005  *  $Revision: 1.1 $
0006  *  \author Paolo Ronchese INFN Padova
0007  *
0008  */
0009 
0010 //-----------------------
0011 // This Class' Header --
0012 //-----------------------
0013 #include "CondTools/DT/test/validate/DTRangeT0ValidateHandler.h"
0014 
0015 //-------------------------------
0016 // Collaborating Class Headers --
0017 //-------------------------------
0018 #include "CondFormats/DTObjects/interface/DTRangeT0.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 #include <cmath>
0024 #include <iostream>
0025 #include <fstream>
0026 #include <sstream>
0027 
0028 //-------------------
0029 // Initializations --
0030 //-------------------
0031 
0032 //----------------
0033 // Constructors --
0034 //----------------
0035 DTRangeT0ValidateHandler::DTRangeT0ValidateHandler(const edm::ParameterSet& ps)
0036     : firstRun(ps.getParameter<unsigned int>("firstRun")),
0037       lastRun(ps.getParameter<unsigned int>("lastRun")),
0038       dataVersion(ps.getParameter<std::string>("version")),
0039       dataFileName(ps.getParameter<std::string>("outFile")),
0040       elogFileName(ps.getParameter<std::string>("logFile")) {
0041   std::ofstream logFile(elogFileName.c_str());
0042 }
0043 
0044 //--------------
0045 // Destructor --
0046 //--------------
0047 DTRangeT0ValidateHandler::~DTRangeT0ValidateHandler() {}
0048 
0049 //--------------
0050 // Operations --
0051 //--------------
0052 void DTRangeT0ValidateHandler::getNewObjects() {
0053   int runNumber = firstRun;
0054   while (runNumber <= lastRun)
0055     addNewObject(runNumber++);
0056   return;
0057 }
0058 
0059 void DTRangeT0ValidateHandler::addNewObject(int runNumber) {
0060   DTRangeT0* tR = new DTRangeT0(dataVersion);
0061 
0062   std::stringstream run_fn;
0063   run_fn << "run" << runNumber << dataFileName;
0064 
0065   int status = 0;
0066   std::ofstream outFile(run_fn.str().c_str());
0067   std::ofstream logFile(elogFileName.c_str(), std::ios_base::app);
0068   int whe;
0069   int sta;
0070   int sec;
0071   int qua;
0072   int t0min;
0073   int t0max;
0074   int ckt0min;
0075   int ckt0max;
0076 
0077   whe = 3;
0078   while (--whe >= -2) {
0079     sta = 5;
0080     while (--sta) {
0081       if (sta == 4)
0082         sec = 15;
0083       else
0084         sec = 13;
0085       while (--sec) {
0086         qua = 4;
0087         while (--qua) {
0088           if ((sta == 4) && (qua == 2))
0089             continue;
0090           t0min = t0max = random() / 0x0000ffff;
0091           t0min -= 50.0;
0092           t0max += 50.0;
0093           status = tR->set(whe, sta, sec, qua, t0min, t0max);
0094           outFile << whe << " " << sta << " " << sec << " " << qua << " " << t0min << " " << t0max << std::endl;
0095           if (status)
0096             logFile << "ERROR while setting range T0" << whe << " " << sta << " " << sec << " " << qua
0097                     << " , status = " << status << std::endl;
0098           status = tR->get(whe, sta, sec, qua, ckt0min, ckt0max);
0099           if (status)
0100             logFile << "ERROR while checking range T0 " << whe << " " << sta << " " << sec << " " << qua
0101                     << " , status = " << status << std::endl;
0102           if ((std::abs(ckt0min - t0min) > 0.0001) || (std::abs(ckt0max - t0max) > 0.0001))
0103             logFile << "MISMATCH WHEN WRITING range T0 " << whe << " " << sta << " " << sec << " " << qua << " : "
0104                     << t0min << " " << t0max << " -> " << ckt0min << " " << ckt0max << std::endl;
0105           //            }
0106           //          }
0107         }
0108       }
0109     }
0110   }
0111 
0112   cond::Time_t snc = runNumber;
0113   m_to_transfer.push_back(std::make_pair(tR, snc));
0114 
0115   return;
0116 }
0117 
0118 std::string DTRangeT0ValidateHandler::id() const { return dataVersion; }