# Analyzing CORSIKA output

**URL:** <https://root-forum.cern.ch/t/analyzing-corsika-output/52901>\
**Category:** Newbie\
**Created:** [December 26, 2022, 9:15am UTC](https://root-forum.cern.ch/t/analyzing-corsika-output/52901 "2022-12-26T09:15:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chege](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@Chege](https://root-forum.cern.ch/u/Chege)\
**Post date:** [December 26, 2022, 9:15am UTC](https://root-forum.cern.ch/t/analyzing-corsika-output/52901/1 "2022-12-26T09:15:55Z")

</div>

Hi. I am unable to edit CorsikaPlotter to analyze Corsika Output using the instruction given.

Edit CorsikPlotter.cc, with editor of your choice, e.g.  
gedit CorsikaPlotter.cc  
 Add ROOT 1D histogram to study shower zenith angle distribution  
  
20 bins from 0 to 90 [degree], name: zenith  
 Fill shower zenith into histogram (take care of units)  
  
Note: check COAST Documentation link on ISAPP 2018 indico page  
 Create TCanvas, draw histogram, save pdf format  
 Type make in directory to compile.

I am just a beginner kindly help.

#include \<crsRead/MCorsikaReader.h\>

#include \<crs/TSubBlock.h\>  
#include \<crs/MRunHeader.h\>  
#include \<crs/MEventHeader.h\>  
#include \<crs/MEventEnd.h\>  
#include \<crs/MParticleBlock.h\>  
#include \<crs/MLongitudinalBlock.h\>  
#include \<crs/MParticle.h\>

#include \<TCanvas.h\>  
#include \<TH1D.h\>

#include   
using namespace std;

int  
main (int argc, char \*\*argv)  
{  
if (argc\<2) {  
cout \<\< " Name of the file " \<\< endl;  
return 1;  
}

// CREATE HISTOGRAMS HERE …

// …

string fname(argv[1]);  
crsRead::MCorsikaReader cr(fname, 3);

int ShowerCounter = 0;  
crs::MRunHeader Run;  
while (cr.GetRun (Run)) {

```
crs::MEventHeader Shower;
while (cr.GetShower(Shower)) {

  
  // FILL SHOWER-LEVEL HISTOGRAMS HERE ....
  
  // ........................................
  

  ++ShowerCounter;           
  crs::TSubBlock Data;
  while (cr.GetData (Data)) {
    
    switch (Data.GetBlockType ()) {
      
        case crs::TSubBlock::ePARTDATA:
        {
          const crs::MParticleBlock& ParticleData = Data;
          crs::MParticleBlock::ParticleListConstIterator iEntry;
          for (iEntry = ParticleData.FirstParticle();
               iEntry != ParticleData.LastParticle();
               ++iEntry) {
            
            if (iEntry->IsParticle()) {
              
              crs::MParticle iPart(*iEntry);
              
              const int id = iPart.GetParticleID();
              const double w = iPart.GetWeight();
              const double e = iPart.GetKinEnergy();
              const double x = iPart.GetX();
              const double y = iPart.GetY();

	  
	  // FILL PARTICLE-LEVEL HISTOGRAMS HERE ....

	  // ........................................
	  
	  
            }
            
          } // end particle loop
          
          break;
        }
        
        case crs::TSubBlock::eLONG:
          break;
          
        default:
          break;
    } // end data block
    
  } // loop data
  
  crs::MEventEnd ShowerSummary;
  cr.GetShowerSummary(ShowerSummary);
  const double Xmax = ShowerSummary.GetXmax();

} // loop shower

```

} // loop runs (usually just 1)

// PERFORM FINAL COMPUTATION ON HISTOGRAMS …  
// AND PRINT/SAVE

// TCanvas\* canvas = new TCanvas(“printout”);

// canvas-\>SaveAs(“canvas.pdf”);

// …

cout \<\< " Read " \<\< ShowerCounter \<\< " showers from file " \<\< endl;

return 0;  
}

My Output is in this format.

/home/sam/Chege1/DAT000002

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [December 26, 2022, 9:19am UTC](https://root-forum.cern.ch/t/analyzing-corsika-output/52901/2 "2022-12-26T09:19:08Z")

</div>

You need to contact the “Corsika” support team and/or your colleagues and/or your supervisor (hopefully, they know “Corsika”).

---

<div class="post-metadata">

**Author:** ![Chege](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@Chege](https://root-forum.cern.ch/u/Chege)\
**Post date:** [December 26, 2022, 1:15pm UTC](https://root-forum.cern.ch/t/analyzing-corsika-output/52901/3 "2022-12-26T13:15:49Z")

</div>

Thank you. will consult them

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [January 9, 2023, 1:16pm UTC](https://root-forum.cern.ch/t/analyzing-corsika-output/52901/4 "2023-01-09T13:16:31Z")

</div>

Closed on January 9, 2023, 1:16pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
