CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/CondCore/DTPlugins/src/DTCompactMapPluginHandler.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2011/02/11 08:00:09 $
00005  *  $Revision: 1.2 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //-----------------------
00011 // This Class' Header --
00012 //-----------------------
00013 #include "CondCore/DTPlugins/interface/DTCompactMapPluginHandler.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
00019 
00020 //---------------
00021 // C++ Headers --
00022 //---------------
00023 #include <iostream>
00024 
00025 //-------------------
00026 // Initializations --
00027 //-------------------
00028 
00029 
00030 //----------------
00031 // Constructors --
00032 //----------------
00033 DTCompactMapPluginHandler::DTCompactMapPluginHandler() {
00034 //  std::cout << "===================================" << std::endl;
00035 //  std::cout << "=                                 =" << std::endl;
00036 //  std::cout << "=  new DTCompactMapPluginHandler  =" << std::endl;
00037 //  std::cout << "=                                 =" << std::endl;
00038 //  std::cout << "===================================" << std::endl;
00039 //  if ( instance == 0 ) instance = this;
00040 }
00041 
00042 
00043 //--------------
00044 // Destructor --
00045 //--------------
00046 DTCompactMapPluginHandler::~DTCompactMapPluginHandler() {
00047 }
00048 
00049 
00050 //--------------
00051 // Operations --
00052 //--------------
00053 void DTCompactMapPluginHandler::build() {
00054   if ( instance == 0 ) instance = new DTCompactMapPluginHandler;
00055 }
00056 
00057 
00058 DTReadOutMapping* DTCompactMapPluginHandler::expandMap( const DTReadOutMapping& compMap ) {
00059   std::vector<DTReadOutGeometryLink> entryList;
00060   DTReadOutMapping::const_iterator compIter = compMap.begin();
00061   DTReadOutMapping::const_iterator compIend = compMap.end();
00062   while ( compIter != compIend ) entryList.push_back( *compIter++ );
00063 
00064   std::string
00065   rosMap = "expand_";
00066   rosMap += compMap.mapRobRos();
00067   std::string
00068   tdcMap = "expand_";
00069   tdcMap += compMap.mapCellTdc();
00070   DTReadOutMapping* fullMap = new DTReadOutMapping( tdcMap, rosMap );
00071   int ddu;
00072   int ros;
00073   int rch;
00074   int tdc;
00075   int tch;
00076   int whe;
00077   int sta;
00078   int sec;
00079   int rob;
00080   int qua;
00081   int lay;
00082   int cel;
00083   int mt1;
00084   int mi1;
00085   int mt2;
00086   int mi2;
00087   int def;
00088   int wha;
00089   int sea;
00090   std::vector<DTReadOutGeometryLink>::const_iterator iter = entryList.begin();
00091   std::vector<DTReadOutGeometryLink>::const_iterator iend = entryList.end();
00092   std::vector<DTReadOutGeometryLink>::const_iterator iros = entryList.end();
00093   std::vector<DTReadOutGeometryLink>::const_iterator irob = entryList.end();
00094   std::vector<DTReadOutGeometryLink>::const_iterator itdc = entryList.end();
00095   while ( iter != iend ) {
00096     const DTReadOutGeometryLink& rosEntry( *iter++ );
00097     if ( rosEntry.dduId > 0x3fffffff ) continue;
00098     ddu = rosEntry.dduId;
00099     ros = rosEntry.rosId;
00100     whe = rosEntry.wheelId;
00101     def = rosEntry.stationId;
00102     sec = rosEntry.sectorId;
00103     rob = rosEntry.slId;
00104     mt1 = rosEntry.layerId;
00105     mi1 = rosEntry.cellId;
00106     iros = entryList.begin();
00107     while ( iros != iend ) {
00108       wha = whe;
00109       sea = sec;
00110       const DTReadOutGeometryLink& rchEntry( *iros++ );
00111       if ( ( rchEntry.dduId != mt1 ) ||
00112            ( rchEntry.rosId != mi1 ) ) continue;
00113       rch =  rchEntry.robId;
00114       if (   rchEntry.wheelId != def   ) wha = rchEntry.wheelId;
00115       sta =  rchEntry.stationId;
00116       if (   rchEntry.sectorId != def   ) sea = rchEntry.sectorId;
00117       rob =  rchEntry.slId;
00118       mt2 =  rchEntry.layerId;
00119       mi2 =  rchEntry.cellId;
00120       irob = entryList.begin();
00121       while ( irob != iend ) {
00122         const DTReadOutGeometryLink& robEntry( *irob++ );
00123         if ( ( robEntry.dduId != mt2 ) ||
00124              ( robEntry.rosId != mi2 ) ) continue;
00125         if (   robEntry.robId != rob   ) {
00126           std::cout << "ROB mismatch " << rob << " "
00127                                        << robEntry.robId << std::endl;
00128         }
00129         tdc =  robEntry.tdcId;
00130         tch =  robEntry.channelId;
00131         qua =  robEntry.slId;
00132         lay =  robEntry.layerId;
00133         cel =  robEntry.cellId;
00134         fullMap->insertReadOutGeometryLink( ddu, ros, rob, tdc, tch,
00135                                                  wha, sta, sea,
00136                                                  qua, lay, cel );
00137 
00138       }
00139     }
00140   }
00141   return fullMap;
00142 }
00143 
00144