Skip to content

Commit

Permalink
Merge pull request #2216 from hidaspal/LA_by_module-from-CMSSW_5_3_14…
Browse files Browse the repository at this point in the history
…_patch2

Lorentz angle by module
  • Loading branch information
smuzaffar committed Feb 26, 2014
2 parents ef385e1 + a9fc7a9 commit d195e26
Show file tree
Hide file tree
Showing 3 changed files with 326 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ class SiPixelLorentzAngleDB : public edm::EDAnalyzer

private:

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

std::vector< std::pair<uint32_t, float> > detid_la;
edm::ParameterSet conf_;
double magneticField_;
std::string recordName_;
float bPixLorentzAnglePerTesla_;
float fPixLorentzAnglePerTesla_;
// float bPixLorentzAnglePerTesla_;
// float fPixLorentzAnglePerTesla_;
//hp
typedef std::vector< edm::ParameterSet > Parameters;
Parameters BPixParameters_;
Parameters FPixParameters_;

std::string fileName_;
bool useFile_;
};
Expand Down
101 changes: 80 additions & 21 deletions CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAngleDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <fstream>
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "CalibTracker/SiPixelLorentzAngle/interface/SiPixelLorentzAngleDB.h"
#include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
#include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
Expand All @@ -25,11 +27,13 @@ SiPixelLorentzAngleDB::SiPixelLorentzAngleDB(edm::ParameterSet const& conf) :
conf_(conf){
magneticField_ = conf_.getParameter<double>("magneticField");
recordName_ = conf_.getUntrackedParameter<std::string>("record","SiPixelLorentzAngleRcd");
bPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("bPixLorentzAnglePerTesla");
fPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("fPixLorentzAnglePerTesla");
// bPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("bPixLorentzAnglePerTesla");
// fPixLorentzAnglePerTesla_ = (float)conf_.getParameter<double>("fPixLorentzAnglePerTesla");
useFile_ = conf_.getParameter<bool>("useFile");
fileName_ = conf_.getParameter<string>("fileName");

BPixParameters_ = conf_.getUntrackedParameter<Parameters>("BPixParameters");
FPixParameters_ = conf_.getUntrackedParameter<Parameters>("FPixParameters");
}

//BeginJob
Expand Down Expand Up @@ -57,30 +61,60 @@ void SiPixelLorentzAngleDB::analyze(const edm::Event& e, const edm::EventSetup&

for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){

if( dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
DetId detid=(*it)->geographicalId();
if( dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
DetId detid=(*it)->geographicalId();

// fill bpix values for LA
if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {

if(!useFile_){
if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),bPixLorentzAnglePerTesla_) )
edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
} else {
cout << "method for reading file not implemented yet" << endl;
}
// fill bpix values for LA
if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {

PXBDetId pxdetid = PXBDetId(detid);
cout << " hp:barrel:" << " layer=" << pxdetid.layer() << " ladder=" << pxdetid.ladder() << " module=" << pxdetid.module() << endl;

if(!useFile_){
/*hp
if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),bPixLorentzAnglePerTesla_) )
edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
*/
//hp
for(Parameters::iterator it = BPixParameters_.begin(); it != BPixParameters_.end(); ++it) {
// cout << " PSet: " << *it << ", module = " << it->getParameter<unsigned int>("module") << endl;
if( it->getParameter<unsigned int>("module") == pxdetid.module() && it->getParameter<unsigned int>("layer") == pxdetid.layer() )
{
float lorentzangle = (float)it->getParameter<double>("angle");
LorentzAngle->putLorentzAngle(detid.rawId(),lorentzangle);
}
}

} else {
// cout << "method for reading file not implemented yet" << endl;
edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] method for reading file not implemented yet" << std::endl;
}

// fill bpix values for LA
} else if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
// fill fpix values for LA
} else if(detid.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {

if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),fPixLorentzAnglePerTesla_) )
edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
} else {
edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid is Pixel but neither bpix nor fpix"<<std::endl;
}

//hp
PXFDetId pxdetid = PXFDetId(detid);
cout << " hp:endcap:" << " side=" << pxdetid.side() << " disk=" << pxdetid.disk() << " blade=" << pxdetid.blade() << " panel=" << pxdetid.panel() << " module=" << pxdetid.module() << endl;
/*hp
if ( ! LorentzAngle->putLorentzAngle(detid.rawId(),fPixLorentzAnglePerTesla_) ) edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid already exists"<<std::endl;
*/

//hp
for(Parameters::iterator it = FPixParameters_.begin(); it != FPixParameters_.end(); ++it) {
// cout << " PSet: " << *it << ", module = " << it->getParameter<unsigned int>("module") << endl;
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()) )
{
float lorentzangle = (float)it->getParameter<double>("angle");
LorentzAngle->putLorentzAngle(detid.rawId(),lorentzangle);
}
}

} else {
edm::LogError("SiPixelLorentzAngleDB")<<"[SiPixelLorentzAngleDB::analyze] detid is Pixel but neither bpix nor fpix"<<std::endl;
}

}

}

Expand Down Expand Up @@ -112,7 +146,32 @@ void SiPixelLorentzAngleDB::analyze(const edm::Event& e, const edm::EventSetup&

}


unsigned int SiPixelLorentzAngleDB::HVgroup(unsigned int panel, unsigned int module){

if( 1 == panel && ( 1 == module || 2 == module )) {
return 1;
}
else if( 1 == panel && ( 3 == module || 4 == module )) {
return 2;
}
else if( 2 == panel && 1 == module ) {
return 1;
}
else if( 2 == panel && ( 2 == module || 3 == module )) {
return 2;
}
else {
cout << " *** error *** in SiPixelLorentzAngleDB::HVgroup(...), panel = " << panel << ", module = " << module << endl;
return 0;
}

}


void SiPixelLorentzAngleDB::endJob(){


}


0 comments on commit d195e26

Please sign in to comment.