CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Alignment/TrackerAlignment/src/TrackerScenarioBuilder.cc

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include <string>
00010 #include <iostream>
00011 #include <sstream>
00012 
00013 // Framework
00014 #include "FWCore/Utilities/interface/Exception.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 
00017 // Alignment
00018 
00019 #include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h"
00020 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00021 
00022 
00023 //__________________________________________________________________________________________________
00024 TrackerScenarioBuilder::TrackerScenarioBuilder(AlignableTracker* alignable) 
00025   : theAlignableTracker(alignable)
00026 {
00027 
00028   if (!theAlignableTracker) {
00029     throw cms::Exception("TypeMismatch") << "Pointer to AlignableTracker is empty.\n";
00030   }
00031 
00032   // Fill what is needed for possiblyPartOf(..):
00033   theSubdets.push_back("TPB"); // Take care, order matters: 1st pixel, 2nd strip.
00034   theSubdets.push_back("TPE");
00035   theFirstStripIndex = theSubdets.size();
00036   theSubdets.push_back("TIB");
00037   theSubdets.push_back("TID");
00038   theSubdets.push_back("TOB");
00039   theSubdets.push_back("TEC");
00040 }
00041 
00042 
00043 //__________________________________________________________________________________________________
00044 void TrackerScenarioBuilder::applyScenario( const edm::ParameterSet& scenario )
00045 {
00046 
00047   // Apply the scenario to all main components of tracker.
00048   theModifierCounter = 0;
00049 
00050   // Seed is set at top-level, and is mandatory
00051   if ( this->hasParameter_( "seed", scenario) )
00052         theModifier.setSeed( static_cast<long>(scenario.getParameter<int>("seed")) );
00053   else
00054         throw cms::Exception("BadConfig") << "No generator seed defined!";  
00055 
00056   // misalignment applied recursively ('subStructures("Tracker")' contains only tracker itself)
00057   this->decodeMovements_(scenario, theAlignableTracker->subStructures("Tracker"));
00058 
00059   edm::LogInfo("TrackerScenarioBuilder") 
00060         << "Applied modifications to " << theModifierCounter << " alignables";
00061 
00062 }
00063 
00064 
00065 //__________________________________________________________________________________________________
00066 bool TrackerScenarioBuilder::isTopLevel_(const std::string &parameterSetName) const
00067 {
00068   // Get root name (strip last character [s])
00069   std::string root = this->rootName_(parameterSetName);
00070 
00071   if (root == "Tracker") return true;
00072 
00073   return false;
00074 }
00075 
00076 //__________________________________________________________________________________________________
00077 bool TrackerScenarioBuilder::possiblyPartOf(const std::string &subStruct, const std::string &largeStr) const
00078 {
00079   // string::find(s) != nPos => 's' is contained in string!
00080   const std::string::size_type nPos = std::string::npos; 
00081 
00082   // First check whether anything from pixel in strip.
00083   if (largeStr.find("Strip") != nPos) {
00084     if (subStruct.find("Pixel") != nPos) return false;
00085     for (unsigned int iPix = 0; iPix < theFirstStripIndex; ++iPix) {
00086       if (subStruct.find(theSubdets[iPix]) != nPos) return false;
00087     }
00088   }
00089 
00090   // Now check whether anything from strip in pixel.
00091   if (largeStr.find("Pixel") != nPos) {
00092     if (subStruct.find("Strip") != nPos) return false;
00093     for (unsigned int iStrip = theFirstStripIndex; iStrip < theSubdets.size(); ++iStrip) {
00094       if (subStruct.find(theSubdets[iStrip]) != nPos) return false;
00095     }
00096   }
00097 
00098   // Finally check for any different detector parts, e.g. TIDEndcap/TIBString gives false.
00099   for (unsigned int iSub = 0; iSub < theSubdets.size(); ++iSub) {
00100     for (unsigned int iLarge = 0; iLarge < theSubdets.size(); ++iLarge) {
00101       if (iLarge == iSub) continue;
00102       if (largeStr.find(theSubdets[iLarge]) != nPos && subStruct.find(theSubdets[iSub]) != nPos) {
00103         return false;
00104       }
00105     }
00106   }
00107 
00108   // It seems like a possible combination:
00109   return true; 
00110 }
00111