CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CondTools/Ecal/src/EcalMappingElectronicsHandler.cc

Go to the documentation of this file.
00001 #include "CondTools/Ecal/interface/EcalLaserHandler.h"
00002 
00003 #include "CondTools/Ecal/interface/EcalMappingElectronicsHandler.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
00005 
00006 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00007 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00008 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
00009 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
00010 
00011 #include "DataFormats/Provenance/interface/Timestamp.h"
00012 #include<iostream>
00013 
00014 EcalMappingElectronicsHandler::EcalMappingElectronicsHandler(const edm::ParameterSet & ps):           
00015   txtFileSource_(ps.getUntrackedParameter<std::string>("txtFile")),
00016   m_name(ps.getUntrackedParameter<std::string>("name","EcalMappingElectronicsHandler")),
00017   since_(ps.getUntrackedParameter<long long>("since",1)) 
00018 {
00019   std::cout << "EcalMappingElectronics Source handler constructor\n" << std::endl;
00020 }
00021 
00022 EcalMappingElectronicsHandler::~EcalMappingElectronicsHandler()
00023 {
00024 }
00025 
00026 
00027 void EcalMappingElectronicsHandler::getNewObjects()
00028 {
00029 
00030   std::cout << "------- Ecal - > getNewObjects\n";
00031   EcalMappingElectronics *payload = new EcalMappingElectronics ;
00032   std::auto_ptr<EcalMappingElectronics> mapping = std::auto_ptr<EcalMappingElectronics>( new EcalMappingElectronics() );
00033   //Filling map reading from file 
00034   edm::LogInfo("EcalMappingElectronicsHandler") << "Reading mapping from file " << edm::FileInPath(txtFileSource_).fullPath().c_str() ;
00035   
00036   std::ifstream f(edm::FileInPath(txtFileSource_).fullPath().c_str());
00037   if (!f.good())
00038     {
00039       edm::LogError("EcalMappingElectronicsHandler") << "File not found";
00040       throw cms::Exception("FileNotFound");
00041     }
00042   
00043   // uint32_t detid, elecid, triggerid;
00044   
00045   int ix, iy, iz, CL;
00046   // int dccid, towerid, stripid, xtalid;
00047   // int tccid, tower, ipseudostrip, xtalinps;
00048   int dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip;
00049   int tccid, tower, pseudostrip_in_TCC, pseudostrip_in_TT;
00050   
00051   while ( ! f.eof()) 
00052     {
00053       // f >> detid >> elecid >> triggerid; 
00054       f >> ix >> iy >> iz >> CL >> dccid >> towerid >> pseudostrip_in_SC >> xtal_in_pseudostrip >> tccid >> tower >> 
00055         pseudostrip_in_TCC >> pseudostrip_in_TT ;
00056       
00057       //       if (!EEDetId::validDetId(ix,iy,iz))
00058       //          continue;
00059       
00060       EEDetId detid(ix,iy,iz,EEDetId::XYMODE);
00061       // std::cout << " dcc tower ps_in_SC xtal_in_ps " << dccid << " " << towerid << " " << pseudostrip_in_SC << " " << xtal_in_pseudostrip << std::endl;
00062       EcalElectronicsId elecid(dccid,towerid, pseudostrip_in_SC, xtal_in_pseudostrip);
00063       // std::cout << " tcc tt ps_in_TT xtal_in_ps " << tccid << " " << tower << " " << pseudostrip_in_TT << " " << xtal_in_pseudostrip << std::endl;
00064       EcalTriggerElectronicsId triggerid(tccid, tower, pseudostrip_in_TT, xtal_in_pseudostrip);
00065       EcalMappingElement aElement;
00066       aElement.electronicsid = elecid.rawId();
00067       aElement.triggerid = triggerid.rawId();
00068       (*payload).setValue(detid, aElement);
00069     }
00070   
00071   f.close();
00072   edm::LogInfo("EcalMappingElectronicsHandler") << "Reading completed ready to insert in DB";  
00073   //Filling completed transferring to DB
00074   m_to_transfer.push_back(std::make_pair(payload,since_));
00075   //  delete payload;
00076 }
00077 
00078 
00079