Build with SCRAM

SCRAM is the tool used to compile/build CMSSW projects. Every CMS user should be familiar with scram b which is basically like make. Here are a few tips beyond the basic scram b:

  • scram b -j4 let you compile with 4 cores (like make -j4).

  • scram b clean let you do a clean build (like make clean).

  • scram b distclean && scram b vclean && scram b clean let you do a really clean build.

  • scram b USER_CXXFLAGS="-g -DDEBUG" let you make a debug build.

For the documentation for SCRAM, see:


CMS Web-Based Monitoring

CMS Web-Based Monitoring (WBM):

You can also find trigger rate vs. PU plots:

Update: WBM has been succeeded by OMS (Online Monitoring System):

If needed, you can still access the offline edition of WBM:


Concatenate two C++ maps of vectors

To concatenate two C++ std::vectors, it is as simple as:

vec2.insert(vec2.end(), vec1.begin(), vec1.end());

Likewise, to concatenate two std::maps:

map2.insert(map1.begin(), map1.end());

Note that when a key is present in both maps, the old value is overwritten by the new value. What if you have two maps of vectors, and when the same key exists in both maps, you want to keep all the values? The following is my implementation:

// Check type for map of vector
template<typename>
struct is_map_of_vectors : public std::false_type { };

template<typename T1, typename T2>
struct is_map_of_vectors<std::map<T1, std::vector<T2> > > : public std::true_type { };

// Merge a map of vectors (map1) into another map of vectors (map2)
template<typename Map>
void concatenate_maps_of_vectors(Map& map1, Map& map2) {
  typedef typename Map::iterator Iterator;
  typedef typename Map::mapped_type Container;

  Iterator first = map1.begin();
  Iterator last = map1.end();

  for (; first != last; ++first) {
    std::pair<Iterator, bool> ins = map2.insert(*first);
    if (!ins.second) {  // if insertion into map2 was not successful
      if (is_map_of_vectors<Map>::value) {  // special case for map of vectors
        Container* vec1 = &(first->second);
        Container* vec2 = &(ins.first->second);
        vec2->insert(vec2->end(), vec1->begin(), vec1->end());
      } else {
        // do nothing
      }
    }
  }
}