| 1 | #include "TH1F.h"
|
|---|
| 2 | #include "TH2F.h"
|
|---|
| 3 | #include "TH3F.h"
|
|---|
| 4 | #include "TLine.h"
|
|---|
| 5 | #include "TTree.h"
|
|---|
| 6 |
|
|---|
| 7 | #include "TCanvas.h"
|
|---|
| 8 | #include "TStyle.h"
|
|---|
| 9 | #include "TString.h"
|
|---|
| 10 | #include "TFile.h"
|
|---|
| 11 | #include "TMath.h"
|
|---|
| 12 |
|
|---|
| 13 | #include "MReadTree.h"
|
|---|
| 14 | #include "MSrcPosCam.h"
|
|---|
| 15 | #include "MWriteRootFile.h"
|
|---|
| 16 | #include "MParList.h"
|
|---|
| 17 | #include "MTaskList.h"
|
|---|
| 18 | #include "MEvtLoop.h"
|
|---|
| 19 |
|
|---|
| 20 | #include "MHillas.h"
|
|---|
| 21 | #include "MHillasExt.h"
|
|---|
| 22 | #include "MHillasExt.h"
|
|---|
| 23 | #include "MHillasSrc.h"
|
|---|
| 24 | #include "MNewImagePar.h"
|
|---|
| 25 |
|
|---|
| 26 | #include "MTaskInteractive.h"
|
|---|
| 27 |
|
|---|
| 28 | #include "iostream.h"
|
|---|
| 29 | #include "stdlib.h"
|
|---|
| 30 | #include "stdio.h"
|
|---|
| 31 | #include "string.h"
|
|---|
| 32 |
|
|---|
| 33 | //--------------------------------------------------------------------------------------
|
|---|
| 34 | // MAIN INPUT/OUTPUT
|
|---|
| 35 |
|
|---|
| 36 | #include "IOMkn421.h"
|
|---|
| 37 | //--------------------------------------------------------------------------------------
|
|---|
| 38 |
|
|---|
| 39 | Double_t estposx = 0.;
|
|---|
| 40 | Double_t estposy = 0.;
|
|---|
| 41 |
|
|---|
| 42 | //--------------------------------------------------------------------------------------
|
|---|
| 43 | // setting for hists
|
|---|
| 44 | const Int_t nBinSize=200;
|
|---|
| 45 | const Int_t nBinDist=1;
|
|---|
| 46 | const Int_t nBinLW=1000;
|
|---|
| 47 |
|
|---|
| 48 | // limits for size and dist for histograms
|
|---|
| 49 | Double_t hSizeLo=2.;
|
|---|
| 50 | Double_t hSizeUp=6.;
|
|---|
| 51 | Double_t hDistLo=0.5;
|
|---|
| 52 | Double_t hDistUp=1.15;
|
|---|
| 53 |
|
|---|
| 54 | // limits for length, width for histograms
|
|---|
| 55 | Double_t hLengthLo=0.;
|
|---|
| 56 | Double_t hLengthUp=0.8;
|
|---|
| 57 | Double_t hWidthLo =0.;
|
|---|
| 58 | Double_t hWidthUp =0.6;
|
|---|
| 59 |
|
|---|
| 60 | // limits for scaled Hillas for histograms
|
|---|
| 61 | Double_t hSLenLo =0.;
|
|---|
| 62 | Double_t hSLenUp =15.;
|
|---|
| 63 | Double_t hSWidLo =0.;
|
|---|
| 64 | Double_t hSWidUp =7.;
|
|---|
| 65 |
|
|---|
| 66 | // special limits for hLength, hWidth (see ReadHillas())
|
|---|
| 67 | const Int_t nBinLWFine=1000;
|
|---|
| 68 | Double_t hLenFineLo=0.;
|
|---|
| 69 | Double_t hLenFineUp=1.;
|
|---|
| 70 | Double_t hWidFineLo=0.;
|
|---|
| 71 | Double_t hWidFineUp=1.;
|
|---|
| 72 |
|
|---|
| 73 | // hists for mean of unscaled Hillas
|
|---|
| 74 | TH2F hLenMean("hLenMean","",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp);
|
|---|
| 75 | TH2F hWidMean("hWidMean","",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp);
|
|---|
| 76 |
|
|---|
| 77 | TH1F hLenMeanSize("hLenMeanSize","",nBinSize,hSizeLo,hSizeUp);
|
|---|
| 78 | TH1F hLenMeanDist("hLenMeanDist","",nBinDist,hDistLo,hDistUp);
|
|---|
| 79 | TH1F hWidMeanSize("hWidMeanSize","",nBinSize,hSizeLo,hSizeUp);
|
|---|
| 80 | TH1F hWidMeanDist("hWidMeanDist","",nBinDist,hDistLo,hDistUp);
|
|---|
| 81 |
|
|---|
| 82 | // hists for unscaled Hillas
|
|---|
| 83 | TH2F hLenSize("hLenSize","",nBinSize,hSizeLo,hSizeUp, nBinLW,hLengthLo,hLengthUp);
|
|---|
| 84 | TH2F hLenDist("hLenDist","",nBinDist,hDistLo,hDistUp, nBinLW,hLengthLo,hLengthUp);
|
|---|
| 85 |
|
|---|
| 86 | TH2F hWidSize("hWidSize","",nBinSize,hSizeLo,hSizeUp, nBinLW,hWidthLo,hWidthUp);
|
|---|
| 87 | TH2F hWidDist("hWidDist","",nBinDist,hDistLo,hDistUp, nBinLW,hWidthLo,hWidthUp);
|
|---|
| 88 |
|
|---|
| 89 | // hists for mean-scaled Hillas
|
|---|
| 90 | TH2F hSLenSize("hSLenSize","",nBinSize,hSizeLo,hSizeUp,nBinLW,hSLenLo,hSLenUp);
|
|---|
| 91 | TH2F hSLenDist("hSLenDist","",nBinDist,hDistLo,hDistUp,nBinLW,hSLenLo,hSLenUp);
|
|---|
| 92 |
|
|---|
| 93 | TH2F hSWidSize("hSWidSize","",nBinSize,hSizeLo,hSizeUp,nBinLW,hSWidLo,hSWidUp);
|
|---|
| 94 | TH2F hSWidDist("hSWidDist","",nBinDist,hDistLo,hDistUp,nBinLW,hSWidLo,hSWidUp);
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | //****************************************************************************************
|
|---|
| 98 | // first part: prepare for scaling, read Hillas to calc mean
|
|---|
| 99 | //****************************************************************************************
|
|---|
| 100 |
|
|---|
| 101 | void ReadHillas()
|
|---|
| 102 | {
|
|---|
| 103 | // fill hillas into histograms to calc mean
|
|---|
| 104 | TFile *file=new TFile(fileHillas.Data());
|
|---|
| 105 | TTree *fEvents=(TTree*)file->Get("Events");
|
|---|
| 106 |
|
|---|
| 107 | // hists for Hillas
|
|---|
| 108 | // in following 2 hists the binning in length/width should be
|
|---|
| 109 | // very fine (like unbinned) and the limits should be generous
|
|---|
| 110 | TH3F hLength("hLength","",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp, nBinLWFine,hLenFineLo,hLenFineUp);
|
|---|
| 111 | TH3F hWidth("hWidth", "",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp, nBinLWFine,hWidFineLo,hWidFineUp);
|
|---|
| 112 |
|
|---|
| 113 | TString strlen = Form("MHillas.fLength*%f:MHillasSrc.fDist*%f:log10(MHillas.fSize)",mm2deg,mm2deg);
|
|---|
| 114 | TString strwid = Form("MHillas.fWidth*%f :MHillasSrc.fDist*%f:log10(MHillas.fSize)",mm2deg,mm2deg);
|
|---|
| 115 |
|
|---|
| 116 | TString strcut="MHillas.fSize>0";
|
|---|
| 117 | fEvents->Project("hLength",strlen.Data(),strcut.Data());
|
|---|
| 118 | fEvents->Project("hWidth", strwid.Data(),strcut.Data());
|
|---|
| 119 |
|
|---|
| 120 | file->Close();
|
|---|
| 121 |
|
|---|
| 122 | // fill hists hLenMean, hWidMean (2-dim (size,dist)-hists)
|
|---|
| 123 | for(Int_t i=1;i<=nBinSize;i++)
|
|---|
| 124 | for(Int_t j=1;j<=nBinDist;j++)
|
|---|
| 125 | {
|
|---|
| 126 | Double_t lsum=0.; Double_t lsum2=0.; Double_t lcnt=0.;
|
|---|
| 127 | Double_t wsum=0.; Double_t wsum2=0.; Double_t wcnt=0.;
|
|---|
| 128 |
|
|---|
| 129 | for(Int_t k=1;k<=nBinLWFine;k++)
|
|---|
| 130 | {
|
|---|
| 131 | Double_t nl = hLength.GetBinContent(i,j,k);
|
|---|
| 132 | Double_t xl = hLength.GetZaxis()->GetBinCenter(k);
|
|---|
| 133 |
|
|---|
| 134 | lsum +=nl*xl;
|
|---|
| 135 | lsum2+=nl*xl*xl;
|
|---|
| 136 | lcnt +=nl;
|
|---|
| 137 |
|
|---|
| 138 | Double_t nw = hWidth.GetBinContent(i,j,k);
|
|---|
| 139 | Double_t xw = hWidth.GetZaxis()->GetBinCenter(k);
|
|---|
| 140 |
|
|---|
| 141 | wsum +=nw*xw;
|
|---|
| 142 | wsum2+=nw*xw*xw;
|
|---|
| 143 | wcnt +=nw;
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | Double_t lmean=0.;
|
|---|
| 147 | Double_t lmeanerr=0.;
|
|---|
| 148 | if(lcnt>1)lmean=lsum/lcnt;
|
|---|
| 149 | if(lcnt>2)lmeanerr=(lsum2/lcnt-lmean*lmean)/(lcnt-1.);
|
|---|
| 150 | lmeanerr=TMath::Sqrt(lmeanerr);
|
|---|
| 151 |
|
|---|
| 152 | hLenMean.SetBinContent(i,j,lmean);
|
|---|
| 153 | hLenMean.SetBinError(i,j,lmeanerr);
|
|---|
| 154 |
|
|---|
| 155 | Double_t wmean=0.;
|
|---|
| 156 | Double_t wmeanerr=0.;
|
|---|
| 157 | if(wcnt>1)wmean=wsum/wcnt;
|
|---|
| 158 | if(wcnt>2)wmeanerr=(wsum2/wcnt-wmean*wmean)/(wcnt-1.);
|
|---|
| 159 | wmeanerr=TMath::Sqrt(wmeanerr);
|
|---|
| 160 |
|
|---|
| 161 | hWidMean.SetBinContent(i,j,wmean);
|
|---|
| 162 | hWidMean.SetBinError(i,j,wmeanerr);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | // fill hists hLenMeanSize, hWidMeanSize (1-dim hists, x-axis = size)
|
|---|
| 166 | for(Int_t i=1;i<=nBinSize;i++)
|
|---|
| 167 | {
|
|---|
| 168 | Double_t lsum=0.; Double_t lsum2=0.; Double_t lcnt=0.;
|
|---|
| 169 | Double_t wsum=0.; Double_t wsum2=0.; Double_t wcnt=0.;
|
|---|
| 170 |
|
|---|
| 171 | for(Int_t j=1;j<=nBinDist;j++)
|
|---|
| 172 | for(Int_t k=1;k<=nBinLWFine;k++)
|
|---|
| 173 | {
|
|---|
| 174 | Double_t nl = hLength.GetBinContent(i,j,k);
|
|---|
| 175 | Double_t xl = hLength.GetZaxis()->GetBinCenter(k);
|
|---|
| 176 |
|
|---|
| 177 | lsum +=nl*xl;
|
|---|
| 178 | lsum2+=nl*xl*xl;
|
|---|
| 179 | lcnt +=nl;
|
|---|
| 180 |
|
|---|
| 181 | Double_t nw = hWidth.GetBinContent(i,j,k);
|
|---|
| 182 | Double_t xw = hWidth.GetZaxis()->GetBinCenter(k);
|
|---|
| 183 |
|
|---|
| 184 | wsum +=nw*xw;
|
|---|
| 185 | wsum2+=nw*xw*xw;
|
|---|
| 186 | wcnt +=nw;
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | Double_t lmean=0.;
|
|---|
| 190 | Double_t lmeanerr=0.;
|
|---|
| 191 | if(lcnt>1)lmean=lsum/lcnt;
|
|---|
| 192 | if(lcnt>2)lmeanerr=(lsum2/lcnt-lmean*lmean)/(lcnt-1.);
|
|---|
| 193 | lmeanerr=TMath::Sqrt(lmeanerr);
|
|---|
| 194 |
|
|---|
| 195 | hLenMeanSize.SetBinContent(i,lmean);
|
|---|
| 196 | hLenMeanSize.SetBinError(i,lmeanerr);
|
|---|
| 197 |
|
|---|
| 198 | Double_t wmean=0.;
|
|---|
| 199 | Double_t wmeanerr=0.;
|
|---|
| 200 | if(wcnt>1)wmean=wsum/wcnt;
|
|---|
| 201 | if(wcnt>2)wmeanerr=(wsum2/wcnt-wmean*wmean)/(wcnt-1.);
|
|---|
| 202 | wmeanerr=TMath::Sqrt(wmeanerr);
|
|---|
| 203 |
|
|---|
| 204 | hWidMeanSize.SetBinContent(i,wmean);
|
|---|
| 205 | hWidMeanSize.SetBinError(i,wmeanerr);
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | // fill hists hLenMeanDist, hWidMeanDist (1-dim hists, x-axis = dist)
|
|---|
| 209 | for(Int_t j=1;j<=nBinDist;j++)
|
|---|
| 210 | {
|
|---|
| 211 | Double_t lsum=0.; Double_t lsum2=0.; Double_t lcnt=0.;
|
|---|
| 212 | Double_t wsum=0.; Double_t wsum2=0.; Double_t wcnt=0.;
|
|---|
| 213 |
|
|---|
| 214 | for(Int_t i=1;i<=nBinSize;i++)
|
|---|
| 215 | for(Int_t k=1;k<=nBinLWFine;k++)
|
|---|
| 216 | {
|
|---|
| 217 | Double_t nl = hLength.GetBinContent(i,j,k);
|
|---|
| 218 | Double_t xl = hLength.GetZaxis()->GetBinCenter(k);
|
|---|
| 219 |
|
|---|
| 220 | lsum +=nl*xl;
|
|---|
| 221 | lsum2+=nl*xl*xl;
|
|---|
| 222 | lcnt +=nl;
|
|---|
| 223 |
|
|---|
| 224 | Double_t nw = hWidth.GetBinContent(i,j,k);
|
|---|
| 225 | Double_t xw = hWidth.GetZaxis()->GetBinCenter(k);
|
|---|
| 226 |
|
|---|
| 227 | wsum +=nw*xw;
|
|---|
| 228 | wsum2+=nw*xw*xw;
|
|---|
| 229 | wcnt +=nw;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | Double_t lmean=0.;
|
|---|
| 233 | Double_t lmeanerr=0.;
|
|---|
| 234 | if(lcnt>1)lmean=lsum/lcnt;
|
|---|
| 235 | if(lcnt>2)lmeanerr=(lsum2/lcnt-lmean*lmean)/(lcnt-1.);
|
|---|
| 236 | lmeanerr=TMath::Sqrt(lmeanerr);
|
|---|
| 237 |
|
|---|
| 238 | hLenMeanDist.SetBinContent(j,lmean);
|
|---|
| 239 | hLenMeanDist.SetBinError(j,lmeanerr);
|
|---|
| 240 |
|
|---|
| 241 | Double_t wmean=0.;
|
|---|
| 242 | Double_t wmeanerr=0.;
|
|---|
| 243 | if(wcnt>1)wmean=wsum/wcnt;
|
|---|
| 244 | if(wcnt>2)wmeanerr=(wsum2/wcnt-wmean*wmean)/(wcnt-1.);
|
|---|
| 245 | wmeanerr=TMath::Sqrt(wmeanerr);
|
|---|
| 246 |
|
|---|
| 247 | hWidMeanDist.SetBinContent(j,wmean);
|
|---|
| 248 | hWidMeanDist.SetBinError(j,wmeanerr);
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | return;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 | //****************************************************************************************
|
|---|
| 256 | // second part: do scaling
|
|---|
| 257 | //****************************************************************************************
|
|---|
| 258 |
|
|---|
| 259 | // pointer to Hillas ParContainer
|
|---|
| 260 | MHillas *fHillas=NULL;
|
|---|
| 261 | MHillasSrc *fHillasSrc=NULL;
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 | Int_t PreProcess(MParList *plist)
|
|---|
| 265 | {
|
|---|
| 266 | fHillas = (MHillas*) plist->FindObject("MHillas");
|
|---|
| 267 | fHillasSrc = (MHillasSrc*) plist->FindObject("MHillasSrc");
|
|---|
| 268 |
|
|---|
| 269 | return (fHillas && fHillasSrc) ? kTRUE : kFALSE;
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | Int_t Process()
|
|---|
| 273 | {
|
|---|
| 274 | // estimated source pos.
|
|---|
| 275 | MSrcPosCam srcpos;
|
|---|
| 276 | srcpos.SetXY(estposx*deg2mm,estposy*deg2mm);
|
|---|
| 277 | fHillasSrc->SetSrcPos(&srcpos);
|
|---|
| 278 | fHillasSrc->Calc(fHillas);
|
|---|
| 279 |
|
|---|
| 280 | Float_t width = fHillas->GetWidth();
|
|---|
| 281 | Float_t length = fHillas->GetLength();
|
|---|
| 282 | Float_t size = fHillas->GetSize();
|
|---|
| 283 | Float_t meanx = fHillas->GetMeanX();
|
|---|
| 284 | Float_t meany = fHillas->GetMeanY();
|
|---|
| 285 | Float_t logsize = TMath::Log10(fHillas->GetSize());
|
|---|
| 286 | Float_t delta = fHillas->GetDelta();
|
|---|
| 287 | Float_t dist = fHillasSrc->GetDist();
|
|---|
| 288 |
|
|---|
| 289 | width *=mm2deg;
|
|---|
| 290 | length*=mm2deg;
|
|---|
| 291 | dist *=mm2deg;
|
|---|
| 292 |
|
|---|
| 293 | hLenSize.Fill(logsize,length);
|
|---|
| 294 | hLenDist.Fill(dist,length);
|
|---|
| 295 | hWidSize.Fill(logsize,width);
|
|---|
| 296 | hWidDist.Fill(dist,width);
|
|---|
| 297 |
|
|---|
| 298 | // (log(size), dist) - bin
|
|---|
| 299 | Int_t ix=hLenMean.GetXaxis()->FindBin(logsize);
|
|---|
| 300 | Int_t iy=hLenMean.GetYaxis()->FindBin(dist);
|
|---|
| 301 |
|
|---|
| 302 | // check for over-/underflow
|
|---|
| 303 | /*if(ix*iy==0 || ix>nBinSize || iy>nBinDist)
|
|---|
| 304 | {
|
|---|
| 305 | cout<<"Warning, over-/underflow: Log(size)-bin="<<ix;
|
|---|
| 306 | cout<<" Dist-bin="<<iy<<endl<<flush;
|
|---|
| 307 | }*/
|
|---|
| 308 | if(ix==0)ix=1;if(ix==nBinSize+1)ix=nBinSize;
|
|---|
| 309 | if(iy==0)iy=1;if(iy==nBinDist+1)iy=nBinDist;
|
|---|
| 310 |
|
|---|
| 311 | Float_t lq=hLenMean.GetBinContent(ix,iy);
|
|---|
| 312 | Float_t wq=hWidMean.GetBinContent(ix,iy);
|
|---|
| 313 |
|
|---|
| 314 | if(lq>0.)lq=1./lq;
|
|---|
| 315 | if(wq>0.)wq=1./wq;
|
|---|
| 316 |
|
|---|
| 317 | width *=wq;
|
|---|
| 318 | length*=lq;
|
|---|
| 319 |
|
|---|
| 320 | hSLenSize.Fill(logsize,length);
|
|---|
| 321 | hSLenDist.Fill(dist,length);
|
|---|
| 322 | hSWidSize.Fill(logsize,width);
|
|---|
| 323 | hSWidDist.Fill(dist,width);
|
|---|
| 324 |
|
|---|
| 325 | // --------------------------------------------------------------------------
|
|---|
| 326 | //
|
|---|
| 327 | // This function is ment for special usage, please never try to set
|
|---|
| 328 | // values via this function
|
|---|
| 329 | //
|
|---|
| 330 | /* void MHillas::Set(const TArrayF &arr)
|
|---|
| 331 | {
|
|---|
| 332 | if (arr.GetSize() != 6)
|
|---|
| 333 | return;
|
|---|
| 334 |
|
|---|
| 335 | fLength = arr.At(0); // [mm] major axis of ellipse
|
|---|
| 336 | fWidth = arr.At(1); // [mm] minor axis of ellipse
|
|---|
| 337 | fDelta = arr.At(2); // [rad] angle of major axis with x-axis
|
|---|
| 338 | fSize = arr.At(3); // [#CerPhot] sum of content of all pixels (number of Cherenkov photons)
|
|---|
| 339 | fMeanX = arr.At(4); // [mm] x-coordinate of center of ellipse
|
|---|
| 340 | fMeanY = arr.At(5); // [mm] y-coordinate of center of ellipse
|
|---|
| 341 | }*/
|
|---|
| 342 |
|
|---|
| 343 | TArrayF farr(6);
|
|---|
| 344 | farr[0]=length;
|
|---|
| 345 | farr[1]=width;
|
|---|
| 346 | farr[2]=delta;
|
|---|
| 347 | farr[3]=size;
|
|---|
| 348 | farr[4]=meanx;
|
|---|
| 349 | farr[5]=meany;
|
|---|
| 350 |
|
|---|
| 351 | fHillas->Set(farr);
|
|---|
| 352 |
|
|---|
| 353 | fHillas->SetReadyToSave();
|
|---|
| 354 | fHillasSrc->SetReadyToSave();
|
|---|
| 355 |
|
|---|
| 356 | return kTRUE;
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 | Int_t PostProcess()
|
|---|
| 360 | {
|
|---|
| 361 |
|
|---|
| 362 | return kTRUE;
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | void ScaleHillas(Int_t nent)
|
|---|
| 366 | {
|
|---|
| 367 | //---------------------------------------------------------------
|
|---|
| 368 | // scale Hillas (length, width) to mean
|
|---|
| 369 |
|
|---|
| 370 | MParList plist;
|
|---|
| 371 | MTaskList tlist;
|
|---|
| 372 | plist.AddToList(&tlist);
|
|---|
| 373 |
|
|---|
| 374 | MReadTree read("Events", fileHillas);
|
|---|
| 375 | read.DisableAutoScheme();
|
|---|
| 376 |
|
|---|
| 377 | MTaskInteractive scale;
|
|---|
| 378 | scale.SetPreProcess(PreProcess);
|
|---|
| 379 | scale.SetProcess(Process);
|
|---|
| 380 | scale.SetPostProcess(PostProcess);
|
|---|
| 381 |
|
|---|
| 382 | MWriteRootFile write(fileHScaled.Data());
|
|---|
| 383 | write.AddContainer("MHillas", "Events");
|
|---|
| 384 | write.AddContainer("MHillasExt", "Events");
|
|---|
| 385 | write.AddContainer("MHillasSrc", "Events");
|
|---|
| 386 | write.AddContainer("MNewImagePar", "Events");
|
|---|
| 387 | write.AddContainer("MRawRunHeader","Events");
|
|---|
| 388 |
|
|---|
| 389 | tlist.AddToList(&read);
|
|---|
| 390 | tlist.AddToList(&scale);
|
|---|
| 391 | tlist.AddToList(&write);
|
|---|
| 392 |
|
|---|
| 393 | MEvtLoop evtloop;
|
|---|
| 394 | evtloop.SetParList(&plist);
|
|---|
| 395 |
|
|---|
| 396 | if (!evtloop.Eventloop(nent))
|
|---|
| 397 | return;
|
|---|
| 398 |
|
|---|
| 399 | tlist.PrintStatistics();
|
|---|
| 400 |
|
|---|
| 401 | return;
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 | //****************************************************************************************
|
|---|
| 406 | // third part: check scaling
|
|---|
| 407 | //****************************************************************************************
|
|---|
| 408 |
|
|---|
| 409 | void CheckScaling()
|
|---|
| 410 | {
|
|---|
| 411 | //---------------------------------------------------------------
|
|---|
| 412 | // check scaling
|
|---|
| 413 | TFile fileHist(fileHScalHist,"recreate");
|
|---|
| 414 |
|
|---|
| 415 | gStyle->SetPalette(1);
|
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 | TCanvas *c1=new TCanvas("c1","",800,400);
|
|---|
| 419 | if(nBinDist>1)
|
|---|
| 420 | c1->Divide(2,2);
|
|---|
| 421 | else
|
|---|
| 422 | c1->Divide(2,1);
|
|---|
| 423 |
|
|---|
| 424 | c1->cd(1);
|
|---|
| 425 | gPad->SetGrid();
|
|---|
| 426 | hSLenSize.SetStats(kFALSE);
|
|---|
| 427 | hSLenSize.GetXaxis()->SetTitle("log(size [#phot])");
|
|---|
| 428 | hSLenSize.GetYaxis()->SetTitle("scaled length");
|
|---|
| 429 | hSLenSize.SetLineWidth(2);
|
|---|
| 430 | hSLenSize.DrawCopy("colz");
|
|---|
| 431 | hSLenSize.Write();
|
|---|
| 432 |
|
|---|
| 433 | TLine lLen(2.7,1.,hSizeUp,1.);
|
|---|
| 434 | TLine lLenUp(2.7,LengthUp,hSizeUp,LengthUp);
|
|---|
| 435 | TLine lLenLo(2.7,LengthLo,hSizeUp,LengthLo);
|
|---|
| 436 |
|
|---|
| 437 | lLen.SetLineColor(2);
|
|---|
| 438 | lLen.SetLineWidth(2);
|
|---|
| 439 | lLenUp.SetLineWidth(2);
|
|---|
| 440 | lLenLo.SetLineWidth(2);
|
|---|
| 441 | lLen.DrawClone();
|
|---|
| 442 | lLenUp.DrawClone();
|
|---|
| 443 | lLenLo.DrawClone();
|
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 | c1->cd(2);
|
|---|
| 447 | gPad->SetGrid();
|
|---|
| 448 | hLenSize.SetStats(kFALSE);
|
|---|
| 449 | hLenSize.SetTitle("");
|
|---|
| 450 | hLenSize.GetXaxis()->SetTitle("log(size [#phot])");
|
|---|
| 451 | hLenSize.GetYaxis()->SetTitle("length [deg]");
|
|---|
| 452 | hLenSize.SetLineWidth(2);
|
|---|
| 453 | hLenSize.DrawCopy("colz");
|
|---|
| 454 | hLenSize.Write();
|
|---|
| 455 | hLenMeanSize.SetLineColor(2);
|
|---|
| 456 | hLenMeanSize.SetLineWidth(2);
|
|---|
| 457 | hLenMeanSize.DrawCopy("e same");
|
|---|
| 458 | hLenMeanSize.Write();
|
|---|
| 459 |
|
|---|
| 460 | TH1F hLenCutLo("hLenCutLo","",nBinSize,hSizeLo,hSizeUp);
|
|---|
| 461 | TH1F hLenCutUp("hLenCutUp","",nBinSize,hSizeLo,hSizeUp);
|
|---|
| 462 | for(Int_t i=1;i<=nBinSize;i++)
|
|---|
| 463 | {
|
|---|
| 464 | Float_t meanval=hLenMeanSize.GetBinContent(i);
|
|---|
| 465 | hLenCutLo.SetBinContent(i,meanval*LengthLo);
|
|---|
| 466 | hLenCutUp.SetBinContent(i,meanval*LengthUp);
|
|---|
| 467 | }
|
|---|
| 468 | hLenCutLo.SetLineWidth(2);
|
|---|
| 469 | hLenCutUp.SetLineWidth(2);
|
|---|
| 470 | hLenCutLo.DrawCopy("][ same");
|
|---|
| 471 | hLenCutUp.DrawCopy("][ same");
|
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 | if(nBinDist>1)
|
|---|
| 475 | {
|
|---|
| 476 | c1->cd(3);
|
|---|
| 477 | gPad->SetGrid();
|
|---|
| 478 | hSLenDist.SetStats(kFALSE);
|
|---|
| 479 | hSLenDist.GetXaxis()->SetTitle("dist [deg]");
|
|---|
| 480 | hSLenDist.GetYaxis()->SetTitle("scaled length");
|
|---|
| 481 | hSLenDist.SetLineWidth(2);
|
|---|
| 482 | hSLenDist.DrawCopy("colz");
|
|---|
| 483 | hSLenDist.Write();
|
|---|
| 484 |
|
|---|
| 485 | c1->cd(4);
|
|---|
| 486 | gPad->SetGrid();
|
|---|
| 487 | hLenDist.SetStats(kFALSE);
|
|---|
| 488 | hLenDist.SetTitle("");
|
|---|
| 489 | hLenDist.GetXaxis()->SetTitle("dist [deg]");
|
|---|
| 490 | hLenDist.GetYaxis()->SetTitle("length");
|
|---|
| 491 | hLenDist.SetLineWidth(2);
|
|---|
| 492 | hLenDist.DrawCopy("colz");
|
|---|
| 493 | hLenDist.Write();
|
|---|
| 494 | hLenMeanDist.SetLineColor(2);
|
|---|
| 495 | hLenMeanDist.SetLineWidth(2);
|
|---|
| 496 | hLenMeanDist.DrawCopy("e same");
|
|---|
| 497 | hLenMeanDist.Write();
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | TCanvas *c2=new TCanvas("c2","",800,400);
|
|---|
| 501 | if(nBinDist>1)
|
|---|
| 502 | c2->Divide(2,2);
|
|---|
| 503 | else
|
|---|
| 504 | c2->Divide(2,1);
|
|---|
| 505 |
|
|---|
| 506 | c2->cd(1);
|
|---|
| 507 | gPad->SetGrid();
|
|---|
| 508 | hSWidSize.SetStats(kFALSE);
|
|---|
| 509 | hSWidSize.GetXaxis()->SetTitle("log(size [#phot])");
|
|---|
| 510 | hSWidSize.GetYaxis()->SetTitle("scaled width");
|
|---|
| 511 | hSWidSize.SetLineWidth(2);
|
|---|
| 512 | hSWidSize.DrawCopy("colz");
|
|---|
| 513 | hSWidSize.Write();
|
|---|
| 514 |
|
|---|
| 515 | TLine lWid(2.7,1.,hSizeUp,1.);
|
|---|
| 516 | TLine lWidUp(2.7,WidthUp,hSizeUp,WidthUp);
|
|---|
| 517 | TLine lWidLo(2.7,WidthLo,hSizeUp,WidthLo);
|
|---|
| 518 |
|
|---|
| 519 | lWid.SetLineColor(2);
|
|---|
| 520 | lWid.SetLineWidth(2);
|
|---|
| 521 | lWidUp.SetLineWidth(2);
|
|---|
| 522 | lWidLo.SetLineWidth(2);
|
|---|
| 523 | lWid.DrawClone();
|
|---|
| 524 | lWidUp.DrawClone();
|
|---|
| 525 | lWidLo.DrawClone();
|
|---|
| 526 |
|
|---|
| 527 | c2->cd(2);
|
|---|
| 528 | gPad->SetGrid();
|
|---|
| 529 | hWidSize.SetStats(kFALSE);
|
|---|
| 530 | hWidSize.SetTitle("");
|
|---|
| 531 | hWidSize.GetXaxis()->SetTitle("log(size [#phot])");
|
|---|
| 532 | hWidSize.GetYaxis()->SetTitle("width [deg]");
|
|---|
| 533 | hWidSize.SetLineWidth(2);
|
|---|
| 534 | hWidSize.DrawCopy("colz");
|
|---|
| 535 | hWidSize.Write();
|
|---|
| 536 | hWidMeanSize.SetLineColor(2);
|
|---|
| 537 | hWidMeanSize.SetLineWidth(2);
|
|---|
| 538 | hWidMeanSize.DrawCopy("e same");
|
|---|
| 539 | hWidMeanSize.Write();
|
|---|
| 540 |
|
|---|
| 541 | TH1F hWidCutLo("hWidCutLo","",nBinSize,hSizeLo,hSizeUp);
|
|---|
| 542 | TH1F hWidCutUp("hWidCutUp","",nBinSize,hSizeLo,hSizeUp);
|
|---|
| 543 | for(Int_t i=1;i<=nBinSize;i++)
|
|---|
| 544 | {
|
|---|
| 545 | Float_t meanval=hWidMeanSize.GetBinContent(i);
|
|---|
| 546 | hWidCutLo.SetBinContent(i,meanval*WidthLo);
|
|---|
| 547 | hWidCutUp.SetBinContent(i,meanval*WidthUp);
|
|---|
| 548 | }
|
|---|
| 549 | hWidCutLo.SetLineWidth(2);
|
|---|
| 550 | hWidCutUp.SetLineWidth(2);
|
|---|
| 551 | hWidCutLo.DrawCopy("][ same");
|
|---|
| 552 | hWidCutUp.DrawCopy("][ same");
|
|---|
| 553 |
|
|---|
| 554 | if(nBinDist>1)
|
|---|
| 555 | {
|
|---|
| 556 | c2->cd(3);
|
|---|
| 557 | gPad->SetGrid();
|
|---|
| 558 | hSWidDist.SetStats(kFALSE);
|
|---|
| 559 | hSWidDist.GetXaxis()->SetTitle("dist [deg]");
|
|---|
| 560 | hSWidDist.GetYaxis()->SetTitle("scaled width");
|
|---|
| 561 | hSWidDist.SetLineWidth(2);
|
|---|
| 562 | hSWidDist.DrawCopy("colz");
|
|---|
| 563 | hSWidDist.Write();
|
|---|
| 564 |
|
|---|
| 565 | c2->cd(4);
|
|---|
| 566 | gPad->SetGrid();
|
|---|
| 567 | hWidDist.SetStats(kFALSE);
|
|---|
| 568 | hWidDist.SetTitle("");
|
|---|
| 569 | hWidDist.GetXaxis()->SetTitle("dist [deg]");
|
|---|
| 570 | hWidDist.GetYaxis()->SetTitle("width");
|
|---|
| 571 | hWidDist.SetLineWidth(2);
|
|---|
| 572 | hWidDist.DrawCopy("colz");
|
|---|
| 573 | hWidDist.Write();
|
|---|
| 574 | hWidMeanDist.SetLineColor(2);
|
|---|
| 575 | hWidMeanDist.SetLineWidth(2);
|
|---|
| 576 | hWidMeanDist.DrawCopy("e same");
|
|---|
| 577 | hWidMeanDist.Write();
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | // mean values
|
|---|
| 581 | if(nBinDist>1)
|
|---|
| 582 | {
|
|---|
| 583 | TCanvas *c4=new TCanvas("c4","",800,400);
|
|---|
| 584 | c4->Divide(1,2);
|
|---|
| 585 |
|
|---|
| 586 | c4->cd(1);
|
|---|
| 587 | gPad->SetGrid();
|
|---|
| 588 | hLenMean.SetStats(kFALSE);
|
|---|
| 589 | hLenMean.SetTitle("mean_length(log(size),dist)");
|
|---|
| 590 | hLenMean.GetXaxis()->SetTitle("log(size [#phot])");
|
|---|
| 591 | hLenMean.GetYaxis()->SetTitle("dist [deg])");
|
|---|
| 592 | hLenMean.DrawCopy("colz");
|
|---|
| 593 | hLenMean.Write();
|
|---|
| 594 |
|
|---|
| 595 | c4->cd(2);
|
|---|
| 596 | gPad->SetGrid();
|
|---|
| 597 | hWidMean.SetStats(kFALSE);
|
|---|
| 598 | hWidMean.SetTitle("mean_width(log(size),dist)");
|
|---|
| 599 | hWidMean.GetXaxis()->SetTitle("log(size [#phot])"); ;
|
|---|
| 600 | hWidMean.GetYaxis()->SetTitle("dist [deg])");
|
|---|
| 601 | hWidMean.DrawCopy("colz");
|
|---|
| 602 | hWidMean.Write("colz");
|
|---|
| 603 | }
|
|---|
| 604 |
|
|---|
| 605 | fileHist.Close();
|
|---|
| 606 |
|
|---|
| 607 | return;
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | //****************************************************************************************
|
|---|
| 611 | // main
|
|---|
| 612 | //****************************************************************************************
|
|---|
| 613 |
|
|---|
| 614 | void RunScaling(Int_t nent=-1)
|
|---|
| 615 | {
|
|---|
| 616 | printf("Prepare for scaling...");
|
|---|
| 617 | ReadHillas();
|
|---|
| 618 | printf("done.\n");
|
|---|
| 619 |
|
|---|
| 620 | ScaleHillas(nent);
|
|---|
| 621 |
|
|---|
| 622 | CheckScaling();
|
|---|
| 623 |
|
|---|
| 624 | return;
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|