CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalEleCalibLooper Class Reference

ECAL TB 2006 calibration with matrix inversion technique. More...

#include <EcalEleCalibLooper.h>

Inheritance diagram for EcalEleCalibLooper:
edm::EDLooper edm::EDLooperBase

Public Member Functions

void beginOfJob ()
 BeginOfJob. More...
 
Status duringLoop (const edm::Event &, const edm::EventSetup &)
 
 EcalEleCalibLooper (const edm::ParameterSet &)
 ctor More...
 
void endOfJob ()
 
Status endOfLoop (const edm::EventSetup &, unsigned int iCounter)
 
void startingNewLoop (unsigned int)
 
 ~EcalEleCalibLooper ()
 dtor More...
 
- Public Member Functions inherited from edm::EDLooper
 EDLooper ()
 
 EDLooper (EDLooper const &)=delete
 
EDLooperoperator= (EDLooper const &)=delete
 
virtual ~EDLooper ()
 
- Public Member Functions inherited from edm::EDLooperBase
virtual void attachTo (ActivityRegistry &)
 Override this method if you need to monitor the state of the processing. More...
 
virtual void beginOfJob (EventSetup const &)
 
void copyInfo (ScheduleInfo const &)
 
void doBeginLuminosityBlock (LuminosityBlockPrincipal &, EventSetup const &, ProcessContext *)
 
void doBeginRun (RunPrincipal &, EventSetup const &, ProcessContext *)
 
Status doDuringLoop (EventPrincipal &eventPrincipal, EventSetup const &es, ProcessingController &, StreamContext *)
 
void doEndLuminosityBlock (LuminosityBlockPrincipal &, EventSetup const &, ProcessContext *)
 
Status doEndOfLoop (EventSetup const &es)
 
void doEndRun (RunPrincipal &, EventSetup const &, ProcessContext *)
 
void doStartingNewLoop ()
 
 EDLooperBase ()
 
 EDLooperBase (EDLooperBase const &)=delete
 
virtual std::set
< eventsetup::EventSetupRecordKey
modifyingRecords () const
 
EDLooperBaseoperator= (EDLooperBase const &)=delete
 
void prepareForNextLoop (eventsetup::EventSetupProvider *esp)
 
void setActionTable (ExceptionToActionTable const *actionTable)
 
void setModuleChanger (ModuleChanger *)
 
virtual ~EDLooperBase ()
 

Private Member Functions

int EBregionCheck (const int eta, const int phi) const
 Tells if you are in the region to be calibrated. More...
 
void EBRegionDefinition ()
 DS EB Region Definition. More...
 
int EBRegionId (const int, const int) const
 Reg Id generator EB --— for the barrel. More...
 
int EBregionsNum () const
 DS number of regions in EB. More...
 
int EEregionCheck (const int, const int) const
 returns zero if the coordinates are in the right place. More...
 
void EERegionDefinition ()
 
int EERegionId (const int, const int) const
 Gives the id of the region. More...
 
int EEregionsNum () const
 DS Number of regions in EE. More...
 
int etaShifter (const int) const
 LP Change the coordinate system. More...
 
double giveLimit (int)
 copes with the infinitives of the tangent More...
 

Private Attributes

bool isfirstcall_
 
edm::InputTag m_barrelAlCa
 EcalBarrel Input Collection name. More...
 
std::vector< DetIdm_barrelCells
 
EcalIntercalibConstantMap m_barrelMap
 the maps of recalib coeffs More...
 
std::vector< VEcalCalibBlock * > m_EcalCalibBlocks
 single blocks calibrators More...
 
edm::InputTag m_ElectronLabel
 To take the electrons. More...
 
edm::InputTag m_endcapAlCa
 EcalEndcap Input Collection name. More...
 
std::vector< DetIdm_endcapCells
 
EcalIntercalibConstantMap m_endcapMap
 
int m_etaEnd
 eta end of the region of interest More...
 
int m_etaStart
 phi size of the additive border to the sub-matrix More...
 
int m_etaWidth
 eta size of the sub-matrix More...
 
unsigned int m_loops
 DS sets the number of loops to do. More...
 
VFillMapm_MapFiller
 
double m_maxCoeff
 maximum coefficient accepted (RAW) More...
 
double m_maxEnergyPerCrystal
 maximum energy per crystal cut More...
 
int m_maxSelectedNumPerXtal
 maximum number of events per crystal More...
 
double m_minCoeff
 minimum coefficient accepted (RAW) More...
 
double m_minEnergyPerCrystal
 minimum energy per crystal cut More...
 
int m_phiEndEB
 phi end of the region of interest More...
 
int m_phiEndEE
 
int m_phiStartEB
 phi start of the region of interest More...
 
int m_phiStartEE
 
int m_phiWidthEB
 eta size of the additive border to the sub-matrix More...
 
int m_phiWidthEE
 
int m_radEnd
 
int m_radStart
 DS For the EE. More...
 
int m_radWidth
 
int m_recoWindowSidex
 reconstruction window size More...
 
int m_recoWindowSidey
 
std::vector< int > m_regions
 
int m_usingBlockSolver
 to exclude the blocksolver More...
 
std::map< int, int > m_xtalNumOfHits
 
std::map< int, int > m_xtalPositionInRegion
 
std::map< int, int > m_xtalRegionId
 

Additional Inherited Members

- Public Types inherited from edm::EDLooperBase
enum  Status { kContinue, kStop }
 
- Protected Member Functions inherited from edm::EDLooperBase
ModuleChangermoduleChanger ()
 This only returns a non-zero value during the call to endOfLoop. More...
 
ScheduleInfo const * scheduleInfo () const
 This returns a non-zero value after the constructor has been called. More...
 

Detailed Description

ECAL TB 2006 calibration with matrix inversion technique.

Author

Definition at line 32 of file EcalEleCalibLooper.h.

Constructor & Destructor Documentation

EcalEleCalibLooper::EcalEleCalibLooper ( const edm::ParameterSet iConfig)
explicit

ctor

LP ctor.

Graphs to ckeck the region definition

End of Graphs

Definition at line 36 of file EcalEleCalibLooper.cc.

References HLT_FULL_cff::algorithm, assert(), EBRegionDefinition(), EBregionsNum(), EERegionDefinition(), EEregionsNum(), eta, cmsRelvalreport::exit, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_barrelMap, m_EcalCalibBlocks, m_endcapMap, m_etaEnd, m_etaStart, m_etaWidth, m_MapFiller, m_maxEnergyPerCrystal, m_minEnergyPerCrystal, m_radEnd, m_radStart, m_radWidth, m_recoWindowSidex, m_recoWindowSidey, m_regions, m_xtalPositionInRegion, m_xtalRegionId, GenerateHcalLaserBadRunList::out, phi, HLT_FULL_cff::region, AlCaHLTBitMon_QueryRunRegistry::string, EBDetId::unhashIndex(), EEDetId::validDetId(), x, and y.

36  :
37  m_barrelAlCa (iConfig.getParameter<edm::InputTag> ("alcaBarrelHitCollection")) ,
38  m_endcapAlCa (iConfig.getParameter<edm::InputTag> ("alcaEndcapHitCollection")) ,
39  m_recoWindowSidex (iConfig.getParameter<int> ("recoWindowSidex")) ,
40  m_recoWindowSidey (iConfig.getParameter<int> ("recoWindowSidey")) ,
41  m_etaWidth (iConfig.getParameter<int> ("etaWidth")) ,
42  m_phiWidthEB (iConfig.getParameter<int> ("phiWidthEB")) ,
43  m_etaStart (etaShifter (iConfig.getParameter<int> ("etaStart"))) ,
44  m_etaEnd (etaShifter (iConfig.getParameter<int> ("etaEnd"))) ,
45  m_phiStartEB (iConfig.getParameter<int> ("phiStartEB")) ,
46  m_phiEndEB (iConfig.getParameter<int> ("phiEndEB")),
47  m_radStart (iConfig.getParameter<int> ("radStart")) ,
48  m_radEnd (iConfig.getParameter<int> ("radEnd")) ,
49  m_radWidth (iConfig.getParameter<int> ("radWidth")) ,
50  m_phiStartEE (iConfig.getParameter<int> ("phiStartEE")) ,
51  m_phiEndEE (iConfig.getParameter<int> ("phiEndEE")) ,
52  m_phiWidthEE (iConfig.getParameter<int> ("phiWidthEE")) ,
53  m_maxSelectedNumPerXtal (iConfig.getParameter<int> ("maxSelectedNumPerCrystal")) ,
54  m_minEnergyPerCrystal (iConfig.getParameter<double> ("minEnergyPerCrystal")),
55  m_maxEnergyPerCrystal (iConfig.getParameter<double> ("maxEnergyPerCrystal")) ,
56  m_minCoeff (iConfig.getParameter<double> ("minCoeff")) ,
57  m_maxCoeff (iConfig.getParameter<double> ("maxCoeff")) ,
58  m_usingBlockSolver (iConfig.getParameter<int> ("usingBlockSolver")) ,
59  m_loops (iConfig.getParameter<int> ("loops")),
60  m_ElectronLabel (iConfig.getParameter<edm::InputTag> ("electronLabel"))
61 {
62  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] asserts" ;
64 
65  assert (m_etaStart >=0 && m_etaStart <= 171);
66  assert (m_etaEnd >= m_etaStart && m_etaEnd <= 171);
67  assert ( (m_radEnd - m_radStart)%m_radWidth == 0) ;
68  assert (m_radStart >=0 && m_radStart <= 50);
69  assert (m_radEnd >= m_radStart && m_radEnd <= 50);
70  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] entering " ;
71  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] region definition" ;
75  TH2F * EBRegion = new TH2F ("EBRegion","EBRegion",170,0,170,360,0,360) ;
76  for (int eta = 0; eta<170; ++eta)
77  for (int phi = 0; phi <360; ++phi){
78  EBRegion->Fill (eta, phi,m_xtalRegionId[EBDetId::unhashIndex(eta*360+phi).rawId()] );
79  }
80  TH2F * EERegion = new TH2F ("EERegion", "EERegion",100,0,100,100,0,100);
81  for (int x = 0; x<100; ++x)
82  for (int y = 0; y<100;++y){
83  if(EEDetId::validDetId(x+1,y+1,1))
84  EERegion->Fill(x,y,m_xtalRegionId[EEDetId(x+1,y+1,-1).rawId()]);
85  }
86 
87  TFile out ("EBZone.root", "recreate");
88  EBRegion->Write ();
89  EERegion->Write ();
90  out.Close ();
91  delete EERegion;
92  delete EBRegion;
94 
95  //PG build the calibration algorithms for the regions
96  //PG ------------------------------------------------
97 
98  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] Calib Block" ;
99  std::string algorithm = iConfig.getParameter<std::string> ("algorithm") ;
100  int eventWeight = iConfig.getUntrackedParameter<int> ("L3EventWeight",1) ;
101 
102  //PG loop over the regions set
103  for (int region = 0 ;
104  region < EBregionsNum () + 2 * EEregionsNum () ;
105  ++region)
106  {
107  if (algorithm == "IMA")
108  m_EcalCalibBlocks.push_back (
109  new IMACalibBlock (m_regions.at (region))
110  ) ;
111  else if (algorithm == "L3")
112  m_EcalCalibBlocks.push_back (
113  new L3CalibBlock (m_regions.at (region), eventWeight)
114  ) ;
115  else
116  {
117  edm::LogError ("building") << algorithm
118  << " is not a valid calibration algorithm" ;
119  exit (1) ;
120  }
121  } //PG loop over the regions set
122  std::string mapFiller = iConfig.getParameter<std::string> ("FillType");
123  if (mapFiller == "Cluster") m_MapFiller= new ClusterFillMap (
127  & m_barrelMap ,
128  & m_endcapMap );
129  if (mapFiller == "Matrix") m_MapFiller = new MatrixFillMap (
133  & m_barrelMap ,
134  & m_endcapMap);
135  } //end ctor
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int EEregionsNum() const
DS Number of regions in EE.
std::vector< VEcalCalibBlock * > m_EcalCalibBlocks
single blocks calibrators
edm::InputTag m_endcapAlCa
EcalEndcap Input Collection name.
assert(m_qm.get())
unsigned int m_loops
DS sets the number of loops to do.
int m_phiWidthEB
eta size of the additive border to the sub-matrix
int m_maxSelectedNumPerXtal
maximum number of events per crystal
double m_minEnergyPerCrystal
minimum energy per crystal cut
double m_maxCoeff
maximum coefficient accepted (RAW)
interface to the L3Univ class for testing
Definition: L3CalibBlock.h:24
int m_usingBlockSolver
to exclude the blocksolver
int m_radStart
DS For the EE.
edm::InputTag m_ElectronLabel
To take the electrons.
int m_etaStart
phi size of the additive border to the sub-matrix
EcalIntercalibConstantMap m_barrelMap
the maps of recalib coeffs
int m_recoWindowSidex
reconstruction window size
std::map< int, int > m_xtalRegionId
void EBRegionDefinition()
DS EB Region Definition.
double m_minCoeff
minimum coefficient accepted (RAW)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
int m_etaWidth
eta size of the sub-matrix
std::vector< int > m_regions
int etaShifter(const int) const
LP Change the coordinate system.
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
int m_phiEndEB
phi end of the region of interest
int m_phiStartEB
phi start of the region of interest
EcalIntercalibConstantMap m_endcapMap
edm::InputTag m_barrelAlCa
EcalBarrel Input Collection name.
int m_etaEnd
eta end of the region of interest
int EBregionsNum() const
DS number of regions in EB.
std::map< int, int > m_xtalPositionInRegion
double m_maxEnergyPerCrystal
maximum energy per crystal cut
EcalEleCalibLooper::~EcalEleCalibLooper ( )

dtor

LP destructor.

Definition at line 142 of file EcalEleCalibLooper.cc.

References m_EcalCalibBlocks.

143 {
144  edm::LogInfo ("IML") << "[EcalEleCalibLooper][dtor]" ;
145  for (std::vector<VEcalCalibBlock *>::iterator calibBlock = m_EcalCalibBlocks.begin () ;
146  calibBlock != m_EcalCalibBlocks.end () ;
147  ++calibBlock)
148  delete (*calibBlock) ;
149 
150 }
std::vector< VEcalCalibBlock * > m_EcalCalibBlocks
single blocks calibrators

Member Function Documentation

void EcalEleCalibLooper::beginOfJob ( )
virtual

BeginOfJob.

Reimplemented from edm::EDLooperBase.

Definition at line 158 of file EcalEleCalibLooper.cc.

References isfirstcall_.

159 {
160  isfirstcall_=true;
161 
162 }
edm::EDLooper::Status EcalEleCalibLooper::duringLoop ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

duringLoop return the status Kcontinue, fills the calibBlock with the recHits

Implements edm::EDLooper.

Definition at line 194 of file EcalEleCalibLooper.cc.

References DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, HcalObjRepresent::Fill(), VFillMap::fillMap(), plotBeamSpotDB::first, geometry, edm::EventSetup::get(), edm::Event::getByLabel(), CaloGeometry::getValidDetIds(), isfirstcall_, edm::HandleBase::isValid(), edm::EDLooperBase::kContinue, m_barrelAlCa, m_barrelCells, m_barrelMap, m_EcalCalibBlocks, m_ElectronLabel, m_endcapAlCa, m_endcapCells, m_endcapMap, m_MapFiller, m_maxSelectedNumPerXtal, m_xtalNumOfHits, m_xtalRegionId, Max(), edm::Handle< T >::product(), and DetId::rawId().

196 {
197 
198  // this chunk used to belong to beginJob(isetup). Moved here
199  // with the beginJob without arguments migration
200 
201  if (isfirstcall_){
202  edm::ESHandle<CaloGeometry> geoHandle;
203  iSetup.get<CaloGeometryRecord> ().get (geoHandle);
204  const CaloGeometry& geometry = *geoHandle;
207  for (std::vector<DetId>::const_iterator barrelIt=m_barrelCells.begin();
208  barrelIt!=m_barrelCells.end();++barrelIt){
209  m_barrelMap[*barrelIt]=1;
210  m_xtalNumOfHits[barrelIt->rawId()]=0;
211  }
212  for (std::vector<DetId>::const_iterator endcapIt=m_endcapCells.begin();
213  endcapIt!=m_endcapCells.end();++endcapIt){
214  m_endcapMap[*endcapIt]=1;
215  m_xtalNumOfHits[endcapIt->rawId()]=0;
216  }
217 
218  isfirstcall_=false;
219  }
220 
221 
222 
223  //take the collection of recHits in the barrel
224  const EBRecHitCollection* barrelHitsCollection = 0;
225  edm::Handle<EBRecHitCollection> barrelRecHitsHandle ;
226  iEvent.getByLabel (m_barrelAlCa, barrelRecHitsHandle) ;
227  barrelHitsCollection = barrelRecHitsHandle.product () ;
228  if (!barrelRecHitsHandle.isValid ()) {
229  edm::LogError ("reading") << "[EcalEleCalibLooper] barrel rec hits not found" ;
230  return kContinue ;
231  }
232 
233  //take the collection of rechis in the endcap
234  const EERecHitCollection * endcapHitsCollection = 0 ;
235  edm::Handle<EERecHitCollection> endcapRecHitsHandle ;
236  iEvent.getByLabel (m_endcapAlCa, endcapRecHitsHandle) ;
237  endcapHitsCollection = endcapRecHitsHandle.product () ;
238  if (!endcapRecHitsHandle.isValid ()) {
239  edm::LogError ("reading") << "[EcalEleCalibLooper] endcap rec hits not found" ;
240  return kContinue;
241  }
242 
243  //Takes the electron collection of the pixel detector
245  iEvent.getByLabel (m_ElectronLabel,pElectrons);
246  if (!pElectrons.isValid ()) {
247  edm::LogError ("reading")<< "[EcalEleCalibLooper] electrons not found" ;
248  return kContinue;
249  }
250 
251  //Start the loop over the electrons
252  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin ();
253  eleIt != pElectrons->end ();
254  ++eleIt )
255  {
256  double pSubtract = 0 ;
257  double pTk = 0 ;
258  std::map<int , double> xtlMap;
259  DetId Max =0;
260  if (fabs(eleIt->eta()<1.49))
261  Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),barrelHitsCollection).first;
262  else
263  Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),endcapHitsCollection).first;
264  if (Max.det()==0) continue;
265  m_MapFiller->fillMap(eleIt->superCluster ()->hitsAndFractions (),Max,
266  barrelHitsCollection,endcapHitsCollection, xtlMap,pSubtract);
267  if (m_maxSelectedNumPerXtal > 0 &&
268  m_xtalNumOfHits[Max.rawId ()] > m_maxSelectedNumPerXtal ) continue;
269  ++m_xtalNumOfHits[Max.rawId()];
270  if (m_xtalRegionId[Max.rawId()]==-1) continue;
271  pTk = eleIt->trackMomentumAtVtx ().R ();
272  m_EcalCalibBlocks.at (m_xtalRegionId[Max.rawId()])->Fill (xtlMap.begin (),
273  xtlMap.end (),pTk,pSubtract) ;
274  } //End of the loop over the electron collection
275 
276  return kContinue;
277 } //end of duringLoop
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.
std::vector< DetId > m_barrelCells
std::vector< VEcalCalibBlock * > m_EcalCalibBlocks
single blocks calibrators
edm::InputTag m_endcapAlCa
EcalEndcap Input Collection name.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int m_maxSelectedNumPerXtal
maximum number of events per crystal
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::vector< DetId > m_endcapCells
edm::InputTag m_ElectronLabel
To take the electrons.
bool isValid() const
Definition: HandleBase.h:75
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
EcalIntercalibConstantMap m_barrelMap
the maps of recalib coeffs
T Max(T a, T b)
Definition: MathUtil.h:44
Definition: DetId.h:18
std::map< int, int > m_xtalRegionId
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
std::map< int, int > m_xtalNumOfHits
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
ESHandle< TrackerGeometry > geometry
EcalIntercalibConstantMap m_endcapMap
edm::InputTag m_barrelAlCa
EcalBarrel Input Collection name.
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
int EcalEleCalibLooper::EBregionCheck ( const int  eta,
const int  phi 
) const
private

Tells if you are in the region to be calibrated.

Definition at line 397 of file EcalEleCalibLooper.cc.

References m_etaEnd, m_etaStart, m_phiEndEB, and m_phiStartEB.

Referenced by EBRegionId().

398  {
399  if (eta < m_etaStart) return 1 ;
400  if (eta >= m_etaEnd) return 2 ;
401  if (phi < m_phiStartEB) return 3 ;
402  if (phi >= m_phiEndEB) return 4 ;
403  return 0 ;
404  }
int m_etaStart
phi size of the additive border to the sub-matrix
int m_phiEndEB
phi end of the region of interest
int m_phiStartEB
phi start of the region of interest
int m_etaEnd
eta end of the region of interest
void EcalEleCalibLooper::EBRegionDefinition ( )
private

DS EB Region Definition.

Definition at line 519 of file EcalEleCalibLooper.cc.

References EBRegionId(), EBregionsNum(), eta, m_regions, m_xtalPositionInRegion, m_xtalRegionId, phi, DetId::rawId(), and EBDetId::unhashIndex().

Referenced by EcalEleCalibLooper().

520 {
521  int reg=-1;
522  for (int it = 0 ; it < EBregionsNum () ; ++it) m_regions.push_back (0) ;
523  for (int eta = 0 ; eta < 170 ; ++eta)
524  for (int phi = 0 ; phi < 360 ; ++phi)
525  {
526  reg = EBRegionId (eta,phi) ;
527  m_xtalRegionId[EBDetId::unhashIndex (eta*360+phi).rawId ()] = reg ;
528  if (reg==-1) continue;
530  ++m_regions.at (reg);
531  }
532 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::map< int, int > m_xtalRegionId
std::vector< int > m_regions
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
int EBRegionId(const int, const int) const
Reg Id generator EB --— for the barrel.
int EBregionsNum() const
DS number of regions in EB.
std::map< int, int > m_xtalPositionInRegion
int EcalEleCalibLooper::EBRegionId ( const int  etaXtl,
const int  phiXtl 
) const
private

Reg Id generator EB --— for the barrel.

Definition at line 455 of file EcalEleCalibLooper.cc.

References EBregionCheck(), m_etaStart, m_etaWidth, m_phiEndEB, m_phiStartEB, and m_phiWidthEB.

Referenced by EBRegionDefinition().

456 {
457  if (EBregionCheck(etaXtl,phiXtl)) return -1;
458  int phifake = m_phiStartEB;
459  if (m_phiStartEB>m_phiEndEB) phifake = m_phiStartEB - 360;
460  int Nphi = (m_phiEndEB-phifake)/m_phiWidthEB ;
461  int etaI = (etaXtl-m_etaStart) / m_etaWidth ;
462  int phiI = (phiXtl-m_phiStartEB) / m_phiWidthEB ;
463  int regionNumEB = phiI + Nphi*etaI ;
464  return (int) regionNumEB;
465 }
int EBregionCheck(const int eta, const int phi) const
Tells if you are in the region to be calibrated.
int m_phiWidthEB
eta size of the additive border to the sub-matrix
int m_etaStart
phi size of the additive border to the sub-matrix
int m_etaWidth
eta size of the sub-matrix
int m_phiEndEB
phi end of the region of interest
int m_phiStartEB
phi start of the region of interest
int EcalEleCalibLooper::EBregionsNum ( ) const
inlineprivate

DS number of regions in EB.

Definition at line 507 of file EcalEleCalibLooper.cc.

References m_etaEnd, m_etaStart, m_etaWidth, m_phiEndEB, m_phiStartEB, m_phiWidthEB, and phi.

Referenced by EBRegionDefinition(), EcalEleCalibLooper(), and EERegionDefinition().

508 {
509  int phi = m_phiStartEB;
510  if (m_phiStartEB>m_phiEndEB) phi = m_phiStartEB - 360;
511  return ( (m_etaEnd - m_etaStart)/m_etaWidth) * ( (m_phiEndEB - phi)/m_phiWidthEB) ;
512 }
int m_phiWidthEB
eta size of the additive border to the sub-matrix
int m_etaStart
phi size of the additive border to the sub-matrix
int m_etaWidth
eta size of the sub-matrix
int m_phiEndEB
phi end of the region of interest
int m_phiStartEB
phi start of the region of interest
int m_etaEnd
eta end of the region of interest
int EcalEleCalibLooper::EEregionCheck ( const int  ics,
const int  ips 
) const
private

returns zero if the coordinates are in the right place.

Definition at line 576 of file EcalEleCalibLooper.cc.

References degrees(), m_phiEndEE, m_phiStartEE, m_radEnd, m_radStart, phi, x, and y.

Referenced by EERegionId().

577 {
578  int x = ics-50;
579  int y = ips-50;
580  double radius2 = x*x + y*y ;
581  if (radius2 < 10*10) return 1; //center of the donut
582  if (radius2 > 50*50) return 1; //outer part of the donut
583  if (radius2 < m_radStart * m_radStart) return 2 ;
584  if (radius2 >= m_radEnd * m_radEnd) return 2 ;
585  double phi = atan2 (static_cast<double> (y),static_cast<double> (x));
586  phi = degrees (phi);
587  if (phi < 0) phi += 360;
588  if (m_phiStartEE < m_phiEndEE
589  && phi > m_phiStartEE && phi < m_phiEndEE ) return 0;
590  if (m_phiStartEE > m_phiEndEE
591  && (phi > m_phiStartEE || phi < m_phiEndEE )) return 0;
592  return 3;
593 }
double degrees(double radiants)
def degrees
int m_radStart
DS For the EE.
void EcalEleCalibLooper::EERegionDefinition ( )
private

Definition at line 539 of file EcalEleCalibLooper.cc.

References bsc_activity_cfg::EBnum, EBregionsNum(), bsc_activity_cfg::EEnum, EERegionId(), EEregionsNum(), h2_mapping_cfi::ics, m_regions, m_xtalPositionInRegion, m_xtalRegionId, DetId::rawId(), and EEDetId::validDetId().

Referenced by EcalEleCalibLooper().

540 {
541  // reset
542  int EBnum=EBregionsNum();
543  int EEnum=EEregionsNum();
544  for (int it = 0 ; it < 2* EEnum ; ++it) m_regions.push_back (0) ;
545  // loop sui xtl
546  int reg=-1;
547  for (int ics = 0 ; ics < 100 ; ++ics)
548  for (int ips = 0 ; ips < 100 ; ++ips)
549  {
550  int ireg = EERegionId(ics, ips);
551  if (ireg==-1) reg =-1;
552  else reg = EBnum + ireg;
553  if (EEDetId::validDetId (ics+1, ips+1, 1))
554  {
555  m_xtalRegionId[EEDetId (ics+1, ips+1, 1).rawId ()] = reg ;
556  if (reg==-1) continue;
557  m_xtalPositionInRegion[EEDetId (ics+1, ips+1, 1).rawId ()] = m_regions.at (reg) ;
558  ++m_regions.at(reg);
559  }
560  if (reg!=-1) reg += EEnum;
561  if (EEDetId::validDetId (ics+1, ips+1, -1))
562  {
563  m_xtalRegionId[EEDetId (ics+1, ips+1, -1).rawId ()] = reg ;
564  if (reg==-1) continue;
565  m_xtalPositionInRegion[EEDetId (ics+1, ips+1, -1).rawId ()] = m_regions.at (reg) ;
566  ++m_regions.at (reg) ;
567  }
568  }
569 }
int EEregionsNum() const
DS Number of regions in EE.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::map< int, int > m_xtalRegionId
int EERegionId(const int, const int) const
Gives the id of the region.
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::vector< int > m_regions
int EBregionsNum() const
DS number of regions in EB.
std::map< int, int > m_xtalPositionInRegion
int EcalEleCalibLooper::EERegionId ( const int  ics,
const int  ips 
) const
private

Gives the id of the region.

Definition at line 472 of file EcalEleCalibLooper.cc.

References degrees(), EEregionCheck(), m_phiEndEE, m_phiStartEE, m_phiWidthEE, m_radStart, m_radWidth, phi, CosmicsPD_Skims::radius, and mathSSE::sqrt().

Referenced by EERegionDefinition().

473 {
474  if (EEregionCheck(ics,ips)) return -1;
475  int phifake = m_phiStartEE;
476  if (m_phiStartEE>m_phiEndEE) phifake = m_phiStartEE - 360;
477  double radius = (ics-50) * (ics-50) + (ips-50) * (ips-50) ;
478  radius = sqrt (radius) ;
479  int Nphi = (m_phiEndEE - phifake)/m_phiWidthEE ;
480  double phi = atan2 (static_cast<double> (ips-50),
481  static_cast<double> (ics-50)) ;
482  phi = degrees (phi);
483  if (phi < 0) phi += 360;
484  int radI = static_cast<int> ((radius-m_radStart) / m_radWidth) ;
485  int phiI = static_cast<int> ((m_phiEndEE-phi) / m_phiWidthEE) ;
486  int regionNumEE = phiI + Nphi*radI ;
487  return regionNumEE ;
488 }
double degrees(double radiants)
def degrees
T sqrt(T t)
Definition: SSEVec.h:18
int m_radStart
DS For the EE.
int EEregionCheck(const int, const int) const
returns zero if the coordinates are in the right place.
int EcalEleCalibLooper::EEregionsNum ( ) const
inlineprivate

DS Number of regions in EE.

Definition at line 495 of file EcalEleCalibLooper.cc.

References m_phiEndEE, m_phiStartEE, m_phiWidthEE, m_radEnd, m_radStart, and m_radWidth.

Referenced by EcalEleCalibLooper(), and EERegionDefinition().

496 {
497  int phifake = m_phiStartEE;
498  if (m_phiStartEE>m_phiEndEE) phifake = m_phiStartEE - 360;
499  return ( (m_radEnd - m_radStart)/m_radWidth) * ( (m_phiEndEE - phifake)/m_phiWidthEE) ;
500 }
int m_radStart
DS For the EE.
void EcalEleCalibLooper::endOfJob ( )
virtual

LP endOfJob writes the coefficients in the xml format and exits

Reimplemented from edm::EDLooperBase.

Definition at line 365 of file EcalEleCalibLooper.cc.

References EcalBarrel, EcalEndcap, m_barrelCells, m_barrelMap, m_endcapCells, m_endcapMap, and calibXMLwriter::writeLine().

366 {
367  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfJob] saving calib coeffs" ;
368 
369 //Writes the coeffs
370  calibXMLwriter barrelWriter (EcalBarrel);
371  calibXMLwriter endcapWriter (EcalEndcap);
372  for (std::vector<DetId>::const_iterator barrelIt = m_barrelCells.begin ();
373  barrelIt!=m_barrelCells.end ();
374  ++barrelIt)
375  {
376  EBDetId eb (*barrelIt);
377  barrelWriter.writeLine (eb,m_barrelMap[*barrelIt]);
378  }
379  for (std::vector<DetId>::const_iterator endcapIt = m_endcapCells.begin ();
380  endcapIt!=m_endcapCells.end ();
381  ++endcapIt)
382  {
383  EEDetId ee (*endcapIt);
384  endcapWriter.writeLine (ee,m_endcapMap[*endcapIt]);
385  }
386  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfJob] Exiting" ;
387 }
std::vector< DetId > m_barrelCells
std::vector< DetId > m_endcapCells
EcalIntercalibConstantMap m_barrelMap
the maps of recalib coeffs
EcalIntercalibConstantMap m_endcapMap
edm::EDLooper::Status EcalEleCalibLooper::endOfLoop ( const edm::EventSetup dumb,
unsigned int  iCounter 
)
virtual

EndOfLoop Return kContinue if there's still another loop to be done; otherwise stops returnig kStop; Takes the coefficients solving the calibBlock;

Implements edm::EDLooperBase.

Definition at line 286 of file EcalEleCalibLooper.cc.

References lut2db_cfg::filename, EBDetId::ieta(), cmsHarvester::index, EBDetId::iphi(), EEDetId::ix(), EEDetId::iy(), edm::EDLooperBase::kContinue, edm::EDLooperBase::kStop, m_barrelCells, m_barrelMap, m_EcalCalibBlocks, m_endcapCells, m_endcapMap, m_loops, m_maxCoeff, m_minCoeff, m_usingBlockSolver, m_xtalPositionInRegion, m_xtalRegionId, and EEDetId::zside().

287 {
288  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfLoop] entering..." ;
289  for (std::vector<VEcalCalibBlock *>::iterator calibBlock = m_EcalCalibBlocks.begin ();
290  calibBlock!=m_EcalCalibBlocks.end ();
291  ++calibBlock)
292  (*calibBlock)->solve (m_usingBlockSolver, m_minCoeff,m_maxCoeff);
293 
294  TH1F * EBcoeffEnd = new TH1F ("EBRegion","EBRegion",100,0.5,2.1) ;
295  TH2F * EBcoeffMap = new TH2F ("EBcoeff","EBcoeff",171,-85,85,360,1,361);
296  TH1F * EEPcoeffEnd = new TH1F ("EEPRegion", "EEPRegion",100,0.5,2.1);
297  TH1F * EEMcoeffEnd = new TH1F ("EEMRegion", "EEMRegion",100,0.5,2.1);
298  TH2F * EEPcoeffMap = new TH2F ("EEPcoeffMap","EEPcoeffMap",101,1,101,101,0,101);
299  TH2F * EEMcoeffMap = new TH2F ("EEMcoeffMap","EEMcoeffMap",101,1,101,101,0,101);
300  //loop over the barrel xtals to get the coeffs
301  for (std::vector<DetId>::const_iterator barrelIt=m_barrelCells.begin();
302  barrelIt!=m_barrelCells.end();++barrelIt)
303  {
304  EBDetId ee (*barrelIt);
305  int index= barrelIt->rawId();
306  if(m_xtalRegionId[index]==-1)continue;
307  m_barrelMap[*barrelIt] *=
309  EBcoeffEnd->Fill(m_barrelMap[*barrelIt]);
310  EBcoeffMap->Fill(ee.ieta(),ee.iphi(),m_barrelMap[*barrelIt]);
311  } //PG loop over phi
312 
313  // loop over the EndCap to get the recalib coefficients
314  for(std::vector<DetId>::const_iterator endcapIt=m_endcapCells.begin();
315  endcapIt!=m_endcapCells.end();++endcapIt)
316  {
317  EEDetId ee (*endcapIt);
318  int index =endcapIt->rawId();
319  if (ee.zside()>0)
320  {
321  if (m_xtalRegionId[index]==-1) continue ;
322  m_endcapMap[*endcapIt] *=
324  EEPcoeffEnd->Fill (m_endcapMap[*endcapIt]) ;
325  EEPcoeffMap->Fill (ee.ix(),ee.iy(),m_endcapMap[*endcapIt]) ;
326  }
327  else
328  {
329  m_endcapMap[*endcapIt] *=
331  EEMcoeffEnd->Fill (m_endcapMap[*endcapIt]) ;
332  EEMcoeffMap->Fill (ee.ix(),ee.iy(),m_endcapMap[*endcapIt]) ;
333  }
334  } // loop over the EndCap to get the recalib coefficients
335 
336  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfLoop] End of endOfLoop" ;
337 
338  char filename[80];
339  sprintf(filename,"coeffs%d.root",iCounter);
340  TFile zout (filename, "recreate");
341  EBcoeffEnd->Write () ;
342  EBcoeffMap->Write () ;
343  EEPcoeffEnd->Write () ;
344  EEPcoeffMap->Write () ;
345  EEMcoeffEnd->Write () ;
346  EEMcoeffMap->Write () ;
347  zout.Close () ;
348  delete EBcoeffEnd;
349  delete EBcoeffMap;
350  delete EEPcoeffEnd;
351  delete EEMcoeffEnd;
352  delete EEPcoeffMap;
353  delete EEMcoeffMap;
354  if (iCounter < m_loops-1 ) return kContinue ;
355  else return kStop;
356 }
std::vector< DetId > m_barrelCells
std::vector< VEcalCalibBlock * > m_EcalCalibBlocks
single blocks calibrators
unsigned int m_loops
DS sets the number of loops to do.
double m_maxCoeff
maximum coefficient accepted (RAW)
std::vector< DetId > m_endcapCells
int m_usingBlockSolver
to exclude the blocksolver
EcalIntercalibConstantMap m_barrelMap
the maps of recalib coeffs
std::map< int, int > m_xtalRegionId
double m_minCoeff
minimum coefficient accepted (RAW)
tuple filename
Definition: lut2db_cfg.py:20
EcalIntercalibConstantMap m_endcapMap
std::map< int, int > m_xtalPositionInRegion
int EcalEleCalibLooper::etaShifter ( const int  etaOld) const
private

LP Change the coordinate system.

Definition at line 600 of file EcalEleCalibLooper.cc.

References assert().

601  {
602  if (etaOld < 0) return etaOld + 85;
603  else if (etaOld > 0) return etaOld + 84;
604  assert(0!=etaOld); // etaOld = 0, apparently not a foreseen value, so fail
605  return 999; // dummy statement to silence compiler warning
606  }
assert(m_qm.get())
double EcalEleCalibLooper::giveLimit ( int  degrees)
private

copes with the infinitives of the tangent

Definition at line 431 of file EcalEleCalibLooper.cc.

References radiants(), and funct::tan().

432  {
433  //PG 200 > atan (50/0.5)
434  if (degrees == 90) return 90 ;
435  return tan (radiants (degrees)) ;
436  }
double degrees(double radiants)
def degrees
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double radiants(int degrees)
DS def radiants.
void EcalEleCalibLooper::startingNewLoop ( unsigned int  ciclo)
virtual

startingNewLoop empties the map of the calibBlock so that it can be filled

Implements edm::EDLooperBase.

Definition at line 170 of file EcalEleCalibLooper.cc.

References m_EcalCalibBlocks, and m_xtalNumOfHits.

171 {
172  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][Start] entering loop " << ciclo;
173 
174 
175 
176  for (std::vector<VEcalCalibBlock *>::iterator calibBlock = m_EcalCalibBlocks.begin () ;
177  calibBlock != m_EcalCalibBlocks.end () ;
178  ++calibBlock)
179  (*calibBlock)->reset ();
180  for (std::map<int,int>::iterator it= m_xtalNumOfHits.begin();
181  it!=m_xtalNumOfHits.end();
182  ++it)
183  it->second = 0 ;
184  return ;
185 }
std::vector< VEcalCalibBlock * > m_EcalCalibBlocks
single blocks calibrators
std::map< int, int > m_xtalNumOfHits

Member Data Documentation

bool EcalEleCalibLooper::isfirstcall_
private

Definition at line 143 of file EcalEleCalibLooper.h.

Referenced by beginOfJob(), and duringLoop().

edm::InputTag EcalEleCalibLooper::m_barrelAlCa
private

EcalBarrel Input Collection name.

Definition at line 68 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

std::vector<DetId> EcalEleCalibLooper::m_barrelCells
private

Definition at line 136 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), endOfJob(), and endOfLoop().

EcalIntercalibConstantMap EcalEleCalibLooper::m_barrelMap
private

the maps of recalib coeffs

Definition at line 119 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), EcalEleCalibLooper(), endOfJob(), and endOfLoop().

std::vector<VEcalCalibBlock *> EcalEleCalibLooper::m_EcalCalibBlocks
private

single blocks calibrators

Definition at line 106 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), EcalEleCalibLooper(), endOfLoop(), startingNewLoop(), and ~EcalEleCalibLooper().

edm::InputTag EcalEleCalibLooper::m_ElectronLabel
private

To take the electrons.

Definition at line 125 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

edm::InputTag EcalEleCalibLooper::m_endcapAlCa
private

EcalEndcap Input Collection name.

Definition at line 70 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

std::vector<DetId> EcalEleCalibLooper::m_endcapCells
private

Definition at line 137 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), endOfJob(), and endOfLoop().

EcalIntercalibConstantMap EcalEleCalibLooper::m_endcapMap
private

Definition at line 120 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), EcalEleCalibLooper(), endOfJob(), and endOfLoop().

int EcalEleCalibLooper::m_etaEnd
private

eta end of the region of interest

Definition at line 88 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBregionsNum(), and EcalEleCalibLooper().

int EcalEleCalibLooper::m_etaStart
private

phi size of the additive border to the sub-matrix

eta start of the region of interest

Definition at line 86 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBRegionId(), EBregionsNum(), and EcalEleCalibLooper().

int EcalEleCalibLooper::m_etaWidth
private

eta size of the sub-matrix

Definition at line 77 of file EcalEleCalibLooper.h.

Referenced by EBRegionId(), EBregionsNum(), and EcalEleCalibLooper().

unsigned int EcalEleCalibLooper::m_loops
private

DS sets the number of loops to do.

Definition at line 123 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

VFillMap* EcalEleCalibLooper::m_MapFiller
private

Definition at line 127 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), and EcalEleCalibLooper().

double EcalEleCalibLooper::m_maxCoeff
private

maximum coefficient accepted (RAW)

Definition at line 114 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

double EcalEleCalibLooper::m_maxEnergyPerCrystal
private

maximum energy per crystal cut

Definition at line 110 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

int EcalEleCalibLooper::m_maxSelectedNumPerXtal
private

maximum number of events per crystal

Definition at line 103 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

double EcalEleCalibLooper::m_minCoeff
private

minimum coefficient accepted (RAW)

Definition at line 112 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

double EcalEleCalibLooper::m_minEnergyPerCrystal
private

minimum energy per crystal cut

Definition at line 108 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

int EcalEleCalibLooper::m_phiEndEB
private

phi end of the region of interest

Definition at line 92 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBRegionId(), and EBregionsNum().

int EcalEleCalibLooper::m_phiEndEE
private

Definition at line 99 of file EcalEleCalibLooper.h.

Referenced by EEregionCheck(), EERegionId(), and EEregionsNum().

int EcalEleCalibLooper::m_phiStartEB
private

phi start of the region of interest

Definition at line 90 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBRegionId(), and EBregionsNum().

int EcalEleCalibLooper::m_phiStartEE
private

Definition at line 98 of file EcalEleCalibLooper.h.

Referenced by EEregionCheck(), EERegionId(), and EEregionsNum().

int EcalEleCalibLooper::m_phiWidthEB
private

eta size of the additive border to the sub-matrix

phi size of the sub-matrix

Definition at line 81 of file EcalEleCalibLooper.h.

Referenced by EBRegionId(), and EBregionsNum().

int EcalEleCalibLooper::m_phiWidthEE
private

Definition at line 100 of file EcalEleCalibLooper.h.

Referenced by EERegionId(), and EEregionsNum().

int EcalEleCalibLooper::m_radEnd
private

Definition at line 95 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper(), EEregionCheck(), and EEregionsNum().

int EcalEleCalibLooper::m_radStart
private

DS For the EE.

Definition at line 94 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper(), EEregionCheck(), EERegionId(), and EEregionsNum().

int EcalEleCalibLooper::m_radWidth
private

Definition at line 96 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper(), EERegionId(), and EEregionsNum().

int EcalEleCalibLooper::m_recoWindowSidex
private

reconstruction window size

Definition at line 73 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

int EcalEleCalibLooper::m_recoWindowSidey
private

Definition at line 74 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

std::vector<int> EcalEleCalibLooper::m_regions
private
int EcalEleCalibLooper::m_usingBlockSolver
private

to exclude the blocksolver

Definition at line 116 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

std::map<int,int> EcalEleCalibLooper::m_xtalNumOfHits
private

Definition at line 141 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), and startingNewLoop().

std::map<int,int> EcalEleCalibLooper::m_xtalPositionInRegion
private
std::map<int,int> EcalEleCalibLooper::m_xtalRegionId
private