96 std::ifstream filestr(inputFile.c_str(),std::ios::in);
99 if (!filestr.is_open()) {
100 std::cout <<
"FCALDistEnergyShowerLib " << inputFile <<
": bad file!" << std::endl;
105 std::getline(filestr,instr);
106 std::stringstream
ss(instr);
122 std::vector<float> etalist;
130 std::cout <<
"file reading failed! (not enough data)" << std::endl;
136 std::cout <<
"no negative dists allowed (" <<
eta <<
")" << std::endl;
139 etalist.push_back(0.);
142 etalist.push_back(
eta);
147 if ((
ss.fail()) || (
eta <= etaold)) {
148 std::cout <<
"screwed dists! (" <<
eta <<
"<=" << etaold <<
")" << std::endl;
152 etalist.push_back(
eta);
153 }
else if (
eta > 4.5) {
154 std::cout <<
"dist can't be bigger than 4.5 (" <<
eta <<
"). ignored" << std::endl;
163 std::cout <<
"this structure is not valid" << std::endl;
173 std::getline(filestr,instr);
174 std::stringstream ss1(instr);
178 std::getline(filestr,instr);
187 std::cout <<
"Library is not created for production use" << std::endl;
193 double x = track->GetPosition().getX();
194 double y = track->GetPosition().getY();
198 G4int particleCode = track->GetDefinition()->GetPDGEncoding();
199 if ( particleCode < 0 ) particleCode = -particleCode;
202 std::cout <<
"wrong particle: " << particleCode <<
"!=" <<
m_particle << std::endl;
208 library::const_iterator libit =
m_libData.upper_bound(dist);
212 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
219 if ((*libit).second.empty()) {
220 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
223 double trenergy = track->GetKineticEnergy();
225 distbin::const_iterator distit = (*libit).second.lower_bound(trenergy);
226 if (distit == (*libit).second.end()) --distit;
227 else if (distit != (*libit).second.begin()) {
228 distbin::const_iterator distitch = distit;
230 if (((*distit).first - trenergy) > (trenergy - (*distitch).first)) {
235 if (randomShift > 0) {
236 double upperEnergy = (*distit).first * 1.01;
237 for (
int i = 0; i < randomShift; i++) {
239 if (distit == (*libit).second.end()) {
243 if ((*distit).first > upperEnergy)
break;
246 if ((randomShift < 0)&&(distit != (*libit).second.begin())) {
247 double lowerEnergy = (*distit).first * 0.99;
248 for (
int i = 0; i > randomShift; i--) {
250 if (distit == (*libit).second.begin()) {
254 if (lowerEnergy > (*distit).first)
break;
259 std::vector<EnergySpot>* outshower =
new std::vector<EnergySpot>();
260 Shower::const_iterator iter;
263 float energyScale = track->GetKineticEnergy() / (*distit).first;
266 for (iter = (*distit).second.begin() ; iter != (*distit).second.end() ; ++iter) {
267 EnergySpot tmp( (*iter)->GetPosition(), (*iter)->GetEnergy(), (*iter)->GetTime() );
268 tmp.SetEnergy(tmp.GetEnergy() * energyScale);
269 outshower->push_back(tmp);
273 if (stats !=
nullptr) {
274 stats->recordShowerLibUse(
calcKey((*libit).first));
283 std::cout <<
"Library is not created for production use" << std::endl;
289 double x = track->GetPosition().getX();
290 double y = track->GetPosition().getY();
294 G4int particleCode = track->GetDefinition()->GetPDGEncoding();
295 if ( particleCode < 0 ) particleCode = -particleCode;
298 std::cout <<
"wrong particle: " << particleCode <<
"!=" <<
m_particle << std::endl;
302 library::const_iterator libit =
m_libData.upper_bound(dist);
306 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
313 if ((*libit).second.empty()) {
314 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
317 double trenergy = track->GetKineticEnergy();
319 distbin::const_iterator distit = (*libit).second.lower_bound(trenergy);
320 if (distit == (*libit).second.end()) --distit;
321 else if (distit != (*libit).second.begin()) {
322 distbin::const_iterator distitch = distit;
324 if (((*distit).first - trenergy) > (trenergy - (*distitch).first)) {
329 double rezZ = (*distit).second.getZSize();
330 distbin::const_iterator distiter = distit;
333 double upperEnergy = (*distit).first * 1.01;
334 for (
int i = 0; i < spread; i++) {
336 if (distiter == (*libit).second.end()) {
339 if (upperEnergy < (*distiter).first)
break;
341 rezZ += (*distiter).second.getZSize();
345 if (distiter != (*libit).second.begin()) {
346 double lowerEnergy = (*distit).first * 0.99;
347 for (
int i = 0; i < spread; i++) {
349 if (lowerEnergy > (*distiter).first)
break;
351 rezZ += (*distiter).second.getZSize();
353 if (distiter == (*libit).second.begin()) {
358 return rezZ/actualNumFS;
364 std::cout <<
"Library is not created for production use" << std::endl;
370 double x = track->GetPosition().getX();
371 double y = track->GetPosition().getY();
375 G4int particleCode = track->GetDefinition()->GetPDGEncoding();
376 if ( particleCode < 0 ) particleCode = -particleCode;
379 std::cout <<
"wrong particle: " << particleCode <<
"!=" <<
m_particle << std::endl;
383 library::const_iterator libit =
m_libData.upper_bound(dist);
387 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
394 if ((*libit).second.empty()) {
395 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
398 double trenergy = track->GetKineticEnergy();
400 distbin::const_iterator distit = (*libit).second.lower_bound(trenergy);
401 if (distit == (*libit).second.end()) --distit;
402 else if (distit != (*libit).second.begin()) {
403 distbin::const_iterator distitch = distit;
405 if (((*distit).first - trenergy) > (trenergy - (*distitch).first)) {
410 double rezR = (*distit).second.getRSize();
411 distbin::const_iterator distiter = distit;
414 double upperEnergy = (*distit).first * 1.01;
415 for (
int i = 0; i < spread; i++) {
417 if (distiter == (*libit).second.end()) {
420 if (upperEnergy < (*distiter).first)
break;
422 rezR += (*distiter).second.getRSize();
426 if (distiter != (*libit).second.begin()) {
427 double lowerEnergy = (*distit).first * 0.99;
428 for (
int i = 0; i < spread; i++) {
430 if (lowerEnergy > (*distiter).first)
break;
432 rezR += (*distiter).second.getRSize();
434 if (distiter == (*libit).second.begin()) {
439 return rezR/actualNumFS;
445 std::cout <<
"ERROR: filled" << std::endl;
449 double x = genParticle->production_vertex()->position().x();
450 double y = genParticle->production_vertex()->position().y();
455 std::cout <<
"ERROR: wrong pdgcode: " <<
m_particle <<
" != " << genParticle->pdg_id() << std::endl;
459 library::iterator libit =
m_libData.upper_bound(dist);
462 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
466 (*libit).second.insert(distbin::value_type(genParticle->momentum().e(),(*shower)));
507 int nentr = source->GetEntriesFast();
508 if (nentr < 3)
return false;
509 Float_t
x,
y,
z,e,time;
510 source->SetBranchAddress(
"x",&
x);
511 source->SetBranchAddress(
"y",&
y);
512 source->SetBranchAddress(
"z",&
z);
513 source->SetBranchAddress(
"e",&e);
514 source->SetBranchAddress(
"time",&time);
517 source->GetEntry(entr++);
524 source->GetEntry(entr++);
525 int nsh = (int)(
x+0.1);
528 for(
int i = 0; i < nsh; i++) {
530 source->GetEntry(entr++);
531 int nhits = (int)(
x+0.1);
533 Shower * shower = &((*curbin)[curEnergy]);
536 for(
int j = 0; j < nhits; j++) {
537 source->GetEntry(entr++);
541 }
while (entr < nentr);
568 Float_t
x,
y,
z,e,time;
569 dest->Branch(
"x",&
x);
570 dest->Branch(
"y",&
y);
571 dest->Branch(
"z",&
z);
572 dest->Branch(
"e",&e);
573 dest->Branch(
"time",&time);
582 library::const_iterator libit;
584 x = (*libit).second.size();
590 distbin::const_iterator distit;
591 for (distit = (*libit).second.begin(); distit != (*libit).second.end(); ++distit) {
592 x = (*distit).second.size();
593 y = (*distit).second.getRSize();
594 z = (*distit).second.getZSize();
598 Shower::const_iterator iter;
599 for (iter = (*distit).second.begin(); iter != (*distit).second.end(); ++iter) {
600 x = (*iter)->GetPosition().x();
601 y = (*iter)->GetPosition().y();
602 z = (*iter)->GetPosition().z();
603 e = (*iter)->GetEnergy();
604 time = (*iter)->GetTime();
634 std::map<int, std::string> names;
635 std::map<int, int> sizes;
637 sizes[
calcKey(it->first)]=it->second.size();
638 float distlow = it->first;
640 library::const_iterator it_copy = it;
645 disthigh = it_copy->first;
647 std::stringstream
ss;
648 ss << std::showpos << std::fixed << std::setprecision(2);
649 ss <<
"DIST: " << distlow <<
" .. " << disthigh;