65 : caloHitSource_(ps.getParameter<
edm::
InputTag>(
"caloHitSource")),
66 simTkLabel_(ps.getParameter<
std::
string>(
"moduleLabelTk")),
67 energyMax_(ps.getParameter<double>(
"energyMax")),
78 if (!
tfile.isAvailable())
80 <<
"please add it to config file";
84 for (
int i = 0;
i < 4;
i++) {
85 sprintf(
name,
"Hits%d",
i);
86 sprintf(
title,
"Number of hits (%s)",
types[
i].c_str());
89 meNHit_[
i]->GetYaxis()->SetTitle(
"Events");
90 sprintf(
name,
"E1T0%d",
i);
91 sprintf(
title,
"E1 (Loss %s) in GeV",
types[
i].c_str());
94 meE1T0_[
i]->GetYaxis()->SetTitle(
"Events");
95 sprintf(
name,
"E9T0%d",
i);
96 sprintf(
title,
"E9 (Loss %s) in GeV",
types[
i].c_str());
99 meE9T0_[
i]->GetYaxis()->SetTitle(
"Events");
100 sprintf(
name,
"E1T1%d",
i);
101 sprintf(
title,
"E1 (Loss %s with t < 400 ns) in GeV",
types[
i].c_str());
104 meE1T1_[
i]->GetYaxis()->SetTitle(
"Events");
105 sprintf(
name,
"E9T1%d",
i);
106 sprintf(
title,
"E9 (Loss %s with t < 400 ns) in GeV",
types[
i].c_str());
109 meE9T1_[
i]->GetYaxis()->SetTitle(
"Events");
111 sprintf(
name,
"PDGType");
112 sprintf(
title,
"PDG ID of first level secondary");
115 mType_->GetYaxis()->SetTitle(
"Tracks");
122 desc.add<
double>(
"energyMax", 2.0);
123 descriptions.
add(
"xtalDedxAnalysis",
desc);
128 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis::Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
130 std::vector<PCaloHit> caloHits;
137 caloHits.insert(caloHits.end(), pCaloHits->begin(), pCaloHits->end());
139 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis: Hit buffer " << caloHits.size();
148 edm::SimTrackContainer::const_iterator simTrkItr;
149 int nHit =
hits.size();
150 double e10[4], e90[4], e11[4], e91[4],
hit[4];
151 for (
int i = 0;
i < 4;
i++)
152 e10[
i] = e90[
i] = e11[
i] = e91[
i] =
hit[
i] = 0;
153 for (
int i = 0;
i < nHit;
i++) {
156 unsigned int id_ =
hits[
i].id();
157 int trackID =
hits[
i].geantTrackId();
159 for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
160 if (trackID == (
int)(simTrkItr->trackId())) {
161 int thePID = simTrkItr->type();
164 else if (thePID != -13 && thePID != 13)
187 <<
" time " <<
time <<
" track " << trackID <<
" type " <<
type;
190 for (
int i = 0;
i < 4;
i++) {
192 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis:Type(" <<
i <<
") Hit " <<
hit[
i] <<
" E10 " << e10[
i]
193 <<
" E11 " << e11[
i] <<
" E90 " << e90[
i] <<
" E91 " << e91[
i];
203 int nvtx = 0, ntrk = 0, k1 = 0;
204 edm::SimVertexContainer::const_iterator simVtxItr;
205 for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++)
207 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); simVtxItr++)
210 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis: " << ntrk <<
" tracks and " << nvtx <<
" vertices";
212 for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++, ++k1) {
214 edm::LogVerbatim(
"CherenkovAnalysis") <<
"Track " << k1 <<
" PDGId " << simTrkItr->type() <<
" Vertex ID " 215 << simTrkItr->vertIndex() <<
" Generator " << simTrkItr->noGenpart();
217 if (simTrkItr->noGenpart()) {
218 int vertIndex = simTrkItr->vertIndex();
219 if (vertIndex >= 0 && vertIndex < nvtx) {
220 simVtxItr = SimVtx->begin();
221 for (
int iv = 0;
iv < vertIndex;
iv++)
223 int parent = simVtxItr->parentIndex(), k2 = 0;
224 for (edm::SimTrackContainer::const_iterator trkItr = SimTk->begin(); trkItr != SimTk->end(); trkItr++, ++k2) {
226 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis::Track " << k2 <<
" ID " << trkItr->trackId()
227 <<
" (" <<
parent <<
") Generator " << trkItr->noGenpart();
229 if ((
int)trkItr->trackId() ==
parent) {
230 if (!trkItr->noGenpart()) {
232 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis::Track found with ID " << simTrkItr->type();
234 mType_->Fill(simTrkItr->type());
static const std::string kSharedResource
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
std::vector< PCaloHit > PCaloHitContainer
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
const edm::InputTag caloHitSource_
const edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
void analyzeHits(std::vector< PCaloHit > &, const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &)
XtalDedxAnalysis(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< SimVertex > SimVertexContainer
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~XtalDedxAnalysis() override
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
std::vector< SimTrack > SimTrackContainer
const std::string simTkLabel_