Esempio n. 1
0
TH1F* get_pid_count_hist(const TString filename, const TString histname, const int counter) 
{
    // counter 5, look at the numbers at the beam pipe
    // const int counter = 5; 
    // TString filename = "../../output/final_900M/final_st_Copper_0.5mm_deg_Air_5mm.root";
    TH1F* hist = make_hist(histname);
    TFile* file = new TFile(filename, "READ");
    TTree* tree = (TTree*) file->Get("t");
    
    in_branch branch; 
    set_addresses(tree, branch);
    
    const int n_entries = tree->GetEntries();
    // const int n_entries = 100;
    for (int entry = 0; entry < n_entries; ++entry)
    { // Loop over all the entries
        tree->GetEntry(entry);
        for (int hit = 0; hit < branch.n_hits; ++hit)
        { // Loop over the hits and fill the histograms
            
            // Skip anything that's not at the correct counter or the first step
            if ( branch.counter[hit] != counter) continue;
            if (!branch.first_step)              continue; // don't double count
            // Translate the PDG id into a bin number (needs cast)
            const int bin_num = get_bin_number((pdg_id) branch.pdgid[hit]);
            // get_bin_number returns -1 if not a charged particle
            if (bin_num == BIN_ERROR) continue;
            hist->Fill(bin_num);
        }
    }
    
    file->Close();
    return hist;
}
Esempio n. 2
0
void ds::BinnedData::add_data_at(double data_point, double data_value)
{
    //Find the appropriate bin
    if ( data_point <= max_range() && data_point >= min_range() ) 
    {
        int bin = get_bin_number(data_point);
        if(bin != -1)
        {   
            _data[bin] += data_value;
            _counts[bin]++;
        }
    }
} 
Esempio n. 3
0
TString get_particle_name (const int id)
{ // Get a string of the particle name 
    
    // If the id isn't a particle_bin id then convert it to one
    // (assuming that it *is* a pdg id)
    const int id_i = (1 <= id && id <= 7) ? id : get_bin_number((pdg_id) id);
    
    switch (id_i) 
    {
        case BIN_PI_MINUS : return TString ("#pi-");
        case BIN_MU_PLUS  : return TString ("#mu+");
        case BIN_E_PLUS   : return TString ("e+");
        case BIN_E_MINUS  : return TString ("e-");
        case BIN_MU_MINUS : return TString ("#mu-");
        case BIN_PI_PLUS  : return TString ("#pi+");
        case BIN_PROTON   : return TString ("p");
        default           : return TString ("ERROR");
    }
}
Esempio n. 4
0
double ds::BinnedData::average_at(double data_point) const
{   
    return average_in(get_bin_number(data_point));       
}
Esempio n. 5
0
double ds::BinnedData::sum_at(double data_point) const
{   
    return sum_in(get_bin_number(data_point));      
}