Ignore:
Timestamp:
01/22/04 20:54:16 (21 years ago)
Author:
moralejo
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/starmc.C

    r2874 r2886  
    11/* ======================================================================== *\
    2 !
    3 ! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
    5 ! * Software. It is distributed to you in the hope that it can be a useful
    6 ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
    7 ! * It is distributed WITHOUT ANY WARRANTY.
    8 ! *
    9 ! * Permission to use, copy, modify and distribute this software and its
    10 ! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
    12 ! * that both that copyright notice and this permission notice appear
    13 ! * in supporting documentation. It is provided "as is" without express
    14 ! * or implied warranty.
    15 ! *
    16 !
    17 !
    18 !   Author(s): Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
    19 !              Thomas Bretz  5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    20 !
    21 !   Copyright: MAGIC Software Development, 2000-2004
    22 !
    23 !
    24 \* ======================================================================== */
     2   !
     3   ! *
     4   ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     5   ! * Software. It is distributed to you in the hope that it can be a useful
     6   ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     7   ! * It is distributed WITHOUT ANY WARRANTY.
     8   ! *
     9   ! * Permission to use, copy, modify and distribute this software and its
     10   ! * documentation for any purpose is hereby granted without fee,
     11   ! * provided that the above copyright notice appear in all copies and
     12   ! * that both that copyright notice and this permission notice appear
     13   ! * in supporting documentation. It is provided "as is" without express
     14   ! * or implied warranty.
     15   ! *
     16   !
     17   !
     18   !   Author(s): Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
     19   !              Thomas Bretz  5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     20   !
     21   !   Copyright: MAGIC Software Development, 2000-2004
     22   !
     23   !
     24   \* ======================================================================== */
    2525
    2626/////////////////////////////////////////////////////////////////////////////
     
    3737void starmc()
    3838{
    39     //
    40     // This is a demonstration program which calculates the image
    41     // parameters from Magic Monte Carlo files (output of camera).
    42 
    43     //
    44     // Create a empty Parameter List and an empty Task List
    45     // The tasklist is identified in the eventloop by its name
    46     //
    47     MParList  plist;
    48 
    49     MTaskList tlist;
    50 
    51     plist.AddToList(&tlist);
    52 
    53     MSrcPosCam src;
    54     src.SetReadyToSave();
    55 
    56     plist.AddToList(&src);
    57 
    58     //
    59     // Now setup the tasks and tasklist:
    60     // ---------------------------------
    61     //
    62     MReadMarsFile read("Events");
    63 
    64     // ------------- user change -----------------
    65 
    66     read.AddFile("Gamma_zbin*.root");
    67 
    68     read.DisableAutoScheme();
    69 
    70     MGeomApply geom; // Reads in geometry from MC file and sets the right sizes for
    71                      // several parameter containers.
    72 
    73     MMcPedestalCopy   pcopy;
    74     // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
    75 
    76     MExtractSignal    sigextract;
    77     // Define ADC slices to be integrated in high and low gain:
    78     sigextract.SetRange(0, 5, 0, 5);
    79 
    80     MMcCalibrationUpdate  mccalibupdate;
    81 
    82     //
    83     // Now introduce conversion factor from ADC counts to photons before camera for
    84     // inner pixels. The corresponding value for outer pixels is then calculated
    85     // automatically. Bear in mind that the conversion factor depend both on the
    86     // parameters used in the camera simulation as well as on the number of
    87     // integrated FADC slices. In the future it should be calculated in a previous
    88     // event loop, either from the same MC file or from a MC calibration file
    89     // written on purpose.
    90     // (FIXME: the conversion must be calculated automatically from the analyzed file)
    91     //
    92     mccalibupdate.SetADC2PhInner(1.2586);
     39  //
     40  // This is a demonstration program which calculates the image
     41  // parameters from Magic Monte Carlo files (output of camera).
    9342
    9443
    95     MCalibrate calib; // Transforms signals from ADC counts into photons.
     44  // ------------- user change -----------------
    9645
    97     //    MBlindPixelCalc   blind;
    98     //    blind.SetUseInterpolation();
     46  TString* CalibrationFilename;
    9947
    100     MImgCleanStd      clean(4.1,3.4); // Applies tail cuts to image.
     48  //
     49  // Comment out next line to disable calibration. In that case the units of the
     50  // MHillas.fSize parameter will be ADC counts (rather, equivalent ADC counts in
     51  // inner pixels, since we correct for the possible differences in gain of outer
     52  // pixels)
     53  //
     54  CalibrationFilename = new TString("../../../nonoise/gammas/Gamma_zbin0_0*.root");
     55  // File to be used in the calibration (must be a camera file without added noise)
     56
     57  Char_t* AnalysisFilename = "Proton_zbin*.root";  // File to be analyzed
     58  Char_t* OutFilename      = "star_mc.root";       // Output file name
     59
     60  Float_t CleanLev[2] = {4., 3.}; // Tail cuts for image analysis
     61
     62  Int_t BinsHigh[2] = {0, 5}; // First and last FADC bin of the range to be integrated,
     63  Int_t BinsLow[2]  = {0, 5}; // for high and low gain respectively.
     64
     65  // -------------------------------------------
     66
     67  //
     68  // Create a empty Parameter List and an empty Task List
     69  // The tasklist is identified in the eventloop by its name
     70  //
     71  MParList  plist;
     72
     73  MTaskList tlist;
     74
     75  plist.AddToList(&tlist);
     76
     77  MSrcPosCam src;
     78  src.SetReadyToSave();
     79
     80  plist.AddToList(&src);
     81
     82  //
     83  // Now setup the tasks and tasklist:
     84  // ---------------------------------
     85  //
     86  MReadMarsFile read("Events");
     87
     88  if (CalibrationFilename)
     89    read.AddFile(CalibrationFilename->Data());
     90
     91  read.DisableAutoScheme();
     92
     93  MGeomApply geom; // Reads in geometry from MC file and sets the right sizes for
     94  // several parameter containers.
     95
     96  MMcPedestalCopy   pcopy;
     97  // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
     98
     99  MExtractSignal    sigextract;
     100  // Define ADC slices to be integrated in high and low gain:
     101  sigextract.SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
     102
     103  MMcCalibrationUpdate  mccalibupdate;
     104
     105  MCalibrate calib; // Transforms signals from ADC counts into photons.
     106
     107  //    MBlindPixelCalc   blind;
     108  //    blind.SetUseInterpolation();
     109
     110  MImgCleanStd      clean(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
     111
     112  MHillasCalc       hcalc; // Calculates Hillas parameters not dependent on source position.
     113  MHillasSrcCalc    scalc; // Calculates source-dependent Hillas parameters
     114
     115  MMcCalibrationCalc mccalibcalc;
     116
     117  tlist.AddToList(&read);
     118  tlist.AddToList(&geom);
     119  tlist.AddToList(&pcopy);
     120
     121  tlist.AddToList(&sigextract);
     122  tlist.AddToList(&mccalibupdate);
     123  tlist.AddToList(&calib);
     124  tlist.AddToList(&clean);
     125  //    tlist.AddToList(&blind);
     126  tlist.AddToList(&hcalc);
     127
     128  tlist.AddToList(&mccalibcalc);
     129
     130  //
     131  // Open output file:
     132  //
     133  MWriteRootFile write(OutFilename); // Writes output
     134  write.AddContainer("MRawRunHeader", "RunHeaders");
     135  write.AddContainer("MMcRunHeader",  "RunHeaders");
     136  write.AddContainer("MSrcPosCam",    "RunHeaders");
     137  write.AddContainer("MMcEvt",        "Events");
     138  write.AddContainer("MHillas",       "Events");
     139  write.AddContainer("MHillasExt",    "Events");
     140  write.AddContainer("MHillasSrc",    "Events");
     141  write.AddContainer("MNewImagePar",  "Events");
     142
     143  //
     144  // First loop: Calibration loop
     145  //
     146
     147  MProgressBar bar;
     148  bar.SetWindowName("Calibrating...");
     149
     150  MEvtLoop evtloop;
     151  evtloop.SetProgressBar(&bar);
     152  evtloop.SetParList(&plist);
     153
     154  if (CalibrationFilename)
     155    {
     156      if (!evtloop.Eventloop())
     157        return;
     158      mccalibcalc->GetHist()->Write();
     159    }
     160
     161  //
     162  // Second loop: analysis loop
     163  //
     164
     165  //
     166  // Change the read task by another one which reads the file we want to analyze:
     167  //
     168
     169  MReadMarsFile read2("Events");
     170  read2.AddFile(AnalysisFilename);
     171  read2.DisableAutoScheme();
     172  tlist.AddToListBefore(&read2, &read, "All");
     173  tlist.RemoveFromList(&read);
     174
     175  bar.SetWindowName("Analyzing...");
     176
     177  tlist.RemoveFromList(&mccalibcalc); // Removes calibration task from list.
     178
     179  tlist.AddToList(&scalc);            // Calculates Source-dependent Hillas parameters
     180
     181  tlist.AddToList(&write);            // Add task to write output.
     182
     183  if (!evtloop.Eventloop())
     184    return;
    101185
    102186
    103     MHillasCalc       hcalc; // Calculates Hillas parameters not dependent on source position.
    104     MHillasSrcCalc    scalc; // Calculates source-dependent Hillas parameters
    105                              // (!!Preliminary!! Will be removed later!)
    106 
    107 
    108     // ------------- user change -----------------
    109 
    110     MWriteRootFile write("star_mc.root"); // Writes output
    111 
    112     write.AddContainer("MRawRunHeader", "RunHeaders");
    113     write.AddContainer("MMcRunHeader",  "RunHeaders");
    114     write.AddContainer("MSrcPosCam",    "RunHeaders");
    115     write.AddContainer("MMcEvt",        "Events");
    116     write.AddContainer("MHillas",       "Events");
    117     write.AddContainer("MHillasExt",    "Events");
    118     write.AddContainer("MHillasSrc",    "Events");
    119     write.AddContainer("MNewImagePar",  "Events");
    120 
    121 
    122     tlist.AddToList(&read);
    123     tlist.AddToList(&geom);
    124     tlist.AddToList(&pcopy);
    125 
    126     tlist.AddToList(&sigextract);
    127     tlist.AddToList(&mccalibupdate);
    128     tlist.AddToList(&calib);
    129     tlist.AddToList(&clean);
    130     //    tlist.AddToList(&blind);
    131     tlist.AddToList(&hcalc);
    132     tlist.AddToList(&scalc);
    133     tlist.AddToList(&write);
    134 
    135     //
    136     // Create and set up the eventloop
    137     //
    138     MProgressBar bar;
    139 
    140     MEvtLoop evtloop;
    141     evtloop.SetProgressBar(&bar);
    142     evtloop.SetParList(&plist);
    143 
    144     //
    145     // Execute your analysis
    146      //
    147     if (!evtloop.Eventloop())
    148         return;
    149 
    150     tlist.PrintStatistics();
     187  tlist.PrintStatistics();
    151188}
Note: See TracChangeset for help on using the changeset viewer.