00001 #ifndef _CSCCHAMBERINDEXVALUES_H 00002 #define _CSCCHAMBERINDEXVALUES_H 00003 00004 #include <memory> 00005 #include "FWCore/Framework/interface/SourceFactory.h" 00006 #include "FWCore/Framework/interface/Frameworkfwd.h" 00007 #include "FWCore/Framework/interface/ESProducer.h" 00008 #include "FWCore/Framework/interface/Event.h" 00009 #include "FWCore/Framework/interface/MakerMacros.h" 00010 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" 00011 #include "FWCore/Framework/interface/ESHandle.h" 00012 #include "FWCore/Framework/interface/EventSetup.h" 00013 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00014 00015 #include <DataFormats/MuonDetId/interface/CSCDetId.h> 00016 #include "CondFormats/CSCObjects/interface/CSCChamberIndex.h" 00017 #include "CondFormats/DataRecord/interface/CSCChamberIndexRcd.h" 00018 #include "OnlineDB/CSCCondDB/interface/CSCChamberIndexValues.h" 00019 #include "CondFormats/CSCObjects/interface/CSCMapItem.h" 00020 #include "OnlineDB/CSCCondDB/interface/CSCMap1.h" 00021 00022 class CSCChamberIndexValues: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder { 00023 public: 00024 CSCChamberIndexValues(const edm::ParameterSet&); 00025 ~CSCChamberIndexValues(); 00026 00027 inline static CSCChamberIndex * fillChamberIndex(); 00028 00029 typedef const CSCChamberIndex * ReturnType; 00030 00031 ReturnType produceChamberIndex(const CSCChamberIndexRcd&); 00032 00033 private: 00034 // ----------member data --------------------------- 00035 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & ); 00036 CSCChamberIndex *mapObj ; 00037 00038 }; 00039 00040 #include<fstream> 00041 #include<vector> 00042 #include<iostream> 00043 00044 // to workaround plugin library 00045 inline CSCChamberIndex * CSCChamberIndexValues::fillChamberIndex() 00046 { 00047 CSCChamberIndex * mapobj = new CSCChamberIndex(); 00048 cscmap1 *map = new cscmap1(); 00049 CSCMapItem::MapItem item; 00050 int chamberid; 00051 00052 int i,j,k,l; //i - endcap, j - station, k - ring, l - chamber. 00053 int r,c; //r - number of rings, c - number of chambers. 00054 int count=0; 00055 00056 mapobj->ch_index.resize(540); 00057 /* This is version for 540 chambers. */ 00058 for(i=1;i<=2;++i){ 00059 for(j=1;j<=4;++j){ 00060 if(j==1) r=3; 00061 //else if(j==4) r=1; 00062 else r=2; 00063 for(k=1;k<=r;++k){ 00064 if(j>1 && k==1) c=18; 00065 else c=36; 00066 for(l=1;l<=c;++l){ 00067 chamberid=i*100000+j*10000+k*1000+l*10; 00068 map->chamber(chamberid,&item); 00069 mapobj->ch_index[item.cscIndex-1]=item; 00070 count=count+1; 00071 } 00072 } 00073 } 00074 } 00075 return mapobj; 00076 } 00077 00078 #endif