Adding flags for better control of event loading from the event number ID.
authorszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 29 Sep 2007 12:50:28 +0000 (12:50 +0000)
committerszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 29 Sep 2007 12:50:28 +0000 (12:50 +0000)
HLT/MUON/OfflineInterface/AliHLTMUONRecHitsSource.cxx
HLT/MUON/OfflineInterface/AliHLTMUONRecHitsSource.h
HLT/MUON/OfflineInterface/AliHLTMUONTriggerRecordsSource.cxx
HLT/MUON/OfflineInterface/AliHLTMUONTriggerRecordsSource.h

index c60d310d11a56e48efa03859f3f88e4670a1b574..fffaa1e6dba6ab0be51c240cf281d8759013c7a2 100644 (file)
@@ -57,8 +57,10 @@ ClassImp(AliHLTMUONRecHitsSource);
 
 AliHLTMUONRecHitsSource::AliHLTMUONRecHitsSource() :
        AliHLTOfflineDataSource(),
-       fMCDataInterface(NULL), fDataInterface(NULL),
-       fSelection(kWholePlane)
+       fMCDataInterface(NULL),
+       fDataInterface(NULL),
+       fSelection(kWholePlane),
+       fCurrentEvent(0)
 {
        for (Int_t i = 0; i < AliMUONConstants::NTrackingCh(); i++)
                fServeChamber[i] = false;
@@ -81,6 +83,9 @@ int AliHLTMUONRecHitsSource::DoInit(int argc, const char** argv)
        bool simdata = false;
        bool recdata = false;
        bool chamberWasSet = false;
+       fCurrentEvent = 0;
+       bool firstEventSet = false;
+       bool eventNumLitSet = false;
        
        for (int i = 0; i < argc; i++)
        {
@@ -139,6 +144,44 @@ int AliHLTMUONRecHitsSource::DoInit(int argc, const char** argv)
                        if (result != 0) return result;
                        chamberWasSet = true;
                }
+               else if (strcmp(argv[i], "-firstevent") == 0)
+               {
+                       if (eventNumLitSet)
+                       {
+                               HLTWarning("The -firstevent flag is overridden by a"
+                                       " previous use of -event_number_literal."
+                               );
+                       }
+                       i++;
+                       if (i >= argc)
+                       {
+                               HLTError("Expected a positive number after -firstevent.");
+                               return EINVAL;
+                       }
+                       char* end = "";
+                       long num = strtol(argv[i], &end, 0);
+                       if (*end != '\0' or num < 0) // Check if the conversion is OK.
+                       {
+                               HLTError(Form(
+                                       "Expected a positive number after -firstevent"
+                                       " but got: %s", argv[i]
+                               ));
+                               return EINVAL;
+                       }
+                       fCurrentEvent = Int_t(num);
+                       firstEventSet = true;
+               }
+               else if (strcmp(argv[i], "-event_number_literal") == 0)
+               {
+                       if (firstEventSet)
+                       {
+                               HLTWarning("The -event_number_literal option will"
+                                       " override -firstevent."
+                               );
+                       }
+                       fCurrentEvent = -1;
+                       eventNumLitSet = true;
+               }
                else
                {
                        Logging(kHLTLogError,
@@ -233,6 +276,21 @@ int AliHLTMUONRecHitsSource::DoInit(int argc, const char** argv)
                }
        }
        
+       // Check that the fCurrentEvent number falls within the correct range.
+       UInt_t maxevent = 0;
+       if (fMCDataInterface != NULL)
+               maxevent = UInt_t(fMCDataInterface->NumberOfEvents());
+       else if (fDataInterface != NULL)
+               maxevent = UInt_t(fDataInterface->NumberOfEvents());
+       if (fCurrentEvent != -1 and UInt_t(fCurrentEvent) >= maxevent and maxevent != 0)
+       {
+               fCurrentEvent = 0;
+               HLTWarning(Form("The selected first event number (%d) was larger than"
+                       " the available number of events (%d). Resetting the event"
+                       " counter to zero.", fCurrentEvent, maxevent
+               ));
+       }
+       
        return 0;
 }
 
@@ -307,12 +365,21 @@ int AliHLTMUONRecHitsSource::GetEvent(
                return EINVAL;
        }
        
-       // Use the fEventID as the event number to load, check it and load that
-       // event with the runloader.
+       // Use the fEventID as the event number to load if fCurrentEvent == -1,
+       // check it and load that event with the runloader.
+       // If fCurrentEvent is a positive number then us it instead and
+       // increment it.
        UInt_t eventnumber = UInt_t(evtData.fEventID);
        UInt_t maxevent = fMCDataInterface != NULL ?
                UInt_t(fMCDataInterface->NumberOfEvents())
                : UInt_t(fDataInterface->NumberOfEvents());
+       if (fCurrentEvent != -1)
+       {
+               eventnumber = UInt_t(fCurrentEvent);
+               fCurrentEvent++;
+               if (UInt_t(fCurrentEvent) >= maxevent)
+                       fCurrentEvent = 0;
+       }
        if ( eventnumber >= maxevent )
        {
                Logging(kHLTLogError,
index 907cf0f0758da7fb9d75057323b859812865d9cf..93ad4c68e84d08aa364a3681df7fb789b6876531 100644 (file)
@@ -49,6 +49,16 @@ class AliMUONDataInterface;
  *      in the range [1..10]. The string after '-chamber' is a comma separated
  *      list of numbers or ranges. Some examples of strings:
  *      1  1-2  1,2,3  1,3-5,7 etc...
+ *  -firstevent <number>
+ *      Indicates the first event number to fetch from AliRoot. The default is to
+ *      start from zero and increment the event number after every GetEvent call.
+ *      This mode causes the component to ignore the event number passed to it by
+ *      the system and rather use an internal counter. This mode can be overriden
+ *      with the -event_number_literal flag.
+ *  -event_number_literal
+ *      This flag indicates to use the event numbers as literal indices into the
+ *      AliRoot trees. This option will cause the component to ignore the -firstevent
+ *      flag.
  */
 class AliHLTMUONRecHitsSource : public AliHLTOfflineDataSource
 {
@@ -107,6 +117,10 @@ private:
 
        SelectionType fSelection; //! Indicates if we should publish from the left, right or whole XY plane.
        bool fServeChamber[10]; //! Flag to indicate if hits from a given chamber should be published.
+       
+       Int_t fCurrentEvent;  //! The current event index that is loaded.
+                             //  -1 indicates that we should rather use the event
+                             // numbers as given by the system.
 
        ClassDef(AliHLTMUONRecHitsSource, 0); // dHLT data source for reconstructed hit data blocks.
 };
index 61a50a4a528ecde612d57bf13510e70f20195ea0..ba4906c9eaf8e626b2612afb24c6b05774f8aa58 100644 (file)
@@ -93,7 +93,8 @@ AliHLTMUONTriggerRecordsSource::AliHLTMUONTriggerRecordsSource() :
        fMCDataInterface(NULL),
        fDataInterface(NULL),
        fBuildFromHits(false),
-       fSelection(kWholePlane)
+       fSelection(kWholePlane),
+       fCurrentEvent(0)
 {
 }
 
@@ -114,6 +115,9 @@ int AliHLTMUONTriggerRecordsSource::DoInit(int argc, const char** argv)
        bool hitdata = false;
        bool simdata = false;
        bool recdata = false;
+       fCurrentEvent = 0;
+       bool firstEventSet = false;
+       bool eventNumLitSet = false;
        
        for (int i = 0; i < argc; i++)
        {
@@ -159,6 +163,44 @@ int AliHLTMUONTriggerRecordsSource::DoInit(int argc, const char** argv)
                                return EINVAL;
                        }
                }
+               else if (strcmp(argv[i], "-firstevent") == 0)
+               {
+                       if (eventNumLitSet)
+                       {
+                               HLTWarning("The -firstevent flag is overridden by a"
+                                       " previous use of -event_number_literal."
+                               );
+                       }
+                       i++;
+                       if (i >= argc)
+                       {
+                               HLTError("Expected a positive number after -firstevent.");
+                               return EINVAL;
+                       }
+                       char* end = "";
+                       long num = strtol(argv[i], &end, 0);
+                       if (*end != '\0' or num < 0) // Check if the conversion is OK.
+                       {
+                               HLTError(Form(
+                                       "Expected a positive number after -firstevent"
+                                       " but got: %s", argv[i]
+                               ));
+                               return EINVAL;
+                       }
+                       fCurrentEvent = Int_t(num);
+                       firstEventSet = true;
+               }
+               else if (strcmp(argv[i], "-event_number_literal") == 0)
+               {
+                       if (firstEventSet)
+                       {
+                               HLTWarning("The -event_number_literal option will"
+                                       " override -firstevent."
+                               );
+                       }
+                       fCurrentEvent = -1;
+                       eventNumLitSet = true;
+               }
                else
                {
                        Logging(kHLTLogError,
@@ -241,6 +283,21 @@ int AliHLTMUONTriggerRecordsSource::DoInit(int argc, const char** argv)
                }
        }
        
+       // Check that the fCurrentEvent number falls within the correct range.
+       UInt_t maxevent = 0;
+       if (fMCDataInterface != NULL)
+               maxevent = UInt_t(fMCDataInterface->NumberOfEvents());
+       else if (fDataInterface != NULL)
+               maxevent = UInt_t(fDataInterface->NumberOfEvents());
+       if (fCurrentEvent != -1 and UInt_t(fCurrentEvent) >= maxevent and maxevent != 0)
+       {
+               fCurrentEvent = 0;
+               HLTWarning(Form("The selected first event number (%d) was larger than"
+                       " the available number of events (%d). Resetting the event"
+                       " counter to zero.", fCurrentEvent, maxevent
+               ));
+       }
+       
        return 0;
 }
 
@@ -317,12 +374,21 @@ int AliHLTMUONTriggerRecordsSource::GetEvent(
                return EINVAL;
        }
        
-       // Use the fEventID as the event number to load, check it and load that
-       // event with the runloader.
+       // Use the fEventID as the event number to load if fCurrentEvent == -1,
+       // check it and load that event with the runloader.
+       // If fCurrentEvent is a positive number then us it instead and
+       // increment it.
        UInt_t eventnumber = UInt_t(evtData.fEventID);
        UInt_t maxevent = fMCDataInterface != NULL ?
                UInt_t(fMCDataInterface->NumberOfEvents())
                : UInt_t(fDataInterface->NumberOfEvents());
+       if (fCurrentEvent != -1)
+       {
+               eventnumber = UInt_t(fCurrentEvent);
+               fCurrentEvent++;
+               if (UInt_t(fCurrentEvent) >= maxevent)
+                       fCurrentEvent = 0;
+       }
        if ( eventnumber >= maxevent )
        {
                Logging(kHLTLogError,
index e75fc71b532877b6eb35fb1f339cc433dc1eab46..576a63ac60c11397b781a5ce81ef9d35d7125ff5 100644 (file)
@@ -49,6 +49,16 @@ class AliMUONDataInterface;
  *  -plane left|right|all
  *      Specifies if data from the left (x < 0), right (x >= 0) or the whole XY
  *      plane should be published.
+ *  -firstevent <number>
+ *      Indicates the first event number to fetch from AliRoot. The default is to
+ *      start from zero and increment the event number after every GetEvent call.
+ *      This mode causes the component to ignore the event number passed to it by
+ *      the system and rather use an internal counter. This mode can be overriden
+ *      with the -event_number_literal flag.
+ *  -event_number_literal
+ *      This flag indicates to use the event numbers as literal indices into the
+ *      AliRoot trees. This option will cause the component to ignore the -firstevent
+ *      flag.
  */
 class AliHLTMUONTriggerRecordsSource : public AliHLTOfflineDataSource
 {
@@ -96,7 +106,11 @@ private:
        };
 
        SelectionType fSelection; //! Indicates if we should publish from the left, right or whole XY plane.
-
+       
+       Int_t fCurrentEvent;  //! The current event index that is loaded.
+                             //  -1 indicates that we should rather use the event
+                             // numbers as given by the system.
+       
        ClassDef(AliHLTMUONTriggerRecordsSource, 0); // dHLT data source for trigger record data blocks.
 };