Changeset 4397 for trunk


Ignore:
Timestamp:
07/15/04 18:04:40 (20 years ago)
Author:
jlopez
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mtemp/mifae
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtemp/mifae/Changelog

    r4396 r4397  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21  2004/07/15  Javier Lopez
     22    * macros/ligthcurve.C
     23      - Macro to compute a light curve from hillas files.
    2024
    2125  2004/07/04  Oscar Blanch Bigas
  • trunk/MagicSoft/Mars/mtemp/mifae/macros/lightcurve.C

    r4387 r4397  
    2222    }
    2323
    24     return chiq/nbinsnozero;
     24    return (nbinsnozero>0?chiq/nbinsnozero:0);
    2525}
    2626
     
    5959
    6060  gROOT->Reset();
     61  gStyle->SetCanvasColor(0);
     62  gStyle->SetCanvasBorderMode(0);
     63  gStyle->SetPadBorderMode(0);
     64  gStyle->SetFrameBorderMode(0);
    6165  gStyle->SetTimeOffset(-3600);
    6266
     
    6468  const Bool_t debug = kFALSE;
    6569  const Double_t timebin = 480.; //[sec]
    66   TString psname = "./20040422_Mrk421." + timebin + "s.ps";
    67   cout << psname << endl;
    68   return;
     70  TString psname = "./20040420_Mrk421.480s.ps";
    6971
    7072  //Constanst
    71   const Double_t kConvDegToRad = TMath::ACos(-1)/180.;
     73  const Double_t kConvDegToRad = TMath::Pi()/180.;
    7274  const Double_t kSec = 1e6;  //[sec/microsec]
    7375  const Double_t kDay = 24.*60.*60.;  //[Day/sec]
     
    8991 
    9092
    91   //none cuts
    92 //   Double_t sizemin   = 2000.; //[Photons]
    93 //   Double_t sizemax   = 10000000000.; //[Photons]
    94 //   Double_t widthmin  = 0.;
    95 //   Double_t widthmax  = 2.0;
    96 //   Double_t lengthmin = 0.;
    97 //   Double_t lengthmax = 2.0;
    98 //   Double_t distmin   = 0.;
    99 //   Double_t distmax   = 4.0;
    100 //   Double_t alphamin   = 0.;
    101 //   Double_t alphamax   = 90.;
    102 
    10393 
    10494  const Int_t numberSizeBins = 4;
     
    10696
    10797  //cuts
    108   Double_t sizemin = 2000.; //[Photons]
    109   Double_t sizemax = 10E9.; //[Photons]
    11098
    11199  Double_t widthmin[numberSizeBins]  = { 0.06, 0.06, 0.06, 0.06 };
     
    135123  // ON containers
    136124  MGeomCamMagic geomcam;
    137   MSrcPosCam source_on;
    138   MHillas hillas;
    139   MHillasSrc hillasscr;
    140  
     125  MRawRunHeader runheader_on;
     126  MRawEvtHeader evtheader_on;
     127  MTime              time_on;
     128  MHillas          hillas_on;
     129  MHillasSrc    hillassrc_on;
     130  MSrcPosCam       srcpos_on;
     131  MReportDrive      drive_on;
     132
    141133  plist_on.AddToList(&geomcam);
    142   plist_on.AddToList(&source_on);
    143   plist_on.AddToList(&hillas);
    144   plist_on.AddToList(&hillasscr);
    145  
    146   //create some 1-dim histo to test only for the ON distribution of dist, width , length, size...
    147   MH3 hDist_on("MHillasSrc.fDist/MGeomCam.fConvMm2Deg");
    148   hDist_on.SetName("Dist_on");
    149   plist_on.AddToList(&hDist_on);
    150   MBinning binsDist_on("BinningDist_on");
     134  plist_on.AddToList(&runheader_on);
     135  plist_on.AddToList(&evtheader_on);
     136  plist_on.AddToList(&time_on);
     137  plist_on.AddToList(&hillas_on);
     138  plist_on.AddToList(&hillassrc_on);
     139  plist_on.AddToList(&srcpos_on);
     140  plist_on.AddToList(&drive_on);
     141
     142  Int_t nbins_Size = 60;
     143  Double_t min_Size = log10(sizeBins[0])*0.8;
     144  Double_t max_Size = log10(1000000)*1.2;
     145  TH1F *hSize_on = new TH1F ("hSizeOn","",nbins_Size,min_Size,max_Size);
     146
     147  Int_t nbins_Width = 20;
     148  Double_t min_Width = 0.;
     149  Double_t max_Width = widthmax[numberSizeBins-1]*1.2;
     150  TH1F *hWidth_on = new TH1F ("hWidthOn","",nbins_Width,min_Width,max_Width);
     151
     152  Int_t nbins_Length = 20;
     153  Double_t min_Length = 0.;
     154  Double_t max_Length =  lengthmax[numberSizeBins-1]*1.2;
     155  TH1F *hLength_on = new TH1F ("hLengthOn","",nbins_Length,min_Length,max_Length);
     156
    151157  Int_t nbins_Dist = 20;
    152158  Double_t min_Dist = 0.;
    153   Double_t max_Dist = distmax[0]*1.2;
    154   binsDist_on.SetEdges(nbins_Dist, min_Dist, max_Dist);
    155   plist_on.AddToList(&binsDist_on);
    156  
    157   MH3 hWidth_on("MHillas.fWidth/MGeomCam.fConvMm2Deg");
    158   hWidth_on.SetName("Width_on");
    159   plist_on.AddToList(&hWidth_on);
    160   MBinning binsWidth_on("BinningWidth_on");
    161   Int_t nbins_Width = 20;
    162   Double_t min_Width = 0.;
    163   Double_t max_Width = widthmax[0]*1.2;
    164   binsWidth_on.SetEdges(nbins_Width, min_Width, max_Width);
    165   plist_on.AddToList(&binsWidth_on);
    166  
    167   MH3 hLength_on("MHillas.fLength/MGeomCam.fConvMm2Deg");
    168   hLength_on.SetName("Length_on");
    169   plist_on.AddToList(&hLength_on);
    170   MBinning binsLength_on("BinningLength_on");
    171   Int_t nbins_Length = 20;
    172   Double_t min_Length = 0.;
    173   Double_t max_Length =  lengthmax[0]*1.2;
    174   binsLength_on.SetEdges(nbins_Length, min_Length, max_Length);
    175   plist_on.AddToList(&binsLength_on);
    176  
    177   MH3 hSize_on("log10(MHillas.fSize)");
    178   hSize_on.SetName("Size_on");
    179   plist_on.AddToList(&hSize_on);
    180   MBinning binsSize_on("BinningSize_on");
    181   Int_t nbins_Size = 60;
    182   Double_t min_Size = log10(sizemin)*0.8;
    183   Double_t max_Size = log10(1000000)*1.2;
    184   binsSize_on.SetEdges(nbins_Size, min_Size, max_Size);
    185   plist_on.AddToList(&binsSize_on);
    186    
    187   //create a histo to fill the alpha values: one alpha plot form 0 to +90 deg in abs value
    188   MH3 hAlpha_on_abs("abs(MHillasSrc.fAlpha)");
    189   hAlpha_on_abs.SetName("Alpha_on_abs");
    190   plist_on.AddToList(&hAlpha_on_abs);
    191   MBinning binsAlpha_on_abs("BinningAlpha_on_abs");
     159  Double_t max_Dist = distmax[numberSizeBins-1]*1.2;
     160  TH1F *hDist_on = new TH1F ("hDistOn","",nbins_Dist,min_Dist,max_Dist);
     161
    192162  Int_t nbins_abs = 18;
    193163  Double_t minalpha_abs = 0.;
    194164  Double_t maxalpha_abs =90.;
    195   binsAlpha_on_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
    196   plist_on.AddToList(&binsAlpha_on_abs);
    197  
    198   //create a histo to fill the alpha values: one alpha plot form -90 to +90 deg.
    199   MH3 hAlpha_on("MHillasSrc.fAlpha");
    200   hAlpha_on.SetName("Alpha_on");
    201   plist_on.AddToList(&hAlpha_on);
    202   MBinning binsAlpha_on("BinningAlpha_on");
     165  TH1F *hAlpha_on_abs = new TH1F ("hAbsAlphaOn","",nbins_abs,minalpha_abs,maxalpha_abs);
     166
    203167  Int_t nbins = nbins_abs*2;
    204168  Double_t minalpha = -90.;
    205169  Double_t maxalpha =  90.;
    206   binsAlpha_on.SetEdges(nbins, minalpha, maxalpha);
    207   plist_on.AddToList(&binsAlpha_on);
    208    
    209 
    210   //create a histo to fill the source position
    211   MH3 hSrcPos_on("MSrcPosCam.fX","MSrcPosCam.fY");
    212   hSrcPos_on.SetName("SrcPos_on");
    213   plist_on.AddToList(&hSrcPos_on);
    214   MBinning binsSrcPos_onX("BinningSrcPos_onX");
    215   MBinning binsSrcPos_onY("BinningSrcPos_onY");
     170  TH1F *hAlpha_on = new TH1F ("hAlphaOn","",nbins,minalpha,maxalpha);
     171
    216172  Int_t nbins_srcpos = 400;
    217173  Double_t minsrcpos = -600.;
    218   Double_t maxsrcpos =  600.;
    219   binsSrcPos_onX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
    220   binsSrcPos_onY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
    221   plist_on.AddToList(&binsSrcPos_onX);
    222   plist_on.AddToList(&binsSrcPos_onY);
    223  
    224   MH3 hDAQEvtNumber_on("MRawEvtHeader.fDAQEvtNumber");
    225   hDAQEvtNumber_on.SetName("DAQEvtNumber_on");
    226   plist_on.AddToList(&hDAQEvtNumber_on);
    227   MBinning binsDAQEvtNumber_onX("BinningDAQEvtNumber_onX");
    228   Int_t nbins_evtnum = 1000;
    229   Double_t minevtnum =  0.;
    230   Double_t maxevtnum =  1000.;
    231   binsDAQEvtNumber_onX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
    232   plist_on.AddToList(&binsDAQEvtNumber_onX);
    233  
     174  Double_t maxsrcpos =  600.;  //[mm]  //!!! position precition 3mm ~ 0.01 deg
     175  TH2F *hSrcPos_on = new TH2F ("hSrcPosOn","",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
    234176
    235177  //
     
    241183 
    242184  MSrcPlace srcplace;
    243 
    244   //cuts
    245   TString sizestr = "(MHillas.fSize < ";
    246   sizestr += sizemin;
    247   sizestr += ") || (";
    248   sizestr += "MHillas.fSize > ";
    249   sizestr += sizemax;
    250   sizestr += ")";
    251   MF sizefilter(sizestr);
    252 
    253   TString widthstr = "({MHillas.fWidth/MGeomCam.fConvMm2Deg} < ";
    254   widthstr += widthmin[0];
    255   widthstr += ") || (";
    256   widthstr += "{MHillas.fWidth/MGeomCam.fConvMm2Deg} > ";
    257   widthstr += widthmax[0];
    258   widthstr += ")";
    259   MF widthfilter(widthstr);
    260  
    261   TString lengthstr = "({MHillas.fLength/MGeomCam.fConvMm2Deg} < ";
    262   lengthstr += lengthmin[0];
    263   lengthstr += ") || (";
    264   lengthstr += "{MHillas.fLength/MGeomCam.fConvMm2Deg} > ";
    265   lengthstr += lengthmax[0];
    266   lengthstr += ")";
    267   MF lengthfilter(lengthstr);
    268  
    269   TString diststr = "({MHillasSrc.fDist/MGeomCam.fConvMm2Deg} < ";
    270   diststr += distmin[0];
    271   diststr += ") || (";
    272   diststr += "{MHillasSrc.fDist/MGeomCam.fConvMm2Deg} > ";
    273   diststr += distmax[0];
    274   diststr += ")";
    275   MF distfilter(diststr);
    276  
    277   MF evenfilter("{MRawEvtHeader.fDAQEvtNumber%3}<0.5");
    278   MF oddfilter("{MRawEvtHeader.fDAQEvtNumber%3}>0.5");
    279  
    280   MContinue cont_size(&sizefilter);
    281   MContinue cont_width(&widthfilter);
    282   MContinue cont_length(&lengthfilter);
    283   MContinue cont_dist(&distfilter);
    284   MContinue cont_even(&evenfilter);
    285   MContinue cont_odd(&oddfilter);
    286  
    287185  MHillasSrcCalc csrc_on;
    288186 
    289   // fill all histograms
    290   MFillH falpha_on_abs(&hAlpha_on_abs);
    291   MFillH falpha_on(&hAlpha_on);
    292   MFillH fdist_on(&hDist_on);
    293   MFillH fwidth_on(&hWidth_on);
    294   MFillH flength_on(&hLength_on);
    295   MFillH fsize_on(&hSize_on);
    296   MFillH fsrcpos_on(&hSrcPos_on);
    297   MFillH fevtnum_on(&hDAQEvtNumber_on);
    298  
    299   // prints
    300   MPrint pevent("MRawEvtHeader");
    301   MPrint phillas("MHillas");
    302   MPrint phillassrc("MHillasSrc");
    303   MPrint psrcpos("MSrcPosCam");
     187//   // prints
     188//   MPrint pevent("MRawEvtHeader");
     189//   MPrint phillas("MHillas");
     190//   MPrint phillassrc("MHillasSrc");
     191//   MPrint psrcpos("MSrcPosCam");
    304192 
    305193  //tasklist
     
    307195  tlist_on.AddToList(&srcplace);
    308196  tlist_on.AddToList(&csrc_on);
    309   tlist_on.AddToList(&fsrcpos_on);
    310   //  tlist_on.AddToList(&cont_odd);
    311   tlist_on.AddToList(&cont_size);
    312   tlist_on.AddToList(&cont_width);
    313   tlist_on.AddToList(&cont_length);
    314   tlist_on.AddToList(&cont_dist);
    315   tlist_on.AddToList(&falpha_on_abs);
    316   tlist_on.AddToList(&falpha_on);
    317   tlist_on.AddToList(&fdist_on);
    318   tlist_on.AddToList(&fwidth_on);
    319   tlist_on.AddToList(&flength_on);
    320   tlist_on.AddToList(&fsize_on);
    321   //  tlist_on.AddToList(&fevtnum_on);
    322197 
    323198  // Create and setup the eventloop
     
    335210    return;
    336211 
    337   MRawRunHeader* runheader_on = plist_on.FindObject("MRawRunHeader");
    338   MRawEvtHeader* evtheader_on = plist_on.FindObject("MRawEvtHeader");
    339   MTime* time_on = plist_on.FindObject("MTime");
    340   MHillas* hillas_on = plist_on.FindObject("MHillas");
    341   MHillasSrc* hillassrc_on = plist_on.FindObject("MHillasSrc");
    342   MReportDrive* drive_on = plist_on.FindObject("MReportDrive");
    343   MSrcPosCam* srcpos_on = plist_on.FindObject("MSrcPosCam");
    344  
    345 
    346212  Double_t mjdFirstEventofBin=0;
    347213  Double_t mjdFirstEvent=0;
     
    363229
    364230  //create histos needed in the time bins
     231
    365232  TString alphaTitle = Form("%s%02i","hAlphaOn",numberTimeBins-1);
    366233  TH1F *hAlpha_on_abs_timebin = new TH1F (alphaTitle,"",nbins_abs,minalpha_abs,maxalpha_abs);
    367   Int_t nbins_srcpos = 200;
    368   Double_t minsrcpos = -600.; //[mm]
    369   Double_t maxsrcpos = 600.;  //[mm]  //!!! position precition 3mm ~ 0.01 deg
     234
    370235  TString srcposTitle =  Form("%s%02i","hSrcPosOn",numberTimeBins-1);
    371236  TH2F *hSrcPos_on_timebin = new TH2F (srcposTitle,"",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
     237
    372238  Int_t nbins_coszenith = 200;
    373239  Double_t mincoszenith = 0.; 
     
    379245    {
    380246      // Compute live time
    381       UInt_t   run = runheader_on->GetRunNumber();
    382       UInt_t   evt = evtheader_on->GetDAQEvtNumber();
    383       Double_t mjd = time_on->GetMjd();
     247      UInt_t   run = runheader_on.GetRunNumber();
     248      UInt_t   evt = evtheader_on.GetDAQEvtNumber();
     249      Double_t mjd = time_on.GetMjd();
    384250
    385251      if (mjd == 0)
     
    393259              cout << "present event:\t run " << run << " event " << evt << " mjd " << mjd <<  endl;
    394260              mtimeLastEvent.Print();
    395               time_on->Print();
     261              time_on.Print();
    396262            }
    397263         
     
    408274              cout << "present event:\t run " << run << " event " << evt << " mjd " << mjd <<  endl;
    409275              mtimeLastEvent.Print();
    410               time_on->Print();
     276              time_on.Print(); 
    411277            }
    412278         
     
    423289              cout << "present event:\t run " << run << " event " << evt << " mjd " << mjd <<  endl;
    424290              mtimeLastEvent.Print();
    425               time_on->Print();
     291              time_on.Print(); 
    426292            }
    427293
     
    438304              cout << "present event:\t run " << run << " event " << evt << " mjd " << mjd <<  endl;
    439305              mtimeLastEvent.Print();
    440               time_on->Print();
     306              time_on.Print(); 
    441307            }
    442308
     
    454320              cout << "present event:\t run " << run << " event " << evt << " mjd " << mjd <<  endl;
    455321              mtimeLastEvent.Print();
    456               time_on->Print();
     322              time_on.Print(); 
    457323            }
    458324
     
    470336              cout << "present event:\t run " << run << " event " << evt << " mjd " << mjd <<  endl;
    471337              mtimeLastEvent.Print();
    472               time_on->Print();
     338              time_on.Print(); 
    473339             
    474340              flag = kFALSE;
     
    489355                      cout << "present event:\t run " << run << " event " << evt << " mjd " << mjd <<  endl;
    490356                      mtimeLastEvent.Print();
    491                       time_on->Print();
     357                      time_on.Print(); 
    492358                    }
    493359                 
     
    506372          runLastEvent = run;
    507373          mjdLastEvent = mjd;
    508           mtimeLastEvent = *time_on;
     374          mtimeLastEvent = time_on;
    509375
    510376     
    511377     
    512           Double_t size = hillas_on->GetSize();
    513           Double_t width = hillas_on->GetWidth()*geomcam.GetConvMm2Deg();
    514           Double_t length = hillas_on->GetLength()*geomcam.GetConvMm2Deg();
    515           Double_t dist = hillassrc_on->GetDist()*geomcam.GetConvMm2Deg();
    516           Double_t alpha = hillassrc_on->GetAlpha();
    517           Double_t srcposx = srcpos_on->GetX();
    518           Double_t srcposy = srcpos_on->GetY();
    519           Double_t zenith = drive_on->GetNominalZd();
     378          Double_t size = hillas_on.GetSize();
     379          Double_t width = hillas_on.GetWidth()*geomcam.GetConvMm2Deg();
     380          Double_t length = hillas_on.GetLength()*geomcam.GetConvMm2Deg();
     381          Double_t dist = hillassrc_on.GetDist()*geomcam.GetConvMm2Deg();
     382          Double_t alpha = hillassrc_on.GetAlpha();
     383          Double_t srcposx = srcpos_on.GetX();
     384          Double_t srcposy = srcpos_on.GetY();
     385          Double_t zenith = drive_on.GetNominalZd();
    520386         
    521387
     
    530396                      if (dist > distmin[sizebin] && dist < distmax[sizebin])
    531397                        {     
     398
     399                          //General histos
     400                          hSize_on->Fill(log10(size));
     401                          hWidth_on->Fill(width);
     402                          hLength_on->Fill(length);
     403                          hDist_on->Fill(dist);
     404                          hAlpha_on_abs->Fill(TMath::Abs(alpha));
     405                          hAlpha_on->Fill(alpha);
     406                          hSrcPos_on->Fill(srcposx,srcposy);
     407                         
     408                          // Time bin histos
    532409                          hAlpha_on_abs_timebin->Fill(TMath::Abs(alpha));
    533410                          hSrcPos_on_timebin->Fill(srcposx,srcposy);
     
    550427              //Compute the time on
    551428              timeOn[numberTimeBins-1] += (mjdLastEvent-mjdFirstEvent)*kDay;
    552               widthTimeBinOn[numberTimeBins-1] = (mjd-mjdFirstEventofBin)/2;
     429              widthTimeBinOn[numberTimeBins-1] = (mjdLastEvent-mjdFirstEventofBin)/2;
    553430              meanTimeBinOn[numberTimeBins-1] = mjdFirstEventofBin + widthTimeBinOn[numberTimeBins-1];
    554431             
     
    671548  plist_off.AddToList(&tlist_off);
    672549 
    673   MSrcPosCam source_off;
     550  MRawRunHeader runheader_off;
     551  MRawEvtHeader evtheader_off;
     552  MTime              time_off;
     553  MHillas          hillas_off;
     554  MHillasSrc    hillassrc_off;
     555  MSrcPosCam       srcpos_off;
     556  MReportDrive      drive_off;
    674557 
    675558  plist_off.AddToList(&geomcam);
    676   plist_off.AddToList(&source_off);
    677   plist_off.AddToList(&hillas);
    678   plist_off.AddToList(&hillasscr);
    679  
    680   //create some 1-dim histo to test only for the OFF distribution of dist, width , length, size...
    681   MH3 hDist_off("MHillasSrc.fDist/MGeomCam.fConvMm2Deg");
    682   hDist_off.SetName("Dist_off");
    683   plist_off.AddToList(&hDist_off);
    684   MBinning binsDist_off("BinningDist_off");
    685   binsDist_off.SetEdges(nbins_Dist, min_Dist, max_Dist);
    686   plist_off.AddToList(&binsDist_off);
    687  
    688   MH3 hWidth_off("MHillas.fWidth/MGeomCam.fConvMm2Deg");
    689   hWidth_off.SetName("Width_off");
    690   plist_off.AddToList(&hWidth_off);
    691   MBinning binsWidth_off("BinningWidth_off");
    692   binsWidth_off.SetEdges(nbins_Width, min_Width, max_Width);
    693   plist_off.AddToList(&binsWidth_off);
    694  
    695   MH3 hLength_off("MHillas.fLength/MGeomCam.fConvMm2Deg");
    696   hLength_off.SetName("Length_off");
    697   plist_off.AddToList(&hLength_off);
    698   MBinning binsLength_off("BinningLength_off");
    699   binsLength_off.SetEdges(nbins_Length, min_Length, max_Length);
    700   plist_off.AddToList(&binsLength_off);
    701  
    702   MH3 hSize_off("log10(MHillas.fSize)");
    703   hSize_off.SetName("Size_off");
    704   plist_off.AddToList(&hSize_off);
    705   MBinning binsSize_off("BinningSize_off");
    706   binsSize_off.SetEdges(nbins_Size, min_Size, max_Size);
    707   plist_off.AddToList(&binsSize_off);
    708  
    709   //create a histo to fill the alpha values: from 0 to 90 deg -> abs value
    710   MH3 hAlpha_off_abs("abs(MHillasSrc.fAlpha)");
    711   hAlpha_off_abs.SetName("Alpha_off_abs");
    712   plist_off.AddToList(&hAlpha_off_abs);
    713   MBinning binsAlpha_off_abs("BinningAlpha_off_abs");
    714   binsAlpha_off_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
    715   plist_off.AddToList(&binsAlpha_off_abs);
    716  
    717   //create a histo to fill the alpha values: from -90 to 90 deg
    718   MH3 hAlpha_off("MHillasSrc.fAlpha");
    719   hAlpha_off.SetName("Alpha_off");
    720   plist_off.AddToList(&hAlpha_off);
    721   MBinning binsAlpha_off("BinningAlpha_off");
    722   binsAlpha_off.SetEdges(nbins, minalpha, maxalpha);
    723   plist_off.AddToList(&binsAlpha_off);
    724  
    725  
    726   MH3 hSrcPos_off("MSrcPosCam.fX","MSrcPosCam.fY");
    727   hSrcPos_off.SetName("SrcPos_off");
    728   plist_off.AddToList(&hSrcPos_off);
    729   MBinning binsSrcPos_offX("BinningSrcPos_offX");
    730   MBinning binsSrcPos_offY("BinningSrcPos_offY");
    731   binsSrcPos_offX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
    732   binsSrcPos_offY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
    733   plist_off.AddToList(&binsSrcPos_offX);
    734   plist_off.AddToList(&binsSrcPos_offY);
    735  
    736   MH3 hDAQEvtNumber_off("MRawEvtHeader.fDAQEvtNumber");
    737   hDAQEvtNumber_off.SetName("DAQEvtNumber_off");
    738   plist_off.AddToList(&hDAQEvtNumber_off);
    739   MBinning binsDAQEvtNumber_offX("BinningDAQEvtNumber_offX");
    740   Int_t nbins_evtnum = 100;
    741   Double_t minevtnum =  0.;
    742   Double_t maxevtnum =  100.;
    743   binsDAQEvtNumber_offX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
    744   plist_off.AddToList(&binsDAQEvtNumber_offX);
    745  
     559  plist_off.AddToList(&runheader_off);
     560  plist_off.AddToList(&evtheader_off);
     561  plist_off.AddToList(&time_off);
     562  plist_off.AddToList(&hillas_off);
     563  plist_off.AddToList(&hillassrc_off);
     564  plist_off.AddToList(&srcpos_off);
     565  plist_off.AddToList(&drive_off);
     566
     567  TH1F *hSize_off      = new TH1F ("hSizeOff","",nbins_Size,min_Size,max_Size);
     568  TH1F *hWidth_off     = new TH1F ("hWidthOff","",nbins_Width,min_Width,max_Width);
     569  TH1F *hLength_off    = new TH1F ("hLengthOff","",nbins_Length,min_Length,max_Length);
     570  TH1F *hDist_off      = new TH1F ("hDistOff","",nbins_Dist,min_Dist,max_Dist);
     571  TH1F *hAlpha_off_abs = new TH1F ("hAbsAlphaOff","",nbins_abs,minalpha_abs,maxalpha_abs);
     572  TH1F *hAlpha_off     = new TH1F ("hAlphaOff","",nbins,minalpha,maxalpha);
     573  TH2F *hSrcPos_off    = new TH2F ("hSrcPosOff","",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
     574
    746575  //tasks
    747576  MReadTree read_off("Parameters", f_off_name);
     
    755584  // --------------------------------------------------------------
    756585
    757   srcplace.SetMode(MSrcPlace::kOff);
     586  //  srcplace.SetMode(MSrcPlace::kOff);
    758587 
    759588  MHillasSrcCalc csrc_off;
    760  
    761   // fill all histograms
    762   MFillH falpha_off_abs(&hAlpha_off_abs);
    763   MFillH falpha_off(&hAlpha_off);
    764   MFillH fdist_off(&hDist_off);
    765   MFillH fwidth_off(&hWidth_off);
    766   MFillH flength_off(&hLength_off);
    767   MFillH fsize_off(&hSize_off);
    768   MFillH fsrcpos_off(&hSrcPos_off);
    769   MFillH fevtnum_off(&hDAQEvtNumber_off);
    770589 
    771590  //tasklist
    772591  tlist_off.AddToList(&read_off);
    773   tlist_off.AddToList(&srcplace);
    774   tlist_off.AddToList(&csrc_off);
    775   tlist_off.AddToList(&fsrcpos_off);
    776 //   tlist_off.AddToList(&cont_even);
    777 //   tlist_off.AddToList(&cont_size);
    778 //   tlist_off.AddToList(&cont_width);
    779 //   tlist_off.AddToList(&cont_length);
    780 //   tlist_off.AddToList(&cont_dist);
    781 //   tlist_off.AddToList(&falpha_off_abs);
    782 //   tlist_off.AddToList(&falpha_off);
    783 //   tlist_off.AddToList(&fdist_off);
    784 //   tlist_off.AddToList(&fwidth_off);
    785 //   tlist_off.AddToList(&flength_off);
    786 //   tlist_off.AddToList(&fsize_off);
    787 //   tlist_off.AddToList(&fevtnum_off);
    788592  tlist_off.AddToList(&srcplace_timebin); // This is just to run the preprocess correctely
     593  tlist_off.AddToList(&csrc_off); // This is just to run the preprocess correctely
    789594 
    790595  // Create and setup the eventloop
     
    802607    return;
    803608
    804 
    805   MHillas* hillas_off = plist_off.FindObject("MHillas");
    806   MHillasSrc* hillassrc_off = plist_off.FindObject("MHillasSrc");
    807   MReportDrive* drive_off = plist_off.FindObject("MReportDrive");
    808   MSrcPosCam* srcpos_off = plist_off.FindObject("MSrcPosCam");
    809 
    810   TArrayI sizecut(numberTimeBins);
    811   TArrayI widthcut(numberTimeBins);
    812   TArrayI lengthcut(numberTimeBins);
    813   TArrayI distcut(numberTimeBins);
    814   TArrayI alphacut(numberTimeBins);
    815  
    816   sizecut.Reset(0);
    817   widthcut.Reset(0);
    818   lengthcut.Reset(0);
    819   distcut.Reset(0);
    820   alphacut.Reset(0);
    821 
    822609  while(tlist_off.Process())
    823610    {
    824611
    825       //Now fill just the alpha plot in the time/zenith bins defined in on
    826       Double_t zenith = drive_off->GetNominalZd();
     612      //First read the variables source(i.e. time bin) independent
     613      Double_t zenith = drive_off.GetNominalZd();
     614
     615      Double_t size = hillas_off.GetSize();
     616      Double_t width = hillas_off.GetWidth()*geomcam.GetConvMm2Deg();
     617      Double_t length = hillas_off.GetLength()*geomcam.GetConvMm2Deg();
    827618     
    828       for (UInt_t bin=0; bin<numberTimeBins; bin++)
     619      Int_t sizebin = GetBin(size,numberSizeBins,sizeBins);
     620     
     621      if (sizebin >= 0)
    829622        {
    830           srcplace_timebin.SetPositionHisto((TH2F*)srcposHistoOn[bin]);
    831           srcplace_timebin.CallProcess();
    832           csrc_off.CallProcess();
    833          
    834           Double_t size = hillas_off->GetSize();
    835           Double_t width = hillas_off->GetWidth()*geomcam.GetConvMm2Deg();
    836           Double_t length = hillas_off->GetLength()*geomcam.GetConvMm2Deg();
    837           Double_t dist = hillassrc_off->GetDist()*geomcam.GetConvMm2Deg();
    838           Double_t alpha = hillassrc_off->GetAlpha();
    839           Double_t srcposx = srcpos_off->GetX();
    840           Double_t srcposy = srcpos_off->GetY();
    841          
    842           Int_t sizebin = GetBin(size,numberSizeBins,sizeBins);
    843          
    844           if (sizebin >= 0)
     623          if (width > widthmin[sizebin] && width < widthmax[sizebin])
    845624            {
    846               if (width > widthmin[sizebin] && width < widthmax[sizebin])
     625              if (length > lengthmin[sizebin] && length < lengthmax[sizebin])
    847626                {
    848                   if (length > lengthmin[sizebin] && length < lengthmax[sizebin])
     627                  //General histos
     628
     629                  if (dist > distmin[sizebin] && dist < distmax[sizebin])
    849630                    {
     631                      hSize_off->Fill(log10(size));
     632                      hWidth_off->Fill(width);
     633                      hLength_off->Fill(length);
     634
     635                      srcplace_timebin.SetPositionHisto(hSrcPos_on);
     636                      srcplace_timebin.CallProcess();
     637                      csrc_off.CallProcess();
     638                 
     639                      Double_t dist = hillassrc_off.GetDist()*geomcam.GetConvMm2Deg();
     640                      Double_t alpha = hillassrc_off.GetAlpha();
     641                      Double_t srcposx = srcpos_off.GetX();
     642                      Double_t srcposy = srcpos_off.GetY();
     643
     644                      hDist_off->Fill(dist);
     645                      hAlpha_off_abs->Fill(TMath::Abs(alpha));
     646                      hAlpha_off->Fill(alpha);
     647                      hSrcPos_off->Fill(srcposx,srcposy);
     648                    }
     649
     650                  // Time bin histos
     651                  for (UInt_t bin=0; bin<numberTimeBins; bin++)
     652                    {
     653                      srcplace_timebin.SetPositionHisto((TH2F*)srcposHistoOn[bin]);
     654                      srcplace_timebin.CallProcess();
     655                      csrc_off.CallProcess();
     656                     
     657                      Double_t dist = hillassrc_off.GetDist()*geomcam.GetConvMm2Deg();
     658                      Double_t alpha = hillassrc_off.GetAlpha();
     659                      Double_t srcposx = srcpos_off.GetX();
     660                      Double_t srcposy = srcpos_off.GetY();
     661                     
    850662                      if (dist > distmin[sizebin] && dist < distmax[sizebin])
    851663                        {
     
    853665                          ((TH2F*)srcposHistoOff[bin])->Fill(srcposx,srcposy);
    854666                        }
    855                       else
    856                         distcut[bin]++;     
    857667                    }
    858                   else 
    859                     lengthcut[bin]++;
    860668                }
    861               else
    862                 widthcut[bin]++;
    863669            }
    864670        }
    865671     
    866 //       if (zenith >  zenithMaximumOn[numberTimeBins-1])
    867 //      {
    868 //        cout << "Exit loop because we arrive to zenith = " << zenith << endl;
    869 //        break;
    870 //      }
     672      //       if (zenith >  zenithMaximumOn[numberTimeBins-1])
     673      //        {
     674      //          cout << "Exit loop because we arrive to zenith = " << zenith << endl;
     675      //          break;
     676      //        }
    871677    }
    872678 
     
    874680
    875681  tlist_off.PrintStatistics();
    876 
    877 //   for (UInt_t bin=0; bin<numberTimeBins; bin++)
    878 //     {
    879 //       cout <<  bin << ' '  << ((TH1F*)alphaHistoOff[bin])->GetEntries() << ' ' << ((TH2F*)srcposHistoOff[bin])->GetEntries() << endl;
    880 //       cout <<  "sizecut " << sizecut[bin] << endl;
    881 //       cout <<  "width   " << widthcut[bin] << endl;
    882 //       cout <<  "length  " << lengthcut[bin] << endl;
    883 //       cout <<  "dist    " << distcut[bin] << endl;
    884 //       cout <<  "alpha   " << alphacut[bin] << endl;
    885 //     }
    886  
    887682
    888683  TArrayD meanTimeBinOnInSec(numberTimeBins);
     
    931726  TString closepsname = psname + ")";
    932727
    933   TCanvas *c1 = new TCanvas;
    934   c1->cd(1);
     728  TCanvas *c0 = new TCanvas;
     729  c0->cd(1);
    935730  TGraphErrors* lightcurvegraph = new TGraphErrors(numberTimeBins,meanTimeBinOnInSec.GetArray(),numberExcessEventsPerMin.GetArray(),widthTimeBinOnInSec.GetArray(),errorNumberExcessEventsPerMin.GetArray());
    936731  lightcurvegraph->SetTitle("LightCurve");
     
    939734  lightcurvegraph->SetMarkerSize(0.03);
    940735  lightcurvegraph->Draw("AP");
     736  lightcurvegraph->GetYaxis()->SetTitle("Excess/min");
     737  lightcurvegraph->GetXaxis()->SetTitle("UTC Time");
    941738  lightcurvegraph->GetXaxis()->SetTimeDisplay(1);
    942   c1->Print(openpsname);
     739  c0->Print(openpsname);
    943740     
    944741  TCanvas** c = new TCanvas*[numberTimeBins];
     
    999796  ((TH1F*)alphaHistoOn[numberTimeBins-1])->DrawCopy("E1PSAME");
    1000797 
    1001   c[numberTimeBins-1]->Print(closepsname);
    1002 
    1003   TFile input("./prueba.root", "RECREATE");
    1004 
    1005    for (UInt_t bin=0; bin<numberTimeBins; bin++)
    1006      {
    1007        ((TH1F*)alphaHistoOn[bin])->Write();
    1008        ((TH1F*)alphaHistoOff[bin])->Write();
    1009        ((TH2F*)srcposHistoOn[bin])->Write();
    1010        ((TH2F*)srcposHistoOff[bin])->Write();
    1011        ((TH1F*)coszenithHistoOn[bin])->Write();
    1012      }
    1013 
    1014    input.Close();
    1015 
    1016   if(kFALSE)
    1017     {
    1018 
    1019   // ############################################################################
    1020   //  look for the histograms
    1021   // ############################################################################
    1022  
    1023   TH1F *hist_size_on = (TH1F*)hSize_on.GetHist();
    1024   TH1F *hist_size_off = (TH1F*)hSize_off.GetHist();
    1025  
    1026   TH1F *hist_dist_on = (TH1F*)hDist_on.GetHist();
    1027   TH1F *hist_dist_off = (TH1F*)hDist_off.GetHist();
    1028 
    1029   TH1F *hist_width_on = (TH1F*)hWidth_on.GetHist();
    1030   TH1F *hist_width_off = (TH1F*)hWidth_off.GetHist();
    1031 
    1032   TH1F *hist_length_on = (TH1F*)hLength_on.GetHist();
    1033   TH1F *hist_length_off = (TH1F*)hLength_off.GetHist();
    1034 
    1035   TH1F *hist_on_abs = (TH1F*)hAlpha_on_abs.GetHist();
    1036   TH1F *hist_off_abs = (TH1F*)hAlpha_off_abs.GetHist();
    1037 
    1038   TH1F *hist_on = (TH1F*)hAlpha_on.GetHist();
    1039   TH1F *hist_off = (TH1F*)hAlpha_off.GetHist();
    1040 
     798  c[numberTimeBins-1]->Print(psname);
     799
     800//   TFile input("./prueba.root", "RECREATE");
     801
     802//    for (UInt_t bin=0; bin<numberTimeBins; bin++)
     803//      {
     804//        ((TH1F*)alphaHistoOn[bin])->Write();
     805//        ((TH1F*)alphaHistoOff[bin])->Write();
     806//        ((TH2F*)srcposHistoOn[bin])->Write();
     807//        ((TH2F*)srcposHistoOff[bin])->Write();
     808//        ((TH1F*)coszenithHistoOn[bin])->Write();
     809//      }
     810
     811//    input.Close();
    1041812
    1042813  // ############################################################################
     
    1044815  // ############################################################################
    1045816
    1046   Double_t norm_on_abs  = (Double_t) hist_on_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
    1047   Double_t exces_on_abs = (Double_t) hist_on_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
    1048   Double_t norm_off_abs  = (Double_t) hist_off_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
    1049   Double_t exces_off_abs = (Double_t) hist_off_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
     817  Double_t norm_on_abs  = (Double_t) hAlpha_on_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
     818  Double_t exces_on_abs = (Double_t) hAlpha_on_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
     819  Double_t norm_off_abs  = (Double_t) hAlpha_off_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
     820  Double_t exces_off_abs = (Double_t) hAlpha_off_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
    1050821  Double_t norm = norm_on_abs/norm_off_abs;
    1051822
    1052823  char text_tit_alpha[256];
    1053824  sprintf(text_tit_alpha, " Alpha Plot On and Off ");
    1054   hist_off_abs->SetTitle(text_tit_alpha);
    1055   hist_on_abs->SetTitle(text_tit_alpha);
     825  hAlpha_off_abs->SetTitle(text_tit_alpha);
     826  hAlpha_on_abs->SetTitle(text_tit_alpha);
    1056827
    1057828  Double_t excess  = exces_on_abs - exces_off_abs*norm;
    1058829  Double_t sign    = excess / sqrt( exces_on_abs + norm*norm*exces_off_abs );
    1059   Double_t int_off = (Double_t) hist_off_abs->Integral(1, 18);
    1060   int hist_on_entries  = (int) hist_on_abs->GetEntries();
    1061   int hist_off_entries = (int) hist_off_abs->GetEntries();
     830  Double_t int_off = (Double_t) hAlpha_off_abs->Integral(1, 18);
     831  int hAlpha_on_entries  = (int) hAlpha_on_abs->GetEntries();
     832  int hAlpha_off_entries = (int) hAlpha_off_abs->GetEntries();
    1062833   
    1063834  cout << "---> Normalization F factor =\t" << norm <<endl;
    1064835  cout << "---> Excess =\t\t\t" << excess <<endl;
    1065836  cout << "---> Significancia =\t\t" << sign <<endl;   
    1066   cout << "---> entries on   =\t\t" << hist_on_entries  <<endl;
    1067   cout << "---> entries off  =\t\t" << hist_off_entries <<endl;
     837  cout << "---> entries on   =\t\t" << hAlpha_on_entries  <<endl;
     838  cout << "---> entries off  =\t\t" << hAlpha_off_entries <<endl;
    1068839  cout << "---> integral off =\t\t" << int_off <<endl;
    1069840
    1070841  Double_t shiftx;
    1071842
    1072   //
    1073   //Create the display -> from now on, all histos are plotted
    1074   MStatusDisplay *display = new MStatusDisplay;
    1075   display->SetUpdateTime(3000);
    1076   display->Resize(850,700);
    1077  
    1078843  // ############################################################################
    1079844  // Draw SIZE
    1080845  // ############################################################################
    1081   display->AddTab("SIZE");
     846  TCanvas *c1 = new TCanvas;
    1082847
    1083848  gPad->cd();
    1084849
    1085850  gPad->SetLogy();
    1086   hist_size_on->Sumw2();
    1087   hist_size_off->Sumw2();
    1088   hist_size_off->Scale(norm);
    1089   hist_size_on->SetLineColor(kBlack);
    1090   hist_size_on->SetMarkerStyle(21);
    1091   hist_size_on->SetMarkerSize(0.7);
    1092   hist_size_on->SetMarkerColor(kBlack);
    1093   hist_size_off->SetFillColor(46);
    1094   hist_size_off->SetLineColor(46);
    1095   hist_size_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
    1096   hist_size_off->SetMinimum(0.1);
    1097   hist_size_on->SetMinimum(0.1);
    1098   hist_size_on->SetTitle("SIZE distribution");
    1099   hist_size_off->SetTitle("SIZE distribution");
    1100 
    1101   hist_size_on->DrawCopy("E1P");
     851  hSize_on->Sumw2();
     852  hSize_off->Sumw2();
     853  hSize_off->Scale(norm);
     854  hSize_on->SetLineColor(kBlack);
     855  hSize_on->SetMarkerStyle(21);
     856  hSize_on->SetMarkerSize(0.7);
     857  hSize_on->SetMarkerColor(kBlack);
     858  hSize_off->SetFillColor(46);
     859  hSize_off->SetLineColor(46);
     860  hSize_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
     861  hSize_off->SetMinimum(0.1);
     862  hSize_on->SetMinimum(0.1);
     863  hSize_on->SetTitle("SIZE distribution");
     864  hSize_off->SetTitle("SIZE distribution");
     865
     866  hSize_on->DrawCopy("E1P");
    1102867
    1103868  // move stat box to make them all visible
    1104869  gPad->Update();
    1105   TPaveStats* pavs_on_size = (TPaveStats*) hist_size_on->GetListOfFunctions()->FindObject("stats");
     870  TPaveStats* pavs_on_size = (TPaveStats*) hSize_on->GetListOfFunctions()->FindObject("stats");
    1106871  if(pavs_on_size){
    1107872    shiftx = pavs_on_size->GetX2NDC() - pavs_on_size->GetX1NDC();
     
    1112877  gPad->Update();
    1113878
    1114   hist_size_off->DrawCopy("HISTSAME");
    1115   hist_size_off->DrawCopy("ESAME");
     879  hSize_off->DrawCopy("HISTSAME");
     880  hSize_off->DrawCopy("ESAME");
    1116881
    1117882  gPad->Modified();
    1118883  gPad->Update();
    1119884
    1120   Double_t chisize = ChiSquareNDof((TH1D*)hist_size_on,(TH1D*)hist_size_off);
     885  Double_t chisize = ChiSquareNDof((TH1D*)hSize_on,(TH1D*)hSize_off);
    1121886
    1122887  Double_t x_label_pos  = log10(1000000)*0.7;
    1123   Double_t y_label_pos  = log10((hist_size_on->GetBinContent(hist_size_on->GetMaximumBin()))/2.);
     888  Double_t y_label_pos  = log10((hSize_on->GetBinContent(hSize_on->GetMaximumBin()))/2.);
    1124889  Double_t textsize = 0.03;
    1125890
     
    1134899  gPad->Update();
    1135900
     901  c1->Print(psname);
     902
    1136903  // ############################################################################
    1137904  // DrawCopy DIST
    1138905  // ############################################################################
    1139   display->AddTab("DIST");
     906  TCanvas *c2 = new TCanvas;
    1140907
    1141908  gPad->cd();
    1142909
    1143   hist_dist_on->Sumw2();
    1144   hist_dist_off->Sumw2();
    1145   hist_dist_off->Scale(norm);
    1146   hist_dist_on->SetLineColor(kBlack);
    1147   hist_dist_on->SetMarkerStyle(21);
    1148   hist_dist_on->SetMarkerSize(0.7);
    1149   hist_dist_on->SetMarkerColor(kBlack);
    1150   hist_dist_off->SetFillColor(46);
    1151   hist_dist_off->SetLineColor(46);
    1152   hist_dist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
    1153   hist_dist_off->SetMinimum(0.);
    1154   hist_dist_on->SetTitle("DIST distribution");
    1155   hist_dist_off->SetTitle("DIST distribution");
    1156 
    1157   hist_dist_on->DrawCopy("E1P");
     910  hDist_on->Sumw2();
     911  hDist_off->Sumw2();
     912  hDist_off->Scale(norm);
     913  hDist_on->SetLineColor(kBlack);
     914  hDist_on->SetMarkerStyle(21);
     915  hDist_on->SetMarkerSize(0.7);
     916  hDist_on->SetMarkerColor(kBlack);
     917  hDist_off->SetFillColor(46);
     918  hDist_off->SetLineColor(46);
     919  hDist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
     920  hDist_off->SetMinimum(0.);
     921  hDist_on->SetTitle("DIST distribution");
     922  hDist_off->SetTitle("DIST distribution");
     923
     924  hDist_on->DrawCopy("E1P");
    1158925
    1159926  // move stat box to make them all visible
    1160927  gPad->Update();
    1161   TPaveStats* pavs_on_dist = (TPaveStats*) hist_dist_on->GetListOfFunctions()->FindObject("stats");
     928  TPaveStats* pavs_on_dist = (TPaveStats*) hDist_on->GetListOfFunctions()->FindObject("stats");
    1162929  if(pavs_on_dist){
    1163930    shiftx = pavs_on_dist->GetX2NDC() - pavs_on_dist->GetX1NDC();
     
    1168935  gPad->Update();
    1169936
    1170   hist_dist_off->DrawCopy("HISTSAME");
    1171   hist_dist_off->DrawCopy("ESAME");
    1172   hist_dist_on->DrawCopy("E1PSAME");
    1173 
    1174   Double_t chidist = ChiSquareNDof((TH1D*)hist_dist_on,(TH1D*)hist_dist_off);
    1175 
    1176   x_label_pos  = distmax[0]*0.7;
    1177   y_label_pos  = hist_dist_on->GetBinContent(hist_dist_on->GetMaximumBin())/2.;
     937  hDist_off->DrawCopy("HISTSAME");
     938  hDist_off->DrawCopy("ESAME");
     939  hDist_on->DrawCopy("E1PSAME");
     940
     941  Double_t chidist = ChiSquareNDof((TH1D*)hDist_on,(TH1D*)hDist_off);
     942
     943  x_label_pos  = distmax[numberSizeBins-1]*0.7;
     944  y_label_pos  = hDist_on->GetBinContent(hDist_on->GetMaximumBin())/2.;
    1178945
    1179946  char text_dist[256];
     
    1187954  gPad->Update();
    1188955
     956  c2->Print(psname);
     957
    1189958   // ############################################################################
    1190959  // DrawCopy WIDTH
    1191960  // ############################################################################
    1192   display->AddTab("WIDTH");
     961  TCanvas *c3 = new TCanvas;
    1193962
    1194963  gPad->cd();
    1195964
    1196   hist_width_off->Sumw2();
    1197   hist_width_off->Scale(norm);
    1198   hist_width_on->SetLineColor(kBlack);
    1199   hist_width_on->SetMarkerStyle(21);
    1200   hist_width_on->SetMarkerSize(0.7);
    1201   hist_width_on->SetMarkerColor(kBlack);
    1202   hist_width_off->SetFillColor(46);
    1203   hist_width_off->SetLineColor(46);
    1204   hist_width_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
    1205   hist_width_off->SetMinimum(0.);
    1206   hist_width_on->SetTitle("WIDTH distribution");
    1207   hist_width_off->SetTitle("WIDTH distribution");
    1208 
    1209   hist_width_on->DrawCopy("E1P");
     965  hWidth_off->Sumw2();
     966  hWidth_off->Scale(norm);
     967  hWidth_on->SetLineColor(kBlack);
     968  hWidth_on->SetMarkerStyle(21);
     969  hWidth_on->SetMarkerSize(0.7);
     970  hWidth_on->SetMarkerColor(kBlack);
     971  hWidth_off->SetFillColor(46);
     972  hWidth_off->SetLineColor(46);
     973  hWidth_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
     974  hWidth_off->SetMinimum(0.);
     975  hWidth_on->SetTitle("WIDTH distribution");
     976  hWidth_off->SetTitle("WIDTH distribution");
     977
     978  hWidth_on->DrawCopy("E1P");
    1210979
    1211980  // move stat box to make them all visible
    1212981  gPad->Update();
    1213   TPaveStats* pavs_on_width = (TPaveStats*) hist_width_on->GetListOfFunctions()->FindObject("stats");
     982  TPaveStats* pavs_on_width = (TPaveStats*) hWidth_on->GetListOfFunctions()->FindObject("stats");
    1214983  if(pavs_on_width){
    1215984    shiftx = pavs_on_width->GetX2NDC() - pavs_on_width->GetX1NDC();
     
    1220989  gPad->Update();
    1221990
    1222   hist_width_off->DrawCopy("HISTSAME");
    1223   hist_width_off->DrawCopy("ESAME");
    1224   hist_width_on->DrawCopy("E1PSAME");
    1225 
    1226   Double_t chiwidth = ChiSquareNDof((TH1D*)hist_width_on,(TH1D*)hist_width_off);
    1227 
    1228   x_label_pos  = widthmax[0]*0.7;
    1229   y_label_pos  = hist_width_on->GetBinContent(hist_width_on->GetMaximumBin())/2.;
     991  hWidth_off->DrawCopy("HISTSAME");
     992  hWidth_off->DrawCopy("ESAME");
     993  hWidth_on->DrawCopy("E1PSAME");
     994
     995  Double_t chiwidth = ChiSquareNDof((TH1D*)hWidth_on,(TH1D*)hWidth_off);
     996
     997  x_label_pos  = widthmax[numberSizeBins-1]*0.7;
     998  y_label_pos  = hWidth_on->GetBinContent(hWidth_on->GetMaximumBin())/2.;
    1230999
    12311000  char text_width[256];
     
    12391008  gPad->Update();
    12401009 
     1010  c3->Print(psname);
     1011
    12411012  // ############################################################################
    12421013  // DrawCopy LENGTH
    12431014  // ############################################################################
    1244   display->AddTab("LENGTH");
     1015  TCanvas *c4 = new TCanvas;
    12451016 
    12461017  gPad->cd();
    12471018
    1248   hist_length_on->Sumw2();
    1249   hist_length_off->Sumw2();
    1250   hist_length_off->Scale(norm);
    1251   hist_length_on->SetLineColor(kBlack);
    1252   hist_length_on->SetMarkerStyle(21);
    1253   hist_length_on->SetMarkerSize(0.7);
    1254   hist_length_on->SetMarkerColor(kBlack);
    1255   hist_length_off->SetFillColor(46);
    1256   hist_length_off->SetLineColor(46);
    1257   hist_length_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
    1258   hist_length_off->SetMinimum(0.);
    1259   hist_length_on->SetTitle("LENGTH distribution");
    1260   hist_length_off->SetTitle("LENGTH distribution");
    1261 
    1262   hist_length_on->DrawCopy("E1P");
     1019  hLength_on->Sumw2();
     1020  hLength_off->Sumw2();
     1021  hLength_off->Scale(norm);
     1022  hLength_on->SetLineColor(kBlack);
     1023  hLength_on->SetMarkerStyle(21);
     1024  hLength_on->SetMarkerSize(0.7);
     1025  hLength_on->SetMarkerColor(kBlack);
     1026  hLength_off->SetFillColor(46);
     1027  hLength_off->SetLineColor(46);
     1028  hLength_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
     1029  hLength_off->SetMinimum(0.);
     1030  hLength_on->SetTitle("LENGTH distribution");
     1031  hLength_off->SetTitle("LENGTH distribution");
     1032
     1033  hLength_on->DrawCopy("E1P");
    12631034
    12641035  // move stat box to make them all visible
    12651036  gPad->Update();
    1266   TPaveStats* pavs_on_length = (TPaveStats*) hist_length_on->GetListOfFunctions()->FindObject("stats");
     1037  TPaveStats* pavs_on_length = (TPaveStats*) hLength_on->GetListOfFunctions()->FindObject("stats");
    12671038  if(pavs_on_length){
    12681039    shiftx = pavs_on_length->GetX2NDC() - pavs_on_length->GetX1NDC();
     
    12731044  gPad->Update();
    12741045
    1275   hist_length_off->DrawCopy("HISTSAME");
    1276   hist_length_off->DrawCopy("ESAME");
    1277   hist_length_on->DrawCopy("E1PSAME");
    1278 
    1279   Double_t chilength = ChiSquareNDof((TH1D*)hist_length_on,(TH1D*)hist_length_off);
    1280 
    1281   x_label_pos  = lengthmax[0]*0.7;
    1282   y_label_pos  = hist_length_on->GetBinContent(hist_length_on->GetMaximumBin())/2.;
     1046  hLength_off->DrawCopy("HISTSAME");
     1047  hLength_off->DrawCopy("ESAME");
     1048  hLength_on->DrawCopy("E1PSAME");
     1049
     1050  Double_t chilength = ChiSquareNDof((TH1D*)hLength_on,(TH1D*)hLength_off);
     1051
     1052  x_label_pos  = lengthmax[numberSizeBins-1]*0.7;
     1053  y_label_pos  = hLength_on->GetBinContent(hLength_on->GetMaximumBin())/2.;
    12831054
    12841055  char text_length[256];
     
    12921063  gPad->Update();
    12931064
    1294   // ############################################################################
     1065  c4->Print(psname);
     1066
     1067 // ############################################################################
    12951068  // DrawCopy normalized ALPHA plot
    12961069  // ############################################################################
    1297   display->AddTab("ALPHA");
     1070  TCanvas *c5 = new TCanvas;
    12981071 
    12991072  gPad->cd();
    13001073
    1301   hist_on_abs->Sumw2();
    1302   hist_off_abs->SetStats(0);
    1303   hist_off_abs->Sumw2();
    1304   hist_off_abs->Scale(norm);
    1305   hist_on_abs->SetStats(0); //-> Do NOT show the legend with statistics
    1306   hist_on_abs->SetLineColor(kBlack);
    1307   hist_on_abs->SetMarkerStyle(21);
    1308   //hist_on_abs->SetMarkerSize();
    1309   hist_on_abs->SetMarkerColor(kBlack);
    1310   hist_on_abs->SetMarkerSize(0.7);
    1311   hist_off_abs->SetFillColor(46);
    1312   hist_off_abs->SetLineColor(46);
    1313   hist_off_abs->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
    1314   hist_off_abs->SetMinimum(0.);
    1315   hist_on_abs->SetTitle("Alpha plot");
    1316   hist_off_abs->SetTitle("Alpha plot");
    1317 
    1318  
    1319   hist_on_abs->DrawCopy("E1P");
    1320   hist_off_abs->DrawCopy("HISTSAME");
    1321   hist_off_abs->DrawCopy("ESAME");
    1322   hist_on_abs->DrawCopy("E1PSAME");
     1074  hAlpha_on_abs->Sumw2();
     1075  hAlpha_off_abs->SetStats(0);
     1076  hAlpha_off_abs->Sumw2();
     1077  hAlpha_off_abs->Scale(norm);
     1078  hAlpha_on_abs->SetStats(0); //-> Do NOT show the legend with statistics
     1079  hAlpha_on_abs->SetLineColor(kBlack);
     1080  hAlpha_on_abs->SetMarkerStyle(21);
     1081  //hAlpha_on_abs->SetMarkerSize();
     1082  hAlpha_on_abs->SetMarkerColor(kBlack);
     1083  hAlpha_on_abs->SetMarkerSize(0.7);
     1084  hAlpha_off_abs->SetFillColor(46);
     1085  hAlpha_off_abs->SetLineColor(46);
     1086  hAlpha_off_abs->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
     1087  hAlpha_off_abs->SetMinimum(0.);
     1088  hAlpha_on_abs->SetTitle("Alpha plot");
     1089  hAlpha_off_abs->SetTitle("Alpha plot");
     1090
     1091 
     1092  hAlpha_on_abs->DrawCopy("E1P");
     1093  hAlpha_off_abs->DrawCopy("HISTSAME");
     1094  hAlpha_off_abs->DrawCopy("ESAME");
     1095  hAlpha_on_abs->DrawCopy("E1PSAME");
    13231096
    13241097
     
    13261099  char text_Fnorm[256], text_excess[256], text_sign[256];
    13271100  char text_entries_on[256], text_entries_off[256], text_integral_off[256];
    1328   int hist_on_entries  = (int) hist_on_abs->GetEntries();
    1329   int hist_off_entries = (int) hist_off_abs->GetEntries();
     1101  int hAlpha_on_entries  = (int) hAlpha_on_abs->GetEntries();
     1102  int hAlpha_off_entries = (int) hAlpha_off_abs->GetEntries();
    13301103  sprintf(text_Fnorm,       " F norm =       %.3f", norm);
    13311104  sprintf(text_excess,      " Excess =       %.3f", excess);
    13321105  sprintf(text_sign,        " Significance = %.3f", sign);
    1333   sprintf(text_entries_on,  " Entries ON   = %d",  hist_on_entries);
    1334   sprintf(text_entries_off, " Entries OFF  = %d",  hist_off_entries);
     1106  sprintf(text_entries_on,  " Entries ON   = %d",  hAlpha_on_entries);
     1107  sprintf(text_entries_off, " Entries OFF  = %d",  hAlpha_off_entries);
    13351108  sprintf(text_integral_off," Integral OFF = %d",  int_off);
    13361109 
    1337   x_label_pos  = alphamax[0]*0.7;
    1338   y_label_pos  = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/1.6; //2.;
     1110  x_label_pos  = 90.*0.7;
     1111  y_label_pos  = (hAlpha_on_abs->GetBinContent(hAlpha_on_abs->GetMaximumBin())); //2.;
    13391112  Double_t y_label_step = y_label_pos / 8.;
    13401113
     
    13591132 
    13601133
    1361   Double_t chialpha = ChiSquareNDof((TH1D*)hist_on_abs,(TH1D*)hist_off_abs);
    1362 
    1363   y_label_pos  = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/2.;
     1134  Double_t chialpha = ChiSquareNDof((TH1D*)hAlpha_on_abs,(TH1D*)hAlpha_off_abs);
     1135
     1136  y_label_pos  = (hAlpha_on_abs->GetBinContent(hAlpha_on_abs->GetMaximumBin()))/2.;
    13641137
    13651138  char text_alpha[256];
     
    13731146  gPad->Update();
    13741147
     1148  c5->Print(psname);
     1149
    13751150  // ############################################################################
    13761151  // DrawCopy normalized alpha histos for alpha form -90 to 90 deg.
    13771152  // ############################################################################
    1378   display->AddTab("ALPHA +-90");
     1153  TCanvas *c6 = new TCanvas;
    13791154
    13801155  gPad->cd();
    13811156
    1382   hist_on->Sumw2();
    1383   hist_off->SetStats(0);
    1384   hist_off->Sumw2();
    1385   hist_off->Scale(norm);
    1386   hist_off->SetFillColor(46);
    1387   hist_off->SetLineColor(46);
    1388   hist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
    1389   hist_off->SetMinimum(0.);
    1390   hist_on->SetStats(0); //-> Do NOT show the legend with statistics
    1391   hist_on->SetLineColor(kBlack);
    1392   hist_on->SetMarkerStyle(21);
    1393   hist_on->SetMarkerSize(0.7);
    1394   hist_on->SetMarkerColor(kBlack);
    1395   hist_on->SetTitle("Alpha plot form -90 to 90 deg");
    1396   hist_off->SetTitle("Alpha plot form -90 to 90 deg");
    1397 
    1398   hist_on->DrawCopy("E1P");
    1399   hist_off->DrawCopy("HISTSAME");
    1400   hist_off->DrawCopy("ESAME");
    1401   hist_on->DrawCopy("E1PSAME");
    1402 
    1403   Double_t chialpha90 = ChiSquareNDof((TH1D*)hist_on,(TH1D*)hist_off);
    1404 
    1405   x_label_pos  = alphamax[0]*0.5;
    1406   y_label_pos  = hist_on->GetBinContent(hist_on->GetMaximumBin())/2.;
     1157  hAlpha_on->Sumw2();
     1158  hAlpha_off->SetStats(0);
     1159  hAlpha_off->Sumw2();
     1160  hAlpha_off->Scale(norm);
     1161  hAlpha_off->SetFillColor(46);
     1162  hAlpha_off->SetLineColor(46);
     1163  hAlpha_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
     1164  hAlpha_off->SetMinimum(0.);
     1165  hAlpha_on->SetStats(0); //-> Do NOT show the legend with statistics
     1166  hAlpha_on->SetLineColor(kBlack);
     1167  hAlpha_on->SetMarkerStyle(21);
     1168  hAlpha_on->SetMarkerSize(0.7);
     1169  hAlpha_on->SetMarkerColor(kBlack);
     1170  hAlpha_on->SetTitle("Alpha plot form -90 to 90 deg");
     1171  hAlpha_off->SetTitle("Alpha plot form -90 to 90 deg");
     1172
     1173  hAlpha_on->DrawCopy("E1P");
     1174  hAlpha_off->DrawCopy("HISTSAME");
     1175  hAlpha_off->DrawCopy("ESAME");
     1176  hAlpha_on->DrawCopy("E1PSAME");
     1177
     1178  Double_t chialpha90 = ChiSquareNDof((TH1D*)hAlpha_on,(TH1D*)hAlpha_off);
     1179
     1180  x_label_pos  = 90.*0.5;
     1181  y_label_pos  = hAlpha_on->GetBinContent(hAlpha_on->GetMaximumBin())/2.;
    14071182
    14081183  char text_alpha90[256];
     
    14161191  gPad->Modified();
    14171192
     1193  c6->Print(psname);
    14181194
    14191195  cout << "---> ChiSquare/NDof [Size] =\t\t" << chisize << endl;
     
    14251201
    14261202
    1427   display->AddTab("SRCPOS ON");
    1428   TH2F *hist_srcpos_on = (TH2F*)hSrcPos_on.GetHist();
    1429   hist_srcpos_on->DrawCopy("BOX");
    1430 
    1431   display->AddTab("SRCPOS OFF");
    1432   TH2F *hist_srcpos_off = (TH2F*)hSrcPos_off.GetHist();
    1433   hist_srcpos_off->DrawCopy("BOX");
    1434 
    1435 //   display->AddTab("EVTNUM ON");
    1436 //   TH1F *hist_evtnum_on = (TH1F*)hDAQEvtNumber_on.GetHist();
    1437 //   hist_evtnum_on->DrawCopy();
    1438 
    1439 //   display->AddTab("EVTNUM OFF");
    1440 //   TH1F *hist_evtnum_off = (TH1F*)hDAQEvtNumber_off.GetHist();
    1441 //   hist_evtnum_off->DrawCopy();
    1442 
    1443     } 
     1203  TCanvas *c7 = new TCanvas;
     1204  hSrcPos_on->DrawCopy("BOX");
     1205  c7->Print(psname);
     1206
     1207  TCanvas *c8 = new TCanvas;
     1208  hSrcPos_off->DrawCopy("BOX");
     1209  c8->Print(closepsname);
    14441210
    14451211  cout << "Done!!" <<endl;
Note: See TracChangeset for help on using the changeset viewer.