Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-14 23:39:50

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGeneratorFactory.h"
0009 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGenerator.h"
0010 // #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0011 
0012 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducerFactory.h"
0013 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
0014 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
0015 #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h"
0016 #include "FWCore/Framework/interface/ConsumesCollector.h"
0017 
0018 //#include "FWCore/Framework/interface/ESWatcher.h"
0019 //#include "UserCode/konec/test/R2DTimerObserver.h"
0020 #include "TH1D.h"
0021 #include "TFile.h"
0022 
0023 class HitTripletProducer : public edm::one::EDAnalyzer<> {
0024 public:
0025   explicit HitTripletProducer(const edm::ParameterSet& conf);
0026   ~HitTripletProducer();
0027   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0028 
0029 private:
0030   std::unique_ptr<OrderedHitsGenerator> theGenerator;
0031   std::unique_ptr<TrackingRegionProducer> theRegionProducer;
0032   TH1D *hCPU, *hNum;
0033 };
0034 
0035 HitTripletProducer::HitTripletProducer(const edm::ParameterSet& conf) {
0036   edm::LogInfo("HitTripletProducer") << " CTOR";
0037   hCPU = new TH1D("hCPU", "hCPU", 140, 0., 0.070);
0038   hNum = new TH1D("hNum", "hNum", 250, 0., 500.);
0039 
0040   edm::ParameterSet orderedPSet = conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
0041   std::string orderedName = orderedPSet.getParameter<std::string>("ComponentName");
0042   edm::ConsumesCollector iC = consumesCollector();
0043   theGenerator = OrderedHitsGeneratorFactory::get()->create(orderedName, orderedPSet, iC);
0044 
0045   edm::ParameterSet regfactoryPSet = conf.getParameter<edm::ParameterSet>("RegionFactoryPSet");
0046   std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
0047   theRegionProducer = TrackingRegionProducerFactory::get()->create(regfactoryName, regfactoryPSet, consumesCollector());
0048 }
0049 
0050 HitTripletProducer::~HitTripletProducer() {
0051   edm::LogInfo("HitTripletProducer") << " DTOR";
0052 
0053   TFile rootFile("analysis.root", "RECREATE", "my histograms");
0054   hCPU->Write();
0055   hNum->Write();
0056   rootFile.Close();
0057 }
0058 
0059 void HitTripletProducer::analyze(const edm::Event& ev, const edm::EventSetup& es) {
0060   typedef std::vector<std::unique_ptr<TrackingRegion> > Regions;
0061   Regions regions = theRegionProducer->regions(ev, es);
0062   const TrackingRegion& region = *regions[0];
0063 
0064   //  static R2DTimerObserver timer("**** MY TIMING REPORT ***");
0065   //  timer.start();
0066   edm::LogInfo("HitTripletProducer") << "call triplets! ";
0067   const OrderedSeedingHits& triplets = theGenerator->run(region, ev, es);
0068   //  timer.stop();
0069   //  hCPU->Fill( timer.lastMeasurement().real() );
0070   hNum->Fill(triplets.size());
0071   edm::LogInfo("HitTripletProducer") << "size of triplets: " << triplets.size();
0072 
0073   theGenerator->clear();
0074 }
0075 
0076 #include "FWCore/Framework/interface/MakerMacros.h"
0077 DEFINE_FWK_MODULE(HitTripletProducer);