12 # include <FMD/AliFMDPreprocessor.h> 23 # include <FMD/AliFMDParameters.h> 24 # include <SHUTTLE/TestShuttle/AliTestShuttle.h> 27 # include <TObjString.h> 38 Float_t Hardware2Ped(
int ddl,
int board,
int chip,
int,
int)
40 return ((chip & 0xf) | ((board & 0x1F) << 4) | (ddl << 9) & 0x3);
42 Float_t Hardware2Noise(
int ddl,
int board,
int chip,
int channel,
int strip)
44 return ((strip & 0x7f) | ((channel & 0xf) << 7));
46 Float_t Hardware2Gain(
int ddl,
int board,
int chip,
int channel,
int strip)
48 return (((strip & 0x7f) << 0) |
49 ((channel & 0x0f) << 7) |
50 ((chip & 0x07) << 11) |
51 ((board & 0x1f) << 14) |
52 ((ddl & 0x03) << 19));
60 class CreateDummyDaData
63 CreateDummyDaData(
const char* output,
64 int firstDDL,
int lastDDL,
65 int firstStrip,
int lastStrip)
67 fFirstDDL(firstDDL), fLastDDL(lastDDL),
68 fFirstStrip(firstStrip), fLastStrip(lastStrip)
72 std::cout <<
"Will write on " << fOutput << std::endl;
73 std::ofstream file(fOutput.Data());
75 std::cerr <<
"Failed to open output file " << fOutput << std::endl;
79 for (
int ddl = fFirstDDL; ddl <= fLastDDL; ddl++) {
80 int boards[] = { 0, 16, (ddl==1 ? -1 : 1), (ddl==1 ? -1 : 17), -1};
83 while ((board = (*bptr++)) >= 0) {
84 for (
int chip = 0; chip < 3; chip++) {
85 for (
int channel = 0; channel < (chip == 1 ? 8 : 16); channel++) {
86 for (
int strip = fFirstStrip; strip <= fLastStrip; strip++) {
87 Output(file, ddl, board, chip, channel, strip);
95 virtual void Header(std::ostream& file) = 0;
96 virtual void Output(std::ostream& file,
int ddl,
int board,
int chip,
97 int channel,
int strip) = 0;
107 class CreateDummyPeds :
public CreateDummyDaData
110 CreateDummyPeds(
const char* out=
"peds.csv",
112 int firstDDL=0,
int lastDDL=2,
113 int firstStrip=0,
int lastStrip=127)
114 : CreateDummyDaData(out, firstDDL, lastDDL, firstStrip, lastStrip),
115 fOverSampling(overSampling)
117 void Output(std::ostream& file,
int ddl,
int board,
int chip,
int channel,
122 for (
int sample = 0; sample < fOverSampling; sample++) {
123 Float_t ped = Hardware2Ped(ddl, board, chip, channel, strip);
124 Float_t noise = Hardware2Noise(ddl, board, chip, channel, strip);
139 void Header(std::ostream& file)
141 file <<
"# Pedestals\n" 142 <<
"# ddl,board,chip,channel,strip,sample,mean,noise,mu,sigma,chi" 150 class CreateDummyGains :
public CreateDummyDaData
153 CreateDummyGains(
const char* out=
"gains.csv",
154 int firstDDL=0,
int lastDDL=2,
155 int firstStrip=0,
int lastStrip=127)
156 : CreateDummyDaData(out, firstDDL, lastDDL, firstStrip, lastStrip)
158 void Output(std::ostream& file,
int ddl,
int board,
int chip,
int channel,
163 Float_t gain = Hardware2Gain(ddl, board, chip, channel, strip);
174 void Header(std::ostream& file)
177 <<
"# ddl,board,chip,channel,strip,gain,errorchi" 187 void ReadBack(
const char* dbBase=
"local://$ALICE_ROOT/OCDB/FMD/")
193 "local://$ALICE_ROOT/OCDB");
197 std::cout <<
"Getting the stuff via AliFMDParameters ... " << std::flush;
201 std::cout <<
"done" << std::endl;
204 for (UShort_t det = 3; det <= 3; det++) {
205 Char_t rs[] = {
'I', (det==1 ?
'\0' :
'O'),
'\0' };
208 while ((rng = *(pr++)) !=
'\0') {
209 UShort_t nsec = (rng ==
'I' ? 20 : 40);
210 UShort_t nstr = (rng ==
'I' ? 512 : 256);
211 for (UShort_t sec = 0; sec < nsec; sec++) {
212 for (UShort_t str = 0; str < nstr; str++) {
216 UInt_t ddl, board, chip, channel;
218 UShort_t strip = str % 128;
219 Float_t eped = Hardware2Ped(ddl, board, chip, channel, strip);
220 Float_t enoise = Hardware2Noise(ddl, board, chip, channel, strip);
221 Float_t egain = Hardware2Gain(ddl, board, chip, channel, strip);
223 Error(Form(
"FMD%d%c[%2d,%3d] (%d,%2d,%1d,%2d)",
224 det,rng,sec,str,ddl,board,chip,channel),
225 "pedestal=%14.7f != %14.7f", ped, eped);
227 Error(Form(
"FMD%d%c[%2d,%3d] (%d,%2d,%1d,%2d)",
228 det,rng,sec,str,ddl,board,chip,channel),
229 "noise=%14.7f != %14.7f", noise, enoise);
233 Error(Form(
"FMD%d%c[%2d,%3d] (%d,%2d,%1d,%2d)",
234 det,rng,sec,str,ddl,board,chip,channel),
235 "gain=%14.7f != %14.7f", gain, egain);
258 Bool_t createDummies=kTRUE,
259 const char* dbBase=
"local://$ALICE_ROOT/OCDB/FMD/")
263 CreateDummyPeds pedMaker;
265 CreateDummyGains gainMaker;
270 gSystem->Load(
"libTestSHUTTLE");
274 AliTestShuttle* shuttle =
new AliTestShuttle(0, 0, 1);
275 AliTestShuttle::SetMainCDB(
"local://$ALICE_ROOT/OCDB/FMD/TestCDB");
276 AliTestShuttle::SetLocalCDB(Form(
"%s/TestCDB", dbBase));
277 AliTestShuttle::SetMainRefStorage(Form(
"%s/TestReference", dbBase));
281 <<
"Test Reference storage Uri: " 286 "source1",
"peds.csv");
288 "source2",
"gains.csv");
289 shuttle->SetInputRunType(runType);
319 TMap* aliasMap =
new TMap;
320 aliasMap->SetOwner(1);
322 for(
int nAlias=0;nAlias<6;nAlias++) {
324 valueSet->SetOwner(1);
326 TString aliasName=
"DCSAlias";
329 for (
int timeStamp = 0; timeStamp < 1000; timeStamp += 10) {
330 Float_t x = Float_t(random.Gaus()+5*nAlias);
332 valueSet->Add(dcsVal);
334 aliasMap->Add(
new TObjString(aliasName), valueSet);
355 ->
Get(
"DET/DCS/Data", 0);
356 return dynamic_cast<TMap*
> (entry->
GetObject());
368 metaData.
SetComment(
"Test object for TestPreprocessor.C");
374 ->
Put(dcsAliasMap,
id, &metaData);
381 Bool_t createDummies = kTRUE;
382 TString dbBase =
"local://$ALICE_ROOT/OCDB/FMD/";
383 for (
int i = 1; i < argc; i++) {
384 if (argv[i][0] ==
'-') {
385 switch (argv[i][1]) {
387 std::cout <<
"Usage: " << argv[0] <<
" [OPTIONS]\n\n" 389 <<
"\t-h\tThis help\n" 390 <<
"\t-d\tToggle dummies\n" 391 <<
"\t-b DIR\tSet database dir\n" 394 case 'd': createDummies = !createDummies;
break;
395 case 'b': dbBase = argv[++i];
break;
void ReadBack(const char *dbBase="local://$ALICE_ROOT/OCDB/FMD/")
AliCDBEntry * Get(const AliCDBId &query)
Bool_t Put(TObject *object, AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate)
int main(int argc, char **argv)
This class is a singleton that handles various parameters of the FMD detectors. This class reads from...
Float_t GetPulseGain(UShort_t detector, Char_t ring, UShort_t sector, UShort_t strip) const
static TString GetMainRefStorage()
void TestPreprocessor(const int physics=1)
static TString GetMainCDB()
AliCDBStorage * GetStorage(const char *dbString)
void SetSpecificStorage(const char *calibType, const char *dbString, Int_t version=-1, Int_t subVersion=-1)
static AliFMDParameters * Instance()
void SetDefaultStorage(const char *dbString)
Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam, UShort_t &ddl, UShort_t &board, UShort_t &altro, UShort_t &channel, UShort_t &timebin) const
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
Float_t GetPedestal(UShort_t detector, Char_t ring, UShort_t sector, UShort_t strip) const
Float_t GetPedestalWidth(UShort_t detector, Char_t ring, UShort_t sector, UShort_t strip) const
UShort_t Init(Bool_t forceReInit=kFALSE, UInt_t what=kAll)
TMap * CreateDCSAliasMap()