Changeset 4245 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
05/31/04 14:52:07 (20 years ago)
Author:
reyes
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4243 r4245  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2004/05/31: Raquel de los Reyes
     22
     23   * macros/DAQDataCheck.C
     24     - committed the macro to check the raw data and display the quality
     25       plots.
    2026
    2127 2004/05/30: Markus Gaug
  • trunk/MagicSoft/Mars/macros/DAQDataCheck.C

    r3546 r4245  
    1616!
    1717!
    18 !   Author(s): Raquel de los Reyes, 03/2004 <mailto:reyes@gae.ucm.es>
     18!   Author(s): Raquel de los Reyes, 05/2004 <mailto:reyes@gae.ucm.es>
    1919!
    2020!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
    23 \* ======================================================================== *//////////////////////////////////////////////////////////////////////////////
     23\* ======================================================================== */
     24/////////////////////////////////////////////////////////////////////////////
    2425//
    25 // This macro made the check of the DAQ files (.raw files).
     26// This macro makes the check of the DAQ files (.raw files).
    2627//
    27 // WARNING!: This macro only works if the directory is alphabetically ordered
     28// The only argument to the macro is the directory with the night raw files
     29// (ended with "/"). The macro sorts the entries in alphabetical order;
     30// it then joins all the consecutive pedestal, calibration and data runs
     31// and analyses all of them together. Data runs are taken consecutively
     32// until it finds a run of other type (pedestal or calibration) or a data run
     33// from another source. When a given source has no previous pedestal and/or
     34// calibration runs, the macro takes the most recent ones.
     35//
     36// The analysis is done through the jobs classes MJPedestal and MJCalibration.
    2837//
    2938///////////////////////////////////////////////////////////////////////////
    30 #include "MAGIC.h"
    31 
    32 void DataAnalysis(const MReadMarsFile *pedfiles,const MReadMarsFile *calfiles,const MReadMarsFile *datafiles,TString directory="./")
     39void DataAnalysis(const Int_t prun1,const Int_t prun2,
     40                  const Int_t crun1,const Int_t crun2,
     41                  const Int_t drun1,const Int_t drun2,
     42                  const TString inpath,
     43                  const TString outdir)
    3344{
    3445
    35   TVirtualPad *c;
    36 
    37   Bool_t batchmode = kTRUE;
    38 
    39   if(!batchmode)
    40     {
    41       MStatusDisplay *d = new MStatusDisplay;
    42       d->SetLogStream(&gLog, kTRUE);            // Disables output to stdout 
    43     }
     46  // Check if no pedestal runs has been detected
     47  if(prun1==0)
     48  {
     49      cout << "No pedestal run(s)!!!"<< endl;
     50      break;
     51  }
     52
     53  gStyle->SetOptStat(1);
     54  gStyle->SetOptFit();
     55
     56  MRunIter pruns;
     57  MRunIter cruns;
     58  MRunIter druns;
     59  //
     60  // Set the filter of MRunIter to .raw files
     61  pruns.SetRawFile(kTRUE);
     62  cruns.SetRawFile(kTRUE);
     63  druns.SetRawFile(kTRUE);
     64
     65  //
     66  // Check if you are analyzing more than one file
     67  if(prun1==prun2)
     68    pruns.AddRun(prun1,inpath);
     69  else
     70    pruns.AddRuns(prun1,prun2,inpath);
     71  if(crun1==crun2)
     72    cruns.AddRun(crun1,inpath);
     73  else
     74    cruns.AddRuns(crun1,crun2,inpath);
     75  if(drun1==drun2)
     76    druns.AddRun(drun1,inpath);
     77  else
     78    druns.AddRuns(drun1,drun2,inpath);
    4479
    4580  //
    4681  // Set up the source run-range
    4782  //
    48   TRegexp run("_[0-9][0-9][0-9][0-9][0-9]_");
    4983  TRegexp type("_[A-Z]_");
    50   TString ped = "", cal = "", data = "", source = "";
    51   if(pedfiles->GetEntries()!=0)
    52     source = pedfiles->GetFileName();
    53   else if(calfiles->GetEntries()!=0)
    54     source = calfiles->GetFileName();
    55   else
    56     source = datafiles->GetFileName();
    57 
    58   ped = pedfiles->GetFileName();
    59   if(calfiles->GetEntries()!=0)
    60     cal = calfiles->GetFileName();
    61   if(datafiles->GetEntries()!=0)
    62     data = datafiles->GetFileName();
    63  
    64   ped = ped(ped.Index(run)+1,5);
    65   cal = cal(cal.Index(run)+1,5);
    66   data = data(data.Index(run)+1,5);
    67 
     84  TString source = "";
     85  if(pruns.GetNumRuns()!=0)
     86    source = pruns.Next();
    6887  source = source(source.Index(type)+3,source.Length());
    6988  source.Remove(source.Last('_'),source.Length());
    7089
    71 //    cout << ped << endl;
    72 //    cout << cal << endl;
    73 //    cout << data << endl;
    74 //    cout << source << endl;
     90  TString title = outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps";
     91
     92  MStatusDisplay *d = new MStatusDisplay;
     93  d->SetTitle(title);
     94  d->SetLogStream(&gLog, kTRUE);
     95
     96  TObject::SetObjectStat(kTRUE);
     97 
     98  //
     99  // Choose the signal Extractor:
     100  //
     101  //  MExtractFixedWindowPeakSearch extractor;
     102  //  MExtractSlidingWindow  extractor;
     103   MExtractFixedWindow    extractor;
     104 
     105  //
     106  // Set Ranges or Windows
     107  //
     108   extractor.SetRange(3,14,3,14);
     109  //  extractor.SetWindows(8,8);
     110 
     111  //
     112  // Choose the arrival time Extractor:
     113  //
     114  //  MExtractTimeHighestIntegral timeext;
     115  MExtractTimeFastSpline timeext;
     116  //
     117  // Set Ranges or Windows
     118  //
     119  timeext.SetRange(2,12,4,14);
     120
     121  // ************************ GENERAL CONTAINERS  *************************
     122  MBadPixelsCam     badcam;
     123  MGeomCamMagic     geomcam;
     124  MGeomApply        geomapl;
     125  MCalibrationQECam qecam; 
    75126
    76127  // **********************************************************************
    77128  // ***************************** PEDESTALS ******************************
    78129  // **********************************************************************
    79   if(pedfiles->GetEntries()==0)
     130  if(pruns.GetNumRuns()==0)
    80131    {
    81132      cout << "Warning, no entries found in pedestal run(s)!!!"<< endl;
    82133      break;
    83134    }
    84   MParList plist;
    85   MTaskList tlist;
    86   plist.AddToList(&tlist);
    87  
    88 //    pedfiles->Print("all");
    89   //
    90   // Now setup the tasks and tasklist for the pedestals:
    91   // ---------------------------------------------------
    92   //
    93  
    94   //tasks
    95   pedfiles->DisableAutoScheme();
    96   tlist.AddToList(pedfiles);
    97  
    98   // pedestal tasks and containers
    99   MGeomCamMagic  geomcam;
    100   plist.AddToList(&geomcam);
    101   MPedestalCam   pedcam;
    102   plist.AddToList(&pedcam);
    103  
    104   MGeomApply geomapl;
    105   tlist.AddToList(&geomapl);
    106   MPedCalcPedRun pedcalc;
    107   tlist.AddToList(&pedcalc);
    108  
    109   //
    110   // Create and setup the eventloop
    111   //
    112   MEvtLoop evtloop;
    113   evtloop.SetParList(&plist);
    114   if(!batchmode)
    115     evtloop.SetDisplay(d);
    116  
     135
     136  MJPedestal pedloop;
     137  pedloop.SetExtractor(&extractor);           
     138  pedloop.SetInput(&pruns);
     139  pedloop.SetDisplay(d);
     140  pedloop.SetBadPixels(badcam);
     141  //
     142  // If you want to run the data-check on RAW DATA!!!, choose:
     143  pedloop.SetDataCheck(kTRUE);
     144
    117145  //
    118146  // Execute first analysis
     
    121149  cout << "** COMPUTING PEDESTALS **" << endl;
    122150  cout << "*************************" << endl;
    123   if (!evtloop.Eventloop())
     151  if (!pedloop.Process())
    124152    return;
    125  
    126   tlist.PrintStatistics();
    127  
    128   //
    129   // Display the pedestal checking plots
    130   //
    131   if ((d = evtloop.GetDisplay()))
    132     TCanvas &c1 = d.AddTab("PEDESTALS");
    133   else
    134     TCanvas *c1 = new TCanvas();
    135   MHCamera meanped(geomcam,"MPedestalCam;ped","Pedestals");
    136   meanped.SetCamContent(pedcam, 0);
    137   meanped.SetCamError(pedcam, 1);
    138   MHCamera rmsped(geomcam,"MPedestalCam;var","Sigma Pedestal");
    139   rmsped.SetCamContent(pedcam, 2);
    140   c1->Divide(1,2);
    141   gPad->SetBorderMode(0);
    142   c1->cd(1);
    143   meanped.DrawClone("nonewEPhist");
    144   c1->cd(2);
    145   gPad->SetBorderMode(0);
    146   c = gPad;
    147   c->Divide(2,1);
    148   c->cd(1);
    149   meanped.DrawClone("nonewpixelindex");
    150   c->cd(2);
    151   rmsped.DrawClone("nonewpixelindex");
    152 
    153   //
    154   // Save canvas/display into a postcript file
    155   //
    156 
    157   if ((d = evtloop.GetDisplay()))
    158     d->SaveAsPS(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
    159   else
    160     c1->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps(");
    161 
    162   if(calfiles->GetEntries()==0)
    163     c1->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps]");
     153
     154  //
     155  // Save display into a postcript file
     156  //
     157  d->SaveAsPS(outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps");
    164158
    165159  // **********************************************************************
    166160  // ***************************** CALIBRATION ****************************
    167161  // **********************************************************************
    168   //
    169   // Create a empty Parameter List and an empty Task List
    170   //
    171   if(calfiles->GetEntries()==0)
     162  if(cruns.GetNumRuns()==0)
    172163    {
    173164      cout << "Warning, no entries found in calibration run(s)!!!"<< endl;
    174165      break;
    175166    }
    176   MParList  plist2;
    177   MTaskList tlist2;
    178   plist2.AddToList(&tlist2);
    179  
    180 //    calfiles->Print("all");
    181   //
    182   // Now setup the new tasks and tasklist for the calibration
    183   // ---------------------------------------------------
    184   //
    185  
    186   calfiles->DisableAutoScheme();
    187   tlist2.AddToList(calfiles); 
    188  
    189   MExtractedSignalCam        sigcam;
    190   MArrivalTimeCam            timecam;
    191   MBadPixelsCam              badcam;
    192   MCalibrationChargeCam      calcam;
    193   MCalibrationChargePINDiode pindiode;
    194   MCalibrationChargeBlindPix blindpix;
    195  
    196   MHCalibrationRelTimeCam     histtime;
    197   MHCalibrationChargeCam      histcharge;
    198   MHCalibrationChargePINDiode histpin;
    199   MHCalibrationChargeBlindPix histblind;
    200   //
    201   // As long, as we don't have digital modules,
    202   // we have to set the color of the pulser LED by hand
    203   //
    204   blindpix.SetColor(kCT1);
    205   pindiode.SetColor(kCT1);
    206   //
    207   // Get the previously created MPedestalCam and MGeomCamMagic
    208   // into the new Parameter List
    209   //
    210   plist2.AddToList(&pedcam);
    211   plist2.AddToList(&geomcam);
    212 
    213   plist2.AddToList(&sigcam);
    214   plist2.AddToList(&timecam);
    215   plist2.AddToList(&badcam);
    216   plist2.AddToList(&calcam);
    217   plist2.AddToList(&histtime);
    218   plist2.AddToList(&histcharge);
    219   plist2.AddToList(&histpin);
    220   plist2.AddToList(&histblind);
    221  
    222   //
    223   // We saw that the signal jumps between slices,
    224   // thus take the sliding window
    225   //
    226   MExtractSignal2        sigcalc2;
    227   MExtractPINDiode       pincalc;
    228   MExtractBlindPixel     blindcalc;
    229   MArrivalTimeCalc2      timecalc;
    230   MCalibrationChargeCalc calcalc;
    231  
    232   MFillH filltime( "MHCalibrationRelTimeCam"    , "MArrivalTimeCam");
    233   MFillH fillpin  ("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
    234   MFillH fillblind("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
    235   MFillH fillcam  ("MHCalibrationChargeCam"     , "MExtractedSignalCam");
    236  
    237   // Skip the MFillH draw function
    238   filltime.SetBit(MFillH::kDoNotDisplay);
    239   fillpin.SetBit(MFillH::kDoNotDisplay);
    240   fillblind.SetBit(MFillH::kDoNotDisplay);
    241   fillcam.SetBit(MFillH::kDoNotDisplay);
    242  
    243   //
    244   // Skip the HiGain vs. LoGain calibration
    245   //
    246   calcalc.SkipHiLoGainCalibration();
    247  
    248   //
    249   // Apply a filter against cosmics
    250   // (was directly in MCalibrationCalc in earlier versions)
    251   //
    252   MFCosmics            cosmics;
    253   MContinue            cont(&cosmics);
    254   //
    255   // Get the previously created MGeomApply into the new Task List
    256   // 
    257   tlist2.AddToList(&geomapl);
    258 
    259   tlist2.AddToList(&sigcalc2);
    260   tlist2.AddToList(&pincalc);
    261   tlist2.AddToList(&blindcalc);
    262   //
    263   // In case, you want to skip the cosmics rejection,
    264   // uncomment the next line
    265   //
    266   tlist2.AddToList(&cont);
    267   //
    268   // In case, you want to skip the somewhat lengthy calculation
    269   // of the arrival times using a spline, uncomment the next two lines
    270   //
    271   tlist2.AddToList(&timecalc);
    272   tlist2.AddToList(&filltime);
    273 
    274   tlist2.AddToList(&fillpin);
    275   tlist2.AddToList(&fillblind);
    276   tlist2.AddToList(&fillcam);
    277   tlist2.AddToList(&calcalc);
    278  
    279   //
    280   // Create and setup the eventloop
    281   //
    282   MEvtLoop evtloop2;
    283   evtloop2.SetParList(&plist2);
    284   if(!batchmode)
    285     evtloop2.SetDisplay(d);
    286  
    287   //
    288   // Execute second analysis
    289   //
    290   cout << "***********************************" << endl;
    291   cout << "** COMPUTING CALIBRATION FACTORS **" << endl;
    292   cout << "***********************************" << endl;
    293   if (!evtloop2.Eventloop())
     167
     168  //
     169  // Tell if you want to calibrate times:
     170  //
     171  static const  Bool_t useTimes = kTRUE;
     172
     173  MJCalibration calloop;
     174  //
     175  // If you want to run the data-check on RAW DATA!!!, choose:
     176  calloop.SetDataCheck();
     177  //
     178  // If you want to see the data-check plots only, choose:
     179  calloop.SetDataCheckDisplay();
     180
     181  calloop.SetRelTimeCalibration(useTimes);
     182  calloop.SetExtractor(&extractor);
     183  calloop.SetTimeExtractor(&timeext);
     184  calloop.SetInput(&cruns);
     185  calloop.SetDisplay(d);
     186  calloop.SetQECam(qecam);
     187  calloop.SetBadPixels(pedloop.GetBadPixels());           
     188
     189  //
     190  // Execute first analysis
     191  //
     192  cout << "***************************" << endl;
     193  cout << "** COMPUTING CALIBRATION **" << endl;
     194  cout << "***************************" << endl;
     195  if (!calloop.Process(pedloop.GetPedestalCam()))
    294196    return;
    295  
    296   tlist2.PrintStatistics();
    297  
    298   //
    299   // print the most important results of all pixels to a file
    300   //
    301   //    MLog gauglog;
    302   //    gauglog.SetOutputFile(Form("%s%s",calcam.GetName(),".txt"),1);
    303   //    calcam.SetLogStream(&gauglog);
    304   //    calcam.Print();
    305   //    calcam.SetLogStream(&gLog);
    306 
    307   TH1 *hist;
    308 
    309   //
    310   // Display the calibration checking plots
    311   //     
    312   // ---------------------- Conversion factor ---------------------------
    313   if ((d = evtloop2.GetDisplay()))
    314     TCanvas &c2 = d.AddTab("CONV FACTOR");
    315   else
    316     TCanvas *c2 = new TCanvas();
    317   c2->Divide(1,2);
    318   c2->cd(1);
    319   gPad->SetBorderMode(0);
    320   c = gPad;
    321   c->Divide(2,1);
    322   gPad->SetBorderMode(0);
    323   c->cd(1);
    324   gPad->SetBorderMode(0);
    325   MHCamera ConvFfactor(geomcam,"Cal;FFactorConv","Conversion Factor to photons (F-Factor method)");
    326   ConvFfactor.SetCamContent(calcam, 11);
    327   ConvFfactor.DrawClone("nonewpixelindex");
    328   c->cd(2);
    329   MHCamera ConvBlindPix(geomcam,"Cal;BlindPixConv","Conversion Factor to photons (Blind Pixel method)");
    330   ConvBlindPix.SetCamContent(calcam, 17);
    331   ConvBlindPix.DrawClone("nonewpixelindex");
    332   c2->cd(2);
    333   gPad->SetBorderMode(0);
    334   MHCamera ConvPINDiode(geomcam,"Cal;PINDiodeConv","Conversion Factor to photons (PINDiode method)");
    335   ConvPINDiode.SetCamContent(calcam, 23);
    336   ConvPINDiode.DrawClone("nonewpixelindex");
    337   // ----------------- Pixels with defects ------------------------------
    338   if ((d = evtloop2.GetDisplay()))
    339     TCanvas &c3 = d.AddTab("DEFECT PIXELS");
    340   else
    341     TCanvas *c3 = new TCanvas();
    342   c3->Divide(3,2);
    343   c3->cd(1);
    344   MHCamera PixExc(geomcam,"Cal;Excluded","Pixels previously excluded");
    345   PixExc.SetCamContent(calcam, 27);
    346   PixExc.DrawClone("nonewpixelindex");
    347   c3->cd(2);
    348   MHCamera PixNoFit(geomcam,"Cal;NotFitted","Pixels that could not be fitted");
    349   PixNoFit.SetCamContent(calcam, 28);
    350   PixNoFit.DrawClone("nonewpixelindex");
    351   c3->cd(3);
    352   MHCamera PixNoValid(geomcam,"Cal;NotValidFit","Pixels with not valid fit results");
    353   PixNoValid.SetCamContent(calcam, 29);
    354   PixNoValid.DrawClone("nonewpixelindex");
    355   c3->cd(4);
    356   MHCamera PixFFactor(geomcam,"Cal;FFactorValid","Pixels with valid F-Factor calibration");
    357   PixFFactor.SetCamContent(calcam, 35);
    358   PixFFactor.DrawClone("nonewpixelindex");
    359   c3->cd(5);
    360   MHCamera PixBlind(geomcam,"Cal;BlindPixelValid","Pixels with valid BlindPixel calibration");
    361   PixBlind.SetCamContent(calcam, 36);
    362   PixBlind.DrawClone("nonewpixelindex");
    363   c3->cd(6);
    364   MHCamera PixPINDiode(geomcam,"Cal;PINdiodeFFactorValid","Pixels with valid PINDiode calibration");
    365   PixPINDiode.SetCamContent(calcam, 37);
    366   PixPINDiode.DrawClone("nonewpixelindex");
    367   // ------------------------- Fitted mean charges ----------------------------
    368   if ((d = evtloop2.GetDisplay()))
    369     TCanvas &c4 = d.AddTab("FIT CHARGES");
    370   else
    371     TCanvas *c4 = new TCanvas();
    372   c4->Divide(1,2);
    373   MHCamera fitmeancharge(geomcam,"Cal;Charge","Fitted Mean Charges");
    374   fitmeancharge.SetCamContent(calcam, 0);
    375   fitmeancharge.SetCamError(calcam, 1);
    376   c4->cd(1);
    377   gPad->SetBorderMode(0);
    378   fitmeancharge.DrawClone("nonewEPhist");
    379   c4->cd(2);
    380   c = gPad;
    381   gPad->SetBorderMode(0);
    382   c->Divide(2,1);
    383   c->cd(1);
    384   gPad->SetBorderMode(0);
    385   fitmeancharge.DrawClone("nonewpixelindex");
    386   c->cd(2);
    387   gPad->SetBorderMode(0);
    388   hist = (TH1*)fitmeancharge->Projection("Charge");
    389   hist->SetXTitle("Charge");
    390   hist->DrawCopy("hist");
    391   // ----------------------- Reduced Sigma per Charge -------------------------
    392   if ((d = evtloop2.GetDisplay()))
    393     TCanvas &c5 = d.AddTab("RED SIGMA");
    394   else
    395     TCanvas *c5 = new TCanvas();
    396   c5->Divide(1,2);
    397   MHCamera redsigmacharge(geomcam,"Cal;RSigmaCharge","Reduced Sigma per Charge");
    398   redsigmacharge.SetCamContent(calcam, 7);
    399   redsigmacharge.SetCamError(calcam, 8);
    400   c5->cd(1);
    401   gPad->SetBorderMode(0);
    402   redsigmacharge.DrawClone("nonewEPhist");
    403   c5->cd(2);
    404   c = gPad;
    405   gPad->SetBorderMode(0);
    406   c->Divide(2,1);
    407   c->cd(1);
    408   gPad->SetBorderMode(0);
    409   redsigmacharge.DrawClone("nonewpixelindex");
    410   c->cd(2);
    411   gPad->SetBorderMode(0);
    412   hist = redsigmacharge->Projection("RSigmaCharge");
    413   hist->SetXTitle("Reduced Sigma per Charge");
    414   hist->Draw("hist");
    415   // ----------------------- Absolute arrival times -------------------------
    416   if ((d = evtloop2.GetDisplay()))
    417     TCanvas &c6 = d.AddTab("ABS TIMES");
    418   else
    419     TCanvas *c6 = new TCanvas();
    420   c6->Divide(1,2);
    421   MHCamera abstime(geomcam,"Cal;AbsTimeMean","Absolute Arrival Times");
    422   abstime.SetCamContent(calcam, 42);
    423   abstime.SetCamError(calcam, 43);
    424   c6->cd(1);
    425   gPad->SetBorderMode(0);
    426   abstime.DrawClone("nonewEPhist");
    427   c6->cd(2);
    428   c = gPad;
    429   gPad->SetBorderMode(0);
    430   c->Divide(2,1);
    431   c->cd(1);
    432   gPad->SetBorderMode(0);
    433   abstime.DrawClone("nonewpixelindex");
    434   c->cd(2);
    435   gPad->SetBorderMode(0);
    436   hist = (TH1*)abstime->Projection("AbsTimeMean");
    437   hist->SetXTitle("Absolute arrival time (time slice)");
    438   hist->DrawCopy("hist");
    439 
    440   //
    441   // Save canvas/display into a postcript file
    442   //
    443 
    444   if ((d = evtloop2.GetDisplay()))
    445     d->SaveAsPS(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
    446   else
     197
     198  //
     199  // Save display into a postcript file
     200  //
     201  d->SaveAsPS(outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps");
     202
     203
     204}
     205
     206void DAQDataCheck(const TString directory="/remote/bigdown/data/Magic-DATA/Period014/rawdata/2004_02_17/",const TString outdir="./")
     207{
     208
     209  MDirIter iter;
     210  iter.AddDirectory(directory,"*.raw");
     211
     212  TString str=iter.Next();
     213
     214  TList list;
     215  while(!str.IsNull())
    447216    {
    448       c2->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
    449       c3->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
    450       c4->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
    451       c5->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
    452       c6->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
     217      list.Add(new TNamed(str,""));
     218      str=iter.Next();
    453219    }
    454 
    455   if(calfiles->GetEntries()!=0)
    456     c6->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps]");
    457 
    458   // ********************************************************************
    459   // ***************************** DATA *********************************
    460   // ********************************************************************
    461 
    462   if(datafiles->GetEntries()==0)
    463     {
    464       cout << "Warning, no entries found in data run(s)!!!"<< endl;
    465       break;
    466     }
    467   //
    468   // Create an empty Parameter List and an empty Task List
    469   //
    470   MParList  plist3;
    471   MTaskList tlist3;
    472   plist3.AddToList(&tlist3);
    473  
    474 //    datafiles->Print("all");
    475   //
    476   // Now setup the new tasks and tasklist for the data
    477   // ---------------------------------------------------
    478   //
    479  
    480   datafiles->DisableAutoScheme();
    481   tlist3.AddToList(datafiles); 
    482  
    483   // Task containers
    484   MExtractedSignalCam sigcam;
    485   //
    486   // Get the previously created MPedestalCam and MGeomCamMagic
    487   // into the new Parameter List
    488   //
    489   plist3.AddToList(&geomcam);
    490   plist3.AddToList(&pedcam);
    491 
    492   plist3.AddToList(&sigcam);
    493 
    494   // Display containers
    495   MHTimeDiffTime difftime("DiffTime","Differential time between events");
    496   plist3.AddToList(&difftime);
    497   MBinning binsdifftime("BinningTimeDiff");
    498   binsdifftime.SetEdges(200, 0., 0.2);
    499   plist3.AddToList(&binsdifftime);
    500   MBinning binstime("BinningTime");
    501   binstime.SetEdges(10000, 0., 1e10);
    502   plist3.AddToList(&binstime);
    503 
    504   // Data tasks
    505   MExtractSignal2 signal2;
    506 
    507   MFillH fillDiffTime(&difftime,"MRawEvtData");
    508   fillDiffTime.SetBit(MFillH::kDoNotDisplay);
    509   tlist3.AddToList(&fillDiffTime);
    510 
    511   //
    512   // Get the previously created MGeomApply into the new Task List
    513   //
    514   tlist3.AddToList(&geomapl);
    515   tlist3.AddToList(&signal2);
    516 
    517   //
    518   // Create and setup the eventloop
    519   //
    520   MEvtLoop evtloop3;
    521   evtloop3.SetParList(&plist3);
    522   if(!batchmode)
    523     evtloop3.SetDisplay(d);
    524  
    525   //
    526   // Execute third analysis
    527   //
    528   cout << "********************" << endl;
    529   cout << "** COMPUTING DATA **" << endl;
    530   cout << "********************" << endl;
    531   if (!evtloop3.Eventloop())
    532     return;
    533  
    534   tlist3.PrintStatistics();
    535 
    536   TH1 *hist1;
    537   TH2 *hist2;
    538 
    539   //
    540   // Display the data checking canvas
    541   //
    542   // -------------------- Diffential time of events ---------------------
    543   if ((d = evtloop3.GetDisplay()))
    544     TCanvas &c9 = d.AddTab("TIME");
    545   else
    546     TCanvas *c9 = new TCanvas();
    547   gStyle->SetPadGridX(kTRUE);
    548   gStyle->SetPadGridY(kTRUE);
    549   gStyle->SetOptFit();
    550   c9->Divide(2,2);
    551   hist2 = difftime.GetHist();
    552   c9->cd(1);
    553   gPad->SetLogy();
    554   hist1 = hist2->ProjectionX("ProjX_sumtime", -1, 9999, "E"); 
    555   hist1->SetTitle("Distribution of \\Delta t [s]");
    556   hist1->SetXTitle("\\Delta t [s]");
    557   hist1->SetYTitle("Counts");
    558   hist1->GetXaxis()->SetRange(0,hist1->GetXaxis()->GetNbins());
    559   TF1 *f1 = new TF1("f1","[0]*exp(x*[1])",hist1->GetMaximumBin(),hist1->GetXaxis()->GetXmax());
    560   hist1->Fit(f1,"");
    561   hist1->DrawCopy();
    562   c9->cd(2);
    563   gPad->SetLogy();
    564   hist1 = hist2->ProjectionX("ProjX_sumtime", -1, 9999, "E"); 
    565   hist1->SetTitle("Distribution of \\Delta t [s] (deadtime)");
    566   hist1->SetXTitle("\\Delta t [s]");
    567   hist1->SetYTitle("Counts");
    568 //    cout << hist1->GetXaxis()->GetBinCenter(hist1->GetMaximumBin())<< endl;
    569   hist1->GetXaxis()->SetRange(0,hist1->GetMaximumBin());
    570   hist1->DrawCopy();
    571   c9->cd(3);
    572   hist1 = difftime.GetHist()->ProjectionY("ProjY_sumtime", -1, 9999, "E"); 
    573   hist1->SetTitle("Distribution of time [s]");
    574   hist1->SetXTitle("Time t [s]");
    575   hist1->SetYTitle("Counts");
    576   hist1->DrawCopy();
    577   c9->cd(4);
    578 
    579   //
    580   // Save canvas/display into a postcript file
    581   //
    582 
    583   if ((d = evtloop3.GetDisplay()))
    584     d->SaveAsPS(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
    585   else
    586     {
    587       c9->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps)");
    588     }
    589  
    590 }
    591 
    592 void DAQDataCheck(const TString directory="/remote/data2/data/Magic-DATA/Period014/rootdata/2004_02_10/")
    593 {
    594 
    595   MDirIter Next;
    596   Next.AddDirectory(directory,"*_E.root",-1);
    597 
    598 //    Next.Print("all");
    599 
    600   TString fName="file.root";
    601 
    602   MReadMarsFile *pedfiles;
    603   MReadMarsFile *calfiles;
    604   MReadMarsFile *datafiles;
     220  list.Sort();
     221
     222  TIter Next(&list);
     223
     224  TString fName="file.raw";
     225
     226  TRegexp run("_[0-9][0-9][0-9][0-9][0-9]_");
     227  TRegexp type("_[A-Z]_");
     228
     229  Int_t pedrun1=0, pedrun2=0;
     230  Int_t calrun1=0, calrun2=0;
     231  Int_t datarun1=0, datarun2=0;
    605232
    606233  TString source="";
    607234
    608   fName = Next();  // absolut path
     235  TObject o*;
     236  o=Next();
     237  fName = o->GetName();  // absolut path
    609238
    610239  while(!fName.IsNull())
    611240    {
    612241
    613       TString file = fName(fName.Last('/')+1,fName.Length()); // root file name
    614       file = file(0,file.Last('_'));
    615 
    616 //        TString run = file(file.First('_')+1,5);
    617 //        TString type = file(file.Index('_',file.First('_')+1)+1,1);
    618       source = file(file.Last('_')+1,file.Length());
     242      source = fName(fName.Index(type)+3,fName.Length());
     243      source.Remove(source.Last('_'),source.Length());
    619244
    620245      // Pedestal runs
    621246      if(fName.Contains("_P_"))
    622         pedfiles = new MReadMarsFile("Events");
    623       else
    624         pedfiles->Rewind();
     247        pedrun1=atoi(fName(fName.Index(run)+1,5).Data());
     248      pedrun2=pedrun1;
    625249
    626250      while(fName.Contains("_P_")&&fName.Contains(source))
    627251        {
    628           pedfiles->AddFile(fName);
    629           fName = Next(); 
     252          pedrun2=atoi(fName(fName.Index(run)+1,5).Data());
     253          o=Next();
     254          if(!o)
     255            {
     256              fName="";
     257              break;
     258            }
     259          fName = o->GetName();
    630260        }
    631261
    632262      // Calibration runs
    633       if(fName.Contains("_C_")||(!fName.Contains(source)))
    634         calfiles = new MReadMarsFile("Events");
    635       else
    636         calfiles->Rewind();
     263      if(fName.Contains("_C_"))//||(!fName.Contains(source)))
     264        calrun1=atoi(fName(fName.Index(run)+1,5).Data());
     265//      else
     266//        calrun1=0;
     267      calrun2=calrun1;
    637268
    638269      while(fName.Contains("_C_")&&fName.Contains(source))
    639270        {
    640           calfiles->AddFile(fName);
    641           fName = Next(); 
     271          calrun2=atoi(fName(fName.Index(run)+1,5).Data());
     272          o=Next();
     273          if(!o)
     274            {
     275              fName = "";
     276              break;
     277            }
     278          fName = o->GetName();
    642279        }
    643280
    644281      // Data runs
    645       if(fName.Contains("_D_")||(!fName.Contains(source)))
    646         datafiles = new MReadMarsFile("Events");
    647 //        else
    648 //      break;
     282      if(fName.Contains("_D_"))//||(!fName.Contains(source)))
     283        datarun1=atoi(fName(fName.Index(run)+1,5).Data());
     284      else
     285          datarun1=0;
     286      datarun2=datarun1;
     287
    649288      while(fName.Contains("_D_")&&fName.Contains(source))
    650289        {
    651           datafiles->AddFile(fName);
    652           fName = Next(); 
     290          datarun2=atoi(fName(fName.Index(run)+1,5).Data());
     291          o=Next();
     292          if(!o)
     293            {
     294              fName = "";
     295              break;
     296            }
     297          fName = o->GetName();
    653298        }
    654299
    655 //        pedfiles->Print();
    656 //        calfiles->Print("all");
    657 //        datafiles->Print("all");
    658 
    659       DataAnalysis(pedfiles,calfiles,datafiles,directory);
     300//        cout << pedrun1 << "\t"<<pedrun2 << endl;
     301//        cout << calrun1 << "\t"<<calrun2 << endl;
     302//        cout << datarun1 << "\t"<<datarun2 << endl;
     303
     304      DataAnalysis(pedrun1,pedrun2,calrun1,calrun2,datarun1,datarun2,directory,outdir);
    660305
    661306      cout << "----------------------------------------------" << endl;
Note: See TracChangeset for help on using the changeset viewer.