]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Noise problem identified with source
authorDennis Doering <dennis@jspc31.x-matter.uni-frankfurt.de>
Thu, 19 Sep 2013 14:34:01 +0000 (16:34 +0200)
committerDennis Doering <dennis@jspc31.x-matter.uni-frankfurt.de>
Thu, 19 Sep 2013 14:34:01 +0000 (16:34 +0200)
newCOMBI/ChargeSpektrum.c
newCOMBI/MAPS.C
newCOMBI/run.C

index 88c8f52162347753e810c1a7f9845c7bbd767de0..fbfc45ed599d1220c7fa69f7663c38ae2359d33d 100755 (executable)
@@ -57,10 +57,18 @@ struct histogram
  Float_t posVeto;
  struct laborbook laborbookdata;
 };
+struct noise
+{
+ TH1F* noiseHisto;
+ Int_t inputRun;
+ Double_t quantiles;
+ struct laborbook laborbookdata;
+};
 struct histogram GenerateHisto(Int_t inputRun);
 Float_t FitPerform(TH1F*, Int_t);
 struct laborbook LaborBuch(Int_t inputRun);
 Int_t* ReadRunList(Int_t* numberRuns);
+struct noise Noise(Int_t inputRun);
 void ChargeSpektrum()
 {
          
@@ -68,10 +76,13 @@ void ChargeSpektrum()
                ReadRunList(&numberRuns);
        Int_t* runList=new Int_t[numberRuns];
        runList=ReadRunList(&numberRuns);
-
+       
+       
        struct histogram* arrayHisto = new struct histogram[numberRuns];
+       struct noise* noiseHisto = new struct noise[numberRuns];
        for(Int_t lauf=0;lauf<numberRuns;lauf++)
        {
+               noiseHisto[lauf]=Noise(runList[lauf]);
                arrayHisto[lauf]=GenerateHisto(runList[lauf]);
        }
        
@@ -90,7 +101,7 @@ void ChargeSpektrum()
        for(Int_t lauf=0;lauf<numberRuns;lauf++)
        {       
                TString header ="Start\t";
-           TString outline=header+Form("%i", arrayHisto[lauf].inputRun)+"\t"+arrayHisto[lauf].laborbookdata.source+"\t"+arrayHisto[lauf].laborbookdata.matrix+"\t"+Form("%.2f", arrayHisto[lauf].posSeed)+"\t"+Form("%.2f", arrayHisto[lauf].posSum)+"\t"+Form("%.2f", arrayHisto[lauf].posVeto);
+           TString outline=header+Form("%i", arrayHisto[lauf].inputRun)+"\t"+arrayHisto[lauf].laborbookdata.source+"\t"+arrayHisto[lauf].laborbookdata.matrix+"\t"+Form("%.2f", arrayHisto[lauf].posSeed)+"\t"+Form("%.2f", arrayHisto[lauf].posSum)+"\t"+Form("%.2f", arrayHisto[lauf].posVeto)+"\t"+Form("%.2f", noiseHisto[lauf].quantiles);
 
                cout<<outline<<endl;
                *fout<<outline<<endl;
@@ -269,7 +280,8 @@ struct histogram GenerateHisto(Int_t inputRun)
          arrayHisto.posSum=posSum;
          arrayHisto.posVeto=posVeto;
          arrayHisto.laborbookdata=laborbookdata;
-return arrayHisto;}
+return arrayHisto;
+}
 
 Float_t FitPerform(TH1F* histNtuple, Int_t inputRun)
 {
@@ -353,6 +365,61 @@ if (DRAW_FITS)
        
 return posMax;
 }
+struct noise Noise(Int_t inputRun)
+{
+         // Read Laborbook, save it in the struct laborbookdata
+         struct laborbook laborbookdata;
+         laborbookdata=LaborBuch(inputRun);
+         TString path = TString(DATAPATH) + Form("%i_0.root", inputRun);
+         TFile* f = TFile::Open(path);
+         if (f->IsZombie()) 
+         {
+           // if we cannot open the file, print an error messageForm("hist%i",nHistNtuple) and return immediatly
+           printf("Error: cannot open %s\n", path.Data());
+           exit(0);
+         }
+         // get a pointer to the tree
+         TNtuple* noiseNtuple = (TNtuple*) f->Get("noise");
+         
+         Float_t noise;
+         TBranch* noiseBranch;
+         noiseNtuple->SetBranchAddress("noise", &noise, &noiseBranch);
+         // create histogram
+         TH1F* histNoise = new TH1F(Form("Noise%i",inputRun), "Noise title", 100, 0, 10);
+         
+         Int_t nentries_N = noiseNtuple->GetEntries();
+         for (Int_t cnt=0; cnt<nentries_N; cnt++) {
+           noiseNtuple->GetEntry(cnt);
+           histNoise->Fill(noise);
+         }
+         
+         // get median and error estimation
+         Double_t const probabilities[] = {0.3415/2, 0.5, 1-0.3415/2}; // sigma/2 from gaus to the left and to the right //{0.17, 0.5, 1-0.17};
+         Double_t quantiles[3];
+         histNoise->GetQuantiles( 3, quantiles, probabilities);
+       //  noiseLowest17percent.push_back((Float_t) quantiles[0]);     // left error bar (lowest 17% noise values are below this quantile)
+       //  noiseMedian.push_back((Float_t) quantiles[1]);              // median of the noise distribution
+       //  noiseHighest17percent.push_back((Float_t) quantiles[2]);    // right error bar (highest 17% noise values are higher than this quantile)
+         cout << "q1: " << quantiles[1] - quantiles[0] << "\tq2: " << quantiles[1] << "\tq3: " << quantiles[2] - quantiles[1] << endl;
+         
+         
+          TCanvas* cNoise = new TCanvas();
+          cNoise->SetTitle(Form("Noise%i",inputRun));
+          histNoise->Draw();
+          TString  legendEntry = TString(Form("Run %i: %.3f %.3f  %.3f",inputRun,quantiles[1],quantiles[1] - quantiles[0],quantiles[2] - quantiles[1] ));
+          TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89);
+       leg->SetFillStyle(0);
+          leg->AddEntry((TObject*) 0, legendEntry, "");
+          leg->SetTextSize(0.03);
+          leg->Draw();
+         struct noise noiseHisto;
+         noiseHisto.noiseHisto=(TH1F*)histNoise->Clone(Form("NoiseX%i",inputRun));
+         noiseHisto.inputRun=inputRun;
+         noiseHisto.quantiles=quantiles[1];
+         noiseHisto.laborbookdata=laborbookdata;
+         //-------------------------------------------------
+return noiseHisto;
+}
 struct laborbook LaborBuch(Int_t inputRun)
 {
   std::string  system;
index 1ce08b22f20498faa386d555e49125d77d4232da..396d29657021be625f0c5e6ff20fa0898bba2697 100755 (executable)
@@ -554,6 +554,7 @@ bool MAPS::getNoise(Int_t Start, Int_t Frames) {
                        
                        for(Int_t j=0; j<Frames;j++)
                        {
+                               if(ARR[j*fPixels+i]>5*PEDESTAL) continue; //throw all frames with a signal >5pedestal away, because of postulated signal charge
                                NOISE+=TMath::Power(ARR[j*fPixels+i]-PEDESTAL,2);
                        }
 
index 3063ddc89abdc4a76499bee4dd51f1dedd31150d..7484688afc85fae4d50172e47c14b1ee118a4bd7 100755 (executable)
@@ -19,7 +19,7 @@ void run()
 //-------------------------------------------------------
        TString path            = "/jspc12_F/Mi32/";
        TString outpath         = "/d/salt/data_recovered/maps/DennisDoering/root/Analysedata/";
-       Int_t   runStart        = 341252;
+       Int_t   runStart        = 34009;
        Int_t   rows            = 8;
        Int_t   columns         = 64;
        TString system          = "USB";
@@ -35,7 +35,7 @@ void run()
        ULong_t progress_tmp=-1;
        Float_t progress;
 //-------------------------------------------------------
-for(Int_t runLauf=0;runLauf<9;runLauf++)
+for(Int_t runLauf=0;runLauf<3;runLauf++)
        {
         Int_t runnumber = runStart+runLauf;
                if(loadNoise)