CMS 3D CMS Logo

HcalTopologyRestrictionParser Class Reference

This utility class is intended to provide a standard way to set restrictions on the HcalTopology to exclude cells for testbeam and other purposes. More...

#include <Geometry/CaloTopology/interface/HcalTopologyRestrictionParser.h>

List of all members.

Public Member Functions

 HcalTopologyRestrictionParser (HcalTopology &target)
std::string parse (const std::string &line)
 Parses a line of restrictions and returns an error string if there is a problem.

Private Attributes

HcalTopologytarget_


Detailed Description

This utility class is intended to provide a standard way to set restrictions on the HcalTopology to exclude cells for testbeam and other purposes.

It functions as a parser to convert textually-encoded restrictions into calls to HcalTopology::exclude().

The grammer is (using a rough notation)

line = rule >> *(; >> rule ) rule = region | subdetector region = subdetname ieta1 ieta2 iphi1 iphi2 [depth1 depth2] subdetector = subdetname subdetname = "HB" | "HE" | "HO" | "HF"

Date
2005/11/30 19:55:34
Revision
1.1
Author:
J. Mans - Minnesota

Definition at line 23 of file HcalTopologyRestrictionParser.h.


Constructor & Destructor Documentation

HcalTopologyRestrictionParser::HcalTopologyRestrictionParser ( HcalTopology target  ) 

Definition at line 5 of file HcalTopologyRestrictionParser.cc.

00005                                                                                  : target_(target) {
00006 }


Member Function Documentation

std::string HcalTopologyRestrictionParser::parse ( const std::string &  line  ) 

Parses a line of restrictions and returns an error string if there is a problem.

The line must be formated as described in the class description.

Definition at line 16 of file HcalTopologyRestrictionParser.cc.

References GenMuonPlsPt100GeV_cfg::cout, determineSubdet(), HLT_VtxMuL3::errors, HcalTopology::exclude(), HcalTopology::excludeSubdetector(), and target_.

Referenced by HcalTopologyIdealEP::produce().

00016                                                                     {
00017 
00018   std::ostringstream errors;
00019   boost::char_separator<char> sep(" \t",";");
00020   typedef boost::tokenizer<boost::char_separator<char> > myTokType;
00021 
00022   std::string totaline(line); totaline+=';'; // terminate
00023   myTokType tok(totaline, sep);
00024   int ieta1=0, ieta2=0, iphi1=-1, iphi2=-1, depth1=1, depth2=4;
00025   HcalSubdetector subdet=(HcalSubdetector)0;
00026 
00027   int phase=0; 
00028   for (myTokType::iterator beg=tok.begin(); beg!=tok.end() && phase>=0; ++beg){
00029     std::cout << phase << " : <" << *beg << ">\n";
00030     if (*beg==";") {
00031       if (phase==0) continue; // empty
00032       if (phase!=1 && phase!=5 && phase!=7) { 
00033         errors << "Expect 1, 5, or 7 arguments, got " << phase;
00034         phase=-1;
00035       } else {
00036         if (phase==1) { // reject whole subdetector...
00037           target_.excludeSubdetector(subdet);
00038         } else {
00039           target_.exclude(subdet,ieta1,ieta2,iphi1,iphi2,depth1,depth2);
00040         }
00041         phase=0;
00042       }
00043     } else {
00044       switch (phase) {
00045       case (0) : subdet=determineSubdet(*beg); break;
00046       case (1) : ieta1=atoi(beg->c_str()); break;
00047       case (2) : ieta2=atoi(beg->c_str()); break;
00048       case (3) : iphi1=atoi(beg->c_str()); break;
00049       case (4) : iphi2=atoi(beg->c_str()); depth1=1; depth2=4; break; // also set defaults...
00050       case (5) : depth1=atoi(beg->c_str()); break;
00051       case (6) : depth2=atoi(beg->c_str()); break;
00052       }
00053       phase++;
00054     }
00055   }
00056   
00057   return errors.str();
00058 
00059 }


Member Data Documentation

HcalTopology& HcalTopologyRestrictionParser::target_ [private]

Definition at line 31 of file HcalTopologyRestrictionParser.h.

Referenced by parse().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:24:00 2009 for CMSSW by  doxygen 1.5.4