00001 #ifndef _CSCCRATEMAPVALUES_H 00002 #define _CSCCRATEMAPVALUES_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/CSCCrateMap.h" 00017 #include "CondFormats/DataRecord/interface/CSCCrateMapRcd.h" 00018 #include "OnlineDB/CSCCondDB/interface/CSCCrateMapValues.h" 00019 #include "CondFormats/CSCObjects/interface/CSCMapItem.h" 00020 #include "OnlineDB/CSCCondDB/interface/CSCMap1.h" 00021 00022 class CSCCrateMapValues: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder { 00023 public: 00024 CSCCrateMapValues(const edm::ParameterSet&); 00025 ~CSCCrateMapValues(); 00026 00027 inline static CSCCrateMap * fillCrateMap(); 00028 00029 typedef const CSCCrateMap * ReturnType; 00030 00031 ReturnType produceCrateMap(const CSCCrateMapRcd&); 00032 00033 private: 00034 // ----------member data --------------------------- 00035 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & ); 00036 CSCCrateMap *mapObj ; 00037 00038 }; 00039 00040 #include<fstream> 00041 #include<vector> 00042 #include<iostream> 00043 00044 // to workaround plugin library 00045 inline CSCCrateMap * CSCCrateMapValues::fillCrateMap() 00046 { 00047 CSCCrateMap * mapobj = new CSCCrateMap(); 00048 cscmap1 *map = new cscmap1 (); 00049 CSCMapItem::MapItem item; 00050 00051 int i,j,k,l; //i - endcap, j - station, k - ring, l - chamber. 00052 int r,c; //r - number of rings, c - number of chambers. 00053 int count=0; 00054 int chamberid; 00055 int crate_cscid; 00056 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 crate_cscid=item.crateid*10+item.cscid; 00070 mapobj->crate_map[crate_cscid]=item; 00071 count=count+1; 00072 } 00073 } 00074 } 00075 } 00076 return mapobj; 00077 } 00078 00079 00080 #endif