CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloTowerConstituentsMapBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CaloTowerConstituentsMapBuilder
4 // Class: CaloTowerConstituentsMapBuilder
5 //
13 //
14 // Original Author: Jeremiah Mans
15 // Created: Mon Oct 3 11:35:27 CDT 2005
16 //
17 //
18 
23 #include <zlib.h>
24 #include <strings.h>
25 
26 //
27 // constructors and destructor
28 //
30  mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile",""))
31 {
32  //the following line is needed to tell the framework what
33  // data is being produced
34  setWhatProduced(this);
35 
36  //now do what ever other initialization is needed
37 }
38 
39 
41 {
42 }
43 
44 
45 //
46 // member functions
47 //
48 
49 void
51 {
53  desc.addUntracked<std::string>( "MapFile", "" );
54  descriptions.add( "caloTowerConstituents", desc );
55 }
56 
57 // ------------ method called to produce the data ------------
60 {
62  iRecord.get( topology ) ;
63 
64  std::auto_ptr<CaloTowerConstituentsMap> prod( new CaloTowerConstituentsMap( &*topology ));
65 
66  prod->useStandardHB(true);
67  prod->useStandardHE(true);
68  prod->useStandardHF(true);
69  prod->useStandardHO(true);
70  prod->useStandardEB(true);
71 
72  if (!mapFile_.empty()) {
73  parseTextMap(mapFile_,*prod);
74  }
75  prod->sort();
76 
77  return prod;
78 }
79 
80 void
82 {
83  edm::FileInPath eff( filename );
84 
85  gzFile gzed = gzopen( eff.fullPath().c_str(), "rb" );
86 
87  while( !gzeof( gzed ))
88  {
89  char line[1024];
90  int ieta, iphi, rawid;
91  if( 0 != gzgets( gzed, line, 1023 ))
92  {
93  if( index( line, '#' ) != 0 )*( index( line, '#' )) = 0;
94  int ct = sscanf( line, "%i %d %d", &rawid, &ieta, &iphi );
95  if( ct == 3 )
96  {
97  DetId detid( rawid );
98  CaloTowerDetId tid( ieta, iphi );
99  theMap.assign( detid, tid );
100  }
101  }
102  }
103  gzclose( gzed );
104 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
CaloTopology const * topology(0)
CaloTowerConstituentsMapBuilder(const edm::ParameterSet &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::auto_ptr< CaloTowerConstituentsMap > ReturnType
void get(HolderT &iHolder) const
void assign(const DetId &cell, const CaloTowerDetId &tower)
set the association between a DetId and a tower
Definition: DetId.h:18
void add(std::string const &label, ParameterSetDescription const &psetDescription)
tuple filename
Definition: lut2db_cfg.py:20
std::string fullPath() const
Definition: FileInPath.cc:165
ReturnType produce(const IdealGeometryRecord &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void parseTextMap(const std::string &filename, CaloTowerConstituentsMap &theMap)