CMS 3D CMS Logo

DTTPDeadWriter.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author S. Bolognesi
5  */
6 
9 
16 
21 
22 /* C++ Headers */
23 #include <vector>
24 #include <set>
25 #include <iostream>
26 #include <fstream>
27 #include <string>
28 #include <sstream>
29 #include "TFile.h"
30 #include "TH1.h"
31 
32 using namespace std;
33 using namespace edm;
34 
35 // Constructor
37  // get selected debug option
38  debug = pset.getUntrackedParameter<bool>("debug", false);
39 
40  // Create the object to be written to DB
41  tpDeadList = new DTDeadFlag();
42 
43  if (debug)
44  cout << "[DTTPDeadWriter]Constructor called!" << endl;
45 }
46 
47 // Destructor
49  if (debug)
50  cout << "[DTTPDeadWriter]Destructor called!" << endl;
51 }
52 
54  // Get the t0 map
56  setup.get<DTT0Rcd>().get(t0);
57  tZeroMap = &*t0;
58 
59  // Get the muon Geometry
60  setup.get<MuonGeometryRecord>().get(muonGeom);
61 }
62 
63 // Do the job
64 void DTTPDeadWriter::analyze(const Event& event, const EventSetup& eventSetup) {
65  set<DTLayerId> analyzedLayers;
66 
67  //Loop on tzero map
68  for (DTT0::const_iterator tzero = tZeroMap->begin(); tzero != tZeroMap->end(); ++tzero) {
69  //Consider what layers have been already considered
70  // @@@ NEW DTT0 FORMAT
71  // DTLayerId layerId = (DTWireId((*tzero).first.wheelId,
72  // (*tzero).first.stationId,
73  // (*tzero).first.sectorId,
74  // (*tzero).first.slId,
75  // (*tzero).first.layerId,
76  // (*tzero).first.cellId)).layerId();
77  int channelId = tzero->channelId;
78  if (channelId == 0)
79  continue;
80  DTLayerId layerId = (DTWireId(channelId)).layerId();
81  // @@@ NEW DTT0 END
82  if (analyzedLayers.find(layerId) == analyzedLayers.end()) {
83  analyzedLayers.insert(layerId);
84 
85  //Take the layer topology
86  const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
87  const int firstWire = dtTopo.firstChannel();
88  //const int lastWire = dtTopo.lastChannel();
89  const int nWires = muonGeom->layer(layerId)->specificTopology().channels();
90 
91  //Loop on wires
92  for (int wire = firstWire; wire <= nWires; wire++) {
93  DTWireId wireId(layerId, wire);
94  float t0 = 0;
95  float t0rms = 0;
96  tZeroMap->get(wireId, t0, t0rms, DTTimeUnits::ns);
97 
98  //If no t0 stored then is a tp dead channel
99  if (!t0) {
100  tpDeadList->setCellDead_TP(wireId, true);
101  cout << "Wire id " << wireId << " is TP dead" << endl;
102  }
103  }
104  }
105  }
106 }
107 
108 // Write objects to DB
110  if (debug)
111  cout << "[DTTPDeadWriter]Writing ttrig object to DB!" << endl;
112 
113  // FIXME: to be read from cfg?
114  string deadRecord = "DTDeadFlagRcd";
115 
116  // Write the object to DB
117  DTCalibDBUtils::writeToDB(deadRecord, tpDeadList);
118 }
DTTPDeadWriter::endJob
void endJob() override
Write ttrig in the DB.
Definition: DTTPDeadWriter.cc:109
DTDeadFlag
Definition: DTDeadFlag.h:66
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
DTTPDeadWriter::~DTTPDeadWriter
~DTTPDeadWriter() override
Destructor.
Definition: DTTPDeadWriter.cc:48
DTT0.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTTPDeadWriter.h
DTTPDeadWriter::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &setup) override
Read t0 map from event.
Definition: DTTPDeadWriter.cc:53
DTDeadFlag.h
DTDeadFlagRcd.h
DTT0Rcd
Definition: DTT0Rcd.h:9
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTTopology
Definition: DTTopology.h:28
DTTPDeadWriter::analyze
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Compute the ttrig by fiting the TB rising edge.
Definition: DTTPDeadWriter.cc:64
debug
#define debug
Definition: HDRShower.cc:19
DTTopology::firstChannel
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
DTWireId
Definition: DTWireId.h:12
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:149
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
edm::ESHandle< DTT0 >
tzero
static const double tzero[3]
Definition: CastorTimeSlew.cc:5
DTLayerId
Definition: DTLayerId.h:12
DTGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
DTT0Rcd.h
DTCalibDBUtils.h
DTTPDeadWriter::DTTPDeadWriter
DTTPDeadWriter(const edm::ParameterSet &pset)
Constructor.
Definition: DTTPDeadWriter.cc:36
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
std
Definition: JetResolutionObject.h:76
DTWireId.h
EventSetup.h
ParameterSet.h
MuonGeometryRecord.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTCalibDBUtils::writeToDB
static void writeToDB(std::string record, T *payload)
Definition: DTCalibDBUtils.h:28
DTT0::const_iterator
std::vector< DTT0Data >::const_iterator const_iterator
Access methods to data.
Definition: DTT0.h:122
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27