CMS 3D CMS Logo

SiStripFedCablingFromXml.cc

Go to the documentation of this file.
00001 #include "CalibTracker/SiStripConnectivity/plugins/SiStripFedCablingFromXml.h"
00002 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
00003 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
00004 #include "CalibFormats/SiStripObjects/interface/SiStripFecCabling.h"
00005 #include <iostream>
00006 #include <fstream>
00007 
00008 #define PARSE_FecInstance 0
00009 #define PARSE_FecSlot 1
00010 #define PARSE_FecRing 2
00011 #define PARSE_CCUAddress 3
00012 #define PARSE_I2CAddress 4
00013 #define PARSE_apv0 5
00014 #define PARSE_apv1 6
00015 #define PARSE_fed_id 7
00016 #define PARSE_fed_ch 8
00017 #define PARSE_IdAcq 9
00018 #define PARSE_pairs 10
00019 #define PARSE_dcu_id 11
00020 #define PARSE_det_id 12
00021 #define PARSED_VALS 13
00022 
00023 // -----------------------------------------------------------------------------
00024 //
00025 SiStripFedCablingFromXml::SiStripFedCablingFromXml( const edm::ParameterSet& pset ) 
00026         : SiStripFedCablingESSource( pset ),
00027         connectionFile_( pset.getParameter<std::string>("XmlParsedFile") )
00028 {
00029   std::cout << "[SiStripFedCablingFromXml::SiStripFedCablingFromXml]"
00030             << " Constructing object from file" << connectionFile_ << " ..." 
00031             << std::endl;
00032   makeFedCabling();
00033 }
00034 
00035 // -----------------------------------------------------------------------------
00036 //
00037 SiStripFedCablingFromXml::~SiStripFedCablingFromXml() {
00038   std::cout << "[SiStripFedCablingFromXml::~SiStripFedCablingFromXml]"
00039             << " Destructing object..." << std::endl;
00040 }
00041 
00042 // -----------------------------------------------------------------------------
00043 //
00044 SiStripFedCabling* SiStripFedCablingFromXml::makeFedCabling() {
00045   std::cout << "[SiStripFedCablingFromXml::makeFedCabling]" << std::endl;
00046 
00047   // Create FEC cabling object 
00048   SiStripFecCabling fec_cabling;
00049 
00050   std::cout << "Cabling the fed a la come viene viene" << std::endl; 
00051 
00052 
00053   bool endOfFile=false;
00054   uint32_t my_values[PARSED_VALS];
00055 
00056   std::ifstream prova(connectionFile_.c_str());
00057   while (!prova.eof()) {
00058     for (int vals=0; vals<PARSED_VALS; vals++) {
00059       prova >> my_values[vals];
00060       if (prova.eof()) {
00061         endOfFile=true;
00062         break;
00063       }
00064     }
00065     // We have a full, complete row of data
00066     // to build a new connection. To put it
00067     // in a nutshell we have aq fiber!
00068 
00069     if (!endOfFile) {
00070       // Let's first write it down to debug
00071       // uncomment the following lines if you need debug
00072       for (int vals=0; vals<PARSED_VALS; vals++) {
00073         std::cout << my_values[vals] << " ";
00074       }
00075       std::cout << std::endl;
00076 
00077       // Then let's go for the buig hunt: creating
00078       // the actual connections!
00079 
00080       // But first here's a bit of .h
00081       //  FedChannelConnection( uint16_t fec_crate,
00082       //      uint16_t fec_slot,
00083       //      uint16_t fec_ring,
00084       //      uint16_t ccu_addr,
00085       //      uint16_t ccu_chan,
00086       //      uint16_t apv0 = 0, // !! hw
00087       //      uint16_t apv1 = 0, // !! hw
00088       //      uint32_t dcu_id = 0, // puo' servire
00089       //      uint32_t det_id = 0, // !!
00090       //      uint16_t pairs  = 0, // 2 0 3
00091       //      uint16_t fed_id = 0, // !!
00092       //      uint16_t fed_ch = 0, // !!
00093       //      uint16_t length = 0, // cosa vuole dire? non ci importa
00094       //      bool dcu = false,
00095       //      bool pll = false,
00096       //      bool mux = false,
00097       //      bool lld = false )
00098 
00099       FedChannelConnection conn( my_values[PARSE_FecInstance],
00100                       my_values[PARSE_FecSlot],
00101                       my_values[PARSE_FecRing],
00102                       my_values[PARSE_CCUAddress],
00103                       my_values[PARSE_I2CAddress],
00104                       my_values[PARSE_apv0],
00105                       my_values[PARSE_apv1], 
00106                       my_values[PARSE_dcu_id], 
00107                       my_values[PARSE_det_id], 
00108                       my_values[PARSE_pairs], 
00109                       my_values[PARSE_fed_id], 
00110                       my_values[PARSE_fed_ch]);
00111       fec_cabling.addDevices( conn ); 
00112 
00113     }
00114   }
00115   // Retrieve connection objects from FEC cabling and build FED cabling
00116   std::vector<FedChannelConnection> conns;
00117   fec_cabling.connections( conns );
00118   SiStripFedCabling* cabling = new SiStripFedCabling( conns );
00119   return cabling;
00120 
00121 }

Generated on Tue Jun 9 17:25:50 2009 for CMSSW by  doxygen 1.5.4