CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
cms::HcalConstantsASCIIWriter Class Reference

#include <HcalConstantsASCIIWriter.h>

Inheritance diagram for cms::HcalConstantsASCIIWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 HcalConstantsASCIIWriter (const edm::ParameterSet &)
 
 ~HcalConstantsASCIIWriter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::string file_input
 
std::string file_output
 
std::ofstream * myout_hcal
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 49 of file HcalConstantsASCIIWriter.h.

Constructor & Destructor Documentation

cms::HcalConstantsASCIIWriter::HcalConstantsASCIIWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 36 of file HcalConstantsASCIIWriter.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

37 {
38  // get name of output file with histogramms
39  file_input="Calibration/HcalCalibAlgos/data/"+iConfig.getParameter <std::string> ("fileInput")+".txt";
40  file_output="Calibration/HcalCalibAlgos/data/"+iConfig.getParameter <std::string> ("fileOutput")+".txt";
41 }
T getParameter(std::string const &) const
cms::HcalConstantsASCIIWriter::~HcalConstantsASCIIWriter ( )

Definition at line 43 of file HcalConstantsASCIIWriter.cc.

44 {
45 
46  // do anything here that needs to be done at desctruction time
47  // (e.g. close files, deallocate resources etc.)
48 
49 }

Member Function Documentation

void cms::HcalConstantsASCIIWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 73 of file HcalConstantsASCIIWriter.cc.

References HcalCondObjectContainer< Item >::addValues(), gather_cfg::cout, HcalDetId::depth(), HLT_25ns14e33_v1_cff::depth, HcalDbASCIIIO::dumpObject(), python.connectstrParser::f1, edm::FileInPath::fullPath(), edm::EventSetup::get(), CaloGeometry::getValidDetIds(), reco::JetExtendedAssociation::getValue(), HcalCondObjectContainer< Item >::getValues(), DetId::Hcal, i, HcalDetId::ieta(), recoMuon::in, HcalDetId::iphi(), geometryCSVtoXML::line, edm::ESHandle< class >::product(), alignCSCRings::r, edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, and HcalCondObjectContainerBase::topo().

74 {
75 
76  std::cout<<" Start HcalConstantsASCIIWriter::analyze "<<std::endl;
77 
79  iSetup.get<HcalRespCorrsRcd>().get(r);
80  HcalRespCorrs* oldRespCorrs = new HcalRespCorrs(*r.product());
81 // std::vector<DetId> dd = oldRespCorrs->getAllChannels();
82 
84  iSetup.get<CaloGeometryRecord>().get(pG);
85  const CaloGeometry* geo = pG.product();
86 // iSetup.get<HcalDbRecord>().get(conditions);
87 
88  std::vector<DetId> did = geo->getValidDetIds();
89 
90 
91  std::map<HcalDetId,float> corrold;
92  //map<HcalDetId,float> corrnew;
93 
94  int mysubd,depth,ieta,iphi;
95  float coradd,corerr;
96 
97  std::vector<HcalDetId> theVector;
98  for(std::vector<DetId>::iterator i = did.begin(); i != did.end(); i++)
99  {
100  if( (*i).det() == DetId::Hcal ) {
101  HcalDetId hid = HcalDetId(*i);
102  theVector.push_back(hid);
103  corrold[hid] = (oldRespCorrs->getValues(*i))->getValue();
104  std::cout<<" Old calibration "<<hid.depth()<<" "<<hid.ieta()<<" "<<hid.iphi()<<std::endl;
105  }
106  }
107 
108  std::cout<<" Get old calibration "<<std::endl;
109 // Read new corrections from file
110 
112  std::string fDataFile = f1.fullPath();
113 
114  std::ifstream in( fDataFile.c_str() );
116 
117  double corrnew_p[5][5][45][75];
118  double corrnew_m[5][5][45][75];
119  std::cout<<" Start to read txt file "<<fDataFile.c_str()<<std::endl;
120  while( std::getline( in, line)){
121 
122 // std::cout<<" Line size "<<line.size()<< " "<<line<< std::endl;
123 
124  if(!line.size() || line[0]=='#') continue;
125  std::istringstream linestream(line);
126 
127  linestream>>mysubd>>depth>>ieta>>iphi>>coradd>>corerr;
128 // DetId mydid(DetId::Hcal,HcalSubdetector(mysubd));
129 // HcalDetId hid(HcalSubdetector(mysubd),ieta,iphi,depth);
130 // HcalDetId hid(mydid);
131 // std::cout<<" Check mysubd "<<hid.subdet()<<" depth "<<hid.depth()<<" ieta "<<hid.ieta()<<" iphi "<<hid.iphi()<<" "<<hid.rawId()<< std::endl;
132  int ietak = ieta;
133  if(ieta<0) ietak = -1*ieta;
134  if(ieta>0) corrnew_p[mysubd][depth][ietak][iphi] = coradd;
135  if(ieta<0) corrnew_m[mysubd][depth][ietak][iphi] = coradd;
136  std::cout<<" Try to initialize mysubd "<<mysubd<<" depth "<<depth<<" ieta "<<ieta<<" "<<ietak<<" iphi "<<iphi<<" "<<coradd<<
137  std::endl;
138  }
139 
140  HcalRespCorrs* mycorrections = new HcalRespCorrs(oldRespCorrs->topo());
141 
142  for(std::vector<HcalDetId>::iterator it = theVector.begin(); it != theVector.end(); it++)
143  {
144  float cc1 = (*corrold.find(*it)).second;
145  // float cc2 = (*corrnew.find(*it)).second;
146  float cc2 = 0.;
147  int ietak = (*it).ieta();
148 
149  if((*it).ieta()<0) ietak=-1*(*it).ieta();
150 
151  if((*it).ieta()>0) cc2 = corrnew_p[(*it).subdet()][(*it).depth()][ietak][(*it).iphi()];
152  if((*it).ieta()<0) cc2 = corrnew_m[(*it).subdet()][(*it).depth()][ietak][(*it).iphi()];
153 
154  float cc = cc1*cc2;
155  std::cout<<" Multiply "<<(*it).subdet()<<" "<<(*it).depth()<<" "<<(*it).ieta()<<" "<<ietak<<" "<<(*it).iphi()<<" "<<(*it).rawId()<<" "<<cc1<<" "<<cc2<<std::endl;
156 
157  // now make the basic object for one cell with HcalDetId myDetId containing the value myValue
158  HcalRespCorr item ((*it).rawId(), cc);
159  mycorrections->addValues(item);
160  }
161 
162  HcalRespCorrs mycc = *mycorrections;
164 
165 }
int i
Definition: DBlmapReader.cc:9
const Item * getValues(DetId fId, bool throwOnFail=true) const
U second(std::pair< T, U > const &p)
int depth() const
get the tower depth
Definition: HcalDetId.h:40
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
tuple cout
Definition: gather_cfg.py:121
bool addValues(const Item &myItem)
const HcalTopology * topo() const
void cms::HcalConstantsASCIIWriter::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file HcalConstantsASCIIWriter.cc.

References gather_cfg::cout, python.connectstrParser::f1, edm::FileInPath::fullPath(), and AlCaHLTBitMon_QueryRunRegistry::string.

52 {
54  std::string fDataFile = f1.fullPath();
55 
56  myout_hcal = new std::ofstream(fDataFile.c_str());
57  if(!myout_hcal) std::cout << " Output file not open!!! "<<std::endl;
58 
59 }
tuple cout
Definition: gather_cfg.py:121
void cms::HcalConstantsASCIIWriter::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 61 of file HcalConstantsASCIIWriter.cc.

62 {
63  delete myout_hcal;
64 }

Member Data Documentation

std::string cms::HcalConstantsASCIIWriter::file_input
private

Definition at line 62 of file HcalConstantsASCIIWriter.h.

std::string cms::HcalConstantsASCIIWriter::file_output
private

Definition at line 63 of file HcalConstantsASCIIWriter.h.

std::ofstream* cms::HcalConstantsASCIIWriter::myout_hcal
private

Definition at line 61 of file HcalConstantsASCIIWriter.h.