CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CaloOnlineTools/HcalOnlineDb/src/HcalLutGenerator.cc

Go to the documentation of this file.
00001 #include "CaloOnlineTools/HcalOnlineDb/interface/HcalLutGenerator.h"
00002 
00003 #include "FWCore/Framework/interface/ESHandle.h"
00004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00005 #include "CalibFormats/HcalObjects/interface/HcalTPGRecord.h"
00006 #include "CalibFormats/HcalObjects/interface/HcalTPGCoder.h"
00007 #include "CaloOnlineTools/HcalOnlineDb/interface/HcalLutManager.h"
00008 #include "CalibFormats/CaloTPG/interface/CaloTPGRecord.h"
00009 #include "CondFormats/HcalObjects/interface/HcalElectronicsMap.h"
00010 
00011 #include "CaloOnlineTools/HcalOnlineDb/interface/LMap.h"
00012 
00013 
00014 #include <iostream>
00015 using std::cerr;
00016 using std::cout;
00017 using std::endl;
00018 
00019 HcalLutGenerator::HcalLutGenerator(const edm::ParameterSet& iConfig)
00020 {
00021   std::cout << " --> HcalLutGenerator::HcalLutGenerator()" << std::endl;
00022   _tag                 = iConfig.getParameter<std::string>("tag");
00023   _lin_file            = iConfig.getParameter<std::string>("HO_master_file");
00024   _status_word_to_mask = iConfig.getParameter<uint32_t>("status_word_to_mask");
00025 }
00026 
00027 HcalLutGenerator::~HcalLutGenerator()
00028 {
00029 }
00030 
00031 void HcalLutGenerator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00032 {
00033   
00034   std::cout << " --> HcalLutGenerator::analyze()" << std::endl;
00035   
00036   //
00037   //_____ get the coders from Event Setup _______________________________
00038   //
00039   edm::ESHandle<HcalTPGCoder> inputCoder;
00040   iSetup.get<HcalTPGRecord>().get(inputCoder);
00041 
00042   //
00043   edm::ESHandle<CaloTPGTranscoder> outTranscoder;
00044   iSetup.get<CaloTPGRecord>().get(outTranscoder);
00045   outTranscoder->setup(iSetup,CaloTPGTranscoder::HcalTPG);
00046   edm::ESHandle<CaloTPGTranscoderULUT> transcoder;
00047   transcoder.swap(outTranscoder);
00048 
00049   //
00050   //_____ get EMAP from Event Setup _____________________________________
00051   //
00052   edm::ESHandle<HcalElectronicsMap> hEmap;
00053   iSetup.get<HcalElectronicsMapRcd>().get(hEmap);
00054   std::vector<HcalGenericDetId> vEmap = hEmap->allPrecisionId();
00055   std::cout << "EMAP from Event Setup has " << vEmap.size() << " entries" << std::endl;
00056 
00057   //
00058   //_____ get Channel Quality conditions from Event Setup (example)______
00059   //
00060   edm::ESHandle<HcalChannelQuality> hCQ;
00061   iSetup.get<HcalChannelQualityRcd>().get(hCQ);
00062   const HcalChannelQuality * _cq = &(*hCQ);
00063   //
00064   /*
00065   // Here's how one gets channel status from the Channel Quality condition.
00066   // One can use their own loop over channels or get a vector of all
00067   // channels from the conditions object
00068   //
00069   //_____ get list of all channels
00070   //
00071   std::vector<DetId> _channels = _cq->getAllChannels();
00072   std::cout << "Channel Quality available for " << _channels.size() << " channels" << std::endl;
00073   //
00074   //_____ loop over channels
00075   //
00076   for (std::vector<DetId>::const_iterator _ch = _channels.begin();
00077        _ch != _channels.end();
00078        _ch++){
00079     //
00080     //_____ select only HBEF logical channels
00081     //
00082     HcalGenericDetId _gid( *_ch );
00083     if ( !(_gid.null()) &&
00084          (_gid.genericSubdet()==HcalGenericDetId::HcalGenBarrel ||
00085           _gid.genericSubdet()==HcalGenericDetId::HcalGenEndcap ||
00086           _gid.genericSubdet()==HcalGenericDetId::HcalGenForward ||
00087           _gid.genericSubdet()==HcalGenericDetId::HcalGenOuter
00088           )
00089          ){
00090       const HcalChannelStatus * _cs = _cq->getValues( *_ch );
00091 
00092       // get the full 32-bit channel status word
00093       uint32_t status_word = _cs->getValue();
00094       
00095       // get the 15th bit (which is supposed to mean hot channel)
00096       bool is_hot = _cs->isBitSet(15);
00097       //edm::LogInfo("LUT") << "HCAL channel ID: " << _ch->rawId()
00098       //std::cout << "HCAL channel ID: " << _ch->rawId()
00099       //   << ", status word: " << status_word
00100       //   << ", hot flag: " << is_hot << std::endl;
00101     }
00102   }
00103   */
00104   //_____end of Channel Quality example_____________________
00105 
00106   //
00107   //_____ generate LUTs _________________________________________________
00108   //
00109   //HcalLutManager * manager = new HcalLutManager(); // old ways
00110   //HcalLutManager * manager = new HcalLutManager(&(*hEmap));
00111   HcalLutManager * manager = new HcalLutManager(&(*hEmap), _cq, _status_word_to_mask);
00112   bool split_by_crate = true;
00113   std::cout << " tag name: " << _tag << std::endl;
00114   std::cout << " HO master file: " << _lin_file << std::endl;
00115 
00116   // default
00117   //manager -> createLutXmlFiles_HBEFFromCoder_HOFromAscii( _tag, *inputCoder, *transcoder, _lin_file, split_by_crate );
00118 
00119   // with ZDC (experimental)
00120   manager -> createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC( _tag, *inputCoder, *transcoder, _lin_file, split_by_crate );
00121   delete manager;
00122 
00123   transcoder->releaseSetup();
00124    
00125 }
00126 
00127 
00128 void HcalLutGenerator::endJob() {
00129 
00130 }