CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/CalibMuon/CSCCalibration/interface/CSCBadChambersConditions.h

Go to the documentation of this file.
00001 #ifndef _CSCBADCHAMBERSCONDITIONS_H
00002 #define _CSCBADCHAMBERSCONDITIONS_H
00003 
00004 #include <memory>
00005 #include <cmath>
00006 #include "FWCore/Framework/interface/SourceFactory.h"
00007 #include "FWCore/Framework/interface/Frameworkfwd.h"
00008 #include "FWCore/Framework/interface/ESProducer.h"
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/Framework/interface/MakerMacros.h"
00011 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00012 #include "FWCore/Framework/interface/ESHandle.h"
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00017 #include "CondFormats/CSCObjects/interface/CSCBadChambers.h"
00018 #include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h"
00019 
00020 class CSCBadChambersConditions: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder  {
00021  public:
00022   CSCBadChambersConditions(const edm::ParameterSet&);
00023   ~CSCBadChambersConditions();
00024   
00025 
00026   inline static CSCBadChambers *  prefillBadChambers();
00027 
00028   typedef const  CSCBadChambers * ReturnType;
00029   
00030   ReturnType produceBadChambers(const CSCBadChambersRcd&);
00031   
00032  private:
00033   // ----------member data ---------------------------
00034   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & );
00035   CSCBadChambers *cndbBadChambers ;
00036 
00037 };
00038 
00039 #include<fstream>
00040 #include<vector>
00041 #include<iostream>
00042 
00043 // to workaround plugin library
00044 inline CSCBadChambers *  CSCBadChambersConditions::prefillBadChambers()
00045 {
00046   //  const int MAX_SIZE = 468;
00047   //cndbbadchambers = new CSCBadChambers();
00048 
00049   int new_chambers;
00050   std::vector<int> new_badchambers;
00051   int old_chamber = -1;
00052   int new_nrlines;
00053   new_nrlines=0;
00054  
00055   std::ifstream newdata;
00056 
00057   newdata.open("badchambers.dat",std::ios::in);
00058   if(!newdata) {
00059     std::cerr <<"Error: badchambers.dat -> no such file!"<< std::endl;
00060     exit(1);
00061   }
00062 
00063   while(!newdata.eof() ) {
00064 
00065     newdata >> new_chambers;
00066     if (new_chambers!=old_chamber){
00067     new_badchambers.push_back(new_chambers);
00068     std::cout<<new_chambers<<std::endl;  
00069     ++new_nrlines;
00070     }
00071     old_chamber = new_chambers;
00072   }
00073   newdata.close();
00074 
00075   CSCBadChambers * cndbbadchambers = new CSCBadChambers(new_nrlines, new_badchambers);  
00076 
00077   //std::cout <<"numberOfBadChambers "<<new_nrlines<<std::endl;
00078 
00079    return cndbbadchambers;
00080 }
00081 
00082 #endif