Changeset 19623 for trunk


Ignore:
Timestamp:
09/04/19 16:40:31 (5 years ago)
Author:
tbretz
Message:
Sanity check for a bad programming style.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/msimcamera/MSimCamera.cc

    r19622 r19623  
    410410    Double_t tot = 0;
    411411
    412     for (int i=0 ; i<1440 ; i++)
    413     {
    414         (*fTruePhotons->cherenkov_photons_weight)[i] = 0;
    415         (*fTruePhotons->cherenkov_photons_number)[i] = 0;
    416         (*fTruePhotons->cherenkov_arrival_time_mean)[i] = 0;
    417         (*fTruePhotons->cherenkov_arrival_time_variance)[i] = 0;
    418         (*fTruePhotons->muon_cherenkov_photons_weight)[i] = 0;
    419         (*fTruePhotons->muon_cherenkov_photons_number)[i] = 0;
    420         (*fTruePhotons->cherenkov_arrival_time_min)[i] = 10000;
    421         (*fTruePhotons->cherenkov_arrival_time_max)[i] = 0;
    422         (*fTruePhotons->noise_photons_weight)[i] = 0;
     412    // Sanity check for bad programming style
     413    if (npix==1440)
     414    {
     415        for (int i=0 ; i<1440 ; i++)
     416        {
     417            (*fTruePhotons->cherenkov_photons_weight)[i] = 0;
     418            (*fTruePhotons->cherenkov_photons_number)[i] = 0;
     419            (*fTruePhotons->cherenkov_arrival_time_mean)[i] = 0;
     420            (*fTruePhotons->cherenkov_arrival_time_variance)[i] = 0;
     421            (*fTruePhotons->muon_cherenkov_photons_weight)[i] = 0;
     422            (*fTruePhotons->muon_cherenkov_photons_number)[i] = 0;
     423            (*fTruePhotons->cherenkov_arrival_time_min)[i] = 10000;
     424            (*fTruePhotons->cherenkov_arrival_time_max)[i] = 0;
     425            (*fTruePhotons->noise_photons_weight)[i] = 0;
     426        }
    423427    }
    424428
     
    441445        // fFixTimeOffsetsBetweenPixelsInNs -> fM matrix. We identify the first
    442446        // column to hold the offsets in ns.
    443         t = t + freq*fFixTimeOffsetsBetweenPixelsInNs->fM[idx][0];
     447        t += freq*fFixTimeOffsetsBetweenPixelsInNs->fM[idx][0];
    444448
    445449        // Jens Buss on residual time spread:
    446450        // add random time offset to the arrivaltimes
    447         t = t + timeoffset[idx];
     451        t += timeoffset[idx];
    448452
    449453        // FIXME: Time jitter?
     
    451455        // add also a time offset to arrival times of single photons
    452456        // TODO: change to ns, use: fRunHeader->GetFreqSampling()
    453         Double_t timeJitter = gRandom->Gaus(0.0, gapdTimeJitter);
    454         t = t + timeJitter;
     457        t += gRandom->Gaus(0.0, gapdTimeJitter);
    455458
    456459        // FIXME: Add additional routing here?
     
    460463        {
    461464            tot += ph.GetWeight();
    462             (*fTruePhotons->cherenkov_photons_weight)[idx] += ph.GetWeight();
    463             (*fTruePhotons->cherenkov_photons_number)[idx] += 1;
    464 
    465             (*fTruePhotons->cherenkov_arrival_time_mean)[idx] += t;
    466             (*fTruePhotons->cherenkov_arrival_time_variance)[idx] += t*t;
    467 
    468             if (ph.GetPrimary()==MMcEvt::kMUON)
     465
     466            // Sanity check for bad programming style
     467            if (npix==1440)
    469468            {
    470                 (*fTruePhotons->muon_cherenkov_photons_weight)[idx] += ph.GetWeight();
    471                 (*fTruePhotons->muon_cherenkov_photons_number)[idx] += 1;
    472             }
    473 
    474             // find min
    475             if (t < (*fTruePhotons->cherenkov_arrival_time_min)[idx] )
    476             {
    477                 (*fTruePhotons->cherenkov_arrival_time_min)[idx] = t;
    478             }
    479             // find max
    480             if (t > (*fTruePhotons->cherenkov_arrival_time_max)[idx] )
    481             {
    482                (*fTruePhotons->cherenkov_arrival_time_max)[idx] = t;
     469                (*fTruePhotons->cherenkov_photons_weight)[idx] += ph.GetWeight();
     470                (*fTruePhotons->cherenkov_photons_number)[idx] += 1;
     471
     472                (*fTruePhotons->cherenkov_arrival_time_mean)[idx] += t;
     473                (*fTruePhotons->cherenkov_arrival_time_variance)[idx] += t*t;
     474
     475                if (ph.GetPrimary()==MMcEvt::kMUON)
     476                {
     477                    (*fTruePhotons->muon_cherenkov_photons_weight)[idx] += ph.GetWeight();
     478                    (*fTruePhotons->muon_cherenkov_photons_number)[idx] += 1;
     479                }
     480
     481                // find min
     482                if (t < (*fTruePhotons->cherenkov_arrival_time_min)[idx] )
     483                {
     484                    (*fTruePhotons->cherenkov_arrival_time_min)[idx] = t;
     485                }
     486                // find max
     487                if (t > (*fTruePhotons->cherenkov_arrival_time_max)[idx] )
     488                {
     489                    (*fTruePhotons->cherenkov_arrival_time_max)[idx] = t;
     490                }
    483491            }
    484492        }
    485493        else
    486494        {
    487             (*fTruePhotons->noise_photons_weight)[idx] += ph.GetWeight();
     495            // Sanity check for bad programming style
     496            if (npix==1440)
     497            {
     498                (*fTruePhotons->noise_photons_weight)[idx] += ph.GetWeight();
     499            }
    488500        }
    489501
     
    496508    }
    497509
    498     for (unsigned int i=0 ; i < 1440 ; i++)
    499     {
    500         float number = (*fTruePhotons->cherenkov_photons_number)[i];
    501         (*fTruePhotons->cherenkov_arrival_time_mean)[i] /= number;
    502         float mean = (*fTruePhotons->cherenkov_arrival_time_mean)[i];
    503         float sum_tt = (*fTruePhotons->cherenkov_arrival_time_variance)[i];
    504         (*fTruePhotons->cherenkov_arrival_time_variance)[i] = (sum_tt / number - mean*mean) /(number - 1);
     510    // Sanity check for bad programming style
     511    if (npix==1440)
     512    {
     513        for (unsigned int i=0 ; i < 1440 ; i++)
     514        {
     515            float number = (*fTruePhotons->cherenkov_photons_number)[i];
     516            (*fTruePhotons->cherenkov_arrival_time_mean)[i] /= number;
     517            float mean = (*fTruePhotons->cherenkov_arrival_time_mean)[i];
     518            float sum_tt = (*fTruePhotons->cherenkov_arrival_time_variance)[i];
     519            (*fTruePhotons->cherenkov_arrival_time_variance)[i] = (sum_tt / number - mean*mean) /(number - 1);
     520        }
    505521    }
    506522
Note: See TracChangeset for help on using the changeset viewer.