reading RAW without data
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 24 Jan 2008 12:35:56 +0000 (12:35 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 24 Jan 2008 12:35:56 +0000 (12:35 +0000)
T0/AliT0CalibLaserData.cxx
T0/AliT0CalibLaserData.h
T0/AliT0CalibViewer.C

index 8b22e14..5988fd0 100644 (file)
@@ -30,6 +30,7 @@
 #include "TBranch.h"
 #include "AliT0RawReader.h"
 #include "TGLabel.h"
+#include "TGFileDialog.h"
 //#include <iostream.h>
 
 #include "AliT0CalibLaserData.h"
 #include "AliT0RawReader.h"
 
 ClassImp(AliT0CalibLaserData)
-
+  //const char *fFileName;
 AliT0CalibLaserData::AliT0CalibLaserData() : TObject(),
-                                        fRunNumber(905)
+                                            fTEntry(0),
+                                            fFileName(" ")
+  
 {
 //
 }
@@ -74,13 +77,12 @@ AliT0CalibLaserData::~AliT0CalibLaserData()
 */
 //________________________________________________________________
 
-void AliT0CalibLaserData::ReadHistSize(Int_t rNumber)
+void AliT0CalibLaserData::ReadHistSize()
 {
   //build GUI frame for reading:
   // - run number
   // - histograms rates
 
-    fRunNumber = rNumber;
     
     TGMainFrame* fMain = new TGMainFrame(0,1500,1500);
     fMain->SetLayoutManager( new TGMatrixLayout(fMain,7,7) );
@@ -108,9 +110,9 @@ void AliT0CalibLaserData::ReadHistSize(Int_t rNumber)
     fMain->AddFrame( new TGLabel(fMain, "LED - CFD" ) );
     fEntries[3] = new TGNumberEntry(fMain, 0);
     fMain->AddFrame(fEntries[3]);
-    fEntries[4] = new TGNumberEntry(fMain, 10000);
+    fEntries[4] = new TGNumberEntry(fMain, 1000);
     fMain->AddFrame(fEntries[4]);
-    fEntries[5] = new TGNumberEntry(fMain, 10000);
+    fEntries[5] = new TGNumberEntry(fMain, 1000);
     fMain->AddFrame(fEntries[5]);
     fMain->AddFrame( new TGLabel(fMain, " ") );
     fMain->AddFrame( new TGLabel(fMain, " ") );
@@ -124,11 +126,11 @@ void AliT0CalibLaserData::ReadHistSize(Int_t rNumber)
     fEntries[8] = new TGNumberEntry(fMain, 700);
     fMain->AddFrame(fEntries[8]);
 // CFD axis Y 
-   fEntries[9] = new TGNumberEntry(fMain, 12000.5);
+   fEntries[9] = new TGNumberEntry(fMain, 2000.5);
     fMain->AddFrame(fEntries[9]);
-    fEntries[10] = new TGNumberEntry(fMain, 18000.5);
+    fEntries[10] = new TGNumberEntry(fMain, 3000.5);
     fMain->AddFrame(fEntries[10]);
-    fEntries[11] = new TGNumberEntry(fMain, 2000);
+    fEntries[11] = new TGNumberEntry(fMain, 1000);
     fMain->AddFrame(fEntries[11]);
 //
     fMain->AddFrame( new TGLabel(fMain, "CFD vs LED-CFD " ) );
@@ -140,18 +142,19 @@ void AliT0CalibLaserData::ReadHistSize(Int_t rNumber)
     fEntries[14] = new TGNumberEntry(fMain, 500);
     fMain->AddFrame(fEntries[14]);
 // CFD axis Y
-    fEntries[15] = new TGNumberEntry(fMain, 14600);
+    fEntries[15] = new TGNumberEntry(fMain, 2000);
     fMain->AddFrame(fEntries[15]);
-    fEntries[16] = new TGNumberEntry(fMain, 14700);
+    fEntries[16] = new TGNumberEntry(fMain, 3000);
     fMain->AddFrame(fEntries[16]);
-    fEntries[17] = new TGNumberEntry(fMain, 100);
+    fEntries[17] = new TGNumberEntry(fMain, 1000);
     fMain->AddFrame(fEntries[17]);
  
-   fMain->AddFrame( new TGLabel(fMain, " Number of run") );
-    fEntries[18] = new TGNumberEntry(fMain, 905);
-     fMain->AddFrame(fEntries[18]);
-    
-    for ( int i=0; i<19; i++ ) fEntries[i]->SetWidth(70);
+   fMain->AddFrame( new TGLabel(fMain, " File name") );
+   fTEntry = new TGTextEntry(fMain,"");
+   fMain->AddFrame(fTEntry);
+   
+   for ( int i=0; i<18; i++ ) fEntries[i]->SetWidth(70);
+   fTEntry->SetWidth(80);
     //    printf( "Max Length %d\n", fEntries[0]->GetMaxWidth() );
 
     TGTextButton *fOk = new TGTextButton(fMain, "OK");
@@ -167,14 +170,14 @@ void AliT0CalibLaserData::ReadHistSize(Int_t rNumber)
     
 void AliT0CalibLaserData::DoOk()
 {
-    //    delete fMain;
-    fRunNumber = Int_t (fEntries[18]->GetNumber());
-    printf(" RUN NUMBER %i\n",fRunNumber);
-    for( int i=0; i<18; i++ ) 
-      fHistLimits[i] = fEntries[i]->GetNumber();
-    ReadData();
+  
+  fFileName = (fTEntry->GetText());
+  //OpenFile();
+  printf(" DoOK >>  File %s\n",fFileName);
+  for( int i=0; i<18; i++ ) 
+    fHistLimits[i] = fEntries[i]->GetNumber();
+  
+  ReadData();
 }
 
 void AliT0CalibLaserData::ReadData()
@@ -182,203 +185,240 @@ void AliT0CalibLaserData::ReadData()
   // reading RAW data from test LCS
   // filling histograms
   // fillinf tree
+  
+  
+  TH1F *hChannel[105];  TH1F *hQTC[24];  
+  TH2F *hCFDvsQTC[24]; TH2F *hCFDvsLED[24]; TH1F *h1CFDminLED[24];
 
+  Int_t allData[110][5];
+  Int_t numberOfHits[105];
+  
+  Char_t  buf1[20], buf2[20], buf3[20], buf4[20], buf7[20];
 
-      TH1F *hChannel[105];  TH1F *hQTC[12];  
-      TH2F *hCFDvsQTC[12]; TH2F *hCFDvsLED[12]; TH1F *h1CFDminLED[12];
-      TH1F *hmpd[12];
-      Int_t allData[110][5];
-      Int_t numberOfHits[105];
-
-      Char_t  buf1[20], buf2[20], buf3[20], buf4[20], buf7[20];
-
-      TTree* digitsTree = new TTree("testData","Tree of test data Digits");
-      TBranch *b[106];
-
-       Int_t channels[106];
-
-      TString names[106], type;
-      AliT0LookUpKey* lookkey= new AliT0LookUpKey();
-      AliT0LookUpValue*  lookvalue= new AliT0LookUpValue();
-      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-      AliCDBManager::Instance()->SetRun(0);
-      AliT0Parameters *fParam = AliT0Parameters::Instance();
-      fParam->Init();
-      TMap *lookup = fParam->GetMapLookup();
-      TMapIter *iter = new TMapIter(lookup);
-
-      for( Int_t iline=0; iline<106; iline++)
-       {
-         lookvalue = ( AliT0LookUpValue*) iter->Next();
-          lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
-         if(lookkey){
-           Int_t key=lookkey->GetKey();
-           names[key]=lookkey->GetChannelName();
-           hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),30000,0,30000);
-           //  hitsname="xHits" + names[key];
-           //  hNumHits[key] = new TH1F(hitsname.Data(),hitsname.Data(),50,-0.25,24.25);
-           type =names[key] + "/I";
-           b[key]=digitsTree->Branch(names[key].Data(),&channels[key], type);
-          }
-         else
-           {printf(" no such value %i \n", iline);}
-
-       } 
-      for(Int_t ic=0; ic<12; ic++) {
-       {
-         sprintf(buf1,"QTC%i",ic+1);
-         sprintf(buf2,"CFDvsQTC%i",ic+1);
-         sprintf(buf3,"CFDvsLED%i",ic+1);
-         sprintf(buf4,"LEDminCFD%i",ic+1);
-         sprintf(buf7,"mpd%i",ic+1);
-
-         hQTC[ic] = new TH1F(buf1,"QTC",(Int_t)fHistLimits[2],fHistLimits[0],fHistLimits[1]);
-         h1CFDminLED[ic] = new TH1F(buf4,"LED - CFD",(Int_t)fHistLimits[5],fHistLimits[3],fHistLimits[4]);
-
-         hmpd[ic] = new TH1F(buf7,"mpd",20000,-10000.0,10000.0);
-         hCFDvsQTC[ic] = new TH2F(buf2,"CFD vs QTC",
-                                (Int_t)fHistLimits[8],fHistLimits[6],fHistLimits[7],
-                                (Int_t)fHistLimits[11],fHistLimits[9],fHistLimits[10]);
-         hCFDvsLED[ic] = new TH2F(buf3,"CFD vs LED-CFD",
-                                (Int_t)fHistLimits[14],fHistLimits[12],fHistLimits[13],
-                                (Int_t)fHistLimits[17],fHistLimits[15],fHistLimits[16]);
-
-
-       }
-
-
+  TTree* digitsTree = new TTree("testData","Tree of test data Digits");
+  TBranch *b[106];
+  
+  Int_t channels[106];
+  
+  TString names[106], type;
+  AliT0LookUpKey* lookkey= new AliT0LookUpKey();
+  AliT0LookUpValue*  lookvalue= new AliT0LookUpValue();
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+  AliCDBManager::Instance()->SetRun(0);
+  AliT0Parameters *fParam = AliT0Parameters::Instance();
+  fParam->Init();
+  TMap *lookup = fParam->GetMapLookup();
+  TMapIter *iter = new TMapIter(lookup);
+  
+  for( Int_t iline=0; iline<106; iline++)
+    {
+      lookvalue = ( AliT0LookUpValue*) iter->Next();
+      lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
+      if(lookkey){
+       Int_t key=lookkey->GetKey();
+       names[key]=lookkey->GetChannelName();
+       if(names[key].Contains("QT0"))
+         hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),1000,3000,5000);
+       else
+         hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),1000,2000,3000);
+       
+       //      hitsname="xHits" + names[key];
+       //      hNumHits[key] = new TH1F(hitsname.Data(),hitsname.Data(),50,-0.25,24.25);
+       type =names[key] + "/I";
+       b[key]=digitsTree->Branch(names[key].Data(),&channels[key], type);
       }
-
-      TH1F*hEffCFD= new TH1F("hEffCFD","Effeciency",50,-0.25,24.25);
-      TH1F*hEffLED= new TH1F("hEffLED","Effeciency",50,-0.25,24.25);
-      TH1F*hEffQT0= new TH1F("hEffQT0","Effeciency",50,-0.25,24.25);
-      TH1F*hEffQT1= new TH1F("hEffQT1","Effeciency",50,-0.25,24.25);
-
+      else
+       {printf(" no such value %i \n", iline);}
+      
+    } 
+  for(Int_t ic=0; ic<24; ic++) {
+    {
+      sprintf(buf1,"QTC%i",ic+1);
+      sprintf(buf2,"CFDvsQTC%i",ic+1);
+      sprintf(buf3,"CFDvsLED%i",ic+1);
+      sprintf(buf4,"LEDminCFD%i",ic+1);
+      sprintf(buf7,"mpd%i",ic+1);
       
-      Char_t filename[13];
-      sprintf(filename,"t0%i.raw",fRunNumber);
-       AliRawReader *reader = new AliRawReaderRoot(filename);
-       //    // AliRawReader *reader = new AliRawReaderFile();
-     // AliRawReader *reader = new AliRawReaderFile();
-      reader->LoadEquipmentIdsMap("T0map.txt");
-      //    reader->RequireHeader(kFALSE);
-       reader->RequireHeader(kTRUE);
-       AliT0RawReader *start = new AliT0RawReader(reader);
-       //  start->SetNumberOfTRM(1);
-       for (Int_t i0=0; i0<105; i0++)
-        {
-          for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;      
-          numberOfHits[i0]=0;
-        }
-       Int_t event=0;
+      hQTC[ic] = new TH1F(buf1,"QTC",(Int_t)fHistLimits[2],fHistLimits[0],fHistLimits[1]);
+      h1CFDminLED[ic] = new TH1F(buf4,"LED - CFD",(Int_t)fHistLimits[5],fHistLimits[3],fHistLimits[4]);
+      
+      hCFDvsQTC[ic] = new TH2F(buf2,"CFD vs    QTC",
+                              (Int_t)fHistLimits[8],fHistLimits[6],fHistLimits[7],
+                              (Int_t)fHistLimits[11],fHistLimits[9],fHistLimits[10]);
+      hCFDvsLED[ic] = new TH2F(buf3,"CFD vs LED-CFD",
+                              (Int_t)fHistLimits[14],fHistLimits[12],fHistLimits[13],
+                              (Int_t)fHistLimits[17],fHistLimits[15],fHistLimits[16]);
 
-       while (reader->NextEvent()) {
-        start->Next();
-        for (Int_t i=0; i<105; i++) {
-          for (Int_t iHit=0; iHit<5; iHit++) 
-           {
-             allData[i][iHit]= start->GetData(i,iHit);
-           }
-       }
       
-       if(event%1000 == 0) printf("Event:%d\n",event);
+    }
 
-       //          if(event > 200000) break;
 
-           for (Int_t it = 0; it<24; it=it+2)
+  }
+  
+  TH1F*hEffCFD= new TH1F("hEffCFD","Effeciency",50,-0.25,24.25);
+  TH1F*hEffLED= new TH1F("hEffLED","Effeciency",50,-0.25,24.25);
+  TH1F*hEffQT0= new TH1F("hEffQT0","Effeciency",50,-0.25,24.25);
+  TH1F*hEffQT1= new TH1F("hEffQT1","Effeciency",50,-0.25,24.25);
+
+      
+     // Char_t filename[80];
+  //     sprintf(filename,"t0%i.raw",fRunNumber);
+  AliRawReader *reader = new AliRawReaderRoot(fFileName);
+   reader->LoadEquipmentIdsMap("T0map.txt");
+  //    reader->RequireHeader(kFALSE);
+  reader->RequireHeader(kTRUE);
+  AliT0RawReader *start = new AliT0RawReader(reader);
+  //  start->SetNumberOfTRM(1);
+  for (Int_t i0=0; i0<105; i0++)
+    {
+      for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;  
+      numberOfHits[i0]=0;
+    }
+  Int_t event=0;
+  
+  while (reader->NextEvent()) {
+    start->Next();
+    for (Int_t i=0; i<105; i++) {
+      for (Int_t iHit=0; iHit<5; iHit++) 
+       {
+         allData[i][iHit]= start->GetData(i,iHit);
+       }
+    }
+    
+    // if(event%1000 == 0) 
+    printf("Event:%d\n",event);
+    
+    //          if(event > 200000) break;
+    
+    for (Int_t it = 0; it<24; it=it+2)
+      {
+       for (Int_t iHit=0; iHit<5; iHit++)
+         {
+           if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0)
              {
-               for (Int_t iHit=0; iHit<5; iHit++)
-                 {
-               if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0)
+               Int_t cc=it/2;
+               hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]);
+               if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+1][iHit]-allData[0][0]);
+               if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 ) 
                  {
-                   Int_t cc=it/2;
-                   hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]);
-                   hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]);
-                   if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+1][iHit]-allData[0][0]);
-                   if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 ) 
-                     {
-                       hCFDvsLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit],allData[cc+1][iHit]-allData[0][0]);  
-                       h1CFDminLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit]);
-                     }
+                   hCFDvsLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit],allData[cc+1][iHit]-allData[0][0]);  
+                   h1CFDminLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit]);
                  }
              }
          }
-
-       for (Int_t iHit=0; iHit<5; iHit++) 
+      }
+    for (Int_t it = 24; it<48; it=it+2)
+      {
+       for (Int_t iHit=0; iHit<5; iHit++)
          {
-
-           for(Int_t ik=1; ik<105; ik++)
-             { 
-               channels[ik] = -100;
-               if((allData[ik][iHit] - allData[0][0]) > 0 ) 
-                 {
-                   numberOfHits[ik]++;
-                   hChannel[ik] -> Fill(allData[ik][iHit] - allData[0][0]);
-                   channels[ik] = allData[ik][iHit] - allData[0][0];
-                 }
+           if(allData[it+57][iHit] != 0 && allData[it+58][iHit] !=0)
+             {
+               Int_t cc=(Int_t)(it/2.0);
+               hQTC[cc]->Fill(allData[it+57][iHit]-allData[it+58][iHit]);
+               //                  hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]);
+             if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+45][iHit]-allData[0][0]);
+             if(allData[cc+57][iHit] != 0 && allData[cc+45][iHit]!=0 ) 
+               {
+                 hCFDvsLED[cc]->Fill(allData[cc+57][iHit]-allData[cc+45][iHit],allData[cc+1][iHit]-allData[0][0]);  
+                 h1CFDminLED[cc]->Fill(allData[cc+57][iHit]-allData[cc+45][iHit]);
+               }
+             }
+       }
+      }
+    
+    
+    for (Int_t iHit=0; iHit<5; iHit++) 
+      {
+       
+       for(Int_t ik=1; ik<105; ik++)
+         { 
+           channels[ik] = -100;
+           if((allData[ik][iHit] - allData[0][0]) > 0 ) 
+             {
+               numberOfHits[ik]++;
+               hChannel[ik] -> Fill(allData[ik][iHit] - allData[0][0]);
+               channels[ik] = allData[ik][iHit] - allData[0][0];
              }
-             digitsTree->Fill();   
          }
+             digitsTree->Fill();   
+      }
 
-       event++;
-
-      } //event
+    event++;
+    
+  } //event
 
 
-     if (event>1)
+  if (event>1)
+    {
+      printf("efficiency for %i events \n",event);
+      for (Int_t i0=1; i0<13;  i0++)
        {
-         printf("efficiency for %i events \n",event);
-         for (Int_t i0=1; i0<13;  i0++)
-           {
-             printf("%s  %f  %s  %f %s  %f  %s  %f \n",
-                    names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event),
-                    names[i0+13].Data(),Float_t(numberOfHits[i0+13])/Float_t(event),
-                    names[i0+57].Data(),Float_t(numberOfHits[i0+57])/Float_t(event),
-                    names[i0+69].Data(),Float_t(numberOfHits[i0+69])/Float_t(event));
-
-             hEffCFD->Fill(i0,Float_t(numberOfHits[i0])  / Float_t(event));
-             hEffLED->Fill(i0,Float_t(numberOfHits[i0+13]) / Float_t(event));
-             hEffCFD->Fill(i0+12,Float_t(numberOfHits[i0+57]) /Float_t(event));
-             hEffLED->Fill(i0+12,Float_t(numberOfHits[i0+69]) /Float_t(event));
-           }
-
-         for (Int_t i0=0; i0<24;  i0=i0+2)
-           {
-             hEffQT1->Fill(i0, Float_t (numberOfHits[i0+25]) / Float_t(event));
-             hEffQT0->Fill(i0, Float_t (numberOfHits[i0]+26) / Float_t(event));
-             hEffQT1->Fill((i0+12), Float_t (numberOfHits[i0]+81) /  Float_t(event));
-             hEffQT0->Fill((i0+12), Float_t (numberOfHits[i0]+82) /  Float_t(event));
-
-             printf("%s  %f  %s  %f %s  %f  %s  %f \n",
-                    names[i0+25].Data(), Float_t(numberOfHits[i0+25])/Float_t(event),
-                    names[i0+26].Data(),Float_t(numberOfHits[i0+26])/Float_t(event),
-                    names[i0+81].Data(),Float_t(numberOfHits[i0+81])/Float_t(event),
-                    names[i0+82].Data(),Float_t(numberOfHits[i0+82])/Float_t(event));
-           }
-       }             
-
+         printf("%s  %f  %s  %f %s  %f  %s  %f \n",
+                names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event),
+                names[i0+13].Data(),Float_t(numberOfHits[i0+13])/Float_t(event),
+                names[i0+57].Data(),Float_t(numberOfHits[i0+57])/Float_t(event),
+                names[i0+69].Data(),Float_t(numberOfHits[i0+69])/Float_t(event));
+         
+         hEffCFD->Fill(i0,Float_t(numberOfHits[i0])  / Float_t(event));
+         hEffLED->Fill(i0,Float_t(numberOfHits[i0+13]) / Float_t(event));
+         hEffCFD->Fill(i0+12,Float_t(numberOfHits[i0+57]) /Float_t(event));
+         hEffLED->Fill(i0+12,Float_t(numberOfHits[i0+69]) /Float_t(event));
+       }
+      
+      for (Int_t i0=0; i0<24;  i0=i0+2)
+       {
+         hEffQT1->Fill(i0, Float_t (numberOfHits[i0+25]) / Float_t(event));
+         hEffQT0->Fill(i0, Float_t (numberOfHits[i0]+26) / Float_t(event));
+         hEffQT1->Fill((i0+12), Float_t (numberOfHits[i0]+81) /  Float_t(event));
+         hEffQT0->Fill((i0+12), Float_t (numberOfHits[i0]+82) /  Float_t(event));
+
+         printf("%s  %f  %s  %f %s  %f  %s  %f \n",
+                names[i0+25].Data(), Float_t(numberOfHits[i0+25])/Float_t(event),
+                names[i0+26].Data(),Float_t(numberOfHits[i0+26])/Float_t(event),
+                names[i0+81].Data(),Float_t(numberOfHits[i0+81])/Float_t(event),
+                names[i0+82].Data(),Float_t(numberOfHits[i0+82])/Float_t(event));
+       }
+    }        
+  
 
-      Char_t filehist[40]; 
-     sprintf(filehist,"t0tree%i.root",fRunNumber);
-     //  sprintf(filehist,"test.root",runNumber);
+  Char_t filehist[40]; 
+  sprintf(filehist,"t0tree%s",fFileName);
+  //  sprintf(filehist,"test.root",runNumber);
      TFile *hist = new TFile(filehist,"RECREATE");
-       hist->cd();
-      //  digitsTree->Write("",TObject::kOverwrite);
-
-      hEffCFD->Write();
-      hEffLED->Write();
-      hEffQT0->Write();
+     hist->cd();
+     //  digitsTree->Write("",TObject::kOverwrite);
+     
+     hEffCFD->Write();
+     hEffLED->Write();
+     hEffQT0->Write();
       hEffQT1->Write();
-
+      
       for(Int_t ik=0; ik<105; ik++)    hChannel[ik] ->Write();
-
-      for (Int_t i=0; i<12; i++)
+      
+      for (Int_t i=0; i<24; i++)
        {
          hQTC[i]->Write();
-         hmpd[i]->Write();
          hCFDvsQTC[i]->Write();
          hCFDvsLED[i]->Write();
          h1CFDminLED[i]->Write();
        }
       
 }
+
+void AliT0CalibLaserData::OpenFile()
+{
+
+const char *ft[]={"T0 raw files","*.root","All files","*",0,0};
+  TString dir(".");
+  TGFileInfo fi; fi.fFileTypes=ft; fi.fIniDir=StrDup(dir);
+  new TGFileDialog(gClient->GetRoot(), 0x0, kFDOpen, &fi);
+  if(!fi.fFilename) return;
+  // fFileName =*( fi.fFilename);
+  fFileName = fi.fFilename;
+  printf(" AliT0CalibLaserData::OpenFile %s %s\n",fi.fFilename, fFileName );
+  //  if(gFile){ gFile->Close(); gFile=0;}
+
+  // gFile=TFile::Open(fi.fFilename);
+
+}
+
index a920dac..188d08f 100644 (file)
@@ -9,6 +9,7 @@
  * See cxx source for full Copyright notice                               
  ***************************************************************************/
 #include "TGNumberEntry.h"
+#include "TGTextEntry.h"
 #include "TObject.h"
 
 class AliT0CalibLaserData : public TObject
@@ -16,19 +17,24 @@ class AliT0CalibLaserData : public TObject
  public:
   AliT0CalibLaserData ();
   AliT0CalibLaserData(const AliT0CalibLaserData &calibda) : TObject(calibda),
-                  fRunNumber(0) {}
+    fTEntry(0),
+    fFileName(" ")
+    {}
   AliT0CalibLaserData & operator= (const AliT0CalibLaserData  &) {return *this;}
   virtual ~AliT0CalibLaserData() {}
-  void ReadHistSize(Int_t rNumber=905);
+  void ReadHistSize();
   void DoOk();
   void            ReadData();
+  void OpenFile();
 
  private:
-  Int_t           fRunNumber;       // run number
-  TGNumberEntry * fEntries[30];     //for GUI
+  TGNumberEntry * fEntries[30];     //for GUI histogram limits
+  TGTextEntry * fTEntry;     //for GUI file name
   double          fHistLimits[30];  // histogram limits
+  const char *fFileName;     // file name
 
-  ClassDef(AliT0CalibLaserData,1)
+
+  ClassDef(AliT0CalibLaserData,2)
 };
 
 #endif
index 75b5926..b09be59 100644 (file)
@@ -37,6 +37,8 @@ void AliT0CalibViewer()
                  "Draw CFD vs QTC");
   menu->AddButton("Draw CFDvsLED","DrawCFDvsLED()",
                  "Draw CFD vs LED-CFD");
+  menu->AddButton("Draw Walk","DrawWalk()",
+                 "Draw CFD vs LED-CFD");
   menu->Show();
 }
 void OpenFile()
@@ -62,7 +64,7 @@ void DrawCFD()
   Bool_t down=false;
   Int_t index[20];
    
-  TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
+  TCanvas *c1 = new TCanvas("c1", "CFD C side",0,48,1280,951);
   c1->Divide(4,3);
   gStyle->SetOptFit(1111);
   //c1->Divide(2,2);
@@ -72,28 +74,71 @@ void DrawCFD()
       c1->cd(i+1);
       sprintf(buf1,"T0_C_%i_CFD",i+1);
       TH1F *cfd = (TH1F*) gFile->Get(buf1);
-      //     cfd->Draw();
+      //    cfd->Draw();
+      
       TSpectrum *s = new TSpectrum(2*npeaks,1);
       Int_t nfound = s->Search(cfd,sigma," ",0.05);
       cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
       if(nfound!=0){
        Float_t *xpeak = s->GetPositionX();
        TMath::Sort(nfound, xpeak, index,down);
-       Float_t xp = xpeak[index[0]];
+       Float_t xp = xpeak[index[0]];
+       cout<<" index[0] "<<index[0]<<endl;
+               //      Float_t xp = xpeak[1];
        Int_t xbin = cfd->GetXaxis()->FindBin(xp);
        Float_t yp = cfd->GetBinContent(xbin);
        cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl;
        Float_t hmax = xp+3*sigma;
        Float_t hmin = xp-3*sigma;
        cout<<hmin<< " "<<hmax<<endl;
-       cfd->GetXaxis()->SetRange(hmin-20,hmax+20);
-       //      cout<<" cfd range "<<mean<<" rms "<<rms<<" "<<hmin<<" "<<hmax<<endl;
+       cfd->GetXaxis()->SetRange(hmin-10,hmax+10);
+       cout<<" cfd range "<<hmin-10<<" "<<hmax+10<<endl;
+       cfd->GetXaxis()->SetLabelSize(0.03);
        TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
-       //      cfd->Fit("g1","R");
-       cfd->Draw();
+               cfd->Fit("g1","R");
+               //      cfd->Draw();
+       
       }
+
     }
+  TCanvas *c2 = new TCanvas("c2", "CFD A side",0,48,1280,951);
+  c2->Divide(4,3);
+  gStyle->SetOptFit(1111);
+  //c1->Divide(2,2);
+  Char_t buf1[10];
+  for (Int_t i=0; i<12; i++)
+    {
+      c2->cd(i+1);
+      sprintf(buf1,"T0_A_%i_CFD",i+1);
+      TH1F *cfd = (TH1F*) gFile->Get(buf1);
+      //    cfd->Draw();
+      
+      TSpectrum *s = new TSpectrum(2*npeaks,1);
+      Int_t nfound = s->Search(cfd,sigma," ",0.05);
+      cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
+      if(nfound!=0){
+       Float_t *xpeak = s->GetPositionX();
+       TMath::Sort(nfound, xpeak, index,down);
+       Float_t xp = xpeak[index[0]];
+       cout<<" index[0] "<<index[0]<<endl;
+               //      Float_t xp = xpeak[1];
+       Int_t xbin = cfd->GetXaxis()->FindBin(xp);
+       Float_t yp = cfd->GetBinContent(xbin);
+       cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl;
+       Float_t hmax = xp+3*sigma;
+       Float_t hmin = xp-3*sigma;
+       cout<<hmin<< " "<<hmax<<endl;
+       cfd->GetXaxis()->SetRange(hmin-10,hmax+10);
+       cout<<" cfd range "<<hmin-10<<" "<<hmax+10<<endl;
+       cfd->GetXaxis()->SetLabelSize(0.03);
+       TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
+               cfd->Fit("g1","R");
+               //      cfd->Draw();
+       
+      }
+
+    }
+
 }
 //------------------------------------------------------------------------
 void DrawLED()
@@ -103,7 +148,7 @@ void DrawLED()
   Bool_t down=false;
   Int_t index[20];
   
-  TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
+  TCanvas *c1 = new TCanvas("c1", "LED C side",0,48,1280,951);
   c1->Divide(4,3);
   
   Char_t buf1[20];
@@ -112,7 +157,37 @@ void DrawLED()
       c1->cd(i+1);
       sprintf(buf1,"T0_C_%i_LED",i+1);
       TH1F *cfd = (TH1F*) gFile->Get(buf1);
-      cfd->Draw();
+       TSpectrum *s = new TSpectrum(2*npeaks,1);
+      Int_t nfound = s->Search(cfd,sigma," ",0.2);
+      cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
+      if(nfound!=0) {
+       Float_t *xpeak = s->GetPositionX();
+       TMath::Sort(nfound, xpeak, index,down);
+       Float_t xp = xpeak[index[0]];
+        Int_t xbin = cfd->GetXaxis()->FindBin(xp);
+        Float_t yp = cfd->GetBinContent(xbin);
+        cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl;
+        Float_t hmin=xp-3*sigma;
+        Float_t hmax =xp+3*sigma;
+        cfd->GetXaxis()->SetRange(hmin,hmax);
+       cfd->GetXaxis()->SetLabelSize(0.03);
+       TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
+       cfd->Fit("g1","R");
+       //      cfd->Draw();
+       
+      }
+      
+    }
+  TCanvas *c2 = new TCanvas("c2", "LED A side",0,48,1280,951);
+  c2->Divide(4,3);
+  
+  Char_t buf1[20];
+  for (Int_t i=0; i<12; i++)
+    {
+      c2->cd(i+1);
+      sprintf(buf1,"T0_A_%i_LED",i+1);
+      TH1F *cfd = (TH1F*) gFile->Get(buf1);
       TSpectrum *s = new TSpectrum(2*npeaks,1);
       Int_t nfound = s->Search(cfd,sigma," ",0.2);
       cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
@@ -126,6 +201,7 @@ void DrawLED()
         Float_t hmin=xp-3*sigma;
         Float_t hmax =xp+3*sigma;
         cfd->GetXaxis()->SetRange(hmin,hmax);
+       cfd->GetXaxis()->SetLabelSize(0.03);
        TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
        cfd->Fit("g1","R");
        //      cfd->Draw();
@@ -139,16 +215,46 @@ void DrawLED()
 void DrawQTC()
 {
   
-  TCanvas *c1 = new TCanvas("c1", "QTC",0,48,1280,951);
-  // c1->Divide(4,3);
-  c1->Divide(2,3);
+  TCanvas *c1 = new TCanvas("c1", "QTC C side",0,48,1280,951);
+   c1->Divide(4,3);
+   // c1->Divide(2,3);
   
   Char_t buf1[10];
   for (Int_t i=0; i<12; i++)
     {
       c1->cd(i+1);
       sprintf(buf1,"QTC%i",i+1);
+      
       TH1F *qtc = (TH1F*) gFile->Get(buf1);
+      
+      Float_t mean = qtc->GetMean();
+      Float_t rms = qtc->GetRMS();
+      Float_t hminR=mean - 0.1*mean;
+      Float_t hmaxR =mean + 0.1*mean;
+      qtc->GetXaxis()->SetRange(hminR,hmaxR);
+      Float_t hmin=mean - 3*rms;
+      Float_t hmax =mean + 3*rms;
+      qtc->GetXaxis()->SetRange(hmin,hmax);
+
+     // TF1 *g2 = new TF1("g2", "gaus", hmin, hmax);
+       //             qtc->Fit("g2","RQ");
+       qtc->GetXaxis()->SetLabelSize(0.03);
+       
+       qtc->Draw();
+    }
+  
+  TCanvas *c2 = new TCanvas("c2", "QTC A side",0,48,1280,951);
+   c2->Divide(4,3);
+   // c1->Divide(2,3);
+  
+  Char_t buf1[10];
+  for (Int_t i=12; i<24; i++)
+    {
+      c2->cd(i+1-12);
+      sprintf(buf1,"QTC%i",i+1);
+      
+      TH1F *qtc = (TH1F*) gFile->Get(buf1);
+      
       Float_t mean = qtc->GetMean();
       Float_t rms = qtc->GetRMS();
       Float_t hminR=mean - 0.1*mean;
@@ -159,6 +265,8 @@ void DrawQTC()
       qtc->GetXaxis()->SetRange(hmin,hmax);
       // TF1 *g2 = new TF1("g2", "gaus", hmin, hmax);
        //             qtc->Fit("g2","RQ");
+       qtc->GetXaxis()->SetLabelSize(0.03);
+      
        qtc->Draw();
     }
   
@@ -173,14 +281,44 @@ void DrawLEDminCFD()
   Bool_t down=false;
   Int_t index[20];
   
-  TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
+  TCanvas *c1 = new TCanvas("c1", " LED-CFD C side",0,48,1280,951);
   c1->Divide(4,3);
   
   Char_t buf1[20];
   for (Int_t i=0; i<12; i++)
     {
       c1->cd(i+1);
-      sprintf(buf1,"LED-CFD%i",i+1);
+      sprintf(buf1,"LEDminCFD%i",i+1);
+      TH1F *cfd = (TH1F*) gFile->Get(buf1);
+      cfd->Draw();
+      TSpectrum *s = new TSpectrum(2*npeaks,1);
+      Int_t nfound = s->Search(cfd,sigma," ",0.2);
+      cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
+      if(nfound!=0) {
+       Float_t *xpeak = s->GetPositionX();
+       TMath::Sort(nfound, xpeak, index,down);
+       Float_t xp = xpeak[index[0]];
+        Int_t xbin = cfd->GetXaxis()->FindBin(xp);
+        Float_t yp = cfd->GetBinContent(xbin);
+        cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl;
+        Float_t hmin=xp-3*sigma;
+        Float_t hmax =xp+3*sigma;
+        cfd->GetXaxis()->SetRange(hmin,hmax);
+       TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
+        cfd->Fit("g1","RQ");
+
+       
+      }
+      
+    }
+ TCanvas *c2 = new TCanvas("c2", "LED-CFD A side",0,48,1280,951);
+  c2->Divide(4,3);
+  
+  Char_t buf1[20];
+  for (Int_t i=12; i<24; i++)
+    {
+      c2->cd(i+1-12);
+      sprintf(buf1,"LEDminCFD%i",i+1);
       TH1F *cfd = (TH1F*) gFile->Get(buf1);
       cfd->Draw();
       TSpectrum *s = new TSpectrum(2*npeaks,1);
@@ -238,11 +376,95 @@ void DrawCFDvsQTC()
   Int_t index[20];
   Char_t buf1[10], buf2[10];
   
+  TCanvas *c1 = new TCanvas("c1", "CFD vs QTC C side",0,48,1280,951);
+  gStyle->SetOptStat(111111);
+  c1->Divide(4,3);
+  
+  for (Int_t i=0; i<12; i++)
+    {
+      c1->cd(i+1);
+      sprintf(buf1,"T0_C_%i_CFD",i+1);
+      sprintf(buf2,"CFDvsQTC%i",i+1);
+      cout<<buf1<<" "<<buf2<<endl;
+      TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
+      TH1F *cfd = (TH1F*) gFile->Get(buf1);
+      //       cfd->Draw();
+      TSpectrum *s = new TSpectrum(2*npeaks,1);
+      Int_t nfound = s->Search(cfd,sigma," ",0.05);
+      cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
+      if(nfound!=0){
+       Float_t *xpeak = s->GetPositionX();
+       TMath::Sort(nfound, xpeak, index,down);
+       Float_t xp = xpeak[index[0]];
+       Int_t xbin = cfd->GetXaxis()->FindBin(xp);
+       Float_t yp = cfd->GetBinContent(xbin);
+       cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl;
+       Float_t hmax = xp+10*sigma;
+       Float_t hmin = xp-10*sigma;
+       cout<<hmin<< " "<<hmax<<endl;
+       //          cfd->GetXaxis()->SetRange(hmin,hmax);
+       //          TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
+       // cfd->Fit("g1","R");
+       qtc_cfd->GetYaxis()->SetRange(hmin,hmax);
+       qtc_cfd->Draw();
+       
+      }
+      
+    }
+  TCanvas *c2 = new TCanvas("c2", "CFD vs QTC A side",0,48,1280,951);
+  gStyle->SetOptStat(111111);
+  c2->Divide(4,3);
+  
+  for (Int_t i=12; i<24; i++)
+    {
+      c2->cd(i+1-12);
+      sprintf(buf1,"T0_A_%i_CFD",i+1-12);
+      sprintf(buf2,"CFDvsQTC%i",i+1);
+      cout<<buf1<<" "<<buf2<<endl;
+      TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
+      TH1F *cfd = (TH1F*) gFile->Get(buf1);
+      //       cfd->Draw();
+      TSpectrum *s = new TSpectrum(2*npeaks,1);
+      Int_t nfound = s->Search(cfd,sigma," ",0.05);
+      cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
+      if(nfound!=0){
+       Float_t *xpeak = s->GetPositionX();
+       TMath::Sort(nfound, xpeak, index,down);
+       Float_t xp = xpeak[index[0]];
+       Int_t xbin = cfd->GetXaxis()->FindBin(xp);
+       Float_t yp = cfd->GetBinContent(xbin);
+       cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl;
+       Float_t hmax = xp+10*sigma;
+       Float_t hmin = xp-10*sigma;
+       cout<<hmin<< " "<<hmax<<endl;
+       //          cfd->GetXaxis()->SetRange(hmin,hmax);
+       //          TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
+       // cfd->Fit("g1","R");
+       qtc_cfd->GetYaxis()->SetRange(hmin,hmax);
+       qtc_cfd->Draw();
+       
+      }
+      
+    }
+  
+  
+  
+}
+//------------------------------------------------------------------------
+void DrawWalk()
+{
+  Int_t npeaks = 20;
+  Int_t sigma=3.;
+  Bool_t down = false;
+
+  Int_t index[20];
+  Char_t buf1[10], buf2[10];
+  
   TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
   gStyle->SetOptStat(0);
-  c1->Divide(3,2);
+  c1->Divide(4,3);
   
-  for (Int_t i=0; i<5; i++)
+  for (Int_t i=0; i<12; i++)
     {
       c1->cd(i+1);
       sprintf(buf1,"T0_C_%i_CFD",i+1);
@@ -273,6 +495,7 @@ void DrawCFDvsQTC()
        cout<<"  qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl;
        //  qtc_cfd->Draw();
        TProfile *pr_y = qtc_cfd->ProfileX();
+       Float_t maxHr=pr_y->GetBinCenter(hmaxbin);
        
        pr_y->SetMaximum(hmax);
        pr_y->SetMinimum(hmin);
@@ -289,14 +512,14 @@ void DrawCFDvsQTC()
              //        cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl;
              ng++;}
            else {
-             xx[ip/20] = Float_t (ip);
+             xx[ip/20] = Float_t (pr_y->GetBinCenter(ip));
              yy[ip/20] = yg/ng;
              yg=0;
              ng=0;
-             //              cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl;
+                     cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl;
            }
          }
-       TH2F *hr = new TH2F("hr"," ",np,0,nbins, np, hmin, hmax);
+       TH2F *hr = new TH2F("hr"," ",np,0,maxHr, np, hmin, hmax);
        hr->Draw();
        TGraph *gr = new TGraph(np,xx,yy);
        gr->SetMinimum(hmin);
@@ -323,14 +546,17 @@ void DrawCFDvsLED()
   Int_t npeaks = 20;
   Int_t sigma=2.;
   Char_t buf1[10], buf2[10];
-  
-  for (Int_t i=0; i<1; i++)
+   TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
+  gStyle->SetOptStat(0);
+  c1->Divide(4,3);
+  for (Int_t i=0; i<12; i++)
     {
-      //   c1->cd(i+1);
+      c1->cd(i+1);
       sprintf(buf1,"T0_C_%i_CFD",i+1);
-      sprintf(buf2,"CFD_LED%i",i+1);
+      sprintf(buf2,"CFDvsLED%i",i+1);
       
       TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
+      //qtc_cfd->Draw();
       TH1F *cfd = (TH1F*) gFile->Get(buf1);
       //       cfd->Draw();
       TSpectrum *s = new TSpectrum(2*npeaks,1);
@@ -357,8 +583,8 @@ void DrawCFDvsLED()
        Int_t hmaxbin=  qtc_cfd->GetXaxis()->GetLast();
        Int_t nbins= qtc_cfd->GetXaxis()->GetNbins();
        cout<<"  qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl;
-       //  qtc_cfd->Draw();
-       TProfile *pr_y = qtc_cfd->ProfileX();
+        qtc_cfd->Draw();
+       /*TProfile *pr_y = qtc_cfd->ProfileX();
        
        pr_y->SetMaximum(hmax);
        pr_y->SetMinimum(hmin);
@@ -393,9 +619,9 @@ void DrawCFDvsLED()
        
        // pr_y->Rebin(10);
        //  pr_y->Draw();
-       
+       */
       }
-      
     }