test
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 
29 #include <zlib.h>
30 #include <strings.h>
31 
32 //
33 // constructors and destructor
34 //
36  mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile","")) {
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 // member functions
50 //
51 
52 void
54 {
56  desc.addUntracked<std::string>( "MapFile", "" );
57  descriptions.add( "caloTowerConstituents", desc );
58 }
59 
60 // ------------ method called to produce the data ------------
63 {
65  iRecord.getRecord<HcalRecNumberingRecord>().get(hcaltopo);
66 
68  iRecord.getRecord<HcalRecNumberingRecord>().get(cttopo);
69 
70  std::auto_ptr<CaloTowerConstituentsMap> prod( new CaloTowerConstituentsMap( &*hcaltopo, &*cttopo ));
71 
72 //std::auto_ptr<CaloTowerConstituentsMap> prod( new CaloTowerConstituentsMap( &*hcaltopo ));
73 
74  //keep geometry pointer as member for alternate EE->HE mapping
76  iRecord.get(pG);
77  const CaloGeometry* geometry = pG.product();
78 
79  prod->useStandardHB(true);
80  prod->useStandardHE(true);
81  prod->useStandardHF(true);
82  prod->useStandardHO(true);
83  prod->useStandardEB(true);
84 
85  if (!mapFile_.empty()) {
86  parseTextMap(mapFile_,*prod);
87  } else {
88  assignEEtoHE(geometry, *prod, &*cttopo);
89  }
90  prod->sort();
91 
92  return prod;
93 }
94 
95 void
97 
98  edm::FileInPath eff( filename );
99 
100  gzFile gzed = gzopen( eff.fullPath().c_str(), "rb" );
101 
102  while( !gzeof( gzed )) {
103  char line[1024];
104  int ieta, iphi, rawid;
105  if( 0 != gzgets( gzed, line, 1023 )) {
106  if( index( line, '#' ) != 0 )*( index( line, '#' )) = 0;
107  int ct = sscanf( line, "%i %d %d", &rawid, &ieta, &iphi );
108  if( ct == 3 ) {
109  DetId detid( rawid );
110  CaloTowerDetId tid( ieta, iphi );
111  theMap.assign( detid, tid );
112  }
113  }
114  }
115  gzclose( gzed );
116 }
117 
118 //algorithm to assign EE cells to HE towers if no text map is provided
120  //get EE and HE geometries
122  if(geomEE==NULL) return; // if no EE is defined don't know where it is used
123 
125 
126  //get list of EE detids
127  const std::vector<DetId>& vec(geomEE->getValidDetIds());
128  //loop over EE detids
129  for(std::vector<DetId>::const_iterator detId_itr =vec.begin();
130  detId_itr != vec.end(); detId_itr++){
131  //get detid position
132  const CaloCellGeometry* cellGeometry = geomEE->getGeometry(*detId_itr);
133  const GlobalPoint gp ( cellGeometry->getPosition() ) ;
134 
135  //find closest HE cell
136  const HcalDetId closestCell ( geomHE->getClosestCell( gp ) ) ;
137 
138  //assign to appropriate CaloTower
139  CaloTowerDetId tid(cttopo->convertHcaltoCT(closestCell.ietaAbs(),closestCell.subdet())*closestCell.zside(), closestCell.iphi());
140  theMap.assign(*detId_itr,tid);
141  }
142 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
int convertHcaltoCT(int hcal_ieta, HcalSubdetector subdet) const
CaloTowerConstituentsMapBuilder(const edm::ParameterSet &)
#define NULL
Definition: scimark2.h:8
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
ReturnType produce(const CaloGeometryRecord &)
Definition: DetId.h:18
T const * product() const
Definition: ESHandle.h:86
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ESHandle< TrackerGeometry > geometry
tuple filename
Definition: lut2db_cfg.py:20
void assignEEtoHE(const CaloGeometry *geometry, CaloTowerConstituentsMap &theMap, const CaloTowerTopology *cttopo)
std::string fullPath() const
Definition: FileInPath.cc:165
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
void parseTextMap(const std::string &filename, CaloTowerConstituentsMap &theMap)