]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFRawDataRead.C
Reject clusters that are matched to more than one track
[u/mrichter/AliRoot.git] / TOF / AliTOFRawDataRead.C
index 90457bf4ab141eea8e2425363003ef4bc2ac6fe2..1629e9bdbe612074d68da823664497662fa2b1cc 100644 (file)
-void AliTOFRawDataRead(Int_t iEvent=0)
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+// Root include files
+#include "TClonesArray.h"
+
+// AliRoot include files
+#include "AliDAQ.h"
+#include "AliHitMap.h"
+
+#include "AliRawReader.h"
+#include "AliRawReaderFile.h"
+
+#include "AliTOFrawData.h"
+#include "AliTOFRawMap.h"
+#include "AliTOFRawStream.h"
+
+#endif
+
+void AliTOFRawDataRead(Int_t iEvent=0);
+
+void AliTOFRawDataRead(Int_t iEvent)
 {
   //
   // To read TOF raw data
   //
 
-  Int_t ii = 0;
-  Int_t indexDDL = 0;
+  AliTOFrawData *tofRawDatum=new AliTOFrawData();
+  TTree *PackedDataTree= new TTree("PackedDataTree", "Decoded Packed Data");
+  PackedDataTree->Branch("HitData", "AliTOFrawData", &tofRawDatum);
+
+  TClonesArray *clonesRawData = new TClonesArray("AliTOFrawData",1000);
+  Int_t fPackedDigits=0;
+
   Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
+  Int_t dummy = -1;
+
+  AliRawReader *reader = new AliRawReaderFile(iEvent);
+  reader->RewindEvents();
+
+  ofstream ftxt;
+  ftxt.open("TOFrawDataReading.txt",ios::app);
+
+  while (reader->NextEvent()) {
 
-  AliRawReaderFile reader(iEvent);
-  reader.RewindEvents();
+    AliTOFRawMap *rawMap = new AliTOFRawMap(clonesRawData);
 
-  while (reader.NextEvent()) {
+    Int_t slot[4] = {-1, -1, -1, -1};
 
-    for (indexDDL = 0; indexDDL < AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
+   for (Int_t indexDDL = 0; indexDDL < AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
 
-      reader.Reset();
-      AliTOFRawStream stream(&reader);
-      reader.Select("TOF", indexDDL, indexDDL);
+     reader->Reset();
+     AliTOFRawStream stream(reader);
+     stream.LoadRawData(indexDDL);
 
-      //FILE *fpw = fopen("TOFrawDataRead.txt","w");
+     clonesRawData = (TClonesArray*)stream.GetRawData();
 
-      while(stream.Next()) {
+     for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
 
-       for (ii=0; ii<5; ii++) detectorIndex[ii] = -1;
+       tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
 
-       detectorIndex[0] = (Int_t)stream.GetSector();
-       detectorIndex[1] = (Int_t)stream.GetPlate();
-       detectorIndex[2] = (Int_t)stream.GetStrip();
-       detectorIndex[3] = (Int_t)stream.GetPadZ();
-       detectorIndex[4] = (Int_t)stream.GetPadX();
+       if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
 
-       if (detectorIndex[0]==-1 ||
-           detectorIndex[1]==-1 ||
-           detectorIndex[2]==-1 ||
-           detectorIndex[3]==-1 ||
-           detectorIndex[4]==-1) continue;
-       else {
+       if (indexDDL<10) ftxt << "  " << indexDDL;
+       else             ftxt << " " << indexDDL;
+       if (tofRawDatum->GetTRM()<10) ftxt << "  " << tofRawDatum->GetTRM();
+       else                          ftxt << " " << tofRawDatum->GetTRM();
+       ftxt << "  " << tofRawDatum->GetTRMchain();
+       if (tofRawDatum->GetTDC()<10) ftxt << "  " << tofRawDatum->GetTDC();
+       else                          ftxt << " " << tofRawDatum->GetTDC();
+       ftxt << "  " << tofRawDatum->GetTDCchannel();
 
-         printf("%2i  %2i  %2i  %2i  %2i      %2i  %1i  %2i  %1i  %2i    %7i  %8i\n",
-                stream.GetDDL(),stream.GetTRM(),stream.GetTRMchain(),
-                stream.GetTDC(),stream.GetTDCchannel(),
-                stream.GetSector(),stream.GetPlate(),
-                stream.GetStrip(),stream.GetPadZ(),stream.GetPadX(),
-                stream.GetToTbin(),stream.GetTofBin());
+       stream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+                                  tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+       dummy = detectorIndex[3];
+       detectorIndex[3] = detectorIndex[4];
+       detectorIndex[4] = dummy;
 
-       } // end else
+       if (detectorIndex[0]<10) ftxt  << "  ->  " << detectorIndex[0];
+       else                     ftxt  << "  -> " << detectorIndex[0];
+       ftxt << "  " << detectorIndex[1];
+       if (detectorIndex[2]<10) ftxt << "  " << detectorIndex[2];
+       else                     ftxt << " " << detectorIndex[2];
+       ftxt << "  " << detectorIndex[3];
+       if (detectorIndex[4]<10) ftxt << "  " << detectorIndex[4];
+       else                     ftxt << " " << detectorIndex[4];
 
-      } // end while loop on next stream
+       if (tofRawDatum->GetTOT()<10)                                            ftxt << "        " << tofRawDatum->GetTOT();
+       else if (tofRawDatum->GetTOT()>=10 && tofRawDatum->GetTOT()<100)         ftxt << "       " << tofRawDatum->GetTOT();
+       else if (tofRawDatum->GetTOT()>=100 && tofRawDatum->GetTOT()<1000)       ftxt << "      " << tofRawDatum->GetTOT();
+       else if (tofRawDatum->GetTOT()>=1000 && tofRawDatum->GetTOT()<10000)     ftxt << "     " << tofRawDatum->GetTOT();
+       else if (tofRawDatum->GetTOT()>=10000 && tofRawDatum->GetTOT()<100000)   ftxt << "    " << tofRawDatum->GetTOT();
+       else if (tofRawDatum->GetTOT()>=100000 && tofRawDatum->GetTOT()<1000000) ftxt << "   " << tofRawDatum->GetTOT();
+       else                                                                     ftxt << "  " << tofRawDatum->GetTOT();
+       if (tofRawDatum->GetTOF()<10)                                            ftxt << "        " << tofRawDatum->GetTOF() << endl;
+       else if (tofRawDatum->GetTOF()>=10 && tofRawDatum->GetTOF()<100)         ftxt << "       " << tofRawDatum->GetTOF() << endl;
+       else if (tofRawDatum->GetTOF()>=100 && tofRawDatum->GetTOF()<1000)       ftxt << "      " << tofRawDatum->GetTOF() << endl;
+       else if (tofRawDatum->GetTOF()>=1000 && tofRawDatum->GetTOF()<10000)     ftxt << "     " << tofRawDatum->GetTOF() << endl;
+       else if (tofRawDatum->GetTOF()>=10000 && tofRawDatum->GetTOF()<100000)   ftxt << "    " << tofRawDatum->GetTOF() << endl;
+       else if (tofRawDatum->GetTOF()>=100000 && tofRawDatum->GetTOF()<1000000) ftxt << "   " << tofRawDatum->GetTOF() << endl;
+       else                                                                     ftxt << "  " << tofRawDatum->GetTOF() << endl;
 
-    } // endl loop on DDL files
+       PackedDataTree->Fill();
+     } // end loop
 
-    iEvent++;
+   } // endl loop on DDL files
+
+   iEvent++;
 
   } // end while loop on event
 
+  ftxt.close();
+  TFile fileOut("TOF_rawQA_OldDecoder.root", "RECREATE");
+  PackedDataTree->Write();
+  fileOut.Close();
+
 }
+