test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFClusterTimeSelector.cc
Go to the documentation of this file.
2 #include <memory>
3 
7 
8 
9 using namespace std;
10 using namespace edm;
11 
12 
14  clusters_(consumes<reco::PFClusterCollection>(iConfig.getParameter<edm::InputTag>("src")))
15 {
16 
17  std::vector<edm::ParameterSet> cuts = iConfig.getParameter<std::vector<edm::ParameterSet> >("cuts");
18  for (const auto& cut :cuts ) {
19  CutInfo info;
20  info.depth = cut.getParameter<double>("depth");
21  info.minE = cut.getParameter<double>("minEnergy");
22  info.maxE = cut.getParameter<double>("maxEnergy");
23  info.minTime = cut.getParameter<double>("minTime");
24  info.maxTime = cut.getParameter<double>("maxTime");
25  info.endcap = cut.getParameter<bool>("endcap");
26  cutInfo_.push_back(info);
27  }
28 
29 
30  produces<reco::PFClusterCollection>();
31  produces<reco::PFClusterCollection>("OOT");
32 }
33 
34 
36  const edm::EventSetup& iSetup) {
37 
39  iEvent.getByToken(clusters_,clusters);
40  std::auto_ptr<reco::PFClusterCollection> out(new reco::PFClusterCollection);
41  std::auto_ptr<reco::PFClusterCollection> outOOT(new reco::PFClusterCollection);
42 
43  for(const auto& cluster : *clusters ) {
44  const double energy = cluster.energy();
45  const double time = cluster.time();
46  const double depth = cluster.depth();
47  const PFLayer::Layer layer = cluster.layer();
48  for (const auto& info : cutInfo_) {
49  if (energy<info.minE || energy>info.maxE)
50  continue;
51  if (depth<0.9*info.depth || depth>1.1*info.depth)
52  continue;
53  if ((info.endcap && (layer==PFLayer::ECAL_BARREL || layer==PFLayer::HCAL_BARREL1 || layer==PFLayer::HCAL_BARREL2))||
54  (((!info.endcap) && (layer==PFLayer::ECAL_ENDCAP || layer==PFLayer::HCAL_ENDCAP))))
55  continue;
56 
57  if (time>info.minTime && time<info.maxTime)
58  out->push_back(cluster);
59  else
60  outOOT->push_back(cluster);
61 
62  break;
63 
64  }
65 
66  }
67 
68 
69 
70  iEvent.put( out);
71  iEvent.put( outOOT,"OOT");
72 
73 }
74 
76 
77 // ------------ method called once each job just before starting event loop ------------
78 void
80  const EventSetup& es) {
81 
82 
83 }
84 
85 
T getParameter(std::string const &) const
static const TGPicture * info(bool iBackgroundIsBlack)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
std::vector< CutInfo > cutInfo_
PFClusterTimeSelector(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
Layer
layer definition
Definition: PFLayer.h:31
virtual void beginRun(const edm::Run &run, const edm::EventSetup &es)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
edm::EDGetTokenT< reco::PFClusterCollection > clusters_
Definition: Run.h:43