Changeset 9937 for trunk/Mars/msim


Ignore:
Timestamp:
09/22/10 15:25:55 (14 years ago)
Author:
tbretz
Message:
Added support for re-use of showers in MMCS.
Location:
trunk/Mars/msim
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/msim/MPhotonData.cc

    r9820 r9937  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
     18!   Author(s): Thomas Bretz, 12/2000 <mailto:thomas.bretz@epfl.ch>
    1919!   Author(s): Qi Zhe,       06/2007 <mailto:qizhe@astro.uni-wuerzburg.de>
    2020!
    21 !   Copyright: CheObs Software Development, 2000-2009
     21!   Copyright: CheObs Software Development, 2000-2010
    2222!
    2323!
     
    3434//   Version 1:
    3535//   ----------
    36 //    - First implementation
     36//    * First implementation
     37//
     38//   Version 2:
     39//   ----------
     40//    - fNumPhotons
    3741//
    3842/////////////////////////////////////////////////////////////////////////////
     
    5761MPhotonData::MPhotonData(/*const char *name, const char *title*/)
    5862    : fPosX(0), fPosY(0), fCosU(0), fCosV(0), fTime(0), fWavelength(0),
    59     fNumPhotons(1), fProductionHeight(0), fPrimary(MMcEvtBasic::kUNDEFINED),
     63    /*fNumPhotons(1),*/ fProductionHeight(0), fPrimary(MMcEvtBasic::kUNDEFINED),
    6064    fTag(-1), fWeight(1)
    6165{
     
    8286    MPhotonData &d = static_cast<MPhotonData&>(obj);
    8387
    84     d.fNumPhotons       = fNumPhotons;
     88//    d.fNumPhotons       = fNumPhotons;
    8589    d.fPosX             = fPosX;
    8690    d.fPosY             = fPosY;
     
    185189
    186190    fPrimary    = MMcEvtBasic::kUNDEFINED;
    187     fNumPhotons =  1;
     191//    fNumPhotons =  1;
    188192    fTag        = -1;
    189193    fWeight     =  1;
     
    201205// system intpo our own.
    202206//
    203 Int_t MPhotonData::FillCorsika(Float_t f[7])
     207Int_t MPhotonData::FillCorsika(Float_t f[7], Int_t i)
    204208{
    205209    const UInt_t n = TMath::Nint(f[0]);
    206210    if (n==0)
     211        // FIXME: Do we need to decode the rest anyway?
     212        return kCONTINUE;
     213
     214    // Check reuse
     215    const Int_t reuse = (n/1000)%100; // Force this to be 1!
     216    if (reuse!=i)
    207217        return kCONTINUE;
    208218
     
    210220    fWavelength = n%1000;
    211221    fPrimary    = MMcEvtBasic::ParticleId_t(n/100000);
    212     fNumPhotons = (n/1000)%100; // Force this to be 1!
    213 
    214     if (fNumPhotons!=1)
    215     {
    216         // FIXME: Could be done in MPhotonEvent::ReadCorsikaEvent
    217         gLog << err << "ERROR - MPhotonData::FillCorsika: fNumPhotons not 1, but " << fNumPhotons << endl;
    218         gLog << "        This is not yet supported." << endl;
    219         return kERROR;
    220     }
    221222
    222223    // x=north, y=west
     
    254255Int_t MPhotonData::FillEventIO(Float_t f[8])
    255256{
     257    if (TMath::Nint(f[6])!=1)
     258    {
     259        gLog << err << "ERROR - Bunch sizes != 1 are not supported." << endl;
     260        return kFALSE;
     261    }
     262
    256263    fPosX             =  f[1];              // xpos relative to telescope [cm]
    257264    fPosY             = -f[0];              // ypos relative to telescope [cm]
     
    260267    fTime             =  f[4];              // a relative arival time [ns]
    261268    fProductionHeight =  f[5];              // altitude of emission [cm]
    262     fNumPhotons       =  TMath::Nint(f[6]); // photons in this bunch
     269//    fNumPhotons       =  TMath::Nint(f[6]); // photons in this bunch
    263270    fWavelength       =  TMath::Nint(f[7]); // so far always zeor = unspec. [nm]
    264 
    265271
    266272    // Now reset all data members which are not in the stream
     
    271277    return kTRUE;
    272278}
    273 
     279/*
    274280// --------------------------------------------------------------------------
    275281//
     
    299305    return rc==kTRUE ? !fin.eof() : rc;
    300306}
     307*/
    301308
    302309// --------------------------------------------------------------------------
     
    308315{
    309316    gLog << inf << endl;
    310     gLog << "Num Photons:      " << fNumPhotons << " from " << MMcEvtBasic::GetParticleName(fPrimary) << endl;
     317//    gLog << "Num Photons:      " << fNumPhotons << " from " << MMcEvtBasic::GetParticleName(fPrimary) << endl;
     318    gLog << "Origin:           " << MMcEvtBasic::GetParticleName(fPrimary) << endl;
    311319    gLog << "Wavelength:       " << fWavelength << "nm" << endl;
    312320    gLog << "Pos X/Y  Cos U/V: " << fPosX << "/" << fPosY << "   " << fCosU << "/" << fCosV << endl;
  • trunk/Mars/msim/MPhotonData.h

    r9616 r9937  
    3737
    3838    Float_t fTime;                       // [ns] Time since first interaction or entrance into atmosphere
    39     // 17M
    4039    UShort_t fWavelength;                // [nm] Wavelength
    41     // 19M
    42     UInt_t   fNumPhotons;                // Number of cherenkov photons ins bunch
     40//    UInt_t   fNumPhotons;                // Number of cherenkov photons ins bunch
    4341    Float_t  fProductionHeight;          // [cm] Height of bunch production
    4442    MMcEvtBasic::ParticleId_t fPrimary;  // Type of emitting particle
    45     // 22M
    46     // gzip
    47     // 25M
    48     // raw
    49     // 32M
    5043
    5144    Int_t   fTag;    //! A tag for external use
     
    129122
    130123    // I/O
    131     Int_t ReadCorsikaEvt(istream &fin);
    132     Int_t ReadRflEvt(istream &fin);
     124    //Int_t ReadCorsikaEvt(istream &fin);
     125    //Int_t ReadRflEvt(istream &fin);
    133126
    134     Int_t FillCorsika(Float_t f[7]);
     127    Int_t FillCorsika(Float_t f[7], Int_t i);
    135128    Int_t FillEventIO(Float_t f[7]);
    136129    Int_t FillRfl(Float_t f[8]);
    137130
    138     ClassDef(MPhotonData, 1) //Container to store a cherenkov photon bunch from a CORSUKA file
     131    ClassDef(MPhotonData, 2) //Container to store a cherenkov photon bunch from a CORSUKA file
    139132};
    140133
  • trunk/Mars/msim/MPhotonEvent.cc

    r9616 r9937  
    449449}
    450450
     451Double_t MPhotonEvent::GetMeanX() const
     452{
     453    const UInt_t n = GetNumPhotons();
     454
     455    Double_t mean = 0;
     456    for (UInt_t i=0; i<n; i++)
     457        mean += operator[](i).GetPosX();
     458
     459    return mean / n;
     460}
     461
     462Double_t MPhotonEvent::GetMeanY() const
     463{
     464    const UInt_t n = GetNumPhotons();
     465
     466    Double_t mean = 0;
     467    for (UInt_t i=0; i<n; i++)
     468        mean += operator[](i).GetPosY();
     469
     470    return mean / n;
     471}
     472
    451473// --------------------------------------------------------------------------
    452474//
    453475// Read the Event section from the file
    454476//
    455 Int_t MPhotonEvent::ReadCorsikaEvt(MCorsikaFormat * fInFormat)
     477Int_t MPhotonEvent::ReadCorsikaEvt(MCorsikaFormat *fInFormat, Int_t i)
    456478{
    457479    Int_t n = 0;
     
    509531            {
    510532
    511             const Int_t rc = Add(n).FillCorsika(buffer);
     533            const Int_t rc = Add(n).FillCorsika(buffer, i);
    512534            switch (rc)
    513535            {
     
    577599}
    578600
    579 Int_t MPhotonEvent::ReadCorsikaEvt(istream &fin)
     601Int_t MPhotonEvent::ReadCorsikaEvt(istream &fin, Int_t i)
    580602{
    581603    Int_t n = 0;
     
    635657            // Get/Add the n-th entry from the array and
    636658            // fill it with the current 7 floats
    637             const Int_t rc = Add(n).FillCorsika(ptr);
     659            const Int_t rc = Add(n).FillCorsika(ptr, i);
    638660            ptr += 7;
    639661
     
    707729
    708730// --------------------------------------------------------------------------
    709 //
    710 Int_t MPhotonEvent::ReadRflEvt(std::istream &fin)
     731/*
     732Int_t MPhotonEvent::ReadRflEvt(std::istream &fin, Int_t i)
    711733{
    712734    Int_t n = 0;
     
    735757        // Now we read a single cherenkov bunch
    736758        //const Int_t rc = static_cast<MPhotonData*>(o)->ReadRflEvt(fin);
    737         const Int_t rc = Add(n).ReadRflEvt(fin);
     759        const Int_t rc = Add(n).ReadRflEvt(fin, i);
    738760
    739761        // Evaluate result from reading event
     
    754776    SetReadyToSave();
    755777
    756     //*fLog << all << "Number of photon bunches: " << fData.GetEntriesFast() << endl;
     778    // *fLog << all << "Number of photon bunches: " << fData.GetEntriesFast() << endl;
    757779    return kTRUE;
    758780}
    759 
     781*/
    760782// --------------------------------------------------------------------------
    761783//
  • trunk/Mars/msim/MPhotonEvent.h

    r9616 r9937  
    3737    Double_t GetTimeMedianDev() const;
    3838
     39    Double_t GetMeanX() const;
     40    Double_t GetMeanY() const;
     41
    3942    TClonesArray &GetArray() { return fData; }
    4043    const TClonesArray &GetArray() const { return fData; }
     
    5356
    5457    // I/O
    55     Int_t ReadCorsikaEvt(MCorsikaFormat * fInFormat);
    56     Int_t ReadCorsikaEvt(istream &fin);
    57     Int_t ReadRflEvt(istream &fin);
     58    Int_t ReadCorsikaEvt(MCorsikaFormat *fInFormat, Int_t i);
     59    Int_t ReadCorsikaEvt(istream &fin, Int_t i);
     60    //Int_t ReadRflEvt(istream &fin, Int_t i);
    5861
    5962    // TObject
  • trunk/Mars/msim/MSimMMCS.cc

    r9595 r9937  
    131131
    132132    // FIXME: Is there a way to write them as LAST entry in the file?
    133     fMcRunHeader->SetNumSimulatedShowers(fRunHeader->GetNumEvents());
     133    fMcRunHeader->SetNumSimulatedShowers(fRunHeader->GetNumEvents()*fRunHeader->GetNumReuse());
    134134    fMcRunHeader->SetCorsikaVersion(TMath::Nint(fRunHeader->GetProgramVersion()*100));
    135135
     
    211211
    212212    fMcEvt->SetEvtNumber(fEvtHeader->GetEvtNumber());
     213    fMcEvt->SetEventReuse(fEvtHeader->GetNumReuse());
    213214    fMcEvt->SetPhotElfromShower(0);
    214215
Note: See TracChangeset for help on using the changeset viewer.