1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONOccupancySubprocessor.h"
20 #include "AliCDBMetaData.h"
21 #include "AliMUON2DMap.h"
22 #include "AliMUONPreprocessor.h"
23 #include "AliMUONTrackerIO.h"
24 #include "TObjString.h"
27 //-----------------------------------------------------------------------------
28 /// \class AliMUONOccupancySubprocessor
30 /// Implementation of AliMUONVSubprocessor class to deal with MUON TRK occupancy.
32 /// Values to compute the occupancy are read in from an ascii file,
33 /// with the format : \n
34 ///---------------------------------------------------------------------------\n
35 /// BUS_PATCH MANU_ADDR SUM_N NEVENTS
36 ///---------------------------------------------------------------------------\n
38 /// \author L. Aphecetche
39 //-----------------------------------------------------------------------------
42 ClassImp(AliMUONOccupancySubprocessor)
45 //_____________________________________________________________________________
46 AliMUONOccupancySubprocessor::AliMUONOccupancySubprocessor(AliMUONPreprocessor* master)
47 : AliMUONVSubprocessor(master,"Occupancy","Upload MUON Tracker occupancy to OCDB"),
53 //_____________________________________________________________________________
54 AliMUONOccupancySubprocessor::~AliMUONOccupancySubprocessor()
60 //_____________________________________________________________________________
62 AliMUONOccupancySubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
64 /// When starting a new run, reads in the occupancy ASCII files.
66 const Int_t kSystem = AliMUONPreprocessor::kDAQ;
67 const char* kId = "OCCUPANCY";
70 fOccupancyMap = new AliMUON2DMap(kTRUE);
72 Master()->Log(Form("Reading occupancy file for Run %d startTime %ld endTime %ld",
73 run,startTime,endTime));
75 TList* sources = Master()->GetFileSources(kSystem,kId);
80 while ( ( o = static_cast<TObjString*>(next()) ) )
82 TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
83 Int_t ok = ReadFile(fileName.Data());
92 Master()->Log("Failed to read any occupancy");
99 //_____________________________________________________________________________
101 AliMUONOccupancySubprocessor::Process(TMap* /*dcsAliasMap*/)
103 /// Store the occupancy map into the CDB
107 // this is the only reason to fail for the moment : getting no occupancy
112 Master()->Log("Storing occupancy map");
114 AliCDBMetaData metaData;
115 metaData.SetBeamPeriod(0);
116 metaData.SetResponsible("MUON TRK");
117 TString comment("Computed by AliMUONOccupancySubprocessor $Id$");
118 comment.ReplaceAll("$","");
119 metaData.SetComment(comment.Data());
121 Bool_t validToInfinity = kFALSE;
122 Bool_t result = Master()->Store("Calib", "OccupancyMap", fOccupancyMap, &metaData, 0, validToInfinity);
124 return ( result != kTRUE ); // return 0 if everything is ok.
127 //_____________________________________________________________________________
129 AliMUONOccupancySubprocessor::ReadFile(const char* filename)
131 /// Read the occupancy from an ASCII file. \n
132 /// Return kFALSE if reading was not successfull. \n
135 TString sFilename(gSystem->ExpandPathName(filename));
137 Master()->Log(Form("Reading %s",sFilename.Data()));
139 Int_t n = AliMUONTrackerIO::ReadOccupancy(sFilename.Data(),*fOccupancyMap);
144 Master()->Log(Form("Could not open %s",sFilename.Data()));
152 //_____________________________________________________________________________
154 AliMUONOccupancySubprocessor::Print(Option_t* opt) const
157 if (fOccupancyMap) fOccupancyMap->Print("",opt);