Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00033 #include "SimDataFormats/CrossingFrame/interface/PCrossingFrame.h"
00034
00035 #include "FWCore/Framework/interface/InputSourceDescription.h"
00036 #include "FWCore/Sources/interface/VectorInputSourceFactory.h"
00037
00038 #include "FWCore/Sources/interface/VectorInputSource.h"
00039
00040 #include "Mixing/Base/interface/PileUp.h"
00041
00042 #include "SecSourceAnalyzer.h"
00043
00044 #include "TH1F.h"
00045
00046
00047
00048
00049 namespace edm
00050 {
00051 SecSourceAnalyzer::SecSourceAnalyzer(const edm::ParameterSet& iConfig)
00052 :minBunch_(0),
00053 maxBunch_(0),
00054 tag_(InputTag())
00055 {
00056 int minb = minBunch_;
00057 int maxb = maxBunch_;
00058 int averageNumber = 1;
00059 std::string histoFileName = " ";
00060 TH1F * histoName = new TH1F("h","",10,0,10);
00061 bool playback = false;
00062
00063 input_.reset(new edm::PileUp(iConfig.getParameter<edm::ParameterSet>("input"),minb,maxb,averageNumber,histoName,playback));
00064
00065 dataStep2_ = iConfig.getParameter<bool>("dataStep2");
00066
00067
00068 if (dataStep2_)
00069
00070 label_ = iConfig.getParameter<edm::InputTag>("collPCF");
00071 else
00072
00073 label_ = iConfig.getParameter<edm::InputTag>("collSimTrack");
00074
00075 }
00076
00077
00078 SecSourceAnalyzer::~SecSourceAnalyzer()
00079 {
00080 }
00081
00082
00083
00084
00085
00086
00087
00088 void
00089 SecSourceAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00090 {
00091
00092 vectorEventIDs_.resize(maxBunch_-minBunch_+1);
00093
00094 input_->readPileUp(pileup_[0],vectorEventIDs_);
00095
00096 std::cout << "-> The std::vector<EventPrincipalVector> of the secondary source 'input' has been filled with "
00097 << pileup_[0].size() << " element corresponding to " << maxBunch_-minBunch_+1
00098 << " bunch." << std::endl;
00099
00100
00101 Loop(pileup_[0][0]);
00102 }
00103
00104
00105 void SecSourceAnalyzer::Loop(const EventPrincipalVector& vec) {
00106
00107
00108
00109 std::cout <<"-> Loop over EventPrincipalVector wich size is "<< vec.size() << "." << std::endl;
00110
00111 for (EventPrincipalVector::const_iterator it = vec.begin(); it != vec.end(); ++it) {
00112 std::cout <<"-> Get the event: id " << (*it)->id() << std::endl;
00113
00114 getBranches(&(**it));
00115 }
00116 }
00117
00118
00119 void SecSourceAnalyzer::getBranches(EventPrincipal *ep)
00120 {
00121 std::cout << "-> dataStep2_ = " << dataStep2_ << std::endl;
00122 tag_ = InputTag(label_);
00123
00124 std::cout << "-> Will try to get the branch with the tag : " << tag_ << std::endl;
00125 std::cout << " and the EventPrincipal ep with a size = " << ep->size() << std::endl;
00126
00127 if (!dataStep2_){
00128
00129
00130
00131 boost::shared_ptr<Wrapper<std::vector<SimTrack> > const> shPtr =
00132 getProductByTag<std::vector<SimTrack> >(*ep, tag_);
00133
00134 if (shPtr)
00135 std::cout << "-> Could get SimTrack !" << std::endl;
00136 else
00137 std::cout << "-> Could not get SimTrack !" << std::endl;
00138
00139 }
00140 else{
00141
00142
00143
00144 tag_ = InputTag("CFwriter","g4SimHits");
00145 boost::shared_ptr<Wrapper<PCrossingFrame<SimTrack> > const> shPtr =
00146 getProductByTag<PCrossingFrame<SimTrack> >(*ep, tag_);
00147
00148 if (shPtr)
00149 std::cout << "-> Could get PCrossingFrame<SimTrack> !" << std::endl;
00150 else
00151 std::cout << "-> Could not get PCrossingFrame<SimTrack> !" << std::endl;
00152
00153 }
00154
00155 }
00156
00157
00158
00159 void
00160 SecSourceAnalyzer::beginJob()
00161 {
00162 }
00163
00164
00165 void
00166 SecSourceAnalyzer::endJob() {
00167 if (input_) input_->endJob();
00168 }
00169
00170 }