CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CalibMuon/CSCCalibration/interface/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   //when bad channels exist use the following
00061    int new_nrlines1=0;
00062    int new_nrlines2=0;
00063   //when empty
00064   //int new_nrlines1=-1;
00065   //int new_nrlines2=-1;
00066 
00067  
00068   std::ifstream newdata1;
00069   std::ifstream newdata2;
00070 
00071   newdata1.open("badstrips1.dat",std::ios::in); //chambercontainer
00072   if(!newdata1) {
00073     std::cerr <<"Error: badstrips1.dat -> no such file!"<< std::endl;
00074     exit(1);
00075   }
00076   newdata2.open("badstrips2.dat",std::ios::in); //channelcontainer
00077   if(!newdata2) {
00078     std::cerr <<"Error: badstrips2.dat -> no such file!"<< std::endl;
00079     exit(1);
00080   }
00081 
00082   while(!newdata1.eof() ) {
00083     newdata1 >> new_index >> new_pointer >> new_chan;
00084     new_index_id.push_back(new_index);
00085     new_point.push_back(new_pointer);
00086     new_badchannels.push_back(new_chan);
00087     new_nrlines1++;
00088   }
00089   newdata1.close();
00090 
00091   while (!newdata2.eof() ) { 
00092     newdata2 >> new_layer >> new_channel >> new_flag1 >> new_flag2 >> new_flag3; 
00093     new_layer_id.push_back(new_layer);
00094     new_chan_id.push_back(new_channel);
00095     new_flag1_id.push_back(new_flag1);
00096     new_flag2_id.push_back(new_flag2);
00097     new_flag3_id.push_back(new_flag3);
00098     new_nrlines2++;
00099   }
00100   newdata2.close();
00101   
00102 
00103   CSCBadStrips::BadChamberContainer & itemvector1 = cndbbadstrips->chambers;
00104   itemvector1.resize(new_nrlines1);
00105   
00106   CSCBadStrips::BadChannelContainer & itemvector2 = cndbbadstrips->channels;
00107   itemvector2.resize(new_nrlines2);
00108   
00109   cndbbadstrips->numberOfBadChannels = new_nrlines2;
00110  
00111   for(int i=0; i<new_nrlines1;i++){
00112     itemvector1[i].chamber_index = new_index_id[i];
00113     itemvector1[i].pointer = new_point[i];
00114     itemvector1[i].bad_channels = new_badchannels[i];
00115   }
00116 
00117   for(int j=0;j<new_nrlines2;j++) {
00118     itemvector2[j].layer =  new_layer_id[j];
00119     itemvector2[j].channel = new_chan_id[j];
00120     itemvector2[j].flag1 =  new_flag1_id[j];
00121     itemvector2[j].flag2 = new_flag2_id[j];
00122     itemvector2[j].flag3 = new_flag3_id[j];
00123   }
00124 
00125    return cndbbadstrips;
00126 }
00127 
00128 #endif
00129