CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripRawToClustersRoI.cc
Go to the documentation of this file.
3 #include "CLHEP/Random/RandFlat.h"
4 
5 using namespace std;
6 using namespace sistrip;
7 
9  cabling_(0),
10  cacheId_(0),
11  allregions_(),
12  nlayers_(conf.getUntrackedParameter<int>("Layers",-1)),
13  global_(conf.getUntrackedParameter<bool>("Global",true)),
14  random_(conf.getUntrackedParameter<bool>("Random",false)),
15  electrons_(conf.getUntrackedParameter<bool>("Electrons",false)),
16  muons_(conf.getUntrackedParameter<bool>("Muons",false)),
17  taujets_(conf.getUntrackedParameter<bool>("TauJets",false)),
18  bjets_(conf.getUntrackedParameter<bool>("BJets",false)),
19  siStripLazyGetter_(conf.getParameter<edm::InputTag>("SiStripLazyGetter")),
20  electronBarrelL2_(conf.getParameter<edm::InputTag>("ElectronBarrelL2")),
21  electronEndcapL2_(conf.getParameter<edm::InputTag>("ElectronEndcapL2")),
22  muonL2_(conf.getParameter<edm::InputTag>("MuonL2")),
23  taujetL2_(conf.getParameter<edm::InputTag>("TauJetL2")),
24  bjetL2_(conf.getParameter<edm::InputTag>("BJetL2")),
25  electrondeta_(conf.getUntrackedParameter<double>("ElectronEtaWindow",0.2)),
26  electrondphi_(conf.getUntrackedParameter<double>("ElectronPhiWindow",0.2)),
27  muondeta_(conf.getUntrackedParameter<double>("MuonEtaWindow",0.2)),
28  muondphi_(conf.getUntrackedParameter<double>("MuonPhiWindow",0.2)),
29  taujetdeta_(conf.getUntrackedParameter<double>("TauJetEtaWindow",0.2)),
30  taujetdphi_(conf.getUntrackedParameter<double>("TauJetPhiWindow",0.2)),
31  bjetdeta_(conf.getUntrackedParameter<double>("BJetEtaWindow",0.2)),
32  bjetdphi_(conf.getUntrackedParameter<double>("BJetPhiWindow",0.2))
33 {
34  produces< RefGetter >();
35 }
36 
38 
40  updateCabling( setup );
41 }
42 
44 
45  updateCabling( setup );
46 
47  edm::Handle< LazyGetter > lazygetter;
48  event.getByLabel(siStripLazyGetter_,lazygetter);
49 
51 
52  if (global_) {
53  std::auto_ptr<RefGetter> globalrefgetter(new RefGetter(lazygetter,allregions_));
54  /*//unpack
55  for (RefGetter::const_iterator iReg = globalrefgetter->begin(); iReg != globalrefgetter->end(); iReg++) *iReg;*/
56  event.put(globalrefgetter);
57  return;
58  }
59 
60  std::auto_ptr<RefGetter> refgetter(new RefGetter(allregions_.size()));
61  refgetter->reserve(10000);
62 
64 
65  if (random_) {random(*refgetter,lazygetter);}
66 
68 
69  if (electrons_) {
72  event.getByLabel(electronBarrelL2_,barrelcollection);
73  event.getByLabel(electronEndcapL2_,endcapcollection);
74  if (barrelcollection.isValid()) {
75  electrons(*barrelcollection,*refgetter,lazygetter);
76  }
77  if (endcapcollection.isValid()) {
78  electrons(*endcapcollection,*refgetter,lazygetter);
79  }
80  }
81 
83 
84  if (muons_) {
86  event.getByLabel(muonL2_,collection);
87  if (collection.isValid()) {
88  muons(*collection,*refgetter,lazygetter);
89  }
90  }
91 
93 
94  if (taujets_) {
96  event.getByLabel(taujetL2_,collection);
97  if (collection.isValid()) {
98  taujets(*collection,*refgetter,lazygetter);
99  }
100  }
101 
103 
104  if (bjets_) {
106  event.getByLabel(bjetL2_,collection);
107  if (collection.isValid()) {
108  bjets(*collection,*refgetter,lazygetter);
109  }
110  }
111 
112  event.put(refgetter);
113 }
114 
115 // -----------------------------------------------------------------------------
118  uint32_t cache_id = setup.get<SiStripRegionCablingRcd>().cacheIdentifier();
119  if ( cacheId_ != cache_id ) {
121  setup.get<SiStripRegionCablingRcd>().get( c );
122  cabling_ = c.product();
123  cacheId_ = cache_id;
124  allregions_.clear();
125  allregions_.reserve( cabling_->getRegionCabling().size() );
126  for (uint32_t iregion=0;iregion<cabling_->getRegionCabling().size();iregion++) {
127  for (uint32_t isubdet=0;isubdet<cabling_->getRegionCabling()[iregion].size();isubdet++) {
128  for (uint32_t ilayer=0;ilayer<cabling_->getRegionCabling()[iregion][isubdet].size();ilayer++) {
129  uint32_t index = SiStripRegionCabling::elementIndex(iregion,static_cast<SubDet>(isubdet),ilayer);
130  allregions_.push_back(index);
131  }
132  }
133  }
134  }
135 }
136 
137 bool SiStripRawToClustersRoI::physicalLayer(SubDet& subdet, uint32_t& layer) const {
138  int signedlayer = static_cast<int>(SiStripRegionCabling::physicalLayer(subdet,layer));
139  return (nlayers_ == -1 || signedlayer < nlayers_) ? true : false;
140 }
141 
143 
144  uint32_t total = cabling_->getRegionCabling().size();
145  uint32_t required = static_cast<uint32_t>(CLHEP::RandFlat::shoot()*(total+1));
146  for (uint32_t iregion = 0; iregion < required; iregion++) {
147  for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
148  SubDet subdet = static_cast<SubDet>(isubdet);
149  for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
150  if (!physicalLayer(subdet,ilayer)) break;
151  cabling_->updateSiStripRefGetter<SiStripCluster>(refgetter,lazygetter,SiStripRegionCabling::elementIndex(iregion,subdet,ilayer));
152  }
153  }
154  }
155 }
156 
158 
159  reco::SuperClusterCollection::const_iterator icollection = collection.begin();
160  for (; icollection!=collection.end(); icollection++) {
161  Position position(icollection->eta(),icollection->phi());
162  for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
163  SubDet subdet = static_cast<SubDet>(isubdet);
164  for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
165  if (!physicalLayer(subdet,ilayer)) break;
167  }
168  }
169  }
170 }
171 
173 
174  reco::TrackCollection::const_iterator icollection = collection.begin();
175  for (; icollection!=collection.end(); icollection++) {
176  Position position(icollection->outerPosition().eta(),icollection->outerPosition().phi());
177  for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
178  SubDet subdet = static_cast<SubDet>(isubdet);
179  for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
180  if (!physicalLayer(subdet,ilayer)) break;
181  cabling_->updateSiStripRefGetter<SiStripCluster>(refgetter,lazygetter,position,muondeta_,muondphi_,subdet,ilayer);
182  }
183  }
184  }
185 }
186 
188 
189  reco::CaloJetCollection::const_iterator icollection = collection.begin();
190  for (; icollection!=collection.end(); icollection++) {
191  Position position(icollection->eta(),icollection->phi());
192  for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
193  SubDet subdet = static_cast<SubDet>(isubdet);
194  for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
195  if (!physicalLayer(subdet,ilayer)) break;
196  cabling_->updateSiStripRefGetter<SiStripCluster>(refgetter,lazygetter,position,taujetdeta_,taujetdphi_,subdet,ilayer);
197  }
198  }
199  }
200 }
201 
203 
204  reco::CaloJetCollection::const_iterator icollection = collection.begin();
205  for (; icollection!=collection.end(); icollection++) {
206  Position position(icollection->eta(),icollection->phi());
207  for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
208  SubDet subdet = static_cast<SubDet>(isubdet);
209  for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
210  if (!physicalLayer(subdet,ilayer)) break;
211  cabling_->updateSiStripRefGetter<SiStripCluster>(refgetter,lazygetter,position,bjetdeta_,bjetdphi_,subdet,ilayer);
212  }
213  }
214  }
215 }
216 
static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer)
bool physicalLayer(SubDet &, uint32_t &) const
static const uint32_t physicalLayer(const SubDet, const uint32_t layer)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
void bjets(const reco::CaloJetCollection &, RefGetter &, edm::Handle< LazyGetter > &) const
std::vector< uint32_t > allregions_
const SiStripRegionCabling * cabling_
void muons(const reco::TrackCollection &, RefGetter &, edm::Handle< LazyGetter > &) const
void random(RefGetter &, edm::Handle< LazyGetter > &) const
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void updateSiStripRefGetter(edm::RefGetter< T > &refgetter, const edm::Handle< edm::LazyGetter< T > > &lazygetter, const ElementIndex) const
void updateCabling(const edm::EventSetup &setup)
const Cabling & getRegionCabling() const
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
bool isValid() const
Definition: HandleBase.h:76
tuple conf
Definition: dbtoconf.py:185
SiStripRawToClustersRoI(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void electrons(const reco::SuperClusterCollection &, RefGetter &, edm::Handle< LazyGetter > &) const
SiStripRegionCabling::Position Position
void taujets(const reco::CaloJetCollection &, RefGetter &, edm::Handle< LazyGetter > &) const
static int position[264][3]
Definition: ReadPGInfo.cc:509
edm::RefGetter< SiStripCluster > RefGetter
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: Run.h:33
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
virtual void beginRun(edm::Run &, const edm::EventSetup &)