Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef _CSCCHAMBERINDEXVALUES_H
0002 #define _CSCCHAMBERINDEXVALUES_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/CSCChamberIndex.h"
0017 #include "CondFormats/DataRecord/interface/CSCChamberIndexRcd.h"
0018 #include "OnlineDB/CSCCondDB/interface/CSCChamberIndexValues.h"
0019 #include "CondFormats/CSCObjects/interface/CSCMapItem.h"
0020 #include "OnlineDB/CSCCondDB/interface/CSCMap1.h"
0021 
0022 class CSCChamberIndexValues : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0023 public:
0024   CSCChamberIndexValues(const edm::ParameterSet &);
0025   ~CSCChamberIndexValues() override;
0026 
0027   typedef std::unique_ptr<CSCChamberIndex> ReturnType;
0028 
0029   inline static CSCChamberIndex *fillChamberIndex();
0030 
0031   ReturnType produceChamberIndex(const CSCChamberIndexRcd &);
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 CSCChamberIndex *CSCChamberIndexValues::fillChamberIndex() {
0046   CSCChamberIndex *mapobj = new CSCChamberIndex();
0047   cscmap1 map;
0048   CSCMapItem::MapItem item;
0049   int chamberid;
0050 
0051   int i, j, k, l;  //i - endcap, j - station, k - ring, l - chamber.
0052   int r, c;        //r - number of rings, c - number of chambers.
0053   int count = 0;
0054 
0055   mapobj->ch_index.resize(540);
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           mapobj->ch_index[item.cscIndex - 1] = item;
0073           count = count + 1;
0074         }
0075       }
0076     }
0077   }
0078   return mapobj;
0079 }
0080 
0081 #endif