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  t0Token_ = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getParameter<string>("debug")));
40 
41  // Create the object to be written to DB
42  tpDeadList = new DTDeadFlag();
43 
44  if (debug)
45  cout << "[DTTPDeadWriter]Constructor called!" << endl;
46 }
47 
48 // Destructor
50  if (debug)
51  cout << "[DTTPDeadWriter]Destructor called!" << endl;
52 }
53 
55  // Get the t0 map
56  tZeroMap = &setup.getData(t0Token_);
57 
58  // Get the muon Geometry
59  muonGeom = setup.getHandle(dtGeomToken_);
60 }
61 
62 // Do the job
64  set<DTLayerId> analyzedLayers;
65 
66  //Loop on tzero map
68  //Consider what layers have been already considered
69  // @@@ NEW DTT0 FORMAT
70  // DTLayerId layerId = (DTWireId((*tzero).first.wheelId,
71  // (*tzero).first.stationId,
72  // (*tzero).first.sectorId,
73  // (*tzero).first.slId,
74  // (*tzero).first.layerId,
75  // (*tzero).first.cellId)).layerId();
76  int channelId = tzero->channelId;
77  if (channelId == 0)
78  continue;
79  DTLayerId layerId = (DTWireId(channelId)).layerId();
80  // @@@ NEW DTT0 END
81  if (analyzedLayers.find(layerId) == analyzedLayers.end()) {
82  analyzedLayers.insert(layerId);
83 
84  //Take the layer topology
85  const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
86  const int firstWire = dtTopo.firstChannel();
87  //const int lastWire = dtTopo.lastChannel();
88  const int nWires = muonGeom->layer(layerId)->specificTopology().channels();
89 
90  //Loop on wires
91  for (int wire = firstWire; wire <= nWires; wire++) {
92  DTWireId wireId(layerId, wire);
93  float t0 = 0;
94  float t0rms = 0;
95  tZeroMap->get(wireId, t0, t0rms, DTTimeUnits::ns);
96 
97  //If no t0 stored then is a tp dead channel
98  if (!t0) {
99  tpDeadList->setCellDead_TP(wireId, true);
100  cout << "Wire id " << wireId << " is TP dead" << endl;
101  }
102  }
103  }
104  }
105 }
106 
107 // Write objects to DB
109  if (debug)
110  cout << "[DTTPDeadWriter]Writing ttrig object to DB!" << endl;
111 
112  // FIXME: to be read from cfg?
113  string deadRecord = "DTDeadFlagRcd";
114 
115  // Write the object to DB
117 }
const DTT0 * tZeroMap
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void beginRun(const edm::Run &, const edm::EventSetup &setup) override
Read t0 map from event.
static void writeToDB(std::string record, const T &payload)
DTDeadFlag * tpDeadList
const_iterator end() const
Definition: DTT0.cc:147
~DTTPDeadWriter() override
Destructor.
std::vector< DTT0Data >::const_iterator const_iterator
Access methods to data.
Definition: DTT0.h:122
const_iterator begin() const
Definition: DTT0.cc:145
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
Transition
Definition: Transition.h:12
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Compute the ttrig by fiting the TB rising edge.
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
DTTPDeadWriter(const edm::ParameterSet &pset)
Constructor.
int setCellDead_TP(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
Definition: DTDeadFlag.cc:218
uint8_t channelId(const VFATFrame &frame)
retrieve this channel identifier
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float &t0mean, float &t0rms, DTTimeUnits::type unit) const
Definition: DTT0.cc:48
edm::ESHandle< DTGeometry > muonGeom
HLT enums.
edm::ESGetToken< DTT0, DTT0Rcd > t0Token_
static const double tzero[3]
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
void endJob() override
Write ttrig in the DB.
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:76
Definition: event.py:1
Definition: Run.h:45
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96