00001 00002 // File: TrackerizerFP420.cc 00003 // Date: 12.2006 00004 // Description: TrackerizerFP420 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/TrackerizerFP420.h" 00018 #include "DataFormats/FP420Cluster/interface/ClusterCollectionFP420.h" 00019 #include "DataFormats/FP420Cluster/interface/TrackCollectionFP420.h" 00020 00021 #include <iostream> 00022 using namespace std; 00023 00024 // 00025 namespace cms 00026 { 00027 TrackerizerFP420::TrackerizerFP420(const edm::ParameterSet& conf):conf_(conf) { 00028 00029 std::string alias ( conf.getParameter<std::string>("@module_label") ); 00030 00031 produces<TrackCollectionFP420>().setBranchAlias( alias ); 00032 00033 trackerContainers.clear(); 00034 trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList"); 00035 00036 verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel"); 00037 if (verbosity > 0) { 00038 std::cout << "Creating a TrackerizerFP420" << std::endl; 00039 } 00040 00041 // Initialization: 00042 sFP420TrackMain_ = new FP420TrackMain(conf_); 00043 00044 } 00045 00046 // Virtual destructor needed. 00047 TrackerizerFP420::~TrackerizerFP420() { 00048 delete sFP420TrackMain_; 00049 } 00050 00051 //Get at the beginning 00052 void TrackerizerFP420::beginJob() { 00053 if (verbosity > 0) { 00054 std::cout << "BeginJob method " << std::endl; 00055 } 00056 } 00057 00058 00059 void TrackerizerFP420::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) 00060 { 00061 // beginJob; 00062 // be lazy and include the appropriate namespaces 00063 using namespace edm; 00064 using namespace std; 00065 00066 // Get input 00067 //A 00068 // edm::Handle<ClusterCollectionFP420> icf_simhit; 00069 /* 00070 Handle<ClusterCollectionFP420> cf_simhit; 00071 std::vector<const ClusterCollectionFP420 *> cf_simhitvec; 00072 for(uint32_t i = 0; i< trackerContainers.size();i++){ 00073 iEvent.getByLabel( trackerContainers[i], cf_simhit); 00074 cf_simhitvec.push_back(cf_simhit.product()); } 00075 std::auto_ptr<ClusterCollectionFP420 > input(new DigiCollectionFP420(cf_simhitvec)); 00076 */ 00077 00078 //B 00079 00080 Handle<ClusterCollectionFP420> input; 00081 try{ 00082 iEvent.getByLabel( trackerContainers[0] , input); 00083 } catch(...){;} 00084 00085 00086 00087 00088 // Step C: create empty output collection 00089 std::auto_ptr<TrackCollectionFP420> toutput(new TrackCollectionFP420); 00090 00091 00092 00093 // put zero to container info from the beginning (important! because not any detID is updated with coming of new event !!!!!! 00094 // clean info of container from previous event 00095 00096 std::vector<TrackFP420> collector; 00097 collector.clear(); 00098 TrackCollectionFP420::Range inputRange; 00099 inputRange.first = collector.begin(); 00100 inputRange.second = collector.end(); 00101 00102 unsigned int detID = 0; 00103 toutput->putclear(inputRange,detID); 00104 00105 unsigned int StID = 1111; 00106 toutput->putclear(inputRange,StID); 00107 StID = 2222; 00108 toutput->putclear(inputRange,StID); 00109 00110 00111 // !!!!!! 00112 // if we want to keep Track container/Collection for one event ---> uncomment the line below and vice versa 00113 toutput->clear(); //container_.clear() --> start from the beginning of the container 00114 00115 // RUN now: !!!!!! 00116 // startFP420TrackMain_.run(input, toutput); 00117 sFP420TrackMain_->run(input, toutput); 00118 // cout <<"======= TrackerizerFP420: end of produce " << endl; 00119 00120 // Step D: write output to file 00121 iEvent.put(toutput); 00122 }//produce 00123 00124 } // namespace cms 00125 00126