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 // $Id: CaloTowerConstituentsMapBuilder.cc,v 1.9 2013/04/26 09:38:11 yana Exp $
17 //
18 //
19 
24 #include <zlib.h>
25 #include <strings.h>
26 
27 //
28 // constructors and destructor
29 //
31  mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile",""))
32 {
33  //the following line is needed to tell the framework what
34  // data is being produced
35  setWhatProduced(this);
36 
37  //now do what ever other initialization is needed
38 }
39 
40 
42 {
43 }
44 
45 
46 //
47 // member functions
48 //
49 
50 void
52 {
54  desc.addUntracked<std::string>( "MapFile", "" );
55  descriptions.add( "caloTowerConstituents", desc );
56 }
57 
58 // ------------ method called to produce the data ------------
61 {
63  iRecord.get( topology ) ;
64 
65  std::auto_ptr<CaloTowerConstituentsMap> prod( new CaloTowerConstituentsMap( &*topology ));
66 
67  prod->useStandardHB(true);
68  prod->useStandardHE(true);
69  prod->useStandardHF(true);
70  prod->useStandardHO(true);
71  prod->useStandardEB(true);
72 
73  if (!mapFile_.empty()) {
74  parseTextMap(mapFile_,*prod);
75  }
76  prod->sort();
77 
78  return prod;
79 }
80 
81 void
83 {
84  edm::FileInPath eff( filename );
85 
86  gzFile gzed = gzopen( eff.fullPath().c_str(), "rb" );
87 
88  while( !gzeof( gzed ))
89  {
90  char line[1024];
91  int ieta, iphi, rawid;
92  if( 0 != gzgets( gzed, line, 1023 ))
93  {
94  if( index( line, '#' ) != 0 )*( index( line, '#' )) = 0;
95  int ct = sscanf( line, "%i %d %d", &rawid, &ieta, &iphi );
96  if( ct == 3 )
97  {
98  DetId detid( rawid );
99  CaloTowerDetId tid( ieta, iphi );
100  theMap.assign( detid, tid );
101  }
102  }
103  }
104  gzclose( gzed );
105 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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:20
void add(std::string const &label, ParameterSetDescription const &psetDescription)
tuple filename
Definition: lut2db_cfg.py:20
std::string fullPath() const
Definition: FileInPath.cc:171
ReturnType produce(const IdealGeometryRecord &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void parseTextMap(const std::string &filename, CaloTowerConstituentsMap &theMap)