CMS 3D CMS Logo

Public Member Functions | Private Attributes

SiPixelLorentzAngleDB Class Reference

#include <SiPixelLorentzAngleDB.h>

Inheritance diagram for SiPixelLorentzAngleDB:
edm::EDAnalyzer

List of all members.

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 ()

Private Attributes

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

Detailed Description

Definition at line 23 of file SiPixelLorentzAngleDB.h.


Constructor & Destructor Documentation

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

Definition at line 24 of file SiPixelLorentzAngleDB.cc.

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

                                                                        : 
  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");
        useFile_ = conf_.getParameter<bool>("useFile");         
        fileName_ = conf_.getParameter<string>("fileName");

}
SiPixelLorentzAngleDB::~SiPixelLorentzAngleDB ( ) [virtual]

Definition at line 42 of file SiPixelLorentzAngleDB.cc.

                                              {  

}  

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 48 of file SiPixelLorentzAngleDB.cc.

References bPixLorentzAnglePerTesla_, gather_cfg::cout, cond::rpcobgas::detid, exception, fPixLorentzAnglePerTesla_, edm::EventSetup::get(), edm::Service< T >::isAvailable(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, SiPixelLorentzAngle::putLorentzAngle(), DetId::rawId(), recordName_, DetId::subdetId(), useFile_, and cms::Exception::what().

{

        SiPixelLorentzAngle* LorentzAngle = new SiPixelLorentzAngle();
           
        
        edm::ESHandle<TrackerGeometry> pDD;
        es.get<TrackerDigiGeometryRecord>().get( pDD );
        edm::LogInfo("SiPixelLorentzAngle") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
        
        for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
    
                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 
                        } 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;
                        }
                
                }
                        
        }      
        

        edm::Service<cond::service::PoolDBOutputService> mydbservice;
        if( mydbservice.isAvailable() ){
                try{
                        if( mydbservice->isNewTagRequest(recordName_) ){
                                mydbservice->createNewIOV<SiPixelLorentzAngle>(LorentzAngle,
                                                                               mydbservice->beginOfTime(),
                                                                               mydbservice->endOfTime(),
                                                                               recordName_);
                        } else {
                                mydbservice->appendSinceTime<SiPixelLorentzAngle>(LorentzAngle,
                                                                                  mydbservice->currentTime(),
                                                                                  recordName_);
                        }
                }catch(const cond::Exception& er){
                        edm::LogError("SiPixelLorentzAngleDB")<<er.what()<<std::endl;
                }catch(const std::exception& er){
                        edm::LogError("SiPixelLorentzAngleDB")<<"caught std::exception "<<er.what()<<std::endl;
                }catch(...){
                        edm::LogError("SiPixelLorentzAngleDB")<<"Funny error"<<std::endl;
                }
        }else{
                edm::LogError("SiPixelLorentzAngleDB")<<"Service is unavailable"<<std::endl;
        }
   

}
void SiPixelLorentzAngleDB::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 37 of file SiPixelLorentzAngleDB.cc.

                                    {
  
}
void SiPixelLorentzAngleDB::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 115 of file SiPixelLorentzAngleDB.cc.

                                  {


}

Member Data Documentation

Definition at line 46 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().

Definition at line 43 of file SiPixelLorentzAngleDB.h.

Referenced by SiPixelLorentzAngleDB().

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

Definition at line 42 of file SiPixelLorentzAngleDB.h.

std::string SiPixelLorentzAngleDB::fileName_ [private]

Definition at line 48 of file SiPixelLorentzAngleDB.h.

Referenced by SiPixelLorentzAngleDB().

Definition at line 47 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().

Definition at line 44 of file SiPixelLorentzAngleDB.h.

Referenced by SiPixelLorentzAngleDB().

std::string SiPixelLorentzAngleDB::recordName_ [private]

Definition at line 45 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().

Definition at line 49 of file SiPixelLorentzAngleDB.h.

Referenced by analyze(), and SiPixelLorentzAngleDB().