14 #include <FairLogger.h> 
   31    fMap = std::make_shared<AtTpcMap>();
 
   32    auto mapFile = TString(getenv(
"VMCWORKDIR")) + 
"/scripts/e12014_pad_map_size.xml";
 
   33    fMap->ParseXMLMap(mapFile.Data());
 
   37    for (ref.aget = 0; ref.aget < 4; ++ref.aget) {
 
   38       for (ref.ch = 0; ref.ch < 68; ++ref.ch) {
 
   42    std::vector<AtPadReference> badPads = {{0, 1, 1, 6},  {0, 1, 1, 7},  {0, 1, 1, 9},  {0, 1, 1, 10},
 
   43                                           {0, 1, 1, 12}, {0, 1, 1, 39}, {0, 1, 1, 40}, {0, 1, 1, 41},
 
   44                                           {0, 1, 1, 44}, {0, 1, 1, 43}, {0, 1, 1, 46}, {0, 1, 3, 13}};
 
   46    for (
auto &badPad : badPads)
 
   50    std::ifstream file(
"/mnt/projects/hira/e12014/tpcSharedInfo/e12014_zap.csv");
 
   52       LOG(error) << 
"Failed to open smart zap file";
 
   56    std::getline(file, temp);
 
   57    std::getline(file, temp);
 
   60       LOG(debug) << 
"Inhibiting " << row[4];
 
   69       LOG(fatal) << 
"The map (E12014::fMap) was never set! Please call E12014::CreateMap()";
 
   71    std::set<int> usedPads;
 
   72    for (
auto &hit : hits) {
 
   77       usedPads.insert(hit->GetPadNum());
 
   79       auto pad = 
event.GetPad(hit->GetPadNum());
 
   83       const auto charge = pad->GetAugment<
AtPadArray>(qName);
 
   84       if (charge == 
nullptr)
 
   88       for (
int tb = 20; tb < 500; ++tb)
 
   89          if (charge->GetArray(tb) > threshold)
 
   90             hist->Fill(tb + 0.5, charge->GetArray(tb));
 
   94 std::set<int> 
E12014::FillHitSum(TH1 &hist, 
const std::vector<AtHit *> &hits, 
int threshold, 
float satThresh)
 
   96    std::vector<double> charge;
 
   97    auto pads = 
FillHitSum(charge, hits, threshold, satThresh);
 
  102 int E12014::FillHitSums(std::vector<double> &exp, std::vector<double> &sim, 
const std::vector<AtHit *> &expHits,
 
  103                         const std::vector<AtHit *> &simHits, 
int threshold, 
float satThresh, 
const AtDigiPar *fPar,
 
  104                         std::vector<double> *expADC, 
AtRawEvent *expEvent)
 
  107       LOG(fatal) << 
"The map (E12014::fMap) was never set!";
 
  111    std::fill_n(exp.begin(), 512, 0);
 
  114    std::fill_n(sim.begin(), 512, 0);
 
  118       std::fill_n(expADC->begin(), 512, 0);
 
  122    for (
auto &expHit : expHits) {
 
  125       if (expHit->GetCharge() > satThresh)
 
  128       if (
fMap->GetPadSize(expHit->GetPadNum()) != 0)
 
  132       if (funcExp == 
nullptr)
 
  137       AtHit *simHit = 
nullptr;
 
  138       for (
auto &hit : simHits) {
 
  139          if (expHit->GetPadNum() == hit->GetPadNum()) {
 
  144       if (simHit == 
nullptr)
 
  147       if (funcSim == 
nullptr)
 
  150       AtPad *pad = 
nullptr;
 
  152          pad = expEvent->
GetPad(expHit->GetPadNum());
 
  157       for (
int tb = 
fTBMin; tb < 512; ++tb) {
 
  159          auto val = funcExp->Eval(tb);
 
  160          if (val > threshold) {
 
  162             sim[tb] += funcSim->Eval(tb);
 
  164                (*expADC)[tb] += pad->
GetADC(tb);
 
  174       LOG(fatal) << 
"The map (E12014::fMap) was never set!";
 
  178    std::fill_n(sim.begin(), 512, 0);
 
  180    for (
auto &expHit : simHits) {
 
  183       if (funcExp == 
nullptr)
 
  186       for (
int tb = 
fTBMin; tb < 512; ++tb) {
 
  187          sim[tb] += funcExp->Eval(tb);
 
  192 void E12014::FillHits(std::vector<double> &exp, std::vector<double> &sim, 
const std::vector<AtHit *> &expHits,
 
  193                       const std::vector<AtHit *> &simHits, 
float satThresh)
 
  196       LOG(fatal) << 
"The map (E12014::fMap) was never set!";
 
  201    for (
auto &expHit : expHits) {
 
  204       if (expHit->GetCharge() > satThresh)
 
  206       if (expHit->GetPosition().z() < 50)
 
  208       if (
fMap->GetPadSize(expHit->GetPadNum()) != 0)
 
  212       exp.push_back(expHit->GetCharge());
 
  215       int padNum = expHit->GetPadNum();
 
  217          std::find_if(simHits.begin(), simHits.end(), [padNum](
const AtHit *a) { return a->GetPadNum() == padNum; });
 
  218       if (simHit == simHits.end())
 
  221          sim.push_back((*simHit)->GetCharge());
 
  225 void E12014::FillZPos(std::vector<double> &exp, std::vector<double> &sim, 
const std::vector<AtHit *> &expHits,
 
  226                       const std::vector<AtHit *> &simHits, 
float satThresh)
 
  229       LOG(fatal) << 
"The map (E12014::fMap) was never set!";
 
  234    for (
auto &expHit : expHits) {
 
  237       if (expHit->GetCharge() > satThresh)
 
  240       if (
fMap->GetPadSize(expHit->GetPadNum()) != 0)
 
  244       int padNum = expHit->GetPadNum();
 
  246          std::find_if(simHits.begin(), simHits.end(), [padNum](
const AtHit *a) { return a->GetPadNum() == padNum; });
 
  247       if (simHit != simHits.end()) {
 
  249          exp.push_back(expHit->GetPosition().z());
 
  250          sim.push_back((*simHit)->GetPosition().z());
 
  256 E12014::FillHitSum(std::vector<double> &vec, 
const std::vector<AtHit *> &hits, 
int threshold, 
float satThresh)
 
  260    std::fill_n(vec.begin(), 512, 0);
 
  261    std::set<int> goodPads;
 
  264       LOG(fatal) << 
"The map (E12014::fMap) was never set!";
 
  266    for (
auto &hit : hits) {
 
  269       if (hit->GetCharge() > satThresh)
 
  277       for (
int tb = 0; tb < vec.size(); ++tb) {
 
  278          auto val = func->Eval(tb);
 
  283       goodPads.insert(hit->GetPadNum());
 
  290                            int threshold, 
float satThresh)
 
  292    std::vector<double> charge;
 
  293    FillSimHitSum(charge, hits, goodPads, amp, threshold, satThresh);
 
  297 void E12014::FillSimHitSum(std::vector<double> &vec, 
const std::vector<AtHit *> &hits, 
const std::set<int> &goodPads,
 
  298                            double amp, 
int threshold, 
float satThresh)
 
  302    std::fill_n(vec.begin(), 512, 0);
 
  304    for (
auto &hit : hits) {
 
  305       if (goodPads.find(hit->GetPadNum()) == goodPads.end()) {
 
  306          LOG(debug) << 
"Skipping pad " << hit->GetPadNum() << 
" because not good";
 
  309       if (hit->GetCharge() > satThresh)
 
  317       LOG(debug) << 
"Adding pad " << hit->GetPadNum();
 
  319       for (
int tb = 0; tb < vec.size(); ++tb) {
 
  320          auto val = func->Eval(tb) * amp;