Energy calibration with TRandom

Hey everyone!

I have two different data sets (gammaspectra) with two different energy calibrations. In the past I simply used SetRangeUser to transform my uncalibrated histograms into calibrated ones. However, if I apply this method to the two different data sets this leads to a different binning.

Now I tried to use a TRandom generator but it always get a segmentation violation.

    for(int n=0; n<23; n++) { 
  //loop over all 23 uncalibrated histograms histo_raw[n]

            TRandom3 *r=new TRandom3(0);

            //loop over all 16384 channels
            for(int k=0;k<16384;k++){
  
            Long64_t counts=histo_raw[n]->GetBinContent(k); //number of counts in each bin
            Double_t center=histo_raw[n]->GetBinCenter(k);

                // loop over all counts in each bin
                for(Long64_t j=0;j<counts;j++){
                              
                    Double_t ea=center+r->Rndm()*0.2-0.1;
                    Double_t cal=Quad1*ea*ea + Slope1*ea + Offset1; //energy calibration
                    calib_histo[n]->Fill(cal); //fill count in the new histogram
                 }
            } 

        }

What am I doing wrong? :smiley:

Where ? can you provide a running macro reproducing the error ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.