Changeset 860


Ignore:
Timestamp:
07/09/01 16:13:19 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r859 r860  
    11                                                                  -*-*- END -*-*-
     2
     3 2001/07/09: Thomas Bretz
     4 
     5   * mbase/MParList.cc:
     6     - made handling of already existing containers in AddToList a bit
     7       more convinient
     8     
     9   * mbase/MTaskList.[h,cc]:
     10     - added come comments
     11     - made handling of already existing tasks in AddToList a bit
     12       more convinient
     13     - Added name-argument to constructor
     14     
     15   * mraw/MRawFileRead.[cc, h]:
     16     - move file-open check from constructor to PreProcess
     17     - added variable for filename
     18     
     19   * mraw/MRawFileWrite.[cc,h]:
     20     - moved fOut->Write from PostProcess to destructor
     21     - removed PostProcess
     22
     23
     24
    225 2001/07/06: Thomas Bretz
    326 
  • trunk/MagicSoft/Mars/NEWS

    r847 r860  
    44 
    55    - Added a task to write a container to an Ascii file (MWriteAsciiFile)
     6
     7    - Added a task to write several container to a root file (MWriteRootFile)
    68   
    7     - Added calculation of the Enegry Threshold
     9    - Added calculation of the Enegry Threshold (MMcThresholdCalc)
    810   
    9     - Added calculation of the collection area
     11    - Added calculation of the collection area (MMcCollectionAreaCalc)
    1012   
    1113    - removed some bugs in the Hillas calculation
     14   
     15    - added filters to be able to control the task execution dependent on
     16      a parameter (for example: the number of level 1 triggers in a MC-file)
    1217   
    1318 
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r858 r860  
    5757{
    5858    *fName  = name  ? name  : "MParList";
    59     *fTitle = title ? title : "List of Parameter Containers";
     59    *fTitle = title ? title : "A list of Parameter Containers";
    6060
    6161    //
     
    100100//  If 'where' is given, the object will be added after this.
    101101//
    102 Bool_t MParList::AddToList(MParContainer *obj, MParContainer *where)
     102Bool_t MParList::AddToList(MParContainer *cont, MParContainer *where)
    103103{
    104104    //
     
    106106    //
    107107
    108     if (!obj) return kTRUE;
    109 
    110     *fLog << "Adding " << obj->GetName() << " to " << GetName() << "... " << flush;
    111   //
    112     //  check if it is in the list yet
    113     //
    114     if (fContainer.FindObject(obj))
     108    if (!cont)
     109        return kFALSE;
     110
     111    //
     112    // Get Name of new container
     113    //
     114    const char *name = cont->GetName();
     115
     116    //
     117    // Check if the new container is already existing in the list
     118    //
     119    const TObject *objn = fContainer.FindObject(name);
     120    const TObject *objt = fContainer.FindObject(cont);
     121
     122    if (objn || objt)
    115123    {
    116         *fLog << dbginf << "Container already added" << endl;
    117         return kTRUE;
     124        //
     125        // If the container is already in the list ignore it.
     126        //
     127        if (objt || objn==cont)
     128        {
     129            *fLog << dbginf << "Warning: Container '" << cont->GetName() << ", 0x" << (void*)cont;
     130            *fLog << "' already existing in '" << GetName() << "'... ignoring." << endl;
     131            return kTRUE;
     132        }
     133
     134        //
     135        // Otherwise add it to the list, but print a warning message
     136        //
     137        *fLog << dbginf << "Warning: Container with the same name '" << cont->GetName();
     138        *fLog << "' already existing in '" << GetName() << "'." << endl;
     139        *fLog << "You may not be able to get a pointer to container task by name." << endl;
    118140    }
    119141
    120142    //
    121143    //  check if you want to add the new parameter container somewhere
    122   //  special (in that case you specify "where")
     144    //  special (in that case you specify "where")
    123145    //
    124146    if (where)
     
    126148        if (!fContainer.FindObject(where))
    127149        {
    128             *fLog << dbginf << "Cannot find parameter container after which the new one should be added!" << endl;
     150            *fLog << dbginf << "Error: Cannot find parameter container after which the new one should be added!" << endl;
    129151            return kFALSE;
    130152        }
    131153    }
    132154
    133     fContainer.Add(obj);
     155    *fLog << "Adding " << name << " to " << GetName() << "... " << flush;
     156
     157    fContainer.Add(cont);
    134158    *fLog << "Done." << endl;
    135159
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r858 r860  
    2727// MTaskList                                                               //
    2828//                                                                         //
    29 // Collection of tasks to be processed in the eventloop                    //
     29// Collection of tasks.                                                    //
     30//                                                                         //
     31// A tasklist is necessary to run the eventloop. It contains the scheduled //
     32// tasks, which should be executed in your program.                        //
     33//                                                                         //
     34// To add a task use AddToList.                                            //
     35//                                                                         //
     36// The tasklist itself is a task, too. You can add a tasklist to another   //
     37// tasklist. This makes sense, if you want to filter the execution of      //
     38// more than one task of your tasklist using the same filter.              //
     39//                                                                         //
     40// The tasks in the list are idetified by their names. If more than one    //
     41// task has the same name, the tasklist will still work correctly, but     //
     42// you might run into trouble trying to get a pointer to a task by name    //
     43// from the list.                                                          //
    3044//                                                                         //
    3145/////////////////////////////////////////////////////////////////////////////
     
    4761// this name in the parameter list (by MEvtLoop::SetParList)
    4862//
    49 MTaskList::MTaskList(const char *title)
    50 {
    51     *fName  = "MTaskList";
    52     *fTitle = title ? title : "List for Tasks";
     63MTaskList::MTaskList(const char *name, const char *title)
     64{
     65    *fName  = name  ? name  : "MTaskList";
     66    *fTitle = title ? title : "A list for tasks to be executed";
    5367}
    5468
     
    95109Bool_t MTaskList::AddToList(MTask *task, const char *type, MTask *where)
    96110{
     111    // FIXME: We agreed to put the task into list in an ordered way.
     112
     113    //
     114    // Sanity check
     115    //
    97116    if (!task)
    98         return kTRUE;
    99 
     117        return kFALSE;
     118
     119    //
     120    // Get Name of new task
     121    //
    100122    const char *name = task->GetName();
    101123
    102     // FIXME: We agreed to put the task into list in an ordered way.
    103 
    104     if (fTasks.FindObject(task))
    105     {
    106         *fLog << dbginf << "Task already existing." << endl;
    107         return kTRUE;
    108     }
    109 
    110     if (fTasks.FindObject(name))
    111     {
    112         *fLog << dbginf << "'" << name << "' exists in List already." << endl;
    113         return kTRUE;
     124    //
     125    // Check if the new task is already existing in the list
     126    //
     127    const TObject *objn = fTasks.FindObject(name);
     128    const TObject *objt = fTasks.FindObject(task);
     129
     130    if (objn || objt)
     131    {
     132        //
     133        // If the task is already in the list ignore it.
     134        //
     135        if (objt || objn==task)
     136        {
     137            *fLog << dbginf << "Warning: Task '" << task->GetName() << ", 0x" << (void*)task;
     138            *fLog << "' already existing in '" << GetName() << "'... ignoring." << endl;
     139            return kTRUE;
     140        }
     141
     142        //
     143        // Otherwise add it to the list, but print a warning message
     144        //
     145        *fLog << dbginf << "Warning: Task with the same name '" << task->GetName();
     146        *fLog << "' already existing in '" << GetName() << "'." << endl;
     147        *fLog << "You may not be able to get a pointer to this task by name." << endl;
    114148    }
    115149
     
    118152        if (!fTasks.FindObject(where))
    119153        {
    120             *fLog << dbginf << "Cannot find task after which the new task should be scheduled!" << endl;
     154            *fLog << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl;
    121155            return kFALSE;
    122156        }
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r858 r860  
    2828
    2929public:
    30     MTaskList(const char *title=NULL);
     30    MTaskList(const char *name=NULL, const char *title=NULL);
    3131
    3232    MTaskList(MTaskList &ts);
  • trunk/MagicSoft/Mars/mmain/MEvtDisp.cc

    r749 r860  
    3333
    3434enum {
    35   M_BUT_DISP1_EVT, 
    36   M_BUT_DISP1_PED, 
    37   M_BUT_DISP1_CAL,
     35  M_BUT_DISP1_EVT,
     36  M_BUT_DISP1_PED,
     37  M_BUT_DISP1_CAL
    3838};
    3939
  • trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h

    r853 r860  
    1414{
    1515private:
    16     MMcEvt  *fMcEvt;
    17     MMcTrig *fMcTrig;
     16    const MMcEvt  *fMcEvt;
     17    const MMcTrig *fMcTrig;
    1818
    1919    MHMcCollectionArea *fCollArea;
  • trunk/MagicSoft/Mars/mraw/MRawFileRead.cc

    r859 r860  
    9797    // open the input stream
    9898    //
     99    fFileName = fname;
    99100    fIn = new ifstream(fname);
    100 
    101     if (!(*fIn))
    102         *fLog << "Error: Trying to open file '" << fname << "'" << endl;
    103101}
    104102
     
    131129{
    132130    //
    133     // remember the pointer to the parameter list fur further usage
    134     //
     131    // first of all check if opening the file in the constructor was
     132    // successfull
     133    //
     134    if (!(*fIn))
     135    {
     136        *fLog << "Error: Cannot open file '" << fFileName << "'" << endl;
     137        return kFALSE;
     138    }
    135139
    136140    //
  • trunk/MagicSoft/Mars/mraw/MRawFileRead.h

    r698 r860  
    2424    MTime          *fRawEvtTime;    // raw evt time information container to fill from file
    2525
     26    TString         fFileName;
    2627    ifstream       *fIn;            //! buffered input stream (file to read from)
    2728
  • trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc

    r859 r860  
    7777{
    7878    //
    79     // delete instance, this laso does a fOut->Close()
    80     //
     79    // delete instance, this also does a fOut->Close()
     80    //
     81    if (fOut->IsOpen())
     82        fOut->Write();
     83
    8184    delete fOut;
    8285}
     
    104107    if (!fOut->IsOpen())
    105108    {
    106         *fLog << dbginf << "Cannot open file '" << fOut->GetName() << "'" << endl;
     109        *fLog << dbginf << "Error: Cannot open file '" << fOut->GetName() << "'" << endl;
    107110        return kFALSE;
    108111    }
     
    200203    //
    201204    const UShort_t type = fRawEvtHeader->GetTrigType();
    202 
     205    cout << "W" << flush;
    203206    //
    204207    // writa data to the tree. the tree is choosen by the type of the event
     
    225228}
    226229
    227 
    228 // --------------------------------------------------------------------------
    229 //
    230 // Close the TFile object and delete it.
    231 //
    232 Bool_t MRawFileWrite::PostProcess()
    233 {
    234     //
    235     // empty data stream
    236     //
    237     fOut->Write();
    238 
    239     return kTRUE;
    240 }
    241 
  • trunk/MagicSoft/Mars/mraw/MRawFileWrite.h

    r852 r860  
    4343    Bool_t PreProcess(MParList *pList);
    4444    Bool_t Process();
    45     Bool_t PostProcess();
    4645
    4746    ClassDef(MRawFileWrite, 0)  // Task to write the raw data containers to a root file
Note: See TracChangeset for help on using the changeset viewer.