File indexing completed on 2024-04-06 11:58:27
0001
0002
0003
0004
0005
0006
0007 #include "CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h"
0008 #include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h"
0009
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0014 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0015 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0016
0017 #include "CondFormats/DTObjects/interface/DTT0.h"
0018 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
0019 #include "CondFormats/DataRecord/interface/DTDeadFlagRcd.h"
0020 #include "CondFormats/DTObjects/interface/DTDeadFlag.h"
0021
0022
0023 #include <vector>
0024 #include <set>
0025 #include <iostream>
0026 #include <fstream>
0027 #include <string>
0028 #include <sstream>
0029 #include "TFile.h"
0030 #include "TH1.h"
0031
0032 using namespace std;
0033 using namespace edm;
0034
0035
0036 DTTPDeadWriter::DTTPDeadWriter(const ParameterSet& pset) : dtGeomToken_(esConsumes<edm::Transition::BeginRun>()) {
0037
0038 debug = pset.getUntrackedParameter<bool>("debug", false);
0039 t0Token_ = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getParameter<string>("debug")));
0040
0041
0042 tpDeadList = new DTDeadFlag();
0043
0044 if (debug)
0045 cout << "[DTTPDeadWriter]Constructor called!" << endl;
0046 }
0047
0048
0049 DTTPDeadWriter::~DTTPDeadWriter() {
0050 if (debug)
0051 cout << "[DTTPDeadWriter]Destructor called!" << endl;
0052 }
0053
0054 void DTTPDeadWriter::beginRun(const edm::Run&, const EventSetup& setup) {
0055
0056 tZeroMap = &setup.getData(t0Token_);
0057
0058
0059 muonGeom = setup.getHandle(dtGeomToken_);
0060 }
0061
0062
0063 void DTTPDeadWriter::analyze(const Event& event, const EventSetup& eventSetup) {
0064 set<DTLayerId> analyzedLayers;
0065
0066
0067 for (DTT0::const_iterator tzero = tZeroMap->begin(); tzero != tZeroMap->end(); ++tzero) {
0068
0069
0070
0071
0072
0073
0074
0075
0076 int channelId = tzero->channelId;
0077 if (channelId == 0)
0078 continue;
0079 DTLayerId layerId = (DTWireId(channelId)).layerId();
0080
0081 if (analyzedLayers.find(layerId) == analyzedLayers.end()) {
0082 analyzedLayers.insert(layerId);
0083
0084
0085 const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
0086 const int firstWire = dtTopo.firstChannel();
0087
0088 const int nWires = muonGeom->layer(layerId)->specificTopology().channels();
0089
0090
0091 for (int wire = firstWire; wire <= nWires; wire++) {
0092 DTWireId wireId(layerId, wire);
0093 float t0 = 0;
0094 float t0rms = 0;
0095 tZeroMap->get(wireId, t0, t0rms, DTTimeUnits::ns);
0096
0097
0098 if (!t0) {
0099 tpDeadList->setCellDead_TP(wireId, true);
0100 cout << "Wire id " << wireId << " is TP dead" << endl;
0101 }
0102 }
0103 }
0104 }
0105 }
0106
0107
0108 void DTTPDeadWriter::endJob() {
0109 if (debug)
0110 cout << "[DTTPDeadWriter]Writing ttrig object to DB!" << endl;
0111
0112
0113 string deadRecord = "DTDeadFlagRcd";
0114
0115
0116 DTCalibDBUtils::writeToDB(deadRecord, tpDeadList);
0117 }