CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlCaHcalNoiseProducer.cc
Go to the documentation of this file.
1 /*
2 Original author Grigory Safronov
3 
4 27/03/09 - compilation from :
5 HLTrigger/special/src/HLTHcalNoiseFilter.cc
6 Calibration/HcalAlCaRecoProducers/src/AlCaEcalHcalReadoutsProducer.cc
7 Calibration/HcalIsolatedTrackReco/src/SubdetFEDSelector.cc
8 
9 */
10 
11 
14 
18 
20 
28 
30 
31 
33 {
34  JetSource_ = iConfig.getParameter<edm::InputTag>("JetSource");
35  MetSource_ = iConfig.getParameter<edm::InputTag>("MetSource");
36  TowerSource_ = iConfig.getParameter<edm::InputTag>("TowerSource");
37  useMet_ = iConfig.getParameter<bool>("UseMET");
38  useJet_ = iConfig.getParameter<bool>("UseJet");
39  MetCut_ = iConfig.getParameter<double>("MetCut");
40  JetMinE_ = iConfig.getParameter<double>("JetMinE");
41  JetHCALminEnergyFraction_ = iConfig.getParameter<double>("JetHCALminEnergyFraction");
42 
43  hoLabel_ = iConfig.getParameter<edm::InputTag>("hoInput");
44  hfLabel_ = iConfig.getParameter<edm::InputTag>("hfInput");
45  hbheLabel_ = iConfig.getParameter<edm::InputTag>("hbheInput");
46  ecalLabels_= iConfig.getParameter<std::vector<edm::InputTag> >("ecalInputs");
47  ecalPSLabel_=iConfig.getParameter<edm::InputTag>("ecalPSInput");
48  rawInLabel_=iConfig.getParameter<edm::InputTag>("rawInput");
49 
50 
51  //register products
52  produces<HBHERecHitCollection>("HBHERecHitCollectionFHN");
53  produces<HORecHitCollection>("HORecHitCollectionFHN");
54  produces<HFRecHitCollection>("HFRecHitCollectionFHN");
55 
56  produces<EcalRecHitCollection>("EcalRecHitCollectionFHN");
57  produces<EcalRecHitCollection>("PSEcalRecHitCollectionFHN");
58 
59  produces<FEDRawDataCollection>("HcalFEDsFHN");
60 
61 }
62 
63 
65 {
66 }
67 
68 
69 // ------------ method called to produce the data ------------
70 void
72 {
73  bool acceptEvent=false;
74 
75  // filtering basing on HLTrigger/special/src/HLTHcalNoiseFilter.cc:
76 
77  bool isAnomalous_BasedOnMET = false;
78  bool isAnomalous_BasedOnEnergyFraction=false;
79 
80  if (useMet_)
81  {
83  iEvent.getByLabel(MetSource_, metHandle);
84  const reco::CaloMETCollection *metCol = metHandle.product();
85  const reco::CaloMET met = metCol->front();
86 
87  if(met.pt() > MetCut_) isAnomalous_BasedOnMET=true;
88  }
89 
90  if (useJet_)
91  {
93  iEvent.getByLabel(JetSource_,calojetHandle);
94 
96  iEvent.getByLabel(TowerSource_, towerHandle);
97 
98  std::vector<CaloTower> TowerContainer;
99  std::vector<reco::CaloJet> JetContainer;
100  TowerContainer.clear();
101  JetContainer.clear();
102  CaloTower seedTower;
103  nEvents++;
104  for(reco::CaloJetCollection::const_iterator calojetIter = calojetHandle->begin();calojetIter != calojetHandle->end();++calojetIter) {
105  if( ((calojetIter->et())*cosh(calojetIter->eta()) > JetMinE_) && (calojetIter->energyFractionHadronic() > JetHCALminEnergyFraction_) ) {
106  JetContainer.push_back(*calojetIter);
107  double maxTowerE = 0.0;
108  for(CaloTowerCollection::const_iterator kal = towerHandle->begin(); kal != towerHandle->end(); kal++) {
109  double dR = deltaR((*calojetIter).eta(),(*calojetIter).phi(),(*kal).eta(),(*kal).phi());
110  if( (dR < 0.50) && (kal->p() > maxTowerE) ) {
111  maxTowerE = kal->p();
112  seedTower = *kal;
113  }
114  }
115  TowerContainer.push_back(seedTower);
116  }
117 
118  }
119  if(JetContainer.size() > 0) {
121  isAnomalous_BasedOnEnergyFraction = true;
122  }
123  }
124 
125  acceptEvent=((useMet_&&isAnomalous_BasedOnMET)||(useJet_&&isAnomalous_BasedOnEnergyFraction));
126 
128 
129  //Create empty output collections
130 
131  std::auto_ptr<HBHERecHitCollection> miniHBHERecHitCollection(new HBHERecHitCollection);
132  std::auto_ptr<HORecHitCollection> miniHORecHitCollection(new HORecHitCollection);
133  std::auto_ptr<HFRecHitCollection> miniHFRecHitCollection(new HFRecHitCollection);
134 
135  std::auto_ptr<EcalRecHitCollection> outputEColl(new EcalRecHitCollection);
136  std::auto_ptr<EcalRecHitCollection> outputESColl(new EcalRecHitCollection);
137 
138  std::auto_ptr<FEDRawDataCollection> outputFEDs(new FEDRawDataCollection);
139 
140 
141  // if good event get and save all colletions
142  if (acceptEvent)
143  {
147 
148  iEvent.getByLabel(hbheLabel_,hbhe);
149  iEvent.getByLabel(hoLabel_,ho);
150  iEvent.getByLabel(hfLabel_,hf);
151 
153  iEvent.getByLabel(ecalPSLabel_,pRecHits);
154 
155  // temporary collection of EB+EE recHits
156 
157  std::auto_ptr<EcalRecHitCollection> tmpEcalRecHitCollection(new EcalRecHitCollection);
158 
159  std::vector<edm::InputTag>::const_iterator i;
160  for (i=ecalLabels_.begin(); i!=ecalLabels_.end(); i++)
161  {
163  iEvent.getByLabel(*i,ec);
164  for(EcalRecHitCollection::const_iterator recHit = (*ec).begin(); recHit != (*ec).end(); ++recHit)
165  {
166  tmpEcalRecHitCollection->push_back(*recHit);
167  }
168  }
169 
171 
173  const HBHERecHitCollection Hithbhe = *(hbhe.product());
174  for(HBHERecHitCollection::const_iterator hbheItr=Hithbhe.begin(); hbheItr!=Hithbhe.end(); hbheItr++)
175  {
176  miniHBHERecHitCollection->push_back(*hbheItr);
177  }
178  const HORecHitCollection Hitho = *(ho.product());
179  for(HORecHitCollection::const_iterator hoItr=Hitho.begin(); hoItr!=Hitho.end(); hoItr++)
180  {
181  miniHORecHitCollection->push_back(*hoItr);
182  }
183 
184  const HFRecHitCollection Hithf = *(hf.product());
185  for(HFRecHitCollection::const_iterator hfItr=Hithf.begin(); hfItr!=Hithf.end(); hfItr++)
186  {
187  miniHFRecHitCollection->push_back(*hfItr);
188  }
190 
192  for (std::vector<EcalRecHit>::const_iterator ehit=tmpEcalRecHitCollection->begin(); ehit!=tmpEcalRecHitCollection->end(); ehit++)
193  {
194  outputEColl->push_back(*ehit);
195  }
197 
198  // write PS
199  const EcalRecHitCollection& psrechits = *(pRecHits.product());
200 
201  for(EcalRecHitCollection::const_iterator i=psrechits.begin(); i!=psrechits.end(); i++)
202  {
203  outputESColl->push_back( *i );
204  }
205 
206 
207  // get HCAL FEDs
209  iEvent.getByLabel(rawInLabel_,rawIn);
210 
211  std::vector<int> selFEDs;
213  {
214  selFEDs.push_back(i);
215  }
217 
218  // Copying FEDs :
219  const FEDRawDataCollection *rdc=rawIn.product();
220 
221  // if ( ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) )
222  // continue ; // skip all raw collections not produced by the current process
223 
224  for ( int j=0; j< FEDNumbering::MAXFEDID; ++j )
225  {
226  bool rightFED=false;
227  for (uint32_t k=0; k<selFEDs.size(); k++)
228  {
229  if (j==selFEDs[k])
230  {
231  rightFED=true;
232  }
233  }
234  if (!rightFED) continue;
235  const FEDRawData & fedData = rdc->FEDData(j);
236  size_t size=fedData.size();
237 
238  if ( size > 0 )
239  {
240  // this fed has data -- lets copy it
241  FEDRawData & fedDataProd = outputFEDs->FEDData(j);
242  if ( fedDataProd.size() != 0 ) {
243  // std::cout << " More than one FEDRawDataCollection with data in FED ";
244  // std::cout << j << " Skipping the 2nd\n";
245  continue;
246  }
247  fedDataProd.resize(size);
248  unsigned char *dataProd=fedDataProd.data();
249  const unsigned char *data=fedData.data();
250  for ( unsigned int k=0; k<size; ++k ) {
251  dataProd[k]=data[k];
252  }
253  }
254  }
256  }
257 
258  //Put selected information in the event
259  iEvent.put( miniHBHERecHitCollection, "HBHERecHitCollectionFHN");
260  iEvent.put( miniHORecHitCollection, "HORecHitCollectionFHN");
261  iEvent.put( miniHFRecHitCollection, "HFRecHitCollectionFHN");
262  iEvent.put( outputEColl, "EcalRecHitCollectionFHN");
263  iEvent.put( outputESColl, "PSEcalRecHitCollectionFHN");
264  iEvent.put( outputFEDs, "HcalFEDsFHN");
265 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< CaloTower >::const_iterator const_iterator
void push_back(T const &t)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
std::vector< edm::InputTag > ecalLabels_
int iEvent
Definition: GenABIO.cc:243
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
int k[5][pyjets_maxn]
const_iterator end() const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
AlCaHcalNoiseProducer(const edm::ParameterSet &)
T const * product() const
Definition: Handle.h:74
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual float pt() const GCC11_FINAL
transverse momentum
tuple size
Write out results.
const_iterator begin() const