CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackCategoriesAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * TrackCategoriesAnalyzer.C
3  *
4  * Created by Victor Eduardo Bazterra on 06/17/08.
5  *
6  */
7 
8 #include "TH1F.h"
9 
15 
17 
19 
20 //
21 // class decleration
22 //
23 
24 class TrackCategoriesAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources>
25 {
26 public:
27 
30 
31 private:
32 
33  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
34 
35  // Member data
36 
38 
39  std::size_t totalTracks_;
40 
42 
44 
46 };
47 
48 
49 TrackCategoriesAnalyzer::TrackCategoriesAnalyzer(const edm::ParameterSet& config) : classifier_(config,consumesCollector())
50 {
51  // Get the track collection
52  trackProducer_ = consumes<edm::View<reco::Track>>(config.getUntrackedParameter<edm::InputTag> ( "trackProducer" ));
53 
54  // Get the file service
55  usesResource("TFileService");
57 
58  // Create a sub directory associated to the analyzer
59  TFileDirectory directory = fs->mkdir( "TrackCategoriesAnalyzer" );
60 
61  // Number of track categories
63 
64  // Define a new histograms
65  trackCategories_ = fs->make<TH1F>(
66  "Frequency",
67  "Frequency for the different track categories",
69  -0.5,
70  numberTrackCategories_ - 0.5
71  );
72 
73  // Set the proper categories names
74  for (Int_t i = 0; i < numberTrackCategories_; ++i)
75  trackCategories_->GetXaxis()->SetBinLabel(i+1, TrackCategories::Names[i]);
76 }
77 
78 
80 
81 
83 {
84  // Track collection
86  event.getByToken(trackProducer_, trackCollection);
87 
88  // Set the classifier for a new event
89  classifier_.newEvent(event, setup);
90 
91  // Loop over the track collection.
92  for (std::size_t index = 0; index < trackCollection->size(); index++)
93  {
94  edm::RefToBase<reco::Track> track(trackCollection, index);
95 
96  // Classify the tracks
97  classifier_.evaluate(track);
98 
99  // Fill the histogram with the categories
100  for (Int_t i = 0; i != numberTrackCategories_; ++i)
101  if (
103  )
104  trackCategories_->Fill(i);
105  }
106 }
107 
108 
110 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static const char *const Names[]
Name of the different categories.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
TrackClassifier const & evaluate(reco::TrackBaseRef const &)
Classify the RecoTrack in categories.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void newEvent(edm::Event const &, edm::EventSetup const &)
Pre-process event information (for accessing reconstraction information)
bool is(Category category) const
Returns track flag for a given category.
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
Get track history and classify it in function of their .
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
TrackCategoriesAnalyzer(const edm::ParameterSet &)
edm::EDGetTokenT< edm::View< reco::Track > > trackProducer_
Category
Categories available to vertex.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")