Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:25

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author S. Bolognesi - INFN Torino
0005  */
0006 
0007 // system include files
0008 #include <memory>
0009 
0010 // user include files
0011 #include "CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.h"
0012 #include "FWCore/Framework/interface/SourceFactory.h"
0013 
0014 #include "FWCore/Framework/interface/ESHandle.h"
0015 #include "FWCore/Framework/interface/ESTransientHandle.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 
0018 #include "CondFormats/DTObjects/interface/DTT0.h"
0019 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
0020 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
0021 
0022 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0023 #include "DetectorDescription/Core/interface/DDCompactView.h"
0024 #include "CalibMuon/DTCalibration/plugins/DTGeometryParserFromDDD.h"
0025 
0026 using namespace std;
0027 
0028 DTFakeT0ESProducer::DTFakeT0ESProducer(const edm::ParameterSet& pset) {
0029   //framework
0030   auto cc = setWhatProduced(this, &DTFakeT0ESProducer::produce);
0031   //  setWhatProduced(this,dependsOn(& DTGeometryESModule::parseDDD()));
0032   findingRecord<DTT0Rcd>();
0033 
0034   //read constant value for t0 from cfg
0035   t0Mean = pset.getParameter<double>("t0Mean");
0036   t0Sigma = pset.getParameter<double>("t0Sigma");
0037   cpvTokenDDD_ = cc.consumesFrom<DDCompactView, IdealGeometryRecord>(edm::ESInputTag());
0038   mdcToken_ = cc.consumes();
0039 }
0040 
0041 DTFakeT0ESProducer::~DTFakeT0ESProducer() {}
0042 
0043 // ------------ method called to produce the data  ------------
0044 std::unique_ptr<DTT0> DTFakeT0ESProducer::produce(const DTT0Rcd& iRecord) {
0045   parseDDD(iRecord);
0046   auto t0Map = std::make_unique<DTT0>();
0047 
0048   //Loop on layerId-nwires map
0049   for (map<DTLayerId, pair<unsigned int, unsigned int> >::const_iterator lIdWire = theLayerIdWiresMap.begin();
0050        lIdWire != theLayerIdWiresMap.end();
0051        ++lIdWire) {
0052     int firstWire = ((*lIdWire).second).first;
0053     int nWires = ((*lIdWire).second).second;
0054     //Loop on wires of each layer
0055     for (int wire = 0; wire < nWires; wire++) {
0056       t0Map->set(DTWireId((*lIdWire).first, wire + firstWire), t0Mean, t0Sigma, DTTimeUnits::counts);
0057     }
0058   }
0059 
0060   return t0Map;
0061 }
0062 
0063 void DTFakeT0ESProducer::parseDDD(const DTT0Rcd& iRecord) {
0064   edm::ESTransientHandle<DDCompactView> cpv = iRecord.getTransientHandle(cpvTokenDDD_);
0065   const auto& mdc = iRecord.get(mdcToken_);
0066 
0067   DTGeometryParserFromDDD parser(&(*cpv), mdc, theLayerIdWiresMap);
0068 }
0069 
0070 void DTFakeT0ESProducer::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0071                                         const edm::IOVSyncValue&,
0072                                         edm::ValidityInterval& oValidity) {
0073   oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0074 }