test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InvRingCalib.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <math.h>
19 
22 
23 //Not to remain in the final version
24 #include "TH2.h"
25 #include "TFile.h"
26 #include <iostream>
27 //----------------------------------------------------------------
28 //ctor
29 
31  m_barrelAlCa (iConfig.getParameter<edm::InputTag>("barrelAlca")),
32  m_endcapAlCa (iConfig.getParameter<edm::InputTag>("endcapAlca")) ,
33  m_ElectronLabel (iConfig.getParameter<edm::InputTag>("ElectronLabel")),
34  m_recoWindowSidex (iConfig.getParameter<int>("recoWindowSidex")),
35  m_recoWindowSidey (iConfig.getParameter<int>("recoWindowSidey")),
36  m_minEnergyPerCrystal (iConfig.getParameter<double>("minEnergyPerCrystal")) ,
37  m_maxEnergyPerCrystal (iConfig.getParameter<double>("maxEnergyPerCrystal")) ,
38  m_etaStart (iConfig.getParameter<int>("etaStart")),
39  m_etaEnd (iConfig.getParameter<int>("etaEnd")),
40  m_etaWidth (iConfig.getParameter<int>("etaWidth")),
41  m_maxSelectedNumPerRing (iConfig.getParameter<int>("maxNumPerRing")),
42  m_minCoeff (iConfig.getParameter<double>("minCoeff")),
43  m_maxCoeff (iConfig.getParameter<double>("maxCoeff")),
44  m_usingBlockSolver(iConfig.getParameter<int>("usingBlockSolver")),
45  m_startRing (iConfig.getParameter<int>("startRing")),
46  m_endRing (iConfig.getParameter<int>("endRing")),
47  m_EBcoeffFile (iConfig.getParameter<std::string>("EBcoeffs")),
48  m_EEcoeffFile (iConfig.getParameter<std::string>("EEcoeffs")),
49  m_EEZone (iConfig.getParameter<int>("EEZone"))
50 {
51  //controls if the parameters inputed are correct
52  if ((m_etaEnd*m_etaStart)>0)
53  assert (!((m_etaEnd - m_etaStart )%m_etaWidth));
54  if ((m_etaEnd*m_etaStart)<0)
55  assert (!((m_etaEnd - m_etaStart-1 )%m_etaWidth));
56 
57  assert (m_etaStart >=-85 && m_etaStart <= 86);
58  assert (m_etaEnd >= m_etaStart && m_etaEnd <= 86);
59  assert (m_startRing>-1 && m_startRing<= 40);
60  assert (m_endRing>=m_startRing && m_endRing<=40);
61 
62  assert (!((m_endRing - m_startRing)%m_etaWidth));
63  assert (( abs(m_EEZone)<=1));
64 
65  m_loops = (unsigned int) iConfig.getParameter<int>("loops")- 1;
66  //LP CalibBlock vector instantiation
67  edm::LogInfo ("IML") << "[InvRingCalib][ctor] Calib Block" ;
68  std::string algorithm = iConfig.getParameter<std::string> ("algorithm") ;
69  m_mapFillerType = iConfig.getParameter<std::string> ("FillType");
70  int eventWeight = iConfig.getUntrackedParameter<int> ("L3EventWeight",1) ;
71 
72  for (int i = 0 ; i < EBRegionNum () ; ++i)
73  {
74  if (algorithm == "IMA")
75  m_IMACalibBlocks.push_back (
76  new IMACalibBlock (m_etaWidth)
77  ) ;
78  else if (algorithm == "L3")
79  m_IMACalibBlocks.push_back (
80  new L3CalibBlock (m_etaWidth, eventWeight)
81  ) ;
82  else
83  {
84  edm::LogError ("building") << algorithm
85  << " is not a valid calibration algorithm" ;
86  exit (1) ;
87  }
88  }
89  int EEBlocks = 0 ;
90  if (m_EEZone == 0) EEBlocks = 2 * EERegionNum () ;
91  if (m_EEZone == 1 || m_EEZone == -1) EEBlocks = EERegionNum () ;
92 
93  for (int i = 0; i < EEBlocks ; ++i)
94  {
95 
96  if (algorithm == "IMA")
97  m_IMACalibBlocks.push_back (
98  new IMACalibBlock (m_etaWidth)
99  ) ;
100  else if (algorithm == "L3")
101  m_IMACalibBlocks.push_back (
102  new L3CalibBlock (m_etaWidth, eventWeight)
103  ) ;
104  else
105  {
106  edm::LogError ("building") << algorithm
107  << " is not a valid calibration algorithm" ;
108  exit (1) ;
109  }
110  }
111  edm::LogInfo ("IML") <<" [InvRingCalib][ctor] end of creator";
112 }
113 
114 
115 //-------------------------------------------------------------- end ctor
117 
118 
120 {
121 }
122 
123 
124 //---------------------------------------------------
125 
126 
127 
129 void
131 {
132  isfirstcall_=true;
133 
134 
135 }
136 
137 
138 //--------------------------------------------------------
139 
140 
142 void InvRingCalib::startingNewLoop (unsigned int ciclo)
143 {
144  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][Start] entering loop " << ciclo;
145  for (std::vector<VEcalCalibBlock *>::iterator calibBlock = m_IMACalibBlocks.begin () ;
146  calibBlock != m_IMACalibBlocks.end () ;
147  ++calibBlock)
148  {
149  //LP empties the energies vector, to fill DuringLoop.
150  (*calibBlock)->reset () ;
151  }
152  for (std::map<int,int>::const_iterator ring=m_xtalRing.begin();
153  ring!=m_xtalRing.end();
154  ++ring)
155  m_RingNumOfHits[ring->second]=0;
156  return ;
157 }
158 
159 
160 //--------------------------------------------------------
161 
162 
166  const edm::EventSetup& iSetup)
167 {
168 
169 
170  if (isfirstcall_){
171  edm::LogInfo ("IML") << "[InvRingCalib][beginOfJob]" ;
172  //gets the geometry from the event setup
173  edm::ESHandle<CaloGeometry> geoHandle;
174  iSetup.get<CaloGeometryRecord>().get(geoHandle);
175  const CaloGeometry& geometry = *geoHandle;
176  edm::LogInfo ("IML") <<"[InvRingCalib] Event Setup read";
177  //fills a vector with all the cells
180  //Defines the EB regions
181  edm::LogInfo ("IML") <<"[InvRingCalib] Defining Barrel Regions";
182  EBRegionDef();
183  //Defines what is a ring in the EE
184  edm::LogInfo ("IML") <<"[InvRingCalib] Defining endcap Rings";
185  EERingDef(iSetup);
186  //Defines the regions in the EE
187  edm::LogInfo ("IML") <<"[InvRingCalib] Defining endcap Regions";
188  EERegionDef();
189  if (m_mapFillerType == "Cluster") m_MapFiller= new ClusterFillMap (
193  & m_barrelMap ,
194  & m_endcapMap );
195  if (m_mapFillerType == "Matrix") m_MapFiller = new MatrixFillMap (
199  & m_barrelMap ,
200  & m_endcapMap);
201  edm::LogInfo ("IML") <<"[InvRingCalib] Initializing the coeffs";
202  //Sets the initial coefficients to 1.
203  //Graphs to check ring, regions and so on, not needed in the final version
204  TH2F EBRegion ("EBRegion","EBRegion",171,-85,86,360,1,361);
205  TH2F EBRing ("EBRing","EBRing",171,-85,86,360,1,361);
206  for (std::vector<DetId>::const_iterator it= m_barrelCells.begin();
207  it!= m_barrelCells.end();
208  ++it )
209  {
210  EBDetId eb (*it);
211  EBRing.Fill(eb.ieta(),eb.iphi(),m_RinginRegion[it->rawId()]);
212  EBRegion.Fill(eb.ieta(),eb.iphi(),m_xtalRegionId[it->rawId()]);
213  }
214 
215  TH2F EEPRegion ("EEPRegion", "EEPRegion",100,1,101,100,1,101);
216  TH2F EEPRing ("EEPRing", "EEPRing",100,1,101,100,1,101);
217  TH2F EEPRingReg ("EEPRingReg", "EEPRingReg",100,1,101,100,1,101);
218  TH2F EEMRegion ("EEMRegion", "EEMRegion",100,1,101,100,1,101);
219  TH2F EEMRing ("EEMRing", "EEMRing",100,1,101,100,1,101);
220  TH2F EEMRingReg ("EEMRingReg", "EEMRingReg",100,1,101,100,1,101);
221  // TH1F eta ("eta","eta",250,-85,165);
222  for (std::vector<DetId>::const_iterator it = m_endcapCells.begin();
223  it!= m_endcapCells.end();
224  ++it)
225  {
226  EEDetId ee (*it);
227  if (ee.zside()>0)
228  {
229  EEPRegion.Fill(ee.ix(),ee.iy(),m_xtalRegionId[ee.rawId()]);
230  EEPRing.Fill(ee.ix(),ee.iy(),m_xtalRing[ee.rawId()]);
231  EEPRingReg.Fill(ee.ix(),ee.iy(),m_RinginRegion[ee.rawId()]);
232  }
233  if (ee.zside()<0)
234  {
235  EEMRegion.Fill(ee.ix(),ee.iy(),m_xtalRegionId[ee.rawId()]);
236  EEMRing.Fill(ee.ix(),ee.iy(),m_xtalRing[ee.rawId()]);
237  EEMRingReg.Fill(ee.ix(),ee.iy(),m_RinginRegion[ee.rawId()]);
238  }
239  }
240 
241  // for (std::map<int,float>::iterator it=m_eta.begin();
242  // it!=m_eta.end();++it)
243  // eta.Fill(it->first,it->second);
244  TFile out ("EBZone.root", "recreate");
245  EBRegion.Write();
246  EBRing.Write();
247  EEPRegion.Write();
248  EEPRing.Write();
249  EEPRingReg.Write();
250  EEMRegion.Write();
251  EEMRing.Write();
252  // eta.Write();
253  EEMRingReg.Write();
254  out.Close();
255  edm::LogInfo ("IML") <<"[InvRingCalib] Start to acquire the coeffs";
256  CaloMiscalibMapEcal EBmap;
257  EBmap.prefillMap ();
258  MiscalibReaderFromXMLEcalBarrel barrelreader (EBmap);
259  if (!m_EBcoeffFile.empty()) barrelreader.parseXMLMiscalibFile (m_EBcoeffFile);
260  EcalIntercalibConstants costants (EBmap.get());
261  m_barrelMap = costants.getMap();
262  CaloMiscalibMapEcal EEmap ;
263  EEmap.prefillMap ();
264  MiscalibReaderFromXMLEcalEndcap endcapreader (EEmap);
265  if (!m_EEcoeffFile.empty()) endcapreader.parseXMLMiscalibFile (m_EEcoeffFile) ;
266  EcalIntercalibConstants EEcostants (EEmap.get());
267  m_endcapMap = EEcostants.getMap();
268 
269  isfirstcall_=false;
270  } // if isfirstcall
271 
272 
273 
274 
275 
276 
277  //gets the barrel recHits
278  double pSubtract = 0.;
279  double pTk = 0.;
280  const EcalRecHitCollection* barrelHitsCollection = 0;
281  edm::Handle<EBRecHitCollection> barrelRecHitsHandle ;
282  iEvent.getByLabel (m_barrelAlCa, barrelRecHitsHandle) ;
283  barrelHitsCollection = barrelRecHitsHandle.product () ;
284 
285  if (!barrelRecHitsHandle.isValid ()) {
286  edm::LogError ("IML") << "[EcalEleCalibLooper] barrel rec hits not found" ;
287  return kContinue ;
288  }
289  //gets the endcap recHits
290  const EcalRecHitCollection* endcapHitsCollection = 0;
291  edm::Handle<EERecHitCollection> endcapRecHitsHandle ;
292  iEvent.getByLabel (m_endcapAlCa, endcapRecHitsHandle) ;
293  endcapHitsCollection = endcapRecHitsHandle.product () ;
294 
295  if (!endcapRecHitsHandle.isValid ()) {
296  edm::LogError ("IML") << "[EcalEleCalibLooper] endcap rec hits not found" ;
297  return kContinue;
298  }
299 
300  //gets the electrons
302  iEvent.getByLabel(m_ElectronLabel,pElectrons);
303 
304  if (!pElectrons.isValid ()) {
305  edm::LogError ("IML")<< "[EcalEleCalibLooper] electrons not found" ;
306  return kContinue;
307  }
308 
309  //loops over the electrons in the event
310  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin();
311  eleIt != pElectrons->end();
312  ++eleIt )
313  {
314  pSubtract =0;
315  pTk=eleIt->trackMomentumAtVtx().R();
316  std::map<int , double> xtlMap;
317  DetId Max=0;
318  if (fabs(eleIt->eta()<1.49))
319  Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),barrelHitsCollection).first;
320  else
321  Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),endcapHitsCollection).first;
322  if (Max.det()==0) continue;
323  m_MapFiller->fillMap(eleIt->superCluster ()->hitsAndFractions (),Max,
324  barrelHitsCollection,endcapHitsCollection, xtlMap,pSubtract);
325  if (m_xtalRegionId[Max.rawId()]==-1) continue;
326  pSubtract += eleIt->superCluster()->preshowerEnergy() ;
327  ++m_RingNumOfHits[m_xtalRing[Max.rawId()]];
328  //fills the calibBlock
330  xtlMap.begin(), xtlMap.end(),pTk,pSubtract
331  ) ;
332  }
333  return kContinue;
334 } //end of duringLoop
335 
336 
337 //-------------------------------------
338 
339 
340 //EndOfLoop
343  unsigned int iCounter)
344 {
345  std::map<int,double> InterRings;
346  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfLoop] Start to invert the matrixes" ;
347  //call the autoexplaining "solve" method for every calibBlock
348  for (std::vector<VEcalCalibBlock *>::iterator calibBlock=m_IMACalibBlocks.begin();
349  calibBlock!=m_IMACalibBlocks.end();
350  ++calibBlock)
351  (*calibBlock)->solve(m_usingBlockSolver,m_minCoeff,m_maxCoeff);
352 
353  edm::LogInfo("IML") << "[InvRingLooper][endOfLoop] Starting to write the coeffs";
354  TH1F *coeffDistr = new TH1F("coeffdistr","coeffdistr",100 ,0.7,1.4);
355  TH1F *coeffMap = new TH1F("coeffRingMap","coeffRingMap",250,-85,165);
356  TH1F *ringDistr = new TH1F("ringDistr","ringDistr",250,-85,165);
357  TH1F *RingFill = new TH1F("RingFill","RingFill",250,-85,165);
358  for(std::map<int,int>::const_iterator it=m_xtalRing.begin();
359  it!=m_xtalRing.end();
360  ++it)
361  ringDistr->Fill(it->second+0.1);
362 
363  int ID;
364  std::map<int,int> flag;
365  for(std::map<int,int>::const_iterator it=m_xtalRing.begin();
366  it!=m_xtalRing.end();
367  ++it)
368  flag[it->second]=0;
369 
370  for (std::vector<DetId>::const_iterator it=m_barrelCells.begin();
371  it!=m_barrelCells.end();
372  ++it)
373  {
374  ID= it->rawId();
375  if (m_xtalRegionId[ID]==-1) continue;
376  if (flag[m_xtalRing[ID]]) continue;
377  flag[m_xtalRing[ID]] =1;
378  RingFill->Fill(m_xtalRing[ID],m_RingNumOfHits[m_xtalRing[ID]]);
379  InterRings[m_xtalRing[ID]] = m_IMACalibBlocks.at(m_xtalRegionId[ID])->at(m_RinginRegion[ID]);
380  coeffMap->Fill (m_xtalRing[ID]+0.1,InterRings[m_xtalRing[ID]]);
381  coeffDistr->Fill(InterRings[m_xtalRing[ID]]);
382  }
383 
384  for (std::vector<DetId>::const_iterator it=m_endcapCells.begin();
385  it!=m_endcapCells.end();
386  ++it)
387  {
388  ID= it->rawId();
389  if (m_xtalRegionId[ID]==-1) continue;
390  if (flag[m_xtalRing[ID]]) continue;
391  flag[m_xtalRing[ID]]= 1;
392  InterRings[m_xtalRing[ID]] = m_IMACalibBlocks.at(m_xtalRegionId[ID])->at(m_RinginRegion[ID]);
393  RingFill->Fill(m_xtalRing[ID],m_RingNumOfHits[m_xtalRing[ID]]);
394  coeffMap->Fill (m_xtalRing[ID],InterRings[m_xtalRing[ID]]);
395  coeffDistr->Fill(InterRings[m_xtalRing[ID]]);
396 
397  }
398 
399  char filename[80];
400  sprintf(filename,"coeff%d.root",iCounter);
401  TFile out(filename,"recreate");
402  coeffDistr->Write();
403  coeffMap->Write();
404  ringDistr->Write();
405  RingFill->Write();
406  out.Close();
407  for (std::vector<DetId>::const_iterator it=m_barrelCells.begin();
408  it!=m_barrelCells.end();
409  ++it){
410  m_barrelMap[*it]*=InterRings[m_xtalRing[it->rawId()]];
411  }
412  for (std::vector<DetId>::const_iterator it=m_endcapCells.begin();
413  it!=m_endcapCells.end();
414  ++it)
415  m_endcapMap[*it]*=InterRings[m_xtalRing[it->rawId()]];
416  if (iCounter < m_loops-1 ) return kContinue ;
417  else return kStop;
418 }
419 
420 
421 //---------------------------------------
422 
423 
424 //LP endOfJob
425 void
427 {
428 
429  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfJob] saving calib coeffs" ;
430  calibXMLwriter barrelWriter(EcalBarrel);
431  calibXMLwriter endcapWriter(EcalEndcap);
432  for (std::vector<DetId>::const_iterator barrelIt =m_barrelCells.begin();
433  barrelIt!=m_barrelCells.end();
434  ++barrelIt) {
435  EBDetId eb (*barrelIt);
436  barrelWriter.writeLine(eb,m_barrelMap[eb]);
437  }
438  for (std::vector<DetId>::const_iterator endcapIt = m_endcapCells.begin();
439  endcapIt!=m_endcapCells.end();
440  ++endcapIt) {
441  EEDetId ee (*endcapIt);
442  endcapWriter.writeLine(ee,m_endcapMap[ee]);
443  }
444 }
445 
446 
447 //------------------------------------//
448 // definition of functions //
449 //------------------------------------//
450 
451 //------------------------------------------------------------
452 
453 
456 {
457  //Gets the Handle for the geometry from the eventSetup
458  edm::ESHandle<CaloGeometry> geoHandle;
459  iSetup.get<CaloGeometryRecord>().get(geoHandle);
460  //Gets the geometry of the endcap
461  const CaloGeometry& geometry = *geoHandle;
462  const CaloSubdetectorGeometry *endcapGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
463 // const CaloSubdetectorGeometry *barrelGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
464  //for every xtal gets the position Vector and the phi position
465 
466 // for (std::vector<DetId>::const_iterator barrelIt = m_barrelCells.begin();
467 // barrelIt!=m_barrelCells.end();
468 // ++barrelIt) {
469 // const CaloCellGeometry *cellGeometry = barrelGeometry->getGeometry(*barrelIt);
470 // GlobalPoint point;
471 // EBDetId eb (*barrelIt);
472 // point=cellGeometry->getPosition();
473 // m_eta[eb.ieta()]=point.eta() ; //cellGeometry->getPosition().eta();
474 // }
475  for (std::vector<DetId>::const_iterator endcapIt = m_endcapCells.begin();
476  endcapIt!=m_endcapCells.end();
477  ++endcapIt) {
478  const CaloCellGeometry *cellGeometry = endcapGeometry->getGeometry(*endcapIt);
479  m_cellPos[endcapIt->rawId()] = cellGeometry->getPosition();
480  m_cellPhi[endcapIt->rawId()] = cellGeometry->getPosition().phi();
481  }
482  //takes the first 39 xtals at a fixed y varying the x coordinate and saves their eta coordinate
483  float eta_ring[39];
484  for (int ring=0; ring<39; ring++)
485  if (EEDetId::validDetId(ring,50,1)){
486  EEDetId det = EEDetId (ring,50,1,EEDetId::XYMODE);
487  eta_ring[ring]=m_cellPos[det.rawId()].eta();
488  }
489  //defines the bonduary of the rings as the average eta of a xtal
490  double etaBonduary[40];
491  etaBonduary[0]=1.49;
492  etaBonduary[39]=4.0;
493  for (int ring=1; ring<39; ++ring)
494  etaBonduary[ring]=(eta_ring[ring]+eta_ring[ring-1])/2.;
495  //assign to each xtal a ring number
496  int CRing;
497  for (int ring=0; ring<39; ring++)
498  for (std::vector<DetId>::const_iterator endcapIt=m_endcapCells.begin();
499  endcapIt!=m_endcapCells.end();++endcapIt){
500  if (fabs(m_cellPos[endcapIt->rawId()].eta())>etaBonduary[ring] &&
501  fabs(m_cellPos[endcapIt->rawId()].eta())<etaBonduary[ring+1])
502  {
503  EEDetId ee(*endcapIt);
504  if (ee.zside()>0) CRing=ring + 86;
505  else CRing = ring + 125;
506  m_xtalRing[endcapIt->rawId()]=CRing;
507 // m_eta[CRing]=m_cellPos[endcapIt->rawId()].eta();
508  }
509  }
510  return;
511 }
512 
513 
514 //------------------------------------------------------------
515 
516 
519 {
520  int reg;
521  int ring;
522  EEDetId ee (id);
523  //sets the reg to -1 if the ring doesn't exist or is outside the region of interest
524  if (m_xtalRing[id] == -1) return -1;
525  //avoid the calibration in the wrong zside
526  if (m_EEZone == 1 ){
527  if (ee.zside()<0) return -1;
528  ring = m_xtalRing[id]-86;
529  if(ring >=m_endRing) return -1;
530  if (ring<m_startRing) return -1;
531  reg = (ring -m_startRing) / m_etaWidth;
532  m_RinginRegion[id]=(ring -m_startRing) % m_etaWidth;
533  return reg;
534  }
535  if (m_EEZone == -1){
536  if (ee.zside()>0) return -1;
537  ring = m_xtalRing[id] -125;
538  if(ring >=m_endRing) return -1;
539  if (ring<m_startRing) return -1;
540  reg = (ring -m_startRing) / m_etaWidth;
541  m_RinginRegion[id]=(ring -m_startRing) % m_etaWidth;
542  return reg;
543  }
544  if (ee.zside()>0) ring=m_xtalRing[id]-86;
545  else ring = m_xtalRing[id]-125;
546  if(ring >=m_endRing) return -1;
547  if (ring<m_startRing) return -1;
548  reg = (ring -m_startRing) / m_etaWidth;
549  m_RinginRegion[id]=(ring -m_startRing) % m_etaWidth;
550  return reg;
551 }
552 //----------------------------------------
556 {
557 int reg;
558 for (std::vector<DetId>::const_iterator endcapIt=m_endcapCells.begin();
559  endcapIt!=m_endcapCells.end();++endcapIt){
560  EEDetId ee(*endcapIt);
561  reg = EERegId(endcapIt->rawId());
562  //If the ring is not of interest saves only the region Id(-1)
563  if(reg==-1)
564  m_xtalRegionId[endcapIt->rawId()]=reg;
565  //sums the number of region in EB or EB+EE to have different regionsId in different regions
566  else {
567  if (ee.zside()>0)reg += EBRegionNum();
568  else reg += EBRegionNum()+EERegionNum();
569  m_xtalRegionId[endcapIt->rawId()]=reg;
570  }
571  }
572 }
573 
574 
575 //------------------------------------------------------------
576 
577 
579 inline int InvRingCalib::EERegionNum () const
580 {
581  return ((m_endRing - m_startRing)/m_etaWidth);
582 }
583 
584 
587 {
588  if ((m_etaEnd*m_etaStart)>0)
589  return ((m_etaEnd - m_etaStart )/m_etaWidth);
590 
591  if ((m_etaEnd*m_etaStart)<0)
592  return ((m_etaEnd - m_etaStart-1 )/m_etaWidth);
593 
594  return 0;
595 }
599 {
600  int k=0;
601  for (int i = m_etaStart;i<m_etaEnd;++i)
602  {
603  if (i==0) continue;
604  m_Reg[i]=k/m_etaWidth;
605  ++k;
606  }
607 }
609 int InvRingCalib::EBRegId(const int ieta)
610 {
611  if (ieta<m_etaStart || ieta>=m_etaEnd) return -1;
612  else return (m_Reg[ieta]);
613 }
614 
615 
616 //------------------------------------------------------------
617 
618 
619 //EB Region Definition
621 {
622  RegPrepare();
623  for (std::vector<DetId>::const_iterator it=m_barrelCells.begin();
624  it!=m_barrelCells.end();++it)
625  {
626  EBDetId eb (it->rawId());
627  m_xtalRing[eb.rawId()] = eb.ieta() ;
628  m_xtalRegionId[eb.rawId()] = EBRegId (eb.ieta());
629  if (m_xtalRegionId[eb.rawId()]==-1) continue;
630  m_RinginRegion[eb.rawId()] = (eb.ieta() - m_etaStart)% m_etaWidth;
631  }
632 }
633 //------------------------------------------------------------
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
virtual void fillMap(const std::vector< std::pair< DetId, float > > &, const DetId, const EcalRecHitCollection *, const EcalRecHitCollection *, std::map< int, double > &xtlMap, double &)=0
The Map filler.
edm::InputTag m_ElectronLabel
To take the electrons.
Definition: InvRingCalib.h:70
int ix() const
Definition: EEDetId.h:76
void EERingDef(const edm::EventSetup &)
Defines the rins in the endcap.
int EBRegionNum() const
Number of regions in EB.
void EBRegionDef()
Defines the regions in the barrel.
double m_maxCoeff
maximum coefficient accepted (RAW)
Definition: InvRingCalib.h:94
const self & getMap() const
Status endOfLoop(const edm::EventSetup &, unsigned int iCounter)
std::string m_EEcoeffFile
Definition: InvRingCalib.h:121
~InvRingCalib()
dtor
int m_recoWindowSidey
Definition: InvRingCalib.h:73
InvRingCalib(const edm::ParameterSet &)
ctor
Definition: InvRingCalib.cc:30
double m_minEnergyPerCrystal
minimum energy per crystal cut
Definition: InvRingCalib.h:75
uint32_t ID
Definition: Definitions.h:26
int m_EEZone
endcap zone to be calibrated
Definition: InvRingCalib.h:123
std::map< int, int > m_cellPhi
Definition: InvRingCalib.h:99
static const int XYMODE
Definition: EEDetId.h:339
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
bool parseXMLMiscalibFile(std::string configFile)
std::map< int, GlobalPoint > m_cellPos
position of the cell, borders, coords etc...
Definition: InvRingCalib.h:98
EcalIntercalibConstantMap m_endcapMap
Definition: InvRingCalib.h:103
void EERegionDef()
Defines the regions in the endcap.
std::map< int, int > m_Reg
EB regions vs. eta index.
Definition: InvRingCalib.h:125
double m_maxEnergyPerCrystal
maximum energy per crystal cut
Definition: InvRingCalib.h:77
std::vector< VEcalCalibBlock * > m_IMACalibBlocks
single blocks calibrators
Definition: InvRingCalib.h:90
int EERegId(int)
gives back in which region of the endcap you are.
int m_etaStart
eta start of the zone of interest
Definition: InvRingCalib.h:79
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
EcalIntercalibConstantMap m_barrelMap
Definition: InvRingCalib.h:102
std::map< int, int > m_RingNumOfHits
number of events already read per Ring
Definition: InvRingCalib.h:88
std::map< int, int > m_xtalRegionId
association map between raw detIds and Region
Definition: InvRingCalib.h:112
int iEvent
Definition: GenABIO.cc:230
edm::InputTag m_endcapAlCa
EcalEndcap Input Collection name.
Definition: InvRingCalib.h:68
VFillMap * m_MapFiller
The class that fills the map!
Definition: InvRingCalib.h:62
const EcalIntercalibConstants & get()
void beginOfJob()
BeginOfJob.
std::vector< DetId > m_barrelCells
geometry things used all over the file
Definition: InvRingCalib.h:117
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int m_startRing
LP define the EE region to calibrate.
Definition: InvRingCalib.h:107
interface to the L3Univ class for testing
Definition: L3CalibBlock.h:24
int zside() const
Definition: EEDetId.h:70
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Status duringLoop(const edm::Event &, const edm::EventSetup &)
duringLoop
void RegPrepare()
Prepares the EB regions;.
int m_etaWidth
eta size of the regions
Definition: InvRingCalib.h:83
int iy() const
Definition: EEDetId.h:82
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
unsigned int m_loops
LP sets the number of loops to do.
Definition: InvRingCalib.h:105
int m_usingBlockSolver
to exclude the blocksolver
Definition: InvRingCalib.h:96
edm::InputTag m_barrelAlCa
EcalBarrel Input Collection name.
Definition: InvRingCalib.h:66
bool first
Definition: L1TdeRCT.cc:75
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
void startingNewLoop(unsigned int)
startingNewLoop
int k[5][pyjets_maxn]
int m_etaEnd
eta end of the zone of interest
Definition: InvRingCalib.h:81
tuple out
Definition: dbtoconf.py:99
T Max(T a, T b)
Definition: MathUtil.h:44
Definition: DetId.h:18
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:81
std::map< int, CalibCoeff > coeffMap
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
double m_minCoeff
minimum coefficient accepted (RAW)
Definition: InvRingCalib.h:92
ESHandle< TrackerGeometry > geometry
void writeLine(EBDetId const &, float)
std::string m_EBcoeffFile
coeffs filenames
Definition: InvRingCalib.h:120
tuple filename
Definition: lut2db_cfg.py:20
int m_recoWindowSidex
reconstruction window size
Definition: InvRingCalib.h:72
std::vector< DetId > m_endcapCells
Definition: InvRingCalib.h:118
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
for(const auto &isodef:isoDefs)
std::map< int, int > m_RinginRegion
association map between raw detIds and the number of the ring inside the region
Definition: InvRingCalib.h:114
std::map< int, int > m_xtalRing
association map between Raw detIds and Rings
Definition: InvRingCalib.h:110
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
std::string m_mapFillerType
Definition: InvRingCalib.h:126
int EBRegId(const int)
Gives back in which region you are:
int EERegionNum() const
The number of regions in EE.