CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTrigPrimDigiProducer.cc
Go to the documentation of this file.
22 
23 #include <algorithm>
24 
25 
26 
27 
29 :
30  theAlgo_(ps.getParameter<bool>("peakFilter"),
31  ps.getParameter<std::vector<double> >("weights"),
32  ps.getParameter<int>("latency"),
33  ps.getParameter<uint32_t>("FG_threshold"),
34  ps.getParameter<uint32_t>("ZS_threshold"),
35  ps.getParameter<int>("numberOfSamples"),
36  ps.getParameter<int>("numberOfPresamples"),
37  ps.getParameter<int>("numberOfSamplesHF"),
38  ps.getParameter<int>("numberOfPresamplesHF"),
39  ps.getParameter<uint32_t>("MinSignalThreshold"),
40  ps.getParameter<uint32_t>("PMTNoiseThreshold")
41  ),
42  inputLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputLabel")),
43  inputTagFEDRaw_(ps.getParameter<edm::InputTag> ("InputTagFEDRaw")),
44  runZS_(ps.getParameter<bool>("RunZS")),
45  runFrontEndFormatError_(ps.getParameter<bool>("FrontEndFormatError"))
46 {
47  HFEMB_ = false;
48  if(ps.exists("LSConfig"))
49  {
51  HFEMB_ = LongShortCut_.getParameter<bool>("HcalFeatureHFEMBit");
52  MinLongEnergy_ = LongShortCut_.getParameter<double>("Min_Long_Energy"); //minimum long energy
53  MinShortEnergy_ = LongShortCut_.getParameter<double>("Min_Short_Energy"); //minimum short energy
54  LongShortSlope_ = LongShortCut_.getParameter<double>("Long_vrs_Short_Slope"); //slope of the line that cuts are based on
55  LongShortOffset_ = LongShortCut_.getParameter<double>("Long_Short_Offset"); //offset of line
56  }
57  // register for data access
59  tok_raw_ = consumes<FEDRawDataCollection>(inputTagFEDRaw_);
60  }
61  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabel_[0]);
62  tok_hf_ = consumes<HFDigiCollection>(inputLabel_[1]);
63 
64  produces<HcalTrigPrimDigiCollection>();
65  theAlgo_.setPeakFinderAlgorithm(ps.getParameter<int>("PeakFinderAlgorithm"));
66 
67  edm::ParameterSet hfSS=ps.getParameter<edm::ParameterSet>("HFTPScaleShift");
68 
69  theAlgo_.setNCTScaleShift(hfSS.getParameter<int>("NCT"));
70  theAlgo_.setRCTScaleShift(hfSS.getParameter<int>("RCT"));
71 }
72 
73 
75 
76  // Step A: get the conditions, for the decoding
77  edm::ESHandle<HcalTPGCoder> inputCoder;
78  eventSetup.get<HcalTPGRecord>().get(inputCoder);
79 
81  eventSetup.get<CaloTPGRecord>().get(outTranscoder);
82 
84  eventSetup.get<HcalLutMetadataRcd>().get(lutMetadata);
85  float rctlsb = lutMetadata->getRctLsb();
86 
88  eventSetup.get<CaloGeometryRecord>().get(pG);
89 
90  // Step B: Create empty output
91  std::auto_ptr<HcalTrigPrimDigiCollection> result(new HcalTrigPrimDigiCollection());
92 
95 
96  iEvent.getByToken(tok_hbhe_,hbheDigis);
97  iEvent.getByToken(tok_hf_,hfDigis);
98 
99  // protect here against missing input collections
100  // there is no protection in HcalTriggerPrimitiveAlgo
101 
102  if (!hbheDigis.isValid()) {
103  edm::LogInfo("HcalTrigPrimDigiProducer")
104  << "\nWarning: HBHEDigiCollection with input tag "
105  << inputLabel_[0]
106  << "\nrequested in configuration, but not found in the event."
107  << "\nQuit returning empty product." << std::endl;
108 
109  // put empty HcalTrigPrimDigiCollection in the event
110  iEvent.put(result);
111 
112  return;
113  }
114 
115  if (!hfDigis.isValid()) {
116  edm::LogInfo("HcalTrigPrimDigiProducer")
117  << "\nWarning: HFDigiCollection with input tag "
118  << inputLabel_[1]
119  << "\nrequested in configuration, but not found in the event."
120  << "\nQuit returning empty product." << std::endl;
121 
122  // put empty HcalTrigPrimDigiCollection in the event
123  iEvent.put(result);
124 
125  return;
126  }
127 
128 
130  eventSetup.get<HcalDbRecord> ().get(pSetup);
131 
132  HcalFeatureBit* hfembit = 0;
133 
134  if(HFEMB_)
135  {
136  hfembit = new HcalFeatureHFEMBit(MinShortEnergy_, MinLongEnergy_, LongShortSlope_, LongShortOffset_, *pSetup); //inputs values that cut will be based on
137  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(),
138  *hbheDigis, *hfDigis, *result, &(*pG), rctlsb, hfembit);
139 
140  }// Step C: Invoke the algorithm, passing in inputs and getting back outputs.
141  else
142  {
143  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(),
144  *hbheDigis, *hfDigis, *result, &(*pG), rctlsb);
145  }
146 
147  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
148 
149 
150  // Step C.1: Run FE Format Error / ZS for real data.
152 
153 
154  const HcalElectronicsMap *emap = pSetup->getHcalMapping();
155 
157  iEvent.getByToken(tok_raw_, fedHandle);
158 
159  if (fedHandle.isValid() && emap != 0) {
160  theAlgo_.runFEFormatError(fedHandle.product(), emap, *result);
161  } else {
162  edm::LogInfo("HcalTrigPrimDigiProducer")
163  << "\nWarning: FEDRawDataCollection with input tag "
164  << inputTagFEDRaw_
165  << "\nrequested in configuration, but not found in the event."
166  << "\nQuit returning empty product." << std::endl;
167 
168  // produce empty HcalTrigPrimDigiCollection and put it in the event
169  std::auto_ptr < HcalTrigPrimDigiCollection > emptyResult(
171 
172  iEvent.put(emptyResult);
173 
174  return;
175  }
176 
177  }
178 
179  if (runZS_) theAlgo_.runZS(*result);
180 
181  // edm::LogInfo("HcalTrigPrimDigiProducer") << "HcalTrigPrims: " << result->size();
182 
183  // Step D: Put outputs into event
184  iEvent.put(result);
185 }
186 
187 
T getParameter(std::string const &) const
edm::InputTag inputTagFEDRaw_
input tag for FEDRawDataCollection
T getUntrackedParameter(std::string const &, T const &) const
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
HcalTrigPrimDigiProducer(const edm::ParameterSet &ps)
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
bool exists(std::string const &parameterName) const
checks if a parameter exists
HcalTriggerPrimitiveAlgo theAlgo_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
tuple result
Definition: query.py:137
bool isValid() const
Definition: HandleBase.h:75
void runZS(HcalTrigPrimDigiCollection &tp)
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
virtual void produce(edm::Event &e, const edm::EventSetup &c)
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
std::vector< edm::InputTag > inputLabel_
input tags for HCAL digis
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HBHEDigiCollection &hbheDigis, const HFDigiCollection &hfDigis, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb, const HcalFeatureBit *LongvrsShortCut=0)