File indexing completed on 2023-03-17 11:19:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "RecoLocalMuon/DTSegment/test/DTMeanTimer.h"
0013
0014
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0018 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0019 #include "CalibMuon/DTDigiSync/interface/DTTTrigBaseSync.h"
0020 using namespace edm;
0021
0022
0023 using namespace std;
0024
0025
0026
0027
0028 DTMeanTimer::DTMeanTimer(const DTSuperLayer* sl, Handle<DTRecHitCollection>& hits, DTTTrigBaseSync* sync) {
0029
0030
0031
0032 for (DTRecHitCollection::const_iterator hit = hits->begin(); hit != hits->end(); ++hit) {
0033
0034 if ((*hit).wireId().superlayerId() != sl->id())
0035 continue;
0036
0037 DTWireId wireId = (*hit).wireId();
0038
0039 float ttrig = sync->offset(wireId);
0040
0041 float time = (*hit).digiTime() - ttrig;
0042
0043 hitsLay[wireId.layer() - 1][wireId.wire()] = time;
0044 }
0045
0046
0047 int nWiresSL = 0;
0048 for (int l = 1; l <= 4; ++l) {
0049 int nWires = sl->layer(l)->specificTopology().channels();
0050 if (nWires > nWiresSL)
0051 nWiresSL = nWires;
0052 }
0053 theNumWires = nWiresSL;
0054 }
0055
0056 DTMeanTimer::DTMeanTimer(const DTSuperLayer* sl, vector<DTRecHit1D>& hits, DTTTrigBaseSync* sync) {
0057
0058
0059
0060 for (vector<DTRecHit1D>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
0061
0062 if ((*hit).wireId().superlayerId() != sl->id())
0063 continue;
0064
0065 DTWireId wireId = (*hit).wireId();
0066
0067 float ttrig = sync->offset(wireId);
0068
0069 float time = (*hit).digiTime() - ttrig;
0070
0071 hitsLay[wireId.layer() - 1][wireId.wire()] = time;
0072 }
0073
0074
0075 int nWiresSL = 0;
0076 for (int l = 1; l <= 4; ++l) {
0077 int nWires = sl->layer(l)->specificTopology().channels();
0078 if (nWires > nWiresSL)
0079 nWiresSL = nWires;
0080 }
0081 theNumWires = nWiresSL;
0082 }
0083
0084
0085 DTMeanTimer::~DTMeanTimer() {}
0086
0087
0088 vector<double> DTMeanTimer::run() const {
0089
0090 vector<double> res123 = computeMT(hitsLay[0], hitsLay[1], hitsLay[2]);
0091 vector<double> res234 = computeMT(hitsLay[1], hitsLay[2], hitsLay[3]);
0092
0093 vector<double> result(res123);
0094 result.insert(result.end(), res234.begin(), res234.end());
0095 return result;
0096 }
0097
0098 vector<double> DTMeanTimer::computeMT(hitColl hits1, hitColl hits2, hitColl hits3) const {
0099 vector<double> result;
0100
0101 for (int w = 1; w <= theNumWires; ++w) {
0102
0103 if (hits1.find(w) != hits1.end() && hits2.find(w) != hits2.end() && hits3.find(w) != hits3.end()) {
0104 result.push_back(tMax(hits1[w], hits2[w], hits3[w]));
0105 }
0106 }
0107 return result;
0108 }
0109
0110 double DTMeanTimer::tMax(const double& t1, const double& t2, const double& t3) const { return (t2 + (t1 + t3) / 2.); }