]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Minor updates
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 4 Aug 2009 10:17:44 +0000 (10:17 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 4 Aug 2009 10:17:44 +0000 (10:17 +0000)
FMD/scripts/ReadRaw.C
FMD/scripts/TestRawIO.C
FMD/scripts/dqm/PatternCalib.C

index 734767339e44108dbcc5c959c19becd8fd6fe12c..aa72aeedfb6d7d7ce3810bbce2d4dd5c2fe74c45 100644 (file)
@@ -7,80 +7,61 @@
     @brief Read raw data into a TClonesArray - for testing 
  */
 void
-ReadRaw(const char* file=0, Int_t evno=0, bool old=false)
+ReadRaw(const char* src=0, Int_t nEv=0, Int_t skip=0)
 {
-  TString        src(file ? file : "");
+  AliLog::SetModuleDebugLevel("FMD", 10);
+
   AliCDBManager* cdb = AliCDBManager::Instance();
   cdb->SetRun(0);
   cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  AliLog::SetModuleDebugLevel("FMD", 1);
-  AliFMDParameters::Instance()->Init();
-  AliFMDParameters::Instance()->UseRcuTrailer(!old);
-  AliFMDParameters::Instance()->UseCompleteHeader(!old);
-  AliRawReader*                   r = 0;
-  if (src.IsNull())               {
-    std::cout << "Reading via AliRawReaderFile" << std::endl;
-    r = new AliRawReaderFile(0);
-  }
-  else if (src.EndsWith(".root")) { 
-    std::cout << "Reading via AliRawReaderRoot" << std::endl;
-    r = new AliRawReaderRoot(src.Data(), evno);
-  }
-  else if (src.EndsWith(".raw"))  {
-    std::cout << "Reading via AliRawReaderDate" << std::endl;
-    r = new AliRawReaderDate(src.Data());
-  }
-  else {
-    std::cerr << "Unknown raw type for source " << src 
-             << " assuming simulated raw files in directory " << src 
-             << std::endl;
-    r = new AliRawReaderFile(src);
-  }
-  AliFMDRawReader* fr = new AliFMDRawReader(r, 0);
-  TClonesArray*    a  = new TClonesArray("AliFMDDigit", 0);
-  fr->ReadAdcs(a);
 
-  std::cout << "Read " << a->GetEntriesFast() << " digits" << std::endl;
+  AliRawReader*    reader    = AliRawReader::Create(src);
+  AliFMDRawReader* fmdReader = new AliFMDRawReader(reader, 0);
+  TClonesArray*    array     = new TClonesArray("AliFMDDigit", 0);
+
+  Int_t evCnt = 0;
+  while (reader->NextEvent()) {
+    if (nEv > 0 && (evCnt-skip) > nEv) break;
+    evCnt++;
+    array->Clear();
+    fmdReader->ReadAdcs(array);
+
+    std::cout << "Event # " << evCnt << std::endl;
+
+    AliFMDBoolMap read(0);
+    read.Reset(kFALSE);
+    std::cout << "Read " << array->GetEntriesFast() << " digits" << std::endl;
   
-  bool read[3][2][40][512];
-  for (UShort_t det = 0; det < 3; det++) {
-    for (UShort_t rng = 0; rng < 2; rng++) { 
-      for (UShort_t sec = 0; sec < 40; sec++) {
-       for (UShort_t str = 0; str < 512; str++) { 
-         read[det][rng][sec][str] = false;
-       }
-      }
+#if 0
+    TIter next(array);
+    AliFMDDigit* digit = 0;
+    while ((digit = static_cast<AliFMDDigit*>(next()))) {
+      UShort_t d = digit->Detector();
+      Char_t   r = digit->Ring();
+      UShort_t s = digit->Sector();
+      UShort_t t = digit->Strip();
+      read(d,r,s,t) = true;
     }
-  }
-  
-
-  TIter next(a);
-  AliFMDDigit* d = 0;
-  while ((d = static_cast<AliFMDDigit*>(next()))) {
-    UShort_t det = d->Detector() - 1;
-    UShort_t rng = d->Ring() == 'I' ? 0 : 1;
-    UShort_t sec = d->Sector();
-    UShort_t str = d->Strip();
-    read[det][rng][sec][str] = true;
-  }
-  const UShort_t lineLength = 64;
-  for (UShort_t det = 0; det < 3; det++) {
-    for (UShort_t rng = 0; rng < 2; rng++) { 
-      if (det == 0 && rng == 1) continue;
-      Char_t   rid  = rng == 0 ? 'I' : 'O';
-      UShort_t nsec = rng == 0 ?  20 :  40;
-      UShort_t nstr = rng == 0 ? 512 : 256;
-      std::cout << "FMD" << det+1 << rid << ":" << std::endl;
-      for (UShort_t sec = 0; sec < nsec; sec++) {
-       std::cout << " Sector " << sec << "\n" << std::flush;
-       for (UShort_t str = 0; str < nstr; str++) { 
-         bool on = read[det][rng][sec][str];
-         if (str % lineLength == 0) std::cout << "  ";
-         std::cout << (on ? '+' : '-');
-         if (str % lineLength == lineLength-1) std::cout << "\n";
+    const UShort_t lineLength = 64;
+    for (UShort_t d = 1; d <= 3; d++) {
+      UShort_t nr = (d == 1 ? 1 : 2);
+      for (UShort_t q = 0; q < nr; q++) { 
+       Char_t   r  = q == 0 ? 'I' : 'O';
+       UShort_t ns = q == 0 ?  20 :  40;
+       UShort_t nt = q == 0 ? 512 : 256;
+       std::cout << "FMD" << d << r << ":" << std::endl;
+       for (UShort_t s = 0; s < ns; s++) {
+         std::cout << " Sector " << s << "\n" << std::flush;
+         for (UShort_t t = 0; t < nt; t++) { 
+           bool on = read(d,r,s,t);
+           if (t % lineLength == 0) std::cout << "  ";
+           std::cout << (on ? '+' : '-');
+           if (t % lineLength == lineLength-1) std::cout << "\n";
+         }
        }
       }
     }
+#endif
   }
   // a->ls();
 }
index b947862dfb29ec1c077814974b9036bd6a424ab5..4b47dbe5ffb9e7cd679dbb3f51a558bc606e3c07 100644 (file)
@@ -6,28 +6,82 @@
 //
 /** @ingroup simple_script
  */
+UShort_t 
+MakeADC(UShort_t d, UShort_t q, UShort_t s, UShort_t t)
+{
+  return t & 0x3FF;
+}
+void 
+MakeData(TClonesArray& array, AliFMDUShortMap& map)
+{
+  size_t i = 0;
+  for (size_t d = 1; d <= 3; d++) { 
+    size_t nRng = (d == 1 ? 1 : 2);
+    for (size_t q = 0; q < nRng; q++) { 
+      Char_t r    = (q == 0 ? 'I' : 'O');
+      size_t nSec = (q == 0 ?  20 :  40);
+      size_t nStr = (q == 0 ? 512 : 256);
+      for (size_t s = 0; s < nSec; s++) { 
+       for (size_t t = 0; t < nStr; t++) { 
+         UShort_t adc = MakeADC(d, q, s, t);
+         new (array[i++]) AliFMDDigit(d, r, s, t, adc, adc, adc, adc);
+         map(d,r,s,t) = adc;
+       }
+      }
+    }
+  }
+}
+void 
+CompareData(TClonesArray& in, const AliFMDUShortMap& map)
+{
+  size_t i = 0;
+  for (size_t i = 0; i < in.GetEntries(); i++) { 
+    AliFMDDigit* inD  = static_cast<AliFMDDigit*>(in.At(i));
+    // AliFMDDigit* outD = static_cast<AliFMDDigit*>(out.At(i));
+
+    UShort_t out = map(inD->Detector(),
+                      inD->Ring(),
+                      inD->Sector(),
+                      inD->Strip());
+    if (out != inD->Counts()) {
+      std::cout << "Entries " << i << " does not match up - expected " 
+               << out << "\n  ";
+      inD->Print();
+    }
+  }
+}
+
 void
 TestRawIO()
 {
-  std::ofstream ofile("foo.dat");
-  AliFMDAltroWriter w(ofile);
-  for (size_t i = 0; i < 16; i++) 
-    w.AddSignal((i << 4)  + i);
-  w.AddChannelTrailer(0xabe);
-  w.Close();
-  ofile.close();
-
-  std::ifstream ifile("foo.dat");
-  AliRawDataHeader h;
-  ifile.read((char*)&h, sizeof(h));
-  AliFMDAltroReader r(ifile);
-  UShort_t hwaddr, last;
-  UShort_t data[1024];
-  int ret = r.ReadChannel(hwaddr, last, data);
-  printf("Read returned %d, w/addr=0x%x, last=%d\n", ret, hwaddr, last);
-  if (ret < 0) return;
-  for (size_t i = 0; i < last; i++)
-    std::cout << i << "\t0x" << std::hex << data[i] << std::endl;
+  AliCDBManager*    cdb   = AliCDBManager::Instance();
+  cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  cdb->SetRun(0);
+
+  AliFMDParameters* param = AliFMDParameters::Instance();
+  param->Init();
+
+  TClonesArray    out("AliFMDDigit");
+  AliFMDUShortMap map(0);
+  MakeData(out, map);
+
+  AliFMDRawWriter writer(0);
+  writer.WriteDigits(&out);
+
+  // gSystem->mkdir("raw0");
+  // gSystem->Rename("FMD_3072.ddl", "raw0/FMD_3072.ddl");
+  // gSystem->Rename("FMD_3073.ddl", "raw0/FMD_3073.ddl");
+  // gSystem->Rename("FMD_3074.ddl", "raw0/FMD_3074.ddl");
+
+  AliRawReader* raw = AliRawReader::Create("./");
+  AliFMDRawReader reader(raw, 0);
+  TClonesArray    in("AliFMDDigit");
+  raw->NextEvent();
+  reader.ReadAdcs(&in);
+
+  std::cout << "Got " << in.GetEntries() << std::endl;
+
+  CompareData(in, map);
 }
 //____________________________________________________________________
 //
index e0512f25fe89af5d8b598cf2eb6ef4fa2381c3cc..148cb9117a60f8d7c43a2dd100597fe40651d185 100644 (file)
@@ -8,16 +8,18 @@
     @ingroup FMD_script
  */
 Bool_t
-CheckFile(const char* prefix, int number, TString& f)
+CheckFile(const char* prefix, const char* path, int number, TString& f)
 {
   f = (Form("%s%d.csv", prefix, number));
-  std::cout << "Checking if " << f << " exists ... " << std::flush;
-  f = gSystem->Which("$(HOME)/calib/", f.Data());
+  std::cout << "Checking if " << f << " exists in " << path << " ... " 
+           << std::flush;
+  f = gSystem->Which(path, f.Data());
   std::cout << '"' << f << '"' << std::endl;
   return !f.IsNull();
 }
 void
-PatternCalib(const char* file="raw.root", Int_t runno=0)
+PatternCalib(const char* file="raw.root", const char* calib="$(HOME)/calib/", 
+            Int_t runno=0)
 {
   // AliLog::SetModuleDebugLevel("FMD", 1);
   gSystem->Load("libFMDutil.so");
@@ -36,20 +38,20 @@ PatternCalib(const char* file="raw.root", Int_t runno=0)
   Bool_t gotGains = kFALSE;
   for (Int_t i = 1; i <= 3; i++) { 
     TString f;
-    if (CheckFile("conditions", i, f)) {
+    if (CheckFile("conditions", calib, i, f)) {
       gotConds = kTRUE;
       std::cout << "Reading conditions for FMD" <<i<< " from " <<f<< std::endl;
       std::ifstream in(f.Data());
       range->ReadFromFile(in);
       rate->ReadFromFile(in);
     }
-    if (CheckFile("peds", i, f)) {
+    if (CheckFile("peds", calib, i, f)) {
       gotPeds = kTRUE;
       std::cout << "Reading pedestals for FMD" <<i<< " from " <<f<< std::endl;
       std::ifstream in(f.Data());
       peds->ReadFromFile(in);
     }
-    if (CheckFile("gains", i, f)) {
+    if (CheckFile("gains", calib, i, f)) {
       gotGains = kTRUE;
       std::cout << "Reading gains for FMD" <<i<< " from " <<f<< std::endl;
       std::ifstream in(f.Data());