CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Geometry/MuonNumbering/src/MuonDDDNumbering.cc

Go to the documentation of this file.
00001 #include "Geometry/MuonNumbering/interface/MuonDDDNumbering.h"
00002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00003 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
00004 
00005 #include <iostream>
00006 
00007 //#define LOCAL_DEBUG
00008 
00009 MuonDDDNumbering::MuonDDDNumbering( const MuonDDDConstants& muonConstants ){
00010   //  MuonDDDConstants muonConstants;
00011   theLevelPart=muonConstants.getValue("level");
00012   theSuperPart=muonConstants.getValue("super");
00013   theBasePart=muonConstants.getValue("base");
00014   theStartCopyNo=muonConstants.getValue("xml_starts_with_copyno");
00015 
00016   // some consistency checks
00017 
00018   if (theBasePart!=1) {
00019     std::cout << "MuonDDDNumbering finds unusual base constant:"
00020          <<theBasePart<<std::endl;
00021   }
00022   if (theSuperPart<100) {
00023     std::cout << "MuonDDDNumbering finds unusual super constant:"
00024          <<theSuperPart<<std::endl;
00025   }
00026   if (theLevelPart<10*theSuperPart) {
00027     std::cout << "MuonDDDNumbering finds unusual level constant:"
00028          <<theLevelPart<<std::endl;
00029   }
00030   if ((theStartCopyNo!=0)&&(theStartCopyNo!=1)) {
00031     std::cout << "MuonDDDNumbering finds unusual start value for copy numbers:"
00032          <<theStartCopyNo<<std::endl;
00033   }
00034 
00035 #ifdef LOCAL_DEBUG
00036   std::cout << "MuonDDDNumbering configured with"<<std::endl;
00037   std::cout << "Level = "<<theLevelPart<<" ";
00038   std::cout << "Super = "<<theSuperPart<<" ";
00039   std::cout << "Base = "<<theBasePart<<" ";
00040   std::cout << "StartCopyNo = "<<theStartCopyNo<<std::endl;
00041 #endif
00042 
00043 }
00044 
00045 MuonBaseNumber MuonDDDNumbering::geoHistoryToBaseNumber(const DDGeoHistory & history){
00046   MuonBaseNumber num;
00047 
00048 #ifdef LOCAL_DEBUG
00049   std::cout << "MuonDDDNumbering create MuonBaseNumber for"<<std::endl;
00050   std::cout << history <<std::endl;
00051 #endif
00052 
00053   //loop over all parents and check
00054   DDGeoHistory::const_iterator cur=history.begin();
00055   DDGeoHistory::const_iterator end=history.end();
00056   while (cur!=end) {
00057     const DDLogicalPart & ddlp = cur->logicalPart();
00058     const int tag=getInt("CopyNoTag",ddlp)/theLevelPart;
00059     if (tag>0) {
00060       const int offset=getInt("CopyNoOffset",ddlp);
00061       const int copyno=(cur->copyno())+offset%theSuperPart;
00062       const int super=offset/theSuperPart;
00063       num.addBase(tag,super,copyno-theStartCopyNo);
00064     }
00065     cur++;
00066   }
00067 
00068 #ifdef LOCAL_DEBUG
00069   std::cout << num.getLevels() <<std::endl;
00070   for (int i=1;i<=num.getLevels();i++) {
00071     std::cout << num.getSuperNo(i)<<" "<<num.getBaseNo(i)<<std::endl;
00072   }
00073 #endif
00074  
00075   return num;
00076 }
00077 
00078 int MuonDDDNumbering::getInt(const std::string & s, const DDLogicalPart & part)
00079 {
00080     DDValue val(s);
00081     std::vector<const DDsvalues_type *> result = part.specifics();
00082     std::vector<const DDsvalues_type *>::iterator it = result.begin();
00083     bool foundIt = false;
00084     for (; it != result.end(); ++it)
00085     {
00086         foundIt = DDfetch(*it,val);
00087         if (foundIt) break;
00088     }    
00089     if (foundIt)
00090     { 
00091       std::vector<double> temp = val.doubles();
00092       if (temp.size() != 1)
00093       {
00094         std::cout << " ERROR: I need only 1 " << s << " in DDLogicalPart " << part.name() << std::endl;
00095          abort();
00096       }      
00097       return int(temp[0]);
00098     }
00099     else return 0;
00100 }
00101