]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/TestMUONPreprocessor.C
Updating gains and make it easier to test different runtypes (Laurent)
[u/mrichter/AliRoot.git] / MUON / TestMUONPreprocessor.C
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
18 #if !defined(__CINT__) || defined(__MAKECINT__)
19
20 /// This macro runs the test preprocessor for MUON.
21 /// It uses AliTestShuttle to simulate a full Shuttle process
22 ///
23 /// The input data has to be created first by other processes (or is created
24 /// here by CreateDCSAliasMap() for tracker HV).
25 ///
26 /// To play with it, you'll have to set/modify several lines, to
27 /// a) select input files, using shuttle->AddInputFile()
28 /// b) select run type, using shuttle->AddInputRunParameter() (the run type
29 ///    dictates which task is really performed by the MUONPreprocessor
30 ///
31 /// For more information on usage, please see READMEshuttle.
32 ///
33 // By Laurent Aphecetche, SUBATECH Nantes
34
35 #include "TestMUONPreprocessor.h"
36 #include "AliCDBManager.h"
37 #include "AliShuttleInterface.h"
38 #include "AliCDBId.h"
39 #include "AliTestShuttle.h"
40 #include "TMap.h"
41 #include "Riostream.h"
42 #include "TSystem.h"
43 #include "AliMpExMap.h"
44 #include "TMap.h"
45 #include "TString.h"
46 #include "TObjArray.h"
47 #include "AliMpHelper.h"
48 #include "AliDCSValue.h"
49 #include "TObjString.h"
50 #include "TRandom.h"
51 #include "AliMUONTrackerPreprocessor.h"
52 #include "AliCDBEntry.h"
53 #include "AliMUONHVNamer.h"
54 #endif
55
56 void TestMUONPreprocessor(Int_t runNumber=80, const char* runType="PEDESTAL_RUN")
57 {
58   // runType can be :
59   //
60   // PEDESTAL_RUN -> pedestals
61   // ELECTRONICS_CALIBRATION_RUN -> gains
62   // PHYSICS -> HV
63   // GMS
64   
65   // load library
66   gSystem->Load("../SHUTTLE/TestShuttle/libTestShuttle.so");
67   gSystem->Load("libMUONshuttle.so");
68   
69   // create AliTestShuttle instance
70   // The parameters are run, startTime, endTime
71   AliTestShuttle* shuttle = new AliTestShuttle(runNumber, 0, 1);
72
73   
74   AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
75   AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
76
77   printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
78   printf("Test Shuttle log dir: %s\n", AliShuttleInterface::GetShuttleLogDir());
79   printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
80   printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
81   
82   // Create DCS HV aliases
83   TMap* dcsAliasMap = CreateDCSAliasMap();
84
85   // now give the alias map to the shuttle
86   shuttle->SetDCSInput(dcsAliasMap);
87
88   // The shuttle can process files that originate from DCS, DAQ and HLT.
89   // To test it, we provide some local files and locations where these would be found when
90   // the online machinery would be there.
91   // In real life this functions would be produces by the sub-detectors
92   // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
93   //
94   // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
95   // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
96   // In this example we add 4 files originating from different LDCs but with the same id (PEDESTALS)
97
98   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC0","$ALICE_ROOT/MUON/data/LDC0.ped");
99   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC1","$ALICE_ROOT/MUON/data/LDC1.ped");
100   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC2","$ALICE_ROOT/MUON/data/LDC2.ped");
101   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC3","$ALICE_ROOT/MUON/data/LDC3.ped");
102   
103   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0","$ALICE_ROOT/MUON/data/LDC0.gain");
104   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC1","$ALICE_ROOT/MUON/data/LDC1.gain");
105   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC2","$ALICE_ROOT/MUON/data/LDC2.gain");
106   shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC3","$ALICE_ROOT/MUON/data/LDC3.gain");
107   
108   // and GMS file
109   shuttle->AddInputFile(AliTestShuttle::kDCS,"MCH","GMS","GMS","$ALICE_ROOT/MUON/data/GMS.root");
110
111   // The shuttle can read run parameters stored in the DAQ run logbook.
112   // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
113   // using GetRunParameter function.
114   // In real life the parameters will be retrieved automatically from the run logbook;
115   shuttle->SetInputRunType(runType);
116   
117   // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
118   new AliMUONTrackerPreprocessor(shuttle);
119
120   shuttle->Print();
121   
122   // Test the preprocessor
123   shuttle->Process();
124 }
125
126 TMap* CreateDCSAliasMap()
127 {
128   /// Creates a DCS structure for MUON Tracker HV
129   ///
130   /// The structure is the following:
131   ///   TMap (key --> value)
132   ///     <DCSAlias> --> <valueList>
133   ///     <DCSAlias> is a string
134   ///     <valueList> is a TObjArray of AliDCSValue
135   ///     An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
136   
137   TMap* aliasMap = new TMap;
138   aliasMap->SetOwner(kTRUE);
139   
140   TRandom random(0);
141   
142   AliMUONHVNamer hvNamer;
143   
144   TObjArray* aliases = hvNamer.GenerateAliases();
145   
146   for ( Int_t i = 0; i < aliases->GetEntries(); ++i ) 
147   {
148     TObjString* alias = static_cast<TObjString*>(aliases->At(i));
149     TString& aliasName = alias->String();
150     if ( aliasName.Contains("sw") ) 
151     {
152       // HV Switch (St345 only)
153       TObjArray* valueSet = new TObjArray;
154       valueSet->SetOwner(kTRUE);
155       Bool_t value = kTRUE;
156 //      Float_t r = random.Uniform();
157 //      if ( r < 0.007 ) value = kFALSE;      
158 //      if ( aliasName.Contains("DE513sw2") ) value = kFALSE;
159       
160       for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
161       {
162         AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
163         valueSet->Add(dcsValue);
164       }
165       aliasMap->Add(new TObjString(*alias),valueSet);
166     }
167     else
168     {
169       TObjArray* valueSet = new TObjArray;
170       valueSet->SetOwner(kTRUE);
171       for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
172       {
173         Float_t value = random.Gaus(1750,62.5);
174         if ( aliasName == "MchHvLvLeft/Chamber00Left/Quad2Sect1.actual.vMon") value = 500;
175         AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
176         valueSet->Add(dcsValue);
177       }
178       if ( aliasName == "MchHvLvLeft/Chamber04Left/Slat06.actual.vMon" ) continue;
179       aliasMap->Add(new TObjString(*alias),valueSet);
180     }
181   }
182   
183   delete aliases;
184     
185   return aliasMap;
186 }
187