Skip to content

Commit

Permalink
Merge pull request #4073 from bsunanda/Phase2-shk24
Browse files Browse the repository at this point in the history
Phase2 shk24
  • Loading branch information
cmsbuild committed Jun 3, 2014
2 parents 902d2ff + 734f4e5 commit 0715781
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 47 deletions.
7 changes: 2 additions & 5 deletions Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/** \class FastTimeDDDConstants
*
* this class reads the constant section of
* the shashlik-numbering xml-file
* the numbering xml-file for fast timer device
*
* $Date: 2014/03/20 00:06:50 $
* \author Sunanda Banerjee, SINP <sunanda.banerjee@cern.ch>
Expand All @@ -24,7 +24,6 @@ class FastTimeDDDConstants {

public:

FastTimeDDDConstants();
FastTimeDDDConstants( const DDCompactView& cpv );
~FastTimeDDDConstants();

Expand All @@ -33,19 +32,17 @@ class FastTimeDDDConstants {
std::pair<int,int> getXY(int copy) const;
std::pair<int,int> getXY(double x, double y) const;
int getCells() const {return 4*nCells;}
void initialize(const DDCompactView& cpv);
bool isValidXY(int ix, int iy) const;
bool isValidCell(int copy) const;
int quadrant(int ix, int iy) const;
int quadrant(int copy) const;

private:
void checkInitialized() const;
void initialize(const DDCompactView& cpv);
void loadSpecPars(const DDFilteredView& fv);
std::vector<double> getDDDArray(const std::string &,
const DDsvalues_type &) const;

bool tobeInitialized;
int nCells, nCols, nRows, cellType;
double rIn, rOut, cellSize;
std::vector<int> firstY, lastY, firstCell, lastCell;
Expand Down
62 changes: 21 additions & 41 deletions Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@

//#define DebugLog

FastTimeDDDConstants::FastTimeDDDConstants() : tobeInitialized(true),nCells(0){

#ifdef DebugLog
edm::LogInfo("HGCalGeom") << "FastTimeDDDConstants::FastTimeDDDConstants constructor";
#endif

}

FastTimeDDDConstants::FastTimeDDDConstants(const DDCompactView& cpv) : tobeInitialized(true) {
FastTimeDDDConstants::FastTimeDDDConstants(const DDCompactView& cpv) {

#ifdef DebugLog
edm::LogInfo("HGCalGeom") << "FastTimeDDDConstants::FastTimeDDDConstants ( const DDCompactView& cpv ) constructor";
Expand Down Expand Up @@ -113,33 +105,6 @@ std::pair<int,int> FastTimeDDDConstants::getXY(double x, double y) const {
}
}

void FastTimeDDDConstants::initialize(const DDCompactView& cpv) {

if (tobeInitialized) {
tobeInitialized = false;

std::string attribute = "Volume";
std::string value = "SFBX";
DDValue val(attribute, value, 0.0);

DDSpecificsFilter filter;
filter.setCriteria(val, DDSpecificsFilter::equals);
DDFilteredView fv(cpv);
fv.addFilter(filter);
bool ok = fv.firstChild();

if (ok) {
loadSpecPars(fv);

} else {
edm::LogError("HGCalGeom") << "FastTimeDDDConstants: cannot get filtered"
<< " view for " << attribute
<< " not matching " << value;
throw cms::Exception("DDException") << "FastTimeDDDConstants: cannot match " << attribute << " to " << value;
}
}
}

bool FastTimeDDDConstants::isValidXY(int ix, int iy) const {
int iq = quadrant(ix,iy);
if (iq != 0) {
Expand Down Expand Up @@ -184,12 +149,27 @@ int FastTimeDDDConstants::quadrant(int copy) const {
return iq;
}

void FastTimeDDDConstants::checkInitialized() const {
if (tobeInitialized) {
edm::LogError("HGCalGeom") << "FastTimeDDDConstants : to be initialized correctly";
throw cms::Exception("DDException") << "FastTimeDDDConstants: to be initialized";
void FastTimeDDDConstants::initialize(const DDCompactView& cpv) {

std::string attribute = "Volume";
std::string value = "SFBX";
DDValue val(attribute, value, 0.0);

DDSpecificsFilter filter;
filter.setCriteria(val, DDSpecificsFilter::equals);
DDFilteredView fv(cpv);
fv.addFilter(filter);
bool ok = fv.firstChild();

if (ok) {
loadSpecPars(fv);
} else {
edm::LogError("HGCalGeom") << "FastTimeDDDConstants: cannot get filtered"
<< " view for " << attribute
<< " not matching " << value;
throw cms::Exception("DDException") << "FastTimeDDDConstants: cannot match " << attribute << " to " << value;
}
}
}

void FastTimeDDDConstants::loadSpecPars(const DDFilteredView& fv) {

Expand Down
2 changes: 1 addition & 1 deletion Validation/HcalHits/test/run_SimHitValidationHcal_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load('Configuration.EventContent.EventContent_cff')
process.load('SimGeneral.MixingModule.mixNoPU_cfi')
process.load('Configuration.StandardSequences.GeometryDB_cff')
process.load('Configuration.StandardSequences.Geometry_cff')
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
process.load('Configuration.StandardSequences.Generator_cff')
process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic7TeV2011Collision_cfi')
Expand Down
9 changes: 9 additions & 0 deletions Validation/ShashlikValidation/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
<use name="SimDataFormats/CaloHit"/>
<use name="DataFormats/EcalDetId"/>
<use name="DQMServices/Core"/>
<use name="Geometry/Records"/>
<use name="DetectorDescription/Core"/>
<flags EDM_PLUGIN="1"/>
247 changes: 247 additions & 0 deletions Validation/ShashlikValidation/plugins/ShashlikSimHitValidation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
// -*- C++ -*-
//
// Package: ShashlikSimHitValidation
// Class: ShashlikSimHitValidation
//
/**\class ShashlikSimHitValidation ShashlikSimHitValidation.cc Validation/ShashlikValidation/plugins/ShashlikSimHitValidation.cc
Description: [one line class summary]
Implementation:
[Notes on implementation]
*/
//
// Original Author: Shilpi Jain
// Created: Tue, 04 Mar 2014 14:17:25 GMT
// $Id$
//
//


// system include files
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
#include "DataFormats/EcalDetId/interface/EKDetId.h"

#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <string>

//
// class declaration
//

class ShashlikSimHitValidation : public edm::EDAnalyzer {

public:
explicit ShashlikSimHitValidation(const edm::ParameterSet&);
~ShashlikSimHitValidation();

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
virtual void beginJob() override;
virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
virtual void endJob() override;

/*
virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
*/

// ----------member data ---------------------------
std::string caloHitSource_;
DQMStore *dbe_;
int verbosity_;
std::map<std::string,MonitorElement*> histmap;
std::map<std::string,MonitorElement*> histmap2d;
};

//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
ShashlikSimHitValidation::ShashlikSimHitValidation(const edm::ParameterSet& iConfig) {
//now do what ever initialization is needed
dbe_ = edm::Service<DQMStore>().operator->();
caloHitSource_ = iConfig.getParameter<std::string>("CaloHitSource");
verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
if (verbosity_ > 0) std::cout << "Start SimHitValidation for PCaloHit at "
<< caloHitSource_ << std::endl;
}

ShashlikSimHitValidation::~ShashlikSimHitValidation() {

// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}


//
// member functions
//

// ------------ method called for each event ------------
void ShashlikSimHitValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {

edm::Handle<edm::PCaloHitContainer> pcalohit;
iEvent.getByLabel("g4SimHits", caloHitSource_, pcalohit);
const edm::PCaloHitContainer* endcapHits = pcalohit.product();

double sumhitE = 0;
unsigned int kount(0);
for (edm::PCaloHitContainer::const_iterator erh = endcapHits->begin();
erh != endcapHits->end(); erh++) {

double time = erh->time();
double energy = erh->energy();

uint32_t detidindex = erh->id();
EKDetId detid(detidindex);
int ix = detid.ix();
int iy = detid.iy();
int iz = detid.zside();

sumhitE += energy;
if (dbe_) {
histmap["time"]->Fill(time);
histmap["timeEwei"]->Fill(time,energy);
histmap["energy"]->Fill(energy);

histmap2d["iyVSix"]->Fill(ix,iy);
histmap2d["iyVSixEwei"]->Fill(ix,iy,energy);

if (time>0 && time<100) {
histmap2d["iyVSixEwei_100"]->Fill(ix,iy,energy);
if (time>0 && time<25) {
histmap2d["iyVSixEwei_25"]->Fill(ix,iy,energy);
}
}

if (iz==-1) { ///same for zside = -1
histmap2d["iyVSix_zM"]->Fill(ix,iy);
histmap2d["iyVSixEwei_zM"]->Fill(ix,iy,energy);

if (time>0 && time<100) {
histmap2d["iyVSixEwei_100_zM"]->Fill(ix,iy,energy);
if (time>0 && time<25) {
histmap2d["iyVSixEwei_25_zM"]->Fill(ix,iy,energy);
}
}
} else if (iz==1) { ///same for zside = +1
histmap2d["iyVSix_zP"]->Fill(ix,iy);
histmap2d["iyVSixEwei_zP"]->Fill(ix,iy,energy);

if (time>0 && time<100) {
histmap2d["iyVSixEwei_100_zP"]->Fill(ix,iy,energy);
if (time>0 && time<25) {
histmap2d["iyVSixEwei_25_zP"]->Fill(ix,iy,energy);
}
}
}
}
kount++;
}
if (dbe_) histmap["sumE"]->Fill(sumhitE);
if (verbosity_ > 1) std::cout << kount << " hits for " << caloHitSource_
<< " with total energy " << sumhitE << std::endl;
}


// ------------ method called once each job just before starting event loop ------------
void ShashlikSimHitValidation::beginJob() {

if (dbe_) {
histmap["time"] = dbe_->book1D("time","Time distribution of the hits",100,0.,530);
histmap["timeEwei"] = dbe_->book1D("timeEwei","Energy weighted time distribution of the hits",100,0,530);
histmap["energy"] = dbe_->book1D("energy","Energy distribution of the hits",100,0,3);
histmap["sumE"] = dbe_->book1D("sumE","Total energy distribution of the hits",500,0,100);

histmap2d["iyVSix"] = dbe_->book2D("iyVSix","iy VS ix",301,0,301,301,0,301);
histmap2d["iyVSixEwei"] = dbe_->book2D("iyVSixEwei","iy VS ix (Energyweighted)",301,0,301,301,0,301);
histmap2d["iyVSixEwei_25"] = dbe_->book2D("iyVSixEwei_25","iy VS ix (Energyweighted) in a time window of 0 to 25 ns",301,0,301,301,0,301);
histmap2d["iyVSixEwei_100"] = dbe_->book2D("iyVSixEwei_100","iy VS ix (Energyweighted) in a time window of 0 to 100 ns",301,0,301,301,0,301);

//iz=-1
histmap2d["iyVSix_zM"] = dbe_->book2D("iyVSix_zM","iy VS ix (-tive z)",301,0,301,301,0,301);
histmap2d["iyVSixEwei_zM"] = dbe_->book2D("iyVSixEwei_zM","iy VS ix (Energyweighted)(-tive z)",301,0,301,301,0,301);
histmap2d["iyVSixEwei_25_zM"] = dbe_->book2D("iyVSixEwei_25_zM","iy VS ix (Energyweighted) in a time window of 0 to 25 ns (-tive z)",301,0,301,301,0,301);
histmap2d["iyVSixEwei_100_zM"] = dbe_->book2D("iyVSixEwei_100_zM","iy VS ix (Energyweighted) in a time window of 0 to 100 ns (-tive z)",301,0,301,301,0,301);

//iz=+1
histmap2d["iyVSix_zP"] = dbe_->book2D("iyVSix_zP","iy VS ix (+tive z)",301,0,301,301,0,301);
histmap2d["iyVSixEwei_zP"] = dbe_->book2D("iyVSixEwei_zP","iy VS ix (Energyweighted)(+tive z)",301,0,301,301,0,301);
histmap2d["iyVSixEwei_25_zP"] = dbe_->book2D("iyVSixEwei_25_zP","iy VS ix (Energyweighted) in a time window of 0 to 25 ns (+tive z)",301,0,301,301,0,301);
histmap2d["iyVSixEwei_100_zP"] = dbe_->book2D("iyVSixEwei_100_zP","iy VS ix (Energyweighted) in a time window of 0 to 100 ns (+tive z)",301,0,301,301,0,301);

if (verbosity_>0)
std::cout << "ShashlikSimHitValidation:: Initialize histograms" << std::endl;
}
}

// ------------ method called once each job just after ending the event loop ------------
void ShashlikSimHitValidation::endJob() {
}

// ------------ method called when starting to processes a run ------------
/*
void ShashlikSimHitValidation::beginRun(edm::Run const&, edm::EventSetup const&) {
}
*/

// ------------ method called when ending the processing of a run ------------
/*
void ShashlikSimHitValidation::endRun(edm::Run const&, edm::EventSetup const&) {
}
*/

// ------------ method called when starting to processes a luminosity block ------------
/*
void ShashlikSimHitValidation::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
}
*/

// ------------ method called when ending the processing of a luminosity block ------------
/*
void ShashlikSimHitValidation::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
}
*/

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void ShashlikSimHitValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}

//define this as a plug-in
DEFINE_FWK_MODULE(ShashlikSimHitValidation);
6 changes: 6 additions & 0 deletions Validation/ShashlikValidation/python/simhitValidation_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import FWCore.ParameterSet.Config as cms

shashlikSimHitValidation = cms.EDAnalyzer('ShashlikSimHitValidation',
CaloHitSource = cms.string("EcalHitsEK"),
Verbosity = cms.untracked.int32(1)
)

0 comments on commit 0715781

Please sign in to comment.