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 Types | Private Member Functions | Private Attributes
SiPixelLorentzAngleDB Class Reference

#include <SiPixelLorentzAngleDB.h>

Inheritance diagram for SiPixelLorentzAngleDB:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &c)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 SiPixelLorentzAngleDB (const edm::ParameterSet &conf)
 
virtual ~SiPixelLorentzAngleDB ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Types

typedef std::vector
< edm::ParameterSet
Parameters
 

Private Member Functions

unsigned int HVgroup (unsigned int panel, unsigned int module)
 

Private Attributes

Parameters BPixParameters_
 
edm::ParameterSet conf_
 
std::vector< std::pair
< uint32_t, float > > 
detid_la
 
std::string fileName_
 
Parameters FPixParameters_
 
double magneticField_
 
std::string recordName_
 
bool useFile_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 23 of file SiPixelLorentzAngleDB.h.

Member Typedef Documentation

typedef std::vector< edm::ParameterSet > SiPixelLorentzAngleDB::Parameters
private

Definition at line 51 of file SiPixelLorentzAngleDB.h.

Constructor & Destructor Documentation

SiPixelLorentzAngleDB::SiPixelLorentzAngleDB ( const edm::ParameterSet conf)
explicit

Definition at line 26 of file SiPixelLorentzAngleDB.cc.

References BPixParameters_, conf_, fileName_, FPixParameters_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), magneticField_, recordName_, and useFile_.

26  :
27  conf_(conf){
28  magneticField_ = conf_.getParameter<double>("magneticField");
29  recordName_ = conf_.getUntrackedParameter<std::string>("record","SiPixelLorentzAngleRcd");
30 // bPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("bPixLorentzAnglePerTesla");
31 // fPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("fPixLorentzAnglePerTesla");
32  useFile_ = conf_.getParameter<bool>("useFile");
33  fileName_ = conf_.getParameter<string>("fileName");
34 
37 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::ParameterSet > Parameters
SiPixelLorentzAngleDB::~SiPixelLorentzAngleDB ( )
virtual

Definition at line 46 of file SiPixelLorentzAngleDB.cc.

46  {
47 
48 }

Member Function Documentation

void SiPixelLorentzAngleDB::analyze ( const edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 52 of file SiPixelLorentzAngleDB.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), PXFDetId::blade(), BPixParameters_, gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::currentTime(), cond::rpcobgas::detid, PXFDetId::disk(), cond::service::PoolDBOutputService::endOfTime(), cppFunctionSkipper::exception, FPixParameters_, edm::EventSetup::get(), HVgroup(), edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), PXBDetId::ladder(), PXBDetId::layer(), PXBDetId::module(), PXFDetId::module(), PXFDetId::panel(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, SiPixelLorentzAngle::putLorentzAngle(), DetId::rawId(), recordName_, PXFDetId::side(), DetId::subdetId(), useFile_, and cms::Exception::what().

53 {
54 
55  SiPixelLorentzAngle* LorentzAngle = new SiPixelLorentzAngle();
56 
57 
59  es.get<TrackerDigiGeometryRecord>().get( pDD );
60  edm::LogInfo("SiPixelLorentzAngle") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
61 
62  for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
63 
64  if( dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
65  DetId detid=(*it)->geographicalId();
66 
67  // fill bpix values for LA
68  if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
69 
70  PXBDetId pxdetid = PXBDetId(detid);
71  cout << " hp:barrel:" << " layer=" << pxdetid.layer() << " ladder=" << pxdetid.ladder() << " module=" << pxdetid.module() << endl;
72 
73  if(!useFile_){
74 /*hp
75  if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),bPixLorentzAnglePerTesla_) )
76  edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
77 */
78 //hp
79  for(Parameters::iterator it = BPixParameters_.begin(); it != BPixParameters_.end(); ++it) {
80 // cout << " PSet: " << *it << ", module = " << it->getParameter<unsigned int>("module") << endl;
81  if( it->getParameter<unsigned int>("module") == pxdetid.module() && it->getParameter<unsigned int>("layer") == pxdetid.layer() )
82  {
83  float lorentzangle = (float)it->getParameter<double>("angle");
84  LorentzAngle->putLorentzAngle(detid.rawId(),lorentzangle);
85  }
86  }
87 
88  } else {
89 // cout << "method for reading file not implemented yet" << endl;
90  edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] method for reading file not implemented yet" << std::endl;
91  }
92 
93  // fill fpix values for LA
94  } else if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
95 
96 //hp
97  PXFDetId pxdetid = PXFDetId(detid);
98  cout << " hp:endcap:" << " side=" << pxdetid.side() << " disk=" << pxdetid.disk() << " blade=" << pxdetid.blade() << " panel=" << pxdetid.panel() << " module=" << pxdetid.module() << endl;
99 /*hp
100  if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),fPixLorentzAnglePerTesla_) ) edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
101 */
102 
103 //hp
104  for(Parameters::iterator it = FPixParameters_.begin(); it != FPixParameters_.end(); ++it) {
105 // cout << " PSet: " << *it << ", module = " << it->getParameter<unsigned int>("module") << endl;
106  if( it->getParameter<unsigned int>("side") == pxdetid.side() && it->getParameter<unsigned int>("disk") == pxdetid.disk() && it->getParameter<unsigned int>("HVgroup") == HVgroup(pxdetid.panel(),pxdetid.module()) )
107  {
108  float lorentzangle = (float)it->getParameter<double>("angle");
109  LorentzAngle->putLorentzAngle(detid.rawId(),lorentzangle);
110  }
111  }
112 
113  } else {
114  edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid is Pixel but neither bpix nor fpix"<<std::endl;
115  }
116 
117  }
118 
119  }
120 
121 
123  if( mydbservice.isAvailable() ){
124  try{
125  if( mydbservice->isNewTagRequest(recordName_) ){
126  mydbservice->createNewIOV<SiPixelLorentzAngle>(LorentzAngle,
127  mydbservice->beginOfTime(),
128  mydbservice->endOfTime(),
129  recordName_);
130  } else {
131  mydbservice->appendSinceTime<SiPixelLorentzAngle>(LorentzAngle,
132  mydbservice->currentTime(),
133  recordName_);
134  }
135  }catch(const cond::Exception& er){
136  edm::LogError("SiPixelLorentzAngleDB")<<er.what()<<std::endl;
137  }catch(const std::exception& er){
138  edm::LogError("SiPixelLorentzAngleDB")<<"caught std::exception "<<er.what()<<std::endl;
139  }catch(...){
140  edm::LogError("SiPixelLorentzAngleDB")<<"Funny error"<<std::endl;
141  }
142  }else{
143  edm::LogError("SiPixelLorentzAngleDB")<<"Service is unavailable"<<std::endl;
144  }
145 
146 
147 }
virtual char const * what() const
Definition: Exception.cc:141
unsigned int panel() const
panel id
Definition: PXFDetId.h:52
unsigned int ladder() const
ladder id
Definition: PXBDetId.h:39
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
unsigned int blade() const
blade id
Definition: PXFDetId.h:48
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:47
unsigned int module() const
det id
Definition: PXBDetId.h:43
unsigned int module() const
det id
Definition: PXFDetId.h:56
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool putLorentzAngle(const uint32_t &, float &)
unsigned int disk() const
disk id
Definition: PXFDetId.h:43
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
Definition: DetId.h:20
unsigned int HVgroup(unsigned int panel, unsigned int module)
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:38
tuple cout
Definition: gather_cfg.py:121
void SiPixelLorentzAngleDB::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 41 of file SiPixelLorentzAngleDB.cc.

41  {
42 
43 }
void SiPixelLorentzAngleDB::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 172 of file SiPixelLorentzAngleDB.cc.

172  {
173 
174 
175 }
unsigned int SiPixelLorentzAngleDB::HVgroup ( unsigned int  panel,
unsigned int  module 
)
private

Definition at line 150 of file SiPixelLorentzAngleDB.cc.

References gather_cfg::cout.

Referenced by analyze().

150  {
151 
152  if( 1 == panel && ( 1 == module || 2 == module )) {
153  return 1;
154  }
155  else if( 1 == panel && ( 3 == module || 4 == module )) {
156  return 2;
157  }
158  else if( 2 == panel && 1 == module ) {
159  return 1;
160  }
161  else if( 2 == panel && ( 2 == module || 3 == module )) {
162  return 2;
163  }
164  else {
165  cout << " *** error *** in SiPixelLorentzAngleDB::HVgroup(...), panel = " << panel << ", module = " << module << endl;
166  return 0;
167  }
168 
169 }
tuple cout
Definition: gather_cfg.py:121
Definition: vlib.h:209

Member Data Documentation

Parameters SiPixelLorentzAngleDB::BPixParameters_
private

Definition at line 52 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().

edm::ParameterSet SiPixelLorentzAngleDB::conf_
private

Definition at line 45 of file SiPixelLorentzAngleDB.h.

Referenced by SiPixelLorentzAngleDB().

std::vector< std::pair<uint32_t, float> > SiPixelLorentzAngleDB::detid_la
private

Definition at line 44 of file SiPixelLorentzAngleDB.h.

std::string SiPixelLorentzAngleDB::fileName_
private

Definition at line 55 of file SiPixelLorentzAngleDB.h.

Referenced by SiPixelLorentzAngleDB().

Parameters SiPixelLorentzAngleDB::FPixParameters_
private

Definition at line 53 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().

double SiPixelLorentzAngleDB::magneticField_
private

Definition at line 46 of file SiPixelLorentzAngleDB.h.

Referenced by SiPixelLorentzAngleDB().

std::string SiPixelLorentzAngleDB::recordName_
private

Definition at line 47 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().

bool SiPixelLorentzAngleDB::useFile_
private

Definition at line 56 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().