Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-16 03:24:10

0001 /******* \class DTMeanTimer *******
0002  *
0003  * Description:
0004  *
0005  * \author : Stefano Lacaprara - INFN LNL <stefano.lacaprara@pd.infn.it>
0006  *
0007  * Modification:
0008  *
0009  *********************************/
0010 
0011 /* This Class Header */
0012 #include "RecoLocalMuon/DTSegment/test/DTMeanTimer.h"
0013 
0014 /* Collaborating Class Header */
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 /* C++ Headers */
0023 using namespace std;
0024 
0025 /* ====================================================================== */
0026 
0027 /* Constructor */
0028 DTMeanTimer::DTMeanTimer(const DTSuperLayer* sl, Handle<DTRecHitCollection>& hits, DTTTrigBaseSync* sync) {
0029   // store the digis in container separated per layer, with the time itself and
0030   // the wire Id: map[int wire]=double time;
0031 
0032   for (DTRecHitCollection::const_iterator hit = hits->begin(); hit != hits->end(); ++hit) {
0033     // get only this SL hits.
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   //get number of wires for the 4 layers
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   // store the digis in container separated per layer, with the time itself and
0058   // the wire Id: map[int wire]=double time;
0059 
0060   for (vector<DTRecHit1D>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
0061     // get only this SL hits.
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   //get number of wires for the 4 layers
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 /* Destructor */
0085 DTMeanTimer::~DTMeanTimer() {}
0086 
0087 /* Operations */
0088 vector<double> DTMeanTimer::run() const {
0089   // the MT can be build from layers 1,2,3 or 2,3,4
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   //loop over wires and get the triplets if they exist
0101   for (int w = 1; w <= theNumWires; ++w) {
0102     // check if we have digis in cell w for the 3 layers
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.); }