Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:13

0001 /// \file AlignmentProducer.cc
0002 ///
0003 ///  \author    : Frederic Ronga
0004 
0005 #include "AlignmentProducer.h"
0006 
0007 #include "FWCore/Framework/interface/LooperFactory.h"
0008 
0009 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0010 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0011 
0012 //------------------------------------------------------------------------------
0013 AlignmentProducer::AlignmentProducer(const edm::ParameterSet &config)
0014     : AlignmentProducerBase(config, consumesCollector()),
0015       maxLoops_{config.getUntrackedParameter<unsigned int>("maxLoops")} {
0016   edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::AlignmentProducer";
0017 
0018   // do now all the consumes
0019   trajTrackAssociationCollectionToken_ = consumes<TrajTrackAssociationCollection>(tjTkAssociationMapTag_);
0020   bsToken_ = consumes<reco::BeamSpot>(beamSpotTag_);
0021   tkFittedLasBeamCollectionToken_ = consumes<TkFittedLasBeamCollection>(tkLasBeamTag_);
0022   tsosVectorCollectionToken_ = consumes<TsosVectorCollection>(tkLasBeamTag_);
0023   aliClusterValueMapToken_ = consumes<AliClusterValueMap>(clusterValueMapTag_);
0024 
0025   // Tell the framework what data is being produced
0026   if (doTracker_) {
0027     setWhatProduced(this, &AlignmentProducer::produceTracker);
0028   }
0029 }
0030 
0031 //------------------------------------------------------------------------------
0032 std::shared_ptr<TrackerGeometry> AlignmentProducer::produceTracker(const TrackerDigiGeometryRecord &) {
0033   edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::produceTracker";
0034   return trackerGeometry_;
0035 }
0036 
0037 //------------------------------------------------------------------------------
0038 void AlignmentProducer::beginOfJob(const edm::EventSetup &iSetup) {
0039   edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::beginOfJob";
0040   initAlignmentAlgorithm(iSetup);
0041 }
0042 
0043 //------------------------------------------------------------------------------
0044 void AlignmentProducer::endOfJob() {
0045   edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfJob";
0046 
0047   if (!finish()) {
0048     edm::LogError("Alignment") << "@SUB=AlignmentProducer::endOfJob"
0049                                << "Did not process any events in last loop, do not dare to store to DB.";
0050   }
0051 }
0052 
0053 //------------------------------------------------------------------------------
0054 void AlignmentProducer::startingNewLoop(unsigned int iLoop) {
0055   edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::startingNewLoop"
0056                             << "Starting loop number " << iLoop;
0057   startProcessing();
0058 }
0059 
0060 //------------------------------------------------------------------------------
0061 edm::EDLooper::Status AlignmentProducer::endOfLoop(const edm::EventSetup &iSetup, unsigned int iLoop) {
0062   if (0 == nEvent()) {
0063     // beginOfJob is usually called by the framework in the first event of the first loop
0064     // (a hack: beginOfJob needs the EventSetup that is not well defined without an event)
0065     // and the algorithms rely on the initialisations done in beginOfJob. We cannot call
0066     // this->beginOfJob(iSetup); here either since that will access the EventSetup to get
0067     // some geometry information that is not defined either without having seen an event.
0068     edm::LogError("Alignment") << "@SUB=AlignmentProducer::endOfLoop"
0069                                << "Did not process any events in loop " << iLoop
0070                                << ", stop processing without terminating algorithm.";
0071     return kStop;
0072   }
0073 
0074   edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::endOfLoop"
0075                             << "Ending loop " << iLoop << ", terminating algorithm.";
0076   terminateProcessing(&iSetup);
0077 
0078   if (iLoop == maxLoops_ - 1 || iLoop >= maxLoops_)
0079     return kStop;
0080   else
0081     return kContinue;
0082 }
0083 
0084 //------------------------------------------------------------------------------
0085 edm::EDLooper::Status AlignmentProducer::duringLoop(const edm::Event &event, const edm::EventSetup &setup) {
0086   if (processEvent(event, setup))
0087     return kContinue;
0088   else
0089     return kStop;
0090 }
0091 
0092 //------------------------------------------------------------------------------
0093 void AlignmentProducer::beginRun(const edm::Run &run, const edm::EventSetup &setup) { beginRunImpl(run, setup); }
0094 
0095 //------------------------------------------------------------------------------
0096 void AlignmentProducer::endRun(const edm::Run &run, const edm::EventSetup &setup) { endRunImpl(run, setup); }
0097 
0098 //------------------------------------------------------------------------------
0099 void AlignmentProducer::beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup) {
0100   beginLuminosityBlockImpl(lumiBlock, setup);
0101 }
0102 
0103 //------------------------------------------------------------------------------
0104 void AlignmentProducer::endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &setup) {
0105   endLuminosityBlockImpl(lumiBlock, setup);
0106 }
0107 
0108 DEFINE_FWK_LOOPER(AlignmentProducer);