Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:44

0001 #ifndef _CSCCRATEMAPVALUES_H
0002 #define _CSCCRATEMAPVALUES_H
0003 
0004 #include <memory>
0005 #include "FWCore/Framework/interface/SourceFactory.h"
0006 #include "FWCore/Framework/interface/Frameworkfwd.h"
0007 #include "FWCore/Framework/interface/ESProducer.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
0016 #include "CondFormats/CSCObjects/interface/CSCCrateMap.h"
0017 #include "CondFormats/DataRecord/interface/CSCCrateMapRcd.h"
0018 #include "OnlineDB/CSCCondDB/interface/CSCCrateMapValues.h"
0019 #include "CondFormats/CSCObjects/interface/CSCMapItem.h"
0020 #include "OnlineDB/CSCCondDB/interface/CSCMap1.h"
0021 
0022 class CSCCrateMapValues : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0023 public:
0024   CSCCrateMapValues(const edm::ParameterSet &);
0025   ~CSCCrateMapValues() override;
0026 
0027   typedef std::unique_ptr<CSCCrateMap> ReturnType;
0028 
0029   inline static CSCCrateMap *fillCrateMap();
0030 
0031   CSCCrateMapValues::ReturnType produceCrateMap(const CSCCrateMapRcd &);
0032 
0033 private:
0034   // ----------member data ---------------------------
0035   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0036                       const edm::IOVSyncValue &,
0037                       edm::ValidityInterval &) override;
0038 };
0039 
0040 #include <fstream>
0041 #include <vector>
0042 #include <iostream>
0043 
0044 // to workaround plugin library
0045 inline CSCCrateMap *CSCCrateMapValues::fillCrateMap() {
0046   CSCCrateMap *mapobj = new CSCCrateMap();
0047   cscmap1 map;
0048   CSCMapItem::MapItem item;
0049 
0050   int i, j, k, l;  //i - endcap, j - station, k - ring, l - chamber.
0051   int r, c;        //r - number of rings, c - number of chambers.
0052   int count = 0;
0053   int chamberid;
0054   int crate_cscid;
0055 
0056   /* This is version for 540 chambers. */
0057   for (i = 1; i <= 2; ++i) {
0058     for (j = 1; j <= 4; ++j) {
0059       if (j == 1)
0060         r = 3;
0061       //else if(j==4) r=1;
0062       else
0063         r = 2;
0064       for (k = 1; k <= r; ++k) {
0065         if (j > 1 && k == 1)
0066           c = 18;
0067         else
0068           c = 36;
0069         for (l = 1; l <= c; ++l) {
0070           chamberid = i * 100000 + j * 10000 + k * 1000 + l * 10;
0071           map.chamber(chamberid, &item);
0072           crate_cscid = item.crateid * 10 + item.cscid;
0073           mapobj->crate_map[crate_cscid] = item;
0074           count = count + 1;
0075         }
0076       }
0077     }
0078   }
0079   return mapobj;
0080 }
0081 
0082 #endif