CMS 3D CMS Logo

ReconstructerFP420.cc

Go to the documentation of this file.
00001 
00002 // File: ReconstructerFP420.cc
00003 // Date: 11.2007
00004 // Description: ReconstructerFP420 for FP420
00005 // Modifications: 
00007 #include <memory>
00008 #include <string>
00009 #include "FWCore/Framework/interface/Frameworkfwd.h"
00010 #include "FWCore/Framework/interface/EDProducer.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/MakerMacros.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 
00017 #include "RecoRomanPot/RecoFP420/interface/ReconstructerFP420.h"
00018 #include "DataFormats/FP420Cluster/interface/TrackCollectionFP420.h"
00019 #include "DataFormats/FP420Cluster/interface/RecoCollectionFP420.h"
00020 
00021 #include <iostream> 
00022 using namespace std;
00023 
00024 //
00025 namespace cms
00026 {
00027   ReconstructerFP420::ReconstructerFP420(const edm::ParameterSet& conf):conf_(conf)     {
00028     
00029     edm::LogInfo ("ReconstructerFP420 ") <<"Enter the FP420 Reco constructer";
00030 
00031 
00032     verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
00033     if (verbosity > 0) {
00034       std::cout << "Constructor of  ReconstructerFP420" << std::endl;
00035     }
00036 
00037 
00038     std::string alias ( conf.getParameter<std::string>("@module_label") );
00039     
00040     produces<RecoCollectionFP420>().setBranchAlias( alias );
00041     
00042     trackerContainers.clear();
00043     trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
00044     
00045     
00046     // Initialization:
00047     sFP420RecoMain_ = new FP420RecoMain(conf_);
00048     
00049   }
00050   
00051   // Virtual destructor needed.
00052   ReconstructerFP420::~ReconstructerFP420() {
00053     if (verbosity > 0) {
00054       std::cout << "ReconstructerFP420:delete FP420RecoMain" << std::endl;
00055     }
00056     delete sFP420RecoMain_;
00057   }  
00058   
00059   //Get at the beginning
00060   void ReconstructerFP420::beginJob() {
00061     if (verbosity > 0) {
00062       std::cout << "ReconstructerFP420:BeginJob method " << std::endl;
00063     }
00064   }
00065   
00066   
00067   void ReconstructerFP420::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00068   {
00069     //  beginJob;
00070     // be lazy and include the appropriate namespaces
00071     using namespace edm; 
00072     using namespace std;   
00073     
00074     // Get input
00075     //A
00076     //   edm::Handle<ClusterCollectionFP420> icf_simhit;
00077     /*
00078     Handle<ClusterCollectionFP420> cf_simhit;
00079     std::vector<const ClusterCollectionFP420 *> cf_simhitvec;
00080     for(uint32_t i = 0; i< trackerContainers.size();i++){
00081       iEvent.getByLabel( trackerContainers[i], cf_simhit);
00082       cf_simhitvec.push_back(cf_simhit.product());   }
00083     std::auto_ptr<ClusterCollectionFP420 > input(new DigiCollectionFP420(cf_simhitvec));
00084     */   
00085     
00086     //B
00087     
00088       Handle<TrackCollectionFP420> input;
00089       try{
00090       iEvent.getByLabel( trackerContainers[0] , input);
00091       } catch(...){;}
00092 
00093 
00094        
00095     
00096     // Step C: create empty output collection
00097     std::auto_ptr<RecoCollectionFP420> toutput(new RecoCollectionFP420);
00098     
00099     
00100     
00101     //    put zero to container info from the beginning (important! because not any detID is updated with coming of new event     !!!!!!   
00102     // clean info of container from previous event
00103     
00104     std::vector<RecoFP420> collector;
00105     collector.clear();
00106     RecoCollectionFP420::Range inputRange;
00107     inputRange.first = collector.begin();
00108     inputRange.second = collector.end();
00109     
00110     unsigned int detID = 0;
00111     toutput->putclear(inputRange,detID);
00112     
00113     unsigned  int StID = 1;
00114     toutput->putclear(inputRange,StID);
00115     StID = 2;
00116     toutput->putclear(inputRange,StID);
00117     
00118     
00119     //                                                                                                                      !!!!!!   
00120     // if we want to keep Reco container/Collection for one event --->   uncomment the line below and vice versa
00121     toutput->clear();   //container_.clear() --> start from the beginning of the container
00122     
00123     //                                RUN now:                                                                                 !!!!!!     
00124     //   startFP420RecoMain_.run(input, toutput);
00125     sFP420RecoMain_->run(input, toutput);
00126     // cout <<"=======           ReconstructerFP420:                    end of produce     " << endl;
00127     
00128         // Step D: write output to file
00129     if (verbosity > 0) {
00130       std::cout << "ReconstructerFP420: iEvent.put(toutput)" << std::endl;
00131     }
00132         iEvent.put(toutput);
00133     if (verbosity > 0) {
00134       std::cout << "ReconstructerFP420: iEvent.put(toutput) DONE" << std::endl;
00135     }
00136   }//produce
00137   
00138 } // namespace cms
00139 
00140 

Generated on Tue Jun 9 17:44:54 2009 for CMSSW by  doxygen 1.5.4