There is actually a safer way to do this
```
std::shared_ptr<const CSCBadChambers> temp( checkBadChambers_ ? std::shared_ptr<const CSCBadChambers>{pBadChambers.product(), [](const void*){}} : std::make_shared<const CSCBadChambers>({}));
```
The first condition creates a ```std::shared_ptr<>``` which knows not to delete the object. It knows this because of the second argument of its constructor is the function it is supposed to use to do the deletion and that function (a C++ lambda) doesn't do anything. The second condition is just a more efficient way of creating a standard ```std::shared_ptr<>```.

With this code change there is no need for the following ```if(!checkBadChambers_)``` since the ```std::shared_ptr<>``` knows if it is supposed to delete the object or not. In general, one should always avoid 'bare' pointers since they are a constant source of problems.