70 << simTkLabel_ <<
" Energy Max " << energyMax;
79 if (!tfile.isAvailable())
81 <<
"please add it to config file";
85 for (
int i = 0;
i < 4;
i++) {
86 sprintf(name,
"Hits%d",
i);
87 sprintf(title,
"Number of hits (%s)", types[
i].c_str());
89 meNHit_[
i]->GetXaxis()->SetTitle(title);
90 meNHit_[
i]->GetYaxis()->SetTitle(
"Events");
91 sprintf(name,
"E1T0%d",
i);
92 sprintf(title,
"E1 (Loss %s) in GeV", types[
i].c_str());
94 meE1T0_[
i]->GetXaxis()->SetTitle(title);
95 meE1T0_[
i]->GetYaxis()->SetTitle(
"Events");
96 sprintf(name,
"E9T0%d",
i);
97 sprintf(title,
"E9 (Loss %s) in GeV", types[
i].c_str());
99 meE9T0_[
i]->GetXaxis()->SetTitle(title);
100 meE9T0_[
i]->GetYaxis()->SetTitle(
"Events");
101 sprintf(name,
"E1T1%d",
i);
102 sprintf(title,
"E1 (Loss %s with t < 400 ns) in GeV", types[
i].c_str());
104 meE1T1_[
i]->GetXaxis()->SetTitle(title);
105 meE1T1_[
i]->GetYaxis()->SetTitle(
"Events");
106 sprintf(name,
"E9T1%d",
i);
107 sprintf(title,
"E9 (Loss %s with t < 400 ns) in GeV", types[
i].c_str());
109 meE9T1_[
i]->GetXaxis()->SetTitle(title);
110 meE9T1_[
i]->GetYaxis()->SetTitle(
"Events");
112 sprintf(name,
"PDGType");
113 sprintf(title,
"PDG ID of first level secondary");
115 mType_->GetXaxis()->SetTitle(title);
116 mType_->GetYaxis()->SetTitle(
"Tracks");
123 desc.
add<
double>(
"energyMax", 2.0);
124 descriptions.
add(
"xtalDedxAnalysis", desc);
131 std::vector<PCaloHit> caloHits;
135 std::vector<SimTrack> theSimTracks;
139 std::vector<SimVertex> theSimVertex;
144 caloHits.insert(caloHits.end(), pCaloHits->begin(), pCaloHits->end());
146 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis: Hit buffer " << caloHits.size();
155 edm::SimTrackContainer::const_iterator simTrkItr;
156 int nHit = hits.size();
157 double e10[4], e90[4], e11[4], e91[4],
hit[4];
158 for (
int i = 0;
i < 4;
i++)
159 e10[
i] = e90[
i] = e11[
i] = e91[
i] = hit[
i] = 0;
160 for (
int i = 0;
i < nHit;
i++) {
161 double energy = hits[
i].energy();
162 double time = hits[
i].time();
163 unsigned int id_ = hits[
i].id();
164 int trackID = hits[
i].geantTrackId();
166 for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
167 if (trackID == (
int)(simTrkItr->trackId())) {
168 int thePID = simTrkItr->type();
171 else if (thePID != -13 && thePID != 13)
193 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis:Hit[" <<
i <<
"] ID " << id_ <<
" E " << energy
194 <<
" time " << time <<
" track " << trackID <<
" type " <<
type;
197 for (
int i = 0;
i < 4;
i++) {
199 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis:Type(" <<
i <<
") Hit " << hit[
i] <<
" E10 " << e10[
i]
200 <<
" E11 " << e11[
i] <<
" E90 " << e90[
i] <<
" E91 " << e91[
i];
210 int nvtx = 0, ntrk = 0, k1 = 0;
211 edm::SimVertexContainer::const_iterator simVtxItr;
212 for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++)
214 for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); simVtxItr++)
217 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis: " << ntrk <<
" tracks and " << nvtx <<
" vertices";
219 for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++, ++k1) {
221 edm::LogVerbatim(
"CherenkovAnalysis") <<
"Track " << k1 <<
" PDGId " << simTrkItr->type() <<
" Vertex ID "
222 << simTrkItr->vertIndex() <<
" Generator " << simTrkItr->noGenpart();
224 if (simTrkItr->noGenpart()) {
225 int vertIndex = simTrkItr->vertIndex();
226 if (vertIndex >= 0 && vertIndex < nvtx) {
227 simVtxItr = SimVtx->begin();
228 for (
int iv = 0;
iv < vertIndex;
iv++)
230 int parent = simVtxItr->parentIndex(),
k2 = 0;
231 for (edm::SimTrackContainer::const_iterator trkItr = SimTk->begin(); trkItr != SimTk->end(); trkItr++, ++
k2) {
233 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis::Track " <<
k2 <<
" ID " << trkItr->trackId()
234 <<
" (" << parent <<
") Generator " << trkItr->noGenpart();
236 if ((
int)trkItr->trackId() ==
parent) {
237 if (!trkItr->noGenpart()) {
239 edm::LogVerbatim(
"CherenkovAnalysis") <<
"XtalDedxAnalysis::Track found with ID " << simTrkItr->type();
241 mType_->Fill(simTrkItr->type());
static const std::string kSharedResource
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
edm::InputTag caloHitSource_
XtalDedxAnalysis(const edm::ParameterSet &)
edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~XtalDedxAnalysis() override
void analyzeHits(std::vector< PCaloHit > &, edm::Handle< edm::SimTrackContainer > &, edm::Handle< edm::SimVertexContainer > &)