CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/EcalCommon/src/NumbersPn.cc

Go to the documentation of this file.
00001 // $Id: NumbersPn.cc,v 1.9 2010/08/08 08:46:05 dellaric Exp $
00002 
00010 #include <sstream>
00011 #include <iomanip>
00012 
00013 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00014 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00015 
00016 #include "DQM/EcalCommon/interface/NumbersPn.h"
00017 
00018 //-------------------------------------------------------------------------
00019 
00020 // return the PN index [0-79] from EcalPnDiodeDetId.id().iPnId() [0-9];
00021 int NumbersPn::ipnEE( const int ism, const int ipnid ) throw( std::runtime_error ) {
00022   
00023   if( ism >=1 && ism <= 18 ) {
00024 
00025     int myFED = -1;
00026 
00027     if( ism ==  1 ) myFED = 0;
00028     if( ism ==  2 ) myFED = 1;
00029     if( ism ==  5 ) myFED = 2;
00030     if( ism ==  6 ) myFED = 3;
00031     if( ism == 10 ) myFED = 4;
00032     if( ism == 11 ) myFED = 5;
00033     if( ism == 14 ) myFED = 6;
00034     if( ism == 15 ) myFED = 7;
00035 
00036     return 10*myFED + (ipnid-1);
00037 
00038   } else {
00039 
00040     std::ostringstream s;
00041     s << "Wrong SM id determination: iSM = " << ism;
00042     throw( std::runtime_error( s.str() ) );
00043 
00044   }
00045 
00046 }
00047 
00048 //-------------------------------------------------------------------------
00049 
00050 // return the list of PNs for a given crystal
00051 void NumbersPn::getPNs( const int ism, const int ix, const int iy, std::vector<int>& PNsInLM ) throw( std::runtime_error ) {
00052 
00053   int ilm = NumbersPn::iLM(ism, ix, iy );
00054 
00055   PNsInLM.clear();
00056 
00057   if( ilm == 0 ) {
00058     PNsInLM.push_back(25);
00059     PNsInLM.push_back(26);
00060     PNsInLM.push_back(27);
00061     PNsInLM.push_back(28);
00062     
00063     PNsInLM.push_back(30);
00064     PNsInLM.push_back(31);
00065     PNsInLM.push_back(32);
00066     PNsInLM.push_back(33);
00067 
00068     return;
00069   }
00070   if( ilm == 1 ) {
00071     PNsInLM.push_back(25);
00072     PNsInLM.push_back(26);
00073     PNsInLM.push_back(27);
00074     PNsInLM.push_back(28);
00075 
00076     PNsInLM.push_back(30);
00077     PNsInLM.push_back(31);
00078     PNsInLM.push_back(32);
00079     PNsInLM.push_back(33);
00080 
00081     return;
00082   }
00083   if( ilm == 2 ) {
00084     PNsInLM.push_back(20);
00085     PNsInLM.push_back(21);
00086     // PNsInLM.push_back(22);
00087     PNsInLM.push_back(23);
00088     PNsInLM.push_back(24);
00089 
00090     PNsInLM.push_back(35);
00091     PNsInLM.push_back(36);
00092     PNsInLM.push_back(37);
00093     PNsInLM.push_back(38);
00094     PNsInLM.push_back(39);
00095 
00096     return;
00097   } 
00098   if( ilm == 3 ) {
00099     PNsInLM.push_back(20);
00100     PNsInLM.push_back(21);
00101     // PNsInLM.push_back(22);
00102     PNsInLM.push_back(23);
00103     PNsInLM.push_back(24);
00104 
00105     PNsInLM.push_back(35);
00106     PNsInLM.push_back(36);
00107     PNsInLM.push_back(37);
00108     PNsInLM.push_back(38);
00109     PNsInLM.push_back(39);
00110 
00111     return;
00112   }
00113   if( ilm == 4 ) {
00114     PNsInLM.push_back(20);
00115     PNsInLM.push_back(21);
00116     // PNsInLM.push_back(22);
00117     PNsInLM.push_back(23);
00118     PNsInLM.push_back(24);
00119 
00120     PNsInLM.push_back(35);
00121     PNsInLM.push_back(36);
00122     PNsInLM.push_back(37);
00123     PNsInLM.push_back(38);
00124     PNsInLM.push_back(39);
00125 
00126     return;
00127   }
00128   if( ilm == 5 ) {
00129     PNsInLM.push_back(0);
00130     PNsInLM.push_back(1);
00131     PNsInLM.push_back(2);
00132     PNsInLM.push_back(4);
00133     // PNsInLM.push_back(9);
00134 
00135     PNsInLM.push_back(14);
00136     PNsInLM.push_back(15);
00137     PNsInLM.push_back(16);
00138     PNsInLM.push_back(17);
00139     PNsInLM.push_back(18);
00140 
00141     return;
00142   }
00143   if( ilm == 6 ) {
00144     PNsInLM.push_back(0);
00145     PNsInLM.push_back(1);
00146     PNsInLM.push_back(2);
00147     PNsInLM.push_back(4);
00148     // PNsInLM.push_back(9);
00149 
00150     PNsInLM.push_back(14);
00151     PNsInLM.push_back(15);
00152     PNsInLM.push_back(16);
00153     PNsInLM.push_back(17);
00154     PNsInLM.push_back(18);
00155 
00156     return;
00157   }
00158   if( ilm == 7 ) {
00159     PNsInLM.push_back(0);
00160     PNsInLM.push_back(1);
00161     PNsInLM.push_back(2);
00162     PNsInLM.push_back(4);
00163 
00164     PNsInLM.push_back(15);
00165     PNsInLM.push_back(16);
00166     PNsInLM.push_back(17);
00167     PNsInLM.push_back(18);
00168 
00169     return;
00170   }
00171   if( ilm == 8 ) {
00172     PNsInLM.push_back(5);
00173     PNsInLM.push_back(6);
00174     PNsInLM.push_back(7);
00175     PNsInLM.push_back(8);
00176 
00177     PNsInLM.push_back(11);
00178     PNsInLM.push_back(12);
00179 
00180     return;
00181   }
00182   if( ilm == 9 ) {
00183     PNsInLM.push_back(5);
00184     PNsInLM.push_back(6);
00185     PNsInLM.push_back(7);
00186     PNsInLM.push_back(8);
00187 
00188     PNsInLM.push_back(11);
00189     PNsInLM.push_back(12);
00190 
00191     return;
00192   }
00193   if( ilm == 10 ) {
00194     PNsInLM.push_back(65);
00195     PNsInLM.push_back(66);
00196     PNsInLM.push_back(67);
00197     PNsInLM.push_back(68);
00198 
00199     PNsInLM.push_back(70);
00200     PNsInLM.push_back(71);
00201     PNsInLM.push_back(72);
00202     PNsInLM.push_back(73);
00203 
00204     return;
00205   }
00206   if( ilm == 11 ) {
00207     PNsInLM.push_back(65);
00208     PNsInLM.push_back(66);
00209     PNsInLM.push_back(67);
00210     PNsInLM.push_back(68);
00211 
00212     PNsInLM.push_back(70);
00213     PNsInLM.push_back(71);
00214     PNsInLM.push_back(72);
00215     PNsInLM.push_back(73);
00216 
00217     return;
00218   }
00219   if( ilm == 12 ) {
00220     PNsInLM.push_back(60);
00221     PNsInLM.push_back(61);
00222     PNsInLM.push_back(62);
00223     PNsInLM.push_back(63);
00224     PNsInLM.push_back(64);
00225 
00226     PNsInLM.push_back(75);
00227     PNsInLM.push_back(76);
00228     PNsInLM.push_back(78);
00229     PNsInLM.push_back(79);
00230 
00231     return;
00232   }
00233   if( ilm == 13 ) {
00234     PNsInLM.push_back(60);
00235     PNsInLM.push_back(61);
00236     PNsInLM.push_back(62);
00237     PNsInLM.push_back(63);
00238     PNsInLM.push_back(64);
00239     PNsInLM.push_back(69);
00240 
00241     PNsInLM.push_back(74);
00242     PNsInLM.push_back(75);
00243     PNsInLM.push_back(76);
00244     PNsInLM.push_back(77);
00245     PNsInLM.push_back(78);
00246     PNsInLM.push_back(79);
00247 
00248     return;
00249   }
00250   if( ilm == 14 ) {
00251     PNsInLM.push_back(60);
00252     PNsInLM.push_back(61);
00253     PNsInLM.push_back(62);
00254     PNsInLM.push_back(63);
00255     PNsInLM.push_back(64);
00256     PNsInLM.push_back(69);
00257 
00258     PNsInLM.push_back(74);
00259     PNsInLM.push_back(75);
00260     PNsInLM.push_back(76);
00261     PNsInLM.push_back(77);
00262     PNsInLM.push_back(78);
00263     PNsInLM.push_back(79);
00264 
00265     return;
00266   }
00267   if( ilm == 15 ) {
00268     PNsInLM.push_back(40);
00269     PNsInLM.push_back(41);
00270     PNsInLM.push_back(42);
00271     PNsInLM.push_back(43);
00272     PNsInLM.push_back(44);
00273     PNsInLM.push_back(49);
00274 
00275     PNsInLM.push_back(54);
00276     PNsInLM.push_back(55);
00277     PNsInLM.push_back(56);
00278     PNsInLM.push_back(57);
00279     PNsInLM.push_back(58);
00280     PNsInLM.push_back(59);
00281 
00282     return;
00283   }
00284   if( ilm == 16 ) {
00285     PNsInLM.push_back(40);
00286     PNsInLM.push_back(41);
00287     PNsInLM.push_back(42);
00288     PNsInLM.push_back(43);
00289     PNsInLM.push_back(44);
00290     PNsInLM.push_back(49);
00291 
00292     PNsInLM.push_back(54);
00293     PNsInLM.push_back(55);
00294     PNsInLM.push_back(56);
00295     PNsInLM.push_back(57);
00296     PNsInLM.push_back(58);
00297     PNsInLM.push_back(59);
00298 
00299     return;
00300   }
00301   if( ilm == 17 ) {
00302     PNsInLM.push_back(40);
00303     PNsInLM.push_back(41);
00304     PNsInLM.push_back(42);
00305     PNsInLM.push_back(43);
00306     PNsInLM.push_back(44);
00307 
00308     PNsInLM.push_back(55);
00309     PNsInLM.push_back(56);
00310     PNsInLM.push_back(58);
00311     PNsInLM.push_back(59);
00312 
00313     return;
00314   }
00315   if( ilm == 18 ) {
00316     PNsInLM.push_back(45);
00317     PNsInLM.push_back(46);
00318     PNsInLM.push_back(47);
00319     PNsInLM.push_back(48);
00320 
00321     PNsInLM.push_back(50);
00322     PNsInLM.push_back(51);
00323     PNsInLM.push_back(52);
00324     PNsInLM.push_back(53);
00325 
00326     return;
00327   }
00328   if( ilm == 19 ) {
00329     PNsInLM.push_back(45);
00330     PNsInLM.push_back(46);
00331     PNsInLM.push_back(47);
00332     PNsInLM.push_back(48);
00333 
00334     PNsInLM.push_back(50);
00335     PNsInLM.push_back(51);
00336     PNsInLM.push_back(52);
00337     PNsInLM.push_back(53);
00338 
00339     return;
00340   }
00341 
00342   std::ostringstream s;
00343   s << "Wrong LM id determination: iLM = " << ilm;
00344   throw( std::runtime_error( s.str() ) );
00345   
00346 }
00347 
00348 //-------------------------------------------------------------------------
00349 
00350 // return the LM for a given crystal
00351 int NumbersPn::iLM( const int ism, const int ix, const int iy ) throw( std::runtime_error ) {
00352 
00353   int iz = 0;
00354 
00355   if( ism >=  1 && ism <=  9 ) iz = -1;
00356   if( ism >= 10 && ism <= 18 ) iz = +1;
00357 
00358   if( EEDetId::validDetId(ix, iy, iz) ) {
00359 
00360     // EE-
00361     if( ism == 1 ) return 7;
00362     if( ism == 2 ) return 8;
00363     if( ism == 3 ) return 9;
00364     if( ism == 4 ) return 0;
00365     if( ism == 5 ) return 1;
00366     if( ism == 6 ) return 2;
00367     if( ism == 7 ) return 3;
00368     if( ism == 8 ) {
00369       if(ix<=50) return 4;
00370       else return 5;
00371     }
00372     if( ism == 9 ) return 6;
00373   
00374     // EE+
00375     if( ism == 10 ) return 17;
00376     if( ism == 11 ) return 18;
00377     if( ism == 12 ) return 19;
00378     if( ism == 13 ) return 10;
00379     if( ism == 14 ) return 11;
00380     if( ism == 15 ) return 12;
00381     if( ism == 16 ) return 13;
00382     if( ism == 17 ) {
00383       if(ix<=50) return 14;
00384       else return 15;
00385     }
00386     if( ism == 18 ) return 16;
00387 
00388   }
00389 
00390   std::ostringstream s;
00391   s << "Wrong LM id determination: iSM = " << ism << " ix = " << ix << " iy = " << iy;
00392   throw( std::runtime_error( s.str() ) );
00393 
00394 }
00395 
00396 //-------------------------------------------------------------------------
00397