CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTrigPrimProducer.cc
Go to the documentation of this file.
1 
17 
24 
30 
61 
62 #include "EcalTrigPrimProducer.h"
64 
66  barrelOnly_(iConfig.getParameter<bool>("BarrelOnly")),
67  tcpFormat_(iConfig.getParameter<bool>("TcpOutput")),
68  debug_(iConfig.getParameter<bool>("Debug")),ps_(iConfig)
69 {
70  //register your products
71  produces <EcalTrigPrimDigiCollection >();
72  if (tcpFormat_) produces <EcalTrigPrimDigiCollection >("formatTCP");
73 
74  label_= iConfig.getParameter<std::string>("Label");
75  instanceNameEB_ = iConfig.getParameter<std::string>("InstanceEB");;
76  instanceNameEE_ = iConfig.getParameter<std::string>("InstanceEE");;
77  algo_=NULL;
78 }
79 
81  bool famos = ps_.getParameter<bool>("Famos");
82 
84 
85  // get a first version of the records
86  cacheID_=this->getRecords(setup);
87 }
88 
90  delete algo_;
91 }
92 
94 
95  // get binOfMax
96  // try first in cfg, then in ProductRegistry
97  // =6 is default (1-10 possible values)
98  binOfMaximum_=0; //starts at 1!
99  bool found=false;
100  std::vector<std::string> names = ps_.getParameterNames();
101  if (find(names.begin(), names.end(), std::string("binOfMaximum"))
102  != names.end()) {
103  binOfMaximum_=ps_.getParameter<int>("binOfMaximum");
104  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in cfg file : "<<binOfMaximum_;
105  found = true;
106  }
107 
109  // Loop over provenance of products in registry.
110  for (edm::ProductRegistry::ProductList::const_iterator it = reg->productList().begin();
111  it != reg->productList().end(); ++it) {
112  edm::BranchDescription desc = it->second;
113  if (desc.friendlyClassName().find("EBDigiCollection")==0 &&
114  desc.moduleLabel()=="ecalUnsuppressedDigis") {
116  if (found ) {
117  if ( result.getParameter<int>("binOfMaximum")!=binOfMaximum_)edm:: LogWarning("EcalTPG")<< "binofMaximum given in configuration (="<<binOfMaximum_<<") is different from the one found in ProductRegistration(="<<result.getParameter<int>("binOfMaximum")<<")!!!";
118  }else {
119  binOfMaximum_=result.getParameter<int>("binOfMaximum");
120  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in ProductRegistry : "<<binOfMaximum_;
121  break;
122  }
123  }
124  }
125 
126 
127  if (binOfMaximum_==0) {
128  binOfMaximum_=6;
129  edm::LogWarning("EcalTPG")<<"Could not find product registry of EBDigiCollection (label ecalUnsuppressedDigis), had to set the following parameters by Hand: binOfMaximum="<<binOfMaximum_;
130  }
131 }
132 
134  // get Eventsetup records
135 
136  // for EcalFenixStrip...
137  // get parameter records for xtals
138  edm::ESHandle<EcalTPGLinearizationConst> theEcalTPGLinearization_handle;
139  setup.get<EcalTPGLinearizationConstRcd>().get(theEcalTPGLinearization_handle);
140  const EcalTPGLinearizationConst * ecaltpLin = theEcalTPGLinearization_handle.product();
141  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle;
142  setup.get<EcalTPGPedestalsRcd>().get(theEcalTPGPedestals_handle);
143  const EcalTPGPedestals * ecaltpPed = theEcalTPGPedestals_handle.product();
144  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle;
145  setup.get<EcalTPGCrystalStatusRcd>().get(theEcalTPGCrystalStatus_handle);
146  const EcalTPGCrystalStatus * ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
147 
148 
149  //for strips
150  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle;
151  setup.get<EcalTPGSlidingWindowRcd>().get(theEcalTPGSlidingWindow_handle);
152  const EcalTPGSlidingWindow * ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
153  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle;
154  setup.get<EcalTPGWeightIdMapRcd>().get(theEcalTPGWEightIdMap_handle);
155  const EcalTPGWeightIdMap * ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
156  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle;
157  setup.get<EcalTPGWeightGroupRcd>().get(theEcalTPGWEightGroup_handle);
158  const EcalTPGWeightGroup * ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
159  edm::ESHandle<EcalTPGFineGrainStripEE> theEcalTPGFineGrainStripEE_handle;
160  setup.get<EcalTPGFineGrainStripEERcd>().get(theEcalTPGFineGrainStripEE_handle);
161  const EcalTPGFineGrainStripEE * ecaltpgFgStripEE = theEcalTPGFineGrainStripEE_handle.product();
162  edm::ESHandle<EcalTPGStripStatus> theEcalTPGStripStatus_handle;
163  setup.get<EcalTPGStripStatusRcd>().get(theEcalTPGStripStatus_handle);
164  const EcalTPGStripStatus * ecaltpgStripStatus = theEcalTPGStripStatus_handle.product();
165 
166  algo_->setPointers(ecaltpLin,ecaltpPed,ecaltpgSlidW,ecaltpgWeightMap,ecaltpgWeightGroup,ecaltpgFgStripEE,ecaltpgBadX,ecaltpgStripStatus);
167 
168  // .. and for EcalFenixTcp
169  // get parameter records for towers
170  edm::ESHandle<EcalTPGFineGrainEBGroup> theEcalTPGFineGrainEBGroup_handle;
171  setup.get<EcalTPGFineGrainEBGroupRcd>().get(theEcalTPGFineGrainEBGroup_handle);
172  const EcalTPGFineGrainEBGroup * ecaltpgFgEBGroup = theEcalTPGFineGrainEBGroup_handle.product();
173 
174  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle;
175  setup.get<EcalTPGLutGroupRcd>().get(theEcalTPGLutGroup_handle);
176  const EcalTPGLutGroup * ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
177 
178  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle;
179  setup.get<EcalTPGLutIdMapRcd>().get(theEcalTPGLutIdMap_handle);
180  const EcalTPGLutIdMap * ecaltpgLut = theEcalTPGLutIdMap_handle.product();
181 
182  edm::ESHandle<EcalTPGFineGrainEBIdMap> theEcalTPGFineGrainEBIdMap_handle;
183  setup.get<EcalTPGFineGrainEBIdMapRcd>().get(theEcalTPGFineGrainEBIdMap_handle);
184  const EcalTPGFineGrainEBIdMap * ecaltpgFineGrainEB = theEcalTPGFineGrainEBIdMap_handle.product();
185 
186  edm::ESHandle<EcalTPGFineGrainTowerEE> theEcalTPGFineGrainTowerEE_handle;
187  setup.get<EcalTPGFineGrainTowerEERcd>().get(theEcalTPGFineGrainTowerEE_handle);
188  const EcalTPGFineGrainTowerEE * ecaltpgFineGrainTowerEE = theEcalTPGFineGrainTowerEE_handle.product();
189 
190  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle;
191  setup.get<EcalTPGTowerStatusRcd>().get(theEcalTPGTowerStatus_handle);
192  const EcalTPGTowerStatus * ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
193 
194  edm::ESHandle<EcalTPGSpike> theEcalTPGSpike_handle;
195  setup.get<EcalTPGSpikeRcd>().get(theEcalTPGSpike_handle);
196  const EcalTPGSpike * ecaltpgSpike = theEcalTPGSpike_handle.product();
197 
198  algo_->setPointers2(ecaltpgFgEBGroup,ecaltpgLutGroup,ecaltpgLut,ecaltpgFineGrainEB,ecaltpgFineGrainTowerEE,ecaltpgBadTT,ecaltpgSpike);
199 
200  // we will suppose that everything is to be updated if the EcalTPGLinearizationConstRcd has changed
201  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
202 }
203 
205 {}
206 
207 
208 // ------------ method called to produce the data ------------
209 void
211 {
212 
213  // update constants if necessary
215 
216  // get input collections
217 
220  bool barrel=true;
221  bool endcap=true;
222  if (barrelOnly_) endcap=false;
223 
224  if (!e.getByLabel(label_,instanceNameEB_,ebDigis)) {
225  barrel=false;
226  edm::LogWarning("EcalTPG") <<" Couldnt find Barrel dataframes with producer "<<label_<<" and label "<<instanceNameEB_<<"!!!";
227  }
228  if (!barrelOnly_) {
229  if (!e.getByLabel(label_,instanceNameEE_,eeDigis)) {
230  endcap=false;
231  edm::LogWarning("EcalTPG") <<" Couldnt find Endcap dataframes with producer "<<label_<<" and label "<<instanceNameEE_<<"!!!";
232  }
233  }
234  if (!barrel && !endcap) {
235  throw cms::Exception(" ProductNotFound") <<"No EBDataFrames(EEDataFrames) with producer "<<label_<<" and label "<<instanceNameEB_<<" found in input!!\n";
236  }
237 
238  if (!barrelOnly_) LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size()<<", Number of EEDataFrames "<<eeDigis.product()->size() ;
239  else LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size();
240 
241  std::auto_ptr<EcalTrigPrimDigiCollection> pOut(new EcalTrigPrimDigiCollection);
242  std::auto_ptr<EcalTrigPrimDigiCollection> pOutTcp(new EcalTrigPrimDigiCollection);
243 
244 
245  // invoke algorithm
246 
247  const EBDigiCollection *ebdc=NULL;
248  const EEDigiCollection *eedc=NULL;
249  if (barrel) {
250  ebdc=ebDigis.product();
251  algo_->run(iSetup,ebdc,*pOut,*pOutTcp);
252  }
253 
254  if (endcap) {
255  eedc=eeDigis.product();
256  algo_->run(iSetup,eedc,*pOut,*pOutTcp);
257  }
258 
259  edm::LogInfo("produce") <<"For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced";
260 
261  // debug prints if TP >0
262 
263  for (unsigned int i=0;i<pOut->size();++i) {
264  bool print=false;
265  for (int isam=0;isam<(*pOut)[i].size();++isam) {
266  if ((*pOut)[i][isam].raw()) print=true;
267  }
268  if (print) LogDebug("EcalTPG") <<" For tower "<<(((*pOut)[i])).id()<<", TP is "<<(*pOut)[i];
269  }
270  if (barrelOnly_) LogDebug("EcalTPG") <<"\n =================> For Barrel , "<<pOut->size()<<" TP Digis were produced (including zero ones)";
271  else LogDebug("EcalTPG") <<"\n =================> For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced (including zero ones)";
272 
273  // put result into the Event
274 
275  e.put(pOut);
276  if (tcpFormat_) e.put(pOutTcp,"formatTCP");
277 }
#define LogDebug(id)
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
int i
Definition: DBlmapReader.cc:9
void setPointers2(const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB, const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE, const EcalTPGTowerStatus *ecaltpgBadTT, const EcalTPGSpike *ecaltpgSpike)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
ParameterSet const & getParameterSet(ParameterSetID const &id)
EcalTrigPrimFunctionalAlgo * algo_
#define NULL
Definition: scimark2.h:8
EcalTrigPrimProducer(const edm::ParameterSet &conf)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
ParameterSetID const & psetID() const
void beginRun(edm::Run &run, const edm::EventSetup &es)
unsigned long long cacheID_
std::string const & moduleLabel() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void run(const edm::EventSetup &, const EBDigiCollection *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp)
tuple result
Definition: query.py:137
unsigned long long getRecords(edm::EventSetup const &setup)
std::string const & friendlyClassName() const
std::vector< std::string > getParameterNames() const
void endRun(edm::Run &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void produce(edm::Event &e, const edm::EventSetup &c)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
void setPointers(const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGPedestals *ecaltpPed, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE, const EcalTPGCrystalStatus *ecaltpgBadX, const EcalTPGStripStatus *ecaltpgStripStatus)
const edm::ParameterSet ps_
edm::EventID id() const
Definition: EventBase.h:56
static const HistoName names[]
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
ProductList const & productList() const
Definition: Run.h:33