1 |
antoniov |
1.2 |
#ifndef ForwardAnalysis_Utilities_TrackMultiplicityEdmNtupleDumper_h
|
2 |
|
|
#define ForwardAnalysis_Utilities_TrackMultiplicityEdmNtupleDumper_h
|
3 |
antoniov |
1.1 |
|
4 |
|
|
#include "FWCore/Framework/interface/EDProducer.h"
|
5 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
6 |
|
|
|
7 |
|
|
class TrackMultiplicityEdmNtupleDumper : public edm::EDProducer {
|
8 |
|
|
public:
|
9 |
|
|
TrackMultiplicityEdmNtupleDumper( const edm::ParameterSet & );
|
10 |
|
|
private:
|
11 |
|
|
void produce( edm::Event &, const edm::EventSetup & );
|
12 |
|
|
edm::InputTag tracksTag_;
|
13 |
|
|
};
|
14 |
|
|
|
15 |
|
|
#endif
|
16 |
|
|
|
17 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
18 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
19 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
20 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
21 |
|
|
|
22 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
23 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
24 |
|
|
|
25 |
|
|
using namespace reco;
|
26 |
|
|
|
27 |
|
|
TrackMultiplicityEdmNtupleDumper::TrackMultiplicityEdmNtupleDumper(const edm::ParameterSet& pset) {
|
28 |
antoniov |
1.2 |
tracksTag_ = pset.getParameter<edm::InputTag>("src");
|
29 |
antoniov |
1.1 |
|
30 |
|
|
std::string alias;
|
31 |
|
|
produces<unsigned int>( alias = "trackMultiplicity" ).setBranchAlias( alias );
|
32 |
|
|
produces<unsigned int>( alias = "trackMultiplicityEtaPlus" ).setBranchAlias( alias );
|
33 |
|
|
produces<unsigned int>( alias = "trackMultiplicityEtaMinus" ).setBranchAlias( alias );
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
void TrackMultiplicityEdmNtupleDumper::produce(edm::Event& event, const edm::EventSetup& setup) {
|
37 |
|
|
// Tracks
|
38 |
|
|
edm::Handle<edm::View<Track> > trackCollectionH;
|
39 |
|
|
event.getByLabel(tracksTag_,trackCollectionH);
|
40 |
|
|
const edm::View<reco::Track>& trkColl = *(trackCollectionH.product());
|
41 |
|
|
|
42 |
|
|
unsigned int ntracks = 0;
|
43 |
|
|
unsigned int ntracks_plus = 0;
|
44 |
|
|
unsigned int ntracks_minus = 0;
|
45 |
|
|
for(edm::View<Track>::const_iterator track = trkColl.begin(); track != trkColl.end(); ++track){
|
46 |
|
|
++ntracks;
|
47 |
|
|
if(track->eta() >= 0.) ++ntracks_plus;
|
48 |
|
|
else ++ntracks_minus;
|
49 |
|
|
}
|
50 |
|
|
std::auto_ptr<unsigned int> trackMultiplicity(new unsigned int(ntracks));
|
51 |
|
|
std::auto_ptr<unsigned int> trackMultiplicityEtaPlus(new unsigned int(ntracks_plus));
|
52 |
|
|
std::auto_ptr<unsigned int> trackMultiplicityEtaMinus(new unsigned int(ntracks_minus));
|
53 |
|
|
|
54 |
|
|
event.put(trackMultiplicity,"trackMultiplicity");
|
55 |
|
|
event.put(trackMultiplicityEtaPlus,"trackMultiplicityEtaPlus");
|
56 |
|
|
event.put(trackMultiplicityEtaMinus,"trackMultiplicityEtaMinus");
|
57 |
|
|
}
|
58 |
|
|
|
59 |
antoniov |
1.2 |
DEFINE_FWK_MODULE(TrackMultiplicityEdmNtupleDumper);
|
60 |
antoniov |
1.1 |
|