CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelLorentzAngleDB.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 #include <iostream>
4 #include <fstream>
12 
13 
18 
19 using namespace std;
20 using namespace edm;
21 
22  //Constructor
23 
25  conf_(conf){
26  magneticField_ = conf_.getParameter<double>("magneticField");
27  recordName_ = conf_.getUntrackedParameter<std::string>("record","SiPixelLorentzAngleRcd");
28  bPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("bPixLorentzAnglePerTesla");
29  fPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("fPixLorentzAnglePerTesla");
30  useFile_ = conf_.getParameter<bool>("useFile");
31  fileName_ = conf_.getParameter<string>("fileName");
32 
33 }
34 
35  //BeginJob
36 
38 
39 }
40 // Virtual destructor needed.
41 
43 
44 }
45 
46 // Analyzer: Functions that gets called by framework every event
47 
49 {
50 
51  SiPixelLorentzAngle* LorentzAngle = new SiPixelLorentzAngle();
52 
53 
55  es.get<TrackerDigiGeometryRecord>().get( pDD );
56  edm::LogInfo("SiPixelLorentzAngle") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
57 
58  for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
59 
60  if( dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
61  DetId detid=(*it)->geographicalId();
62 
63  // fill bpix values for LA
64  if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
65 
66  if(!useFile_){
67  if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),bPixLorentzAnglePerTesla_) )
68  edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
69  } else {
70  cout << "method for reading file not implemented yet" << endl;
71  }
72 
73 
74  // fill bpix values for LA
75  } else if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
76 
77  if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),fPixLorentzAnglePerTesla_) )
78  edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
79  } else {
80  edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid is Pixel but neither bpix nor fpix"<<std::endl;
81  }
82 
83  }
84 
85  }
86 
87 
89  if( mydbservice.isAvailable() ){
90  try{
91  if( mydbservice->isNewTagRequest(recordName_) ){
92  mydbservice->createNewIOV<SiPixelLorentzAngle>(LorentzAngle,
93  mydbservice->beginOfTime(),
94  mydbservice->endOfTime(),
95  recordName_);
96  } else {
97  mydbservice->appendSinceTime<SiPixelLorentzAngle>(LorentzAngle,
98  mydbservice->currentTime(),
99  recordName_);
100  }
101  }catch(const cond::Exception& er){
102  edm::LogError("SiPixelLorentzAngleDB")<<er.what()<<std::endl;
103  }catch(const std::exception& er){
104  edm::LogError("SiPixelLorentzAngleDB")<<"caught std::exception "<<er.what()<<std::endl;
105  }catch(...){
106  edm::LogError("SiPixelLorentzAngleDB")<<"Funny error"<<std::endl;
107  }
108  }else{
109  edm::LogError("SiPixelLorentzAngleDB")<<"Service is unavailable"<<std::endl;
110  }
111 
112 
113 }
114 
116 
117 
118 }
virtual char const * what() const
Definition: Exception.cc:141
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
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
SiPixelLorentzAngleDB(const edm::ParameterSet &conf)
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 &)
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:121