CMS 3D CMS Logo

CSCBadWiresConditions.h

Go to the documentation of this file.
00001 #ifndef _CSCBADWIRESCONDITIONS_H
00002 #define _CSCBADWIRESCONDITIONS_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/CSCBadWires.h"
00018 #include "CondFormats/DataRecord/interface/CSCBadWiresRcd.h"
00019 
00020 class CSCBadWiresConditions: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder  {
00021  public:
00022   CSCBadWiresConditions(const edm::ParameterSet&);
00023   ~CSCBadWiresConditions();
00024   
00025 
00026   inline static CSCBadWires *  prefillBadWires();
00027 
00028   typedef const  CSCBadWires * ReturnType;
00029   
00030   ReturnType produceBadWires(const CSCBadWiresRcd&);
00031   
00032  private:
00033   // ----------member data ---------------------------
00034   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & );
00035   CSCBadWires *cndbBadWires ;
00036 
00037 };
00038 
00039 #include<fstream>
00040 #include<vector>
00041 #include<iostream>
00042 
00043 // to workaround plugin library
00044 inline CSCBadWires *  CSCBadWiresConditions::prefillBadWires()
00045 {
00046   CSCBadWires * cndbbadwires = new CSCBadWires();
00047   bool bad=false; //use boolean to fill bad channels
00048 
00049   int new_index;
00050   int new_layer,new_channel, new_flag1, new_cham,new_pointer;
00051   std::vector<int> new_index_id;
00052   std::vector<short int> new_layer_id;
00053   std::vector<short int> new_chan_id;
00054   std::vector<short int> new_flag_id;
00055   std::vector<int> new_cham_id;
00056   std::vector<int> new_point;
00057 
00058   int new_nrlines=0;
00059  
00060   std::ifstream newdata;
00061   newdata.open("badwires.dat",std::ios::in); 
00062   if(!newdata) {
00063     std::cerr <<"Error: badwires.dat -> no such file!"<< std::endl;
00064     exit(1);
00065   }
00066   
00067   while (!newdata.eof() ) { 
00068     newdata >> new_index >> new_layer >> new_channel >> new_flag1 >> new_cham >> new_pointer; 
00069     new_index_id.push_back(new_index);
00070     new_layer_id.push_back(new_layer);
00071     new_chan_id.push_back(new_channel);
00072     new_flag_id.push_back(new_flag1);
00073     new_cham_id.push_back(new_cham);
00074     new_point.push_back(new_pointer);
00075     new_nrlines++;
00076   }
00077   newdata.close();
00078   
00079 
00080   CSCBadWires::BadChannelContainer & itemvector = cndbbadwires->channels;
00081   itemvector.resize(new_nrlines);
00082   CSCBadWires::BadChamberContainer & itemvector1 = cndbbadwires->chambers;
00083   itemvector1.resize(new_nrlines);
00084   cndbbadwires->numberOfBadChannels = new_nrlines;
00085 
00086   if(new_index_id.empty()) bad=false; 
00087   if(!new_index_id.empty()) bad=true;
00088 
00089   for(unsigned int i=0; i<new_index_id.size();++i){
00090        itemvector[i].layer =  new_layer;
00091        itemvector[i].channel =  new_channel;
00092        itemvector[i].flag1 =  new_flag1;
00093        itemvector1[i].chamber_index = new_cham;
00094        itemvector1[i].pointer = new_pointer;
00095        itemvector1[i].bad_channels = new_index;
00096   }
00097 
00098   return cndbbadwires;
00099 }
00100 
00101 #endif
00102 

Generated on Tue Jun 9 17:25:27 2009 for CMSSW by  doxygen 1.5.4