CMS 3D CMS Logo

CSCBadStripsConditions.h

Go to the documentation of this file.
00001 #ifndef _CSCBADSTRIPSCONDITIONS_H
00002 #define _CSCBADSTRIPSCONDITIONS_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/CSCBadStrips.h"
00018 #include "CondFormats/DataRecord/interface/CSCBadStripsRcd.h"
00019 
00020 class CSCBadStripsConditions: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder  {
00021  public:
00022   CSCBadStripsConditions(const edm::ParameterSet&);
00023   ~CSCBadStripsConditions();
00024   
00025 
00026   inline static CSCBadStrips *  prefillBadStrips();
00027 
00028   typedef const  CSCBadStrips * ReturnType;
00029   
00030   ReturnType produceBadStrips(const CSCBadStripsRcd&);
00031   
00032  private:
00033   // ----------member data ---------------------------
00034   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & );
00035   CSCBadStrips *cndbBadStrips ;
00036 
00037 };
00038 
00039 #include<fstream>
00040 #include<vector>
00041 #include<iostream>
00042 
00043 // to workaround plugin library
00044 inline CSCBadStrips *  CSCBadStripsConditions::prefillBadStrips()
00045 {
00046   CSCBadStrips * cndbbadstrips = new CSCBadStrips();
00047 
00048   int new_index, new_chan;
00049   int new_layer,new_channel, new_flag1, new_flag2, new_flag3,new_pointer;
00050   std::vector<int> new_index_id;
00051   std::vector<short int> new_layer_id;
00052   std::vector<short int> new_chan_id;
00053   std::vector<int> new_badchannels;
00054   std::vector<short int> new_flag1_id;
00055   std::vector<short int> new_flag2_id;
00056   std::vector<short int> new_flag3_id;
00057   std::vector<int> new_cham_id;
00058   std::vector<int> new_point;
00059 
00060   int new_nrlines1=0;
00061   int new_nrlines2=0;
00062  
00063   std::ifstream newdata1;
00064   std::ifstream newdata2;
00065 
00066   newdata1.open("badstrips1.dat",std::ios::in); //chambercontainer
00067   if(!newdata1) {
00068     std::cerr <<"Error: badstrips1.dat -> no such file!"<< std::endl;
00069     exit(1);
00070   }
00071   newdata2.open("badstrips2.dat",std::ios::in); //channelcontainer
00072   if(!newdata2) {
00073     std::cerr <<"Error: badstrips2.dat -> no such file!"<< std::endl;
00074     exit(1);
00075   }
00076 
00077   while(!newdata1.eof() ) {
00078     newdata1 >> new_index >> new_pointer >> new_chan;
00079     new_index_id.push_back(new_index);
00080     new_point.push_back(new_pointer);
00081     new_badchannels.push_back(new_chan);
00082     new_nrlines1++;
00083   }
00084   newdata1.close();
00085 
00086   while (!newdata2.eof() ) { 
00087     newdata2 >> new_layer >> new_channel >> new_flag1 >> new_flag2 >> new_flag3; 
00088     new_layer_id.push_back(new_layer);
00089     new_chan_id.push_back(new_channel);
00090     new_flag1_id.push_back(new_flag1);
00091     new_flag2_id.push_back(new_flag2);
00092     new_flag3_id.push_back(new_flag3);
00093     new_nrlines2++;
00094   }
00095   newdata2.close();
00096   
00097 
00098   CSCBadStrips::BadChamberContainer & itemvector1 = cndbbadstrips->chambers;
00099   itemvector1.resize(new_nrlines1);
00100   
00101   CSCBadStrips::BadChannelContainer & itemvector2 = cndbbadstrips->channels;
00102   itemvector2.resize(new_nrlines2);
00103   
00104   cndbbadstrips->numberOfBadChannels = new_nrlines2;
00105 
00106   for(int i=0; i<new_nrlines1;i++){
00107     itemvector1[i].chamber_index = new_index_id[i];
00108     itemvector1[i].pointer = new_point[i];
00109     itemvector1[i].bad_channels = new_badchannels[i];
00110   }
00111 
00112   for(int j=0;j<new_nrlines2;j++) {
00113     itemvector2[j].layer =  new_layer_id[j];
00114     itemvector2[j].channel = new_chan_id[j];
00115     itemvector2[j].flag1 =  new_flag1_id[j];
00116     itemvector2[j].flag2 = new_flag2_id[j];
00117     itemvector2[j].flag3 = new_flag3_id[j];
00118   }
00119 
00120    return cndbbadstrips;
00121 }
00122 
00123 #endif
00124 

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