ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitEdm/Producers/interface/TrackToTrackAssociator.h
Revision: 1.2
Committed: Wed Jul 15 20:38:24 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, V07-05-00, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, ConvRejection-10-06-09, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010, HEAD
Branch point for: Mit_025c_branch
Changes since 1.1: +23 -22 lines
Log Message:
Cleanup

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: TrackToTrackAssociator.h,v 1.1 2008/11/04 19:25:55 bendavid Exp $
3 //
4 // TrackToTrackAssociator
5 //
6 // Base class for all more specific candidate producers.
7 //
8 // Authors: C.Paus
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITEDM_PRODUCERS_TRACKTOTRACKASSOCIATOR_H
12 #define MITEDM_PRODUCERS_TRACKTOTRACKASSOCIATOR_H
13
14 #include <vector>
15 #include <iostream>
16 #include <TString.h>
17 #include "FWCore/Framework/interface/Frameworkfwd.h"
18 #include "FWCore/Framework/interface/EDProducer.h"
19 #include "FWCore/Framework/interface/Event.h"
20 #include "FWCore/Framework/interface/MakerMacros.h"
21 #include "FWCore/ParameterSet/interface/ParameterSet.h"
22
23 namespace mitedm
24 {
25 class TrackToTrackAssociator : public edm::EDProducer
26 {
27 public:
28 explicit TrackToTrackAssociator(const edm::ParameterSet&);
29 ~TrackToTrackAssociator() {}
30
31 protected:
32 void beginJob(const edm::EventSetup&) {}
33 void produce(edm::Event&, const edm::EventSetup&);
34 void endJob() {}
35
36 // generic accessors to make the code more simple
37 void PrintErrorAndExit(const char *msg) const;
38 template <typename TYPE>
39 bool GetProduct(const std::string name, edm::Handle<TYPE> &product,
40 const edm::Event &event, bool ignore = true) const;
41
42 std::string fromTracksName_; //name of tracks which are association keys
43 std::string toTracksName_; //name of tracks which are association values
44 };
45 }
46
47 //--------------------------------------------------------------------------------------------------
48 template <typename TYPE>
49 inline bool mitedm::TrackToTrackAssociator::GetProduct(const std::string edmName,
50 edm::Handle<TYPE> &product,
51 const edm::Event &evt, bool ignore) const
52 {
53 // Try to access data collection from EDM file. We check if we really get just one
54 // product with the given name. If not we print an error and exit.
55
56 try {
57 evt.getByLabel(edm::InputTag(edmName),product);
58 if (! product.isValid())
59 throw edm::Exception(edm::errors::Configuration, "TrackToTrackAssociator::GetProduct()\n")
60 << "Cannot get collection with label " << edmName << std::endl;
61 } catch (...) {
62 if (ignore)
63 return false;
64 else {
65 edm::LogError("TrackToTrackAssociator") << "Cannot get collection with label "
66 << edmName << std::endl;
67 PrintErrorAndExit(Form("Cannot get collection with label %s", edmName.c_str()));
68 }
69 }
70 return true;
71 }
72 #endif