Ejemplo n.º 1
0
void checkOpenHLT::saveAllHistograms(const TString & name)
{
  saveHistograms("pt"+name);
  saveHistograms("eta"+name);
  saveHistograms("phi"+name);
  saveHistograms("nhits"+name);
  saveHistograms("nchambers"+name);
  saveHistogram((TH1F*)histoMap_["parallelism"+name]);
}
void SecondaryElectronsNeutrons(const char* fileName,int numEvents){

    double XMAX = 2.75;
    char histKey_1[128] ="secElectronKinE_00_01PID";
    char histKey_2[128] ="secElectronKinE_00_02PID";
    char histKey_3[128] ="secElectronKinE_00_03PID";
    char histKey_4[128] ="secElectronKinE_00_04PID";
    // Getting the files and thickness
    FILE* in = fopen(fileName,"r");
    TObjArray *files = new TObjArray();
    TObjArray *histPID1 = new TObjArray();
    TObjArray *histPID2 = new TObjArray();
    TObjArray *histPID3 = new TObjArray();
    TObjArray *histPID4 = new TObjArray();
    TObjArray *thickness = new TObjArray();
    char* token;
    TFile* f = NULL;
    TH1F* h = NULL;
    TH1F* hRef = NULL;
    TObjString *s = NULL;
    if (in != NULL){
        char line[128];
        while ( fscanf(in,"%s\n",line) == 1 ){
            f = new TFile(line,"READ");
            files->Add(f);
            // Getting the histograms
            h = (TH1F*) f->Get(histKey_1);
            histPID1->Add(h);
            h = (TH1F*) f->Get(histKey_2);
            histPID2->Add(h);
            h = (TH1F*) f->Get(histKey_3);
            histPID3->Add(h);
            h = (TH1F*) f->Get(histKey_4);
            histPID4->Add(h);
            token = strtok(line,"_");
            s = new TObjString(token);
            thickness->Add(s);
        }
        fclose(in);
    }
    else{
        perror(fileName);
    }
    fprintf(stdout,"Files:\n");
    files->Print();
    fprintf(stdout,"\nThickness:\n");
    thickness->Print();

    plotHistograms("SecElec_Neutrons_PID3.eps",histPID3,thickness,XMAX,"PID = 3","Electron Kinetic Energy (MeV)");
    plotHistograms("SecElec_Neutrons_PID4.eps",histPID4,thickness,XMAX,"PID = 4","Electron Kinetic Energy (MeV)");

    // Saving the histograms
    saveHistograms("Neutron_PID3_HistData.txt", histPID3, thickness);
    saveHistograms("Neutron_PID4_HistData.txt", histPID4, thickness);
}