CMS 3D CMS Logo

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