CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTrigTowerConstituentsMapBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalTrigTowerConstituentsMapBuilder
4 // Class: EcalTrigTowerConstituentsMapBuilder
5 //
13 //
14 // Original Author: Paolo Meridiani
15 // $Id: EcalTrigTowerConstituentsMapBuilder.cc,v 1.3 2009/04/08 20:36:57 heltsley Exp $
16 //
17 //
18 
19 
20 // user include files
25 
26 #include <iostream>
27 #include <fstream>
28 
30 
31 //
32 // constructors and destructor
33 //
35  mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile",""))
36 {
37  //the following line is needed to tell the framework what
38  // data is being produced
39  setWhatProduced(this);
40 
41  //now do what ever other initialization is needed
42 }
43 
44 
46 {
47 }
48 
49 //
50 // member functions
51 //
52 
53 // ------------ method called to produce the data ------------
56 {
57  std::auto_ptr<EcalTrigTowerConstituentsMap> prod(new EcalTrigTowerConstituentsMap());
58 
59  if (!mapFile_.empty()) {
60  parseTextMap(mapFile_,*prod);
61  }
62  return prod;
63 }
64 
66  edm::FileInPath eff(filename);
67 
68  std::ifstream f(eff.fullPath().c_str());
69  if (!f.good())
70  return;
71 
72  int ietaTower,iphiTower;
73  int ix,iy,iz;
74  char line[80]; // a buffer for the line to read
75  char ch; // a temporary for holding the end of line
76  while ((ch = f.peek()) != '-') {
77  f.get(line,80,'\n'); // read 80 characters to end of line
78  f.get(ch); // eat out the '\n'
79  // extract the numbers
80 /*
81  int mod,cry;
82  int nread = sscanf (line, " %d %d %d %d",&mod,&cry,&ietaTower,&iphiTower);
83  if (nread == 4 )
84  {
85  EEDetId eeid(mod,cry,1,EEDetId::SCCRYSTALMODE);
86  EcalTrigTowerDetId etid(1,EcalEndcap,ietaTower-45+17,iphiTower);
87  // std::cout << eeid << "\n->" << etid << std::endl;
88  theMap.assign(DetId(eeid),etid);
89  }
90 */
91  int nread = sscanf (line, " %d %d %d %d %d",&ix,&iy,&iz,&ietaTower, &iphiTower);
92  if (nread == 5) {
93  EEDetId eeid(ix,iy,iz,0);
94  // std::cout << "-- manu ix eta phi " << DetId(eeid).rawId() << " " << iz << " " << ietaTower << " " << iphiTower << std::endl;
95  EcalTrigTowerDetId etid(iz,EcalEndcap,ietaTower,iphiTower);
96  theMap.assign(DetId(eeid),etid);
97  }
98 
99  }
100  // Pass comment line
101  f.get(line,80,'\n'); // read 80 characters to end of line
102  f.get(ch); // eat out the '\n'
103  // Next info line
104  f.get(line,80,'\n'); // read 80 characters to end of line
105  f.get(ch); // eat out the '\n'
106  // extract the numbers
107  // int nTE;
108  // sscanf (line, " %d",&nTE);
109  // nTowEta_e=nTE;
110  // while ((ch = f.peek()) != EOF) {
111  // f.get(line,80,'\n'); // read 80 characters to end of line
112  // f.get(ch); // eat out the '\n'
113  // // extract the numbers
114  // float bound;
115  // sscanf (line, " %f", &bound);
116  // eta_boundaries.push_back(bound);
117  // }
118 
119  f.close();
120  return;
121 }
void assign(const DetId &cell, const EcalTrigTowerDetId &tower)
set the association between a DetId and a tower
ReturnType produce(const IdealGeometryRecord &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::auto_ptr< EcalTrigTowerConstituentsMap > ReturnType
double f[11][100]
Definition: DetId.h:20
void parseTextMap(const std::string &filename, EcalTrigTowerConstituentsMap &theMap)
tuple filename
Definition: lut2db_cfg.py:20
std::string fullPath() const
Definition: FileInPath.cc:170