File indexing completed on 2024-04-06 12:26:09
0001
0002
0003
0004
0005
0006
0007 #include "RecoLocalMuon/DTSegment/src/DTSegment4DT0Corrector.h"
0008
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/Utilities/interface/InputTag.h"
0014
0015 #include "DataFormats/Common/interface/OwnVector.h"
0016
0017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0018
0019 using namespace edm;
0020 using namespace std;
0021
0022 DTSegment4DT0Corrector::DTSegment4DT0Corrector(const ParameterSet& pset) {
0023 produces<DTRecSegment4DCollection>();
0024
0025
0026 debug = pset.getUntrackedParameter<bool>("debug");
0027
0028 if (debug)
0029 cout << "[DTSegment4DT0Corrector] Constructor called" << endl;
0030
0031
0032 recHits4DToken_ = consumes<DTRecSegment4DCollection>(pset.getParameter<InputTag>("recHits4DLabel"));
0033
0034
0035 theUpdator = new DTSegmentUpdator(pset, consumesCollector());
0036 }
0037
0038
0039 DTSegment4DT0Corrector::~DTSegment4DT0Corrector() {
0040 if (debug)
0041 cout << "[DTSegment4DT0Corrector] Destructor called" << endl;
0042 delete theUpdator;
0043 }
0044
0045 void DTSegment4DT0Corrector::produce(Event& event, const EventSetup& setup) {
0046
0047 Handle<DTRecSegment4DCollection> all4DSegments;
0048 event.getByToken(recHits4DToken_, all4DSegments);
0049
0050
0051 theUpdator->setES(setup);
0052
0053
0054 auto segments4DCollection = std::make_unique<DTRecSegment4DCollection>();
0055
0056
0057 DTRecSegment4DCollection::id_iterator chamberId;
0058
0059 if (debug)
0060 cout << "[DTSegment4DT0Corrector] Starting to loop over segments" << endl;
0061
0062 for (chamberId = all4DSegments->id_begin(); chamberId != all4DSegments->id_end(); ++chamberId) {
0063 OwnVector<DTRecSegment4D> result;
0064
0065
0066 DTRecSegment4DCollection::range range = all4DSegments->get(*chamberId);
0067
0068
0069 for (DTRecSegment4DCollection::const_iterator segment4D = range.first; segment4D != range.second; ++segment4D) {
0070 const DTRecSegment4D& tmpseg = *segment4D;
0071
0072 DTRecSegment4D* newSeg = tmpseg.clone();
0073
0074 if (newSeg == nullptr)
0075 continue;
0076
0077 theUpdator->update(newSeg, true, false);
0078 result.push_back(*newSeg);
0079 }
0080
0081 segments4DCollection->put(*chamberId, result.begin(), result.end());
0082 }
0083
0084 if (debug)
0085 cout << "[DTSegment4DT0Corrector] Saving modified segments into the event" << endl;
0086
0087
0088 event.put(std::move(segments4DCollection));
0089 }