Ignore:
Timestamp:
01/25/05 12:03:14 (20 years ago)
Author:
moralejo
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r5021 r5989  
    3838void starmc2()
    3939{
    40   Char_t* AnalysisFilename = "calibrated_data.root"; // File to be analyzed
    41   Char_t* OutFilename      = "star.root";        // Output file name
     40  Char_t* AnalysisFilename = "calibrated_protons.root"; // File to be analyzed
    4241
    43   Float_t CleanLev[2] = {4., 3.}; // Tail cuts for image analysis
     42  TString* OutFilename1;
     43  TString* OutFilename2;
     44
     45  // Change output file names as desired. If you want only one output, comment
     46  // out the initialization of OutFilename2:
     47//   OutFilename1 = new TString("star_train.root");   // Output file name 1 (test)
     48//   OutFilename2 = new TString("star_test.root");    // Output file name 2 (train)
     49
     50   OutFilename1 = new TString("star.root");   // Output file name 1 (test)
     51
     52
     53  Float_t CleanLev[2] = {3., 2.}; // Tail cuts for image analysis
    4454
    4555  // ------------------------------------------------------------------
     
    8090
    8191  //
    82   // Open output file:
     92  // Open output file(s):
    8393  //
    84   MWriteRootFile write(OutFilename); // Writes output
    85   write.AddContainer("MRawRunHeader", "RunHeaders");
    86   write.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
    87   write.AddContainer("MSrcPosCam",    "RunHeaders");
    88   write.AddContainer("MMcEvt",        "Events", kFALSE);
    89   write.AddContainer("MPointingPos",  "Events", kFALSE);
    90   write.AddContainer("MHillas",       "Events");
    91   write.AddContainer("MHillasExt",    "Events");
    92   write.AddContainer("MHillasSrc",    "Events");
    93   write.AddContainer("MNewImagePar",  "Events");
     94  MWriteRootFile write1(OutFilename1->Data()); // Writes output   
     95  //
     96  // Add MC containers only if they exist. In this way you can also run on real calibrated data.
     97  //
     98  write1.AddContainer("MRawRunHeader", "RunHeaders");
     99  write1.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
     100  write1.AddContainer("MSrcPosCam",    "RunHeaders");
     101  write1.AddContainer("MGeomCam",      "RunHeaders", kFALSE);
     102  write1.AddContainer("MMcConfigRunHeader",  "RunHeaders", kFALSE);
     103  write1.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
     104  write1.AddContainer("MMcFadcHeader",  "RunHeaders", kFALSE);
     105  write1.AddContainer("MMcTrigHeader",  "RunHeaders", kFALSE);
    94106
    95   tlist.AddToList(&write);            // Add task to write output.
     107  write1.AddContainer("MMcEvt",        "Events", kFALSE);
     108  write1.AddContainer("MPointingPos",  "Events", kFALSE);
     109  write1.AddContainer("MMcTrig",       "Events", kFALSE);
     110  write1.AddContainer("MRawEvtHeader", "Events");
     111  write1.AddContainer("MHillas",       "Events");
     112  write1.AddContainer("MHillasExt",    "Events");
     113  write1.AddContainer("MHillasSrc",    "Events");
     114  write1.AddContainer("MNewImagePar",  "Events");
     115
     116  if (OutFilename2) // Second output file, in case we want a split output
     117    {
     118      MWriteRootFile write2(OutFilename2->Data()); // Writes output
     119      write2.AddContainer("MRawRunHeader", "RunHeaders");
     120      write2.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
     121      write2.AddContainer("MSrcPosCam",    "RunHeaders");
     122      write2.AddContainer("MGeomCam",      "RunHeaders", kFALSE);
     123      write2.AddContainer("MMcConfigRunHeader",  "RunHeaders", kFALSE);
     124      write2.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
     125      write2.AddContainer("MMcFadcHeader",  "RunHeaders", kFALSE);
     126      write2.AddContainer("MMcTrigHeader",  "RunHeaders", kFALSE);
     127
     128      write2.AddContainer("MMcEvt",        "Events", kFALSE);
     129      write2.AddContainer("MPointingPos",  "Events", kFALSE);
     130      write2.AddContainer("MMcTrig",       "Events", kFALSE);
     131      write2.AddContainer("MRawEvtHeader", "Events");
     132      write2.AddContainer("MHillas",       "Events");
     133      write2.AddContainer("MHillasExt",    "Events");
     134      write2.AddContainer("MHillasSrc",    "Events");
     135      write2.AddContainer("MNewImagePar",  "Events");
     136
     137      //
     138      // Divide output in train and test samples, using the event number
     139      // (odd/even) to achieve otherwise unbiased event samples:
     140      //
     141     
     142      MF filter1("{MMcEvt.fEvtNumber%2}>0.5");
     143      MF filter2("{MMcEvt.fEvtNumber%2}<0.5");
     144
     145      write1.SetFilter(&filter1);
     146      write2.SetFilter(&filter2);
     147
     148      tlist.AddToList(&filter1);
     149      tlist.AddToList(&filter2);
     150    }
     151
     152
     153  tlist.AddToList(&write1);
     154
     155  if (OutFilename2)
     156    tlist.AddToList(&write2);   
     157 
    96158
    97159  //
Note: See TracChangeset for help on using the changeset viewer.