AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONOccupancySubprocessor.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 
16 // $Id$
17 
19 
20 #include "AliCDBMetaData.h"
21 #include "AliMUON2DMap.h"
22 #include "AliMUONPreprocessor.h"
23 #include "AliMUONTrackerIO.h"
24 #include "TObjString.h"
25 #include "TSystem.h"
26 
27 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
40 
44 
45 //_____________________________________________________________________________
47 : AliMUONVSubprocessor(master,"Occupancy","Upload MUON Tracker occupancy to OCDB"),
48 fOccupancyMap(0x0)
49 {
51 }
52 
53 //_____________________________________________________________________________
55 {
57  delete fOccupancyMap;
58 }
59 
60 //_____________________________________________________________________________
61 Bool_t
62 AliMUONOccupancySubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
63 {
65 
66  const Int_t kSystem = AliMUONPreprocessor::kDAQ;
67  const char* kId = "OCCUPANCY";
68 
69  delete fOccupancyMap;
70  fOccupancyMap = new AliMUON2DMap(kTRUE);
71 
72  Master()->Log(Form("Reading occupancy file for Run %d startTime %u endTime %u",
73  run,startTime,endTime));
74 
75  TList* sources = Master()->GetFileSources(kSystem,kId);
76  TIter next(sources);
77  TObjString* o(0x0);
78  Int_t n(0);
79 
80  while ( ( o = static_cast<TObjString*>(next()) ) )
81  {
82  TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
83  Int_t ok = ReadFile(fileName.Data());
84  if ( ok>0 || ok == AliMUONTrackerIO::kNoInfoFile )
85  {
86  n += ok;
87  }
88  }
89 
90  delete sources;
91 
92  if (!n)
93  {
94  Master()->Log("Failed to read any occupancy");
95  delete fOccupancyMap;
96  fOccupancyMap = 0;
97  return kFALSE;
98  }
99  return kTRUE;
100 }
101 
102 //_____________________________________________________________________________
103 UInt_t
105 {
107 
108  if (!fOccupancyMap)
109  {
110  // this is the only reason to fail for the moment : getting no occupancy
111  // at all.
112  return 1;
113  }
114 
115  if ( fOccupancyMap->GetSize() )
116  {
117  Master()->Log("Storing occupancy map");
118 
119  AliCDBMetaData metaData;
120  metaData.SetBeamPeriod(0);
121  metaData.SetResponsible("MUON TRK");
122  TString comment("Computed by AliMUONOccupancySubprocessor $Id$");
123  comment.ReplaceAll("$","");
124  metaData.SetComment(comment.Data());
125 
126  Bool_t validToInfinity = kFALSE;
127  Bool_t result = Master()->Store("Calib", "OccupancyMap", fOccupancyMap, &metaData, 0, validToInfinity);
128 
129  return ( result != kTRUE ); // return 0 if everything is ok.
130  }
131  else
132  {
133  Master()->Log("No occupancy map to store");
134  return 0;
135  }
136 }
137 
138 //_____________________________________________________________________________
139 Int_t
141 {
145 
146  TString sFilename(gSystem->ExpandPathName(filename));
147 
148  Master()->Log(Form("Reading %s",sFilename.Data()));
149 
150  Int_t n = AliMUONTrackerIO::ReadOccupancy(sFilename.Data(),*fOccupancyMap);
151 
152  switch (n)
153  {
154  case -1:
155  Master()->Log(Form("Could not open %s",sFilename.Data()));
156  break;
157  }
158 
159  return n;
160 }
161 
162 
163 //_____________________________________________________________________________
164 void
166 {
168  if (fOccupancyMap) fOccupancyMap->Print("",opt);
169 }
170 
static Int_t ReadOccupancy(const char *filename, AliMUONVStore &occupancyMap)
AliMUONPreprocessor * Master() const
Return the pointer to our master.
UInt_t Process(TMap *dcsAliasMap)
Process this sub-task.
virtual void Print(Option_t *wildcard="") const
Print all objects whose name matches wildcard.
static TString comment
Definition: ConfigCosmic.C:131
virtual Int_t GetSize() const =0
The number of objects stored.
AliMUONVStore * fOccupancyMap
! Occupancy map (at the manu level) for the MUON TRK
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Base class for a shuttle sub-task for MUON (either TRK or TRG)
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
Bool_t Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
void Occupancy(ostream &outfile)
void Log(const char *message)
Publish AliPreprocessor::Log function.
Basic implementation of AliMUONVStore container using AliMpExMap internally.
Definition: AliMUON2DMap.h:20
TList * GetFileSources(Int_t system, const char *id)
Publish AliPreprocessor::GetFileSources function.
Bool_t Store(const char *pathLevel2, const char *pathLevel3, TObject *object, AliCDBMetaData *metaData, Int_t validityStart=0, Bool_t validityInfinite=kFALSE)
Publish AliPreprocessor::Store function.
Implementation of AliMUONVSubprocessor for MUON TRK occupancy.
Shuttle preprocessor for MUON subsystems (TRK and TRG)
file is not of the expected format