RooMapCatEntry.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  * @(#)root/roofitcore:$Id: RooMapCatEntry.cxx 20879 2007-11-19 11:22:56Z rdm $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 
00017 // -- CLASS DESCRIPTION [AUX] --
00018 // RooMapCatEntry is an auxilary class for RooMappedCategory and defines a 
00019 // a mapping. A mapping consists of a wildcard regular expression, that
00020 // can be matched against the input category state label and an output
00021 // category state (RooCatType), which should be assign if the match is successfull.
00022 
00023 #include "RooFit.h"
00024 
00025 #include "RooMapCatEntry.h"
00026 #include "RooMapCatEntry.h"
00027 #include "TString.h"
00028 
00029 ClassImp(RooMapCatEntry)
00030 ;
00031 
00032 RooMapCatEntry::RooMapCatEntry(const char* exp, const RooCatType* cat) : 
00033   TNamed(exp,mangle(exp).Data()), _regexp(mangle(exp),kTRUE), _cat(*cat) 
00034 {
00035 }
00036 
00037 
00038 RooMapCatEntry::RooMapCatEntry(const RooMapCatEntry& other) : 
00039   TNamed(other), _regexp(other.GetTitle(),kTRUE), _cat(other._cat) 
00040 {
00041 }
00042 
00043 
00044 Bool_t RooMapCatEntry::match(const char* testPattern) const 
00045 {
00046   return (TString(testPattern).Index(_regexp)>=0) ;
00047 }
00048 
00049 
00050 
00051 TString RooMapCatEntry::mangle(const char* exp) const
00052 {
00053   // Mangle name : escape regexp character '+'
00054   TString t ;
00055   const char *c = exp ;
00056   while(*c) {
00057     if (*c=='+') t.Append('\\') ;
00058     t.Append(*c) ;
00059     c++ ;
00060   }
00061   return t ;
00062 }

Generated on Tue Jul 5 15:06:46 2011 for ROOT_528-00b_version by  doxygen 1.5.1