Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:52

0001 /** \file
0002  *
0003  * \author Riccardo Bellan - INFN TO <riccardo.bellan@cern.ch>
0004  */
0005 
0006 /* This Class Header */
0007 #include "RecoLocalMuon/DTSegment/test/DTRecSegment4DReader.h"
0008 
0009 /* Collaborating Class Header */
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/Framework/interface/Frameworkfwd.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 
0014 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0015 
0016 #include "TFile.h"
0017 #include "TH1F.h"
0018 
0019 /* C++ Headers */
0020 #include <string>
0021 
0022 using namespace std;
0023 /* ====================================================================== */
0024 
0025 /// Constructor
0026 DTRecSegment4DReader::DTRecSegment4DReader(const edm::ParameterSet& pset) {
0027   // Get the debug parameter for verbose output
0028   debug = pset.getUntrackedParameter<bool>("debug");
0029   theRootFileName = pset.getUntrackedParameter<string>("rootFileName");
0030  
0031  // the name of the 4D rec hits collection
0032   theRecHits4DLabel = pset.getParameter<string>("recHits4DLabel");
0033 
0034   if(debug)
0035     cout << "[DTRecSegment4DReader] Constructor called" << endl;
0036 
0037   // Create the root file
0038   theFile = new TFile(theRootFileName.c_str(), "RECREATE");
0039   theFile->cd();
0040   hPositionX = new TH1F("hPositionX","X Position of the Segments",200,-210,210);
0041 }
0042 
0043 /// Destructor
0044 DTRecSegment4DReader::~DTRecSegment4DReader() {
0045   if(debug) 
0046     cout << "[DTRecSegment4DReader] Destructor called" << endl;
0047 
0048   // Write the histos to file
0049   theFile->cd();
0050   hPositionX->Write();
0051   theFile->Close();
0052 }
0053 
0054 /* Operations */ 
0055 void DTRecSegment4DReader::analyze(const edm::Event & event, const
0056                                  edm::EventSetup& eventSetup) {
0057   cout << endl<<"--- [DTRecSegment4DReader] Event analysed #Run: " << event.id().run()
0058        << " #Event: " << event.id().event() << endl;
0059 
0060   // Get the rechit collection from the event
0061   edm::Handle<DTRecSegment4DCollection> all4DSegments;
0062   event.getByLabel(theRecHits4DLabel, all4DSegments);
0063 
0064   DTRecSegment4DCollection::const_iterator segment;
0065 
0066   cout<<"Reconstructed segments: "<<endl;
0067   for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
0068     cout<<*segment<<endl;
0069     hPositionX->Fill( (*segment).localPosition().x());
0070   }
0071   cout<<"---"<<endl;
0072 
0073 
0074 }
0075 
0076 DEFINE_FWK_MODULE(DTRecSegment4DReader);