added possibility to read TRM BC ID, calibration done by QTC amplitude
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 20 Jul 2010 09:36:31 +0000 (09:36 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 20 Jul 2010 09:36:31 +0000 (09:36 +0000)
T0/AliT0Calibrator.cxx
T0/AliT0RawReader.cxx
T0/AliT0RawReader.h
T0/AliT0Reconstructor.cxx

index be4a787..8a8cbef 100644 (file)
@@ -55,9 +55,9 @@ ClassImp(AliT0Calibrator)
   for (Int_t i=0; i<24; i++){
     fMaxValue[i]=0;
     fTimeDelayCFD[i] = Int_t (param->GetTimeDelayCFD(i));
-    //    TGraph* fu = param ->GetWalk(i);
+     TGraph* fu = param ->GetWalk(i);
     // fWalk.AddAtAndExpand(fu,i);
-    TGraph* fu = param ->GetAmpLEDRec(i);
+    //TGraph* fu = param ->GetAmpLEDRec(i);
     fWalk.AddAtAndExpand(fu,i);
      
   }
@@ -108,16 +108,17 @@ Int_t  AliT0Calibrator::WalkCorrection(Int_t refAmp,  Int_t ipmt, Int_t qt, Int_
   if(fu1 && fu1->GetN()>0) {
     grY = fu1->GetY();
     fMaxValue[ipmt]=grY[refAmp-1];
-    //    TGraph* fu  = param ->GetAmpLEDRec(i);
-    walk = Int_t (fMaxValue[ipmt]) + Int_t(fu1->Eval(Double_t(qt)));
+    // TGraph* fu  = param ->GetAmpLEDRec(i);
+    // walk = Int_t (fMaxValue[ipmt]) + Int_t(fu1->Eval(Double_t(qt)));
+    walk = Int_t(fu1->Eval(Double_t(qt)));
   }
   
   timeWalk = time - walk   ;
   timeEq= timeWalk - fTimeDelayCFD[ipmt];
-  // printf(" ipmt %i time before %i timeWalk %i , walk %i  qt %i fTimeDelayCFD[ipmt] %i timeEq %i \n ",
+  //   printf(" ipmt %i time before %i timeWalk %i , walk %i  qt %i fTimeDelayCFD[ipmt] %i timeEq %i \n ",
   //    ipmt, time,timeWalk, walk, qt,fTimeDelayCFD[ipmt], timeEq );
-  //   AliDebug(10,Form(" ipmt %i time before %i timeWalk %i , walk %i  qt %i timeEq %i \n ",
-  //   ipmt, time,timeWalk, walk, qt, timeEq ));
+     AliDebug(10,Form(" ipmt %i time before %i timeWalk %i , walk %i  qt %i timeEq %i \n ",
+     ipmt, time,timeWalk, walk, qt, timeEq ));
   
    return timeEq;
 }
index 894e81a..3aefb2d 100644 (file)
@@ -39,7 +39,10 @@ ClassImp(AliT0RawReader)
        fData(NULL),
        fPosition(0),
        fParam(NULL),
-       fIsOnline(isOnline)
+       fIsOnline(isOnline),
+       fBunchID(0),
+       fPrintout(kFALSE)
+
 {
   //
 // create an object to read T0raw digits
@@ -97,7 +100,6 @@ Bool_t  AliT0RawReader::Next()
 //  allData[48]  mean (T0) signal  
 // allData[49]   time difference (vertex)
 
   UInt_t word;
   Int_t time=0,  itdc=0, ichannel=0, uu; 
   Int_t numberOfWordsInTRM=0, iTRM=0;
@@ -110,39 +112,45 @@ Bool_t  AliT0RawReader::Next()
   Bool_t correct=kTRUE;
   Int_t header;
 
-   Int_t fNTRM = fParam->GetNumberOfTRMs();
-   for ( Int_t k=0; k<110; k++) {
+  Int_t fNTRM = fParam->GetNumberOfTRMs();
+  for ( Int_t k=0; k<110; k++) {
     koefhits[k]=0;
     for ( Int_t jj=0; jj<5; jj++) {
       fAllData[k][jj]=0;
-     }
-   }
-    do {
-      if (!fRawReader->ReadNextData(fData)) return kFALSE;
-    } while (fRawReader->GetDataSize() == 0);
-    
-    fPosition = 0;
-     cout.setf( ios_base::hex, ios_base::basefield );
-    
-    //DRM header
+    }
+  }
+  do {
+    if (!fRawReader->ReadNextData(fData)) return kFALSE;
+  } while (fRawReader->GetDataSize() == 0);
+  
+  fPosition = 0;
+  //  cout.setf( ios_base::hex, ios_base::basefield );
+  if(fPrintout)
+    cout<<" CDH :: BC ID "<< (fRawReader->GetBCID())<<
+      " Event size"<<fRawReader->GetDataSize()<<
+      " orbit ID "<<fRawReader->GetOrbitID()<< 
+      " event index "<<fRawReader->GetEventIndex()<<
+      " event type " <<fRawReader->GetType()<<endl;
+  //DRM header
     for (Int_t i=0; i<6; i++) {
       word = GetNextWord();
-      // cout<<" DRM header "<<word<<endl;
+      if(fPrintout && i==0) cout<<" DRM header:: event words "<<AliBitPacking::UnpackWord(word,4, 20);
+      //  cout<<i<<" DRM header "<<word<<endl;
+      if (fPrintout && i==4 ) cout<<" L0BC ID "<< AliBitPacking::UnpackWord(word,4, 15)<<endl;
       header = AliBitPacking::UnpackWord(word,28,31);
-      if( header !=4 )
+      if( header !=4 ) 
        {
          AliWarning(Form(" !!!! wrong  DRM header  %x!!!!", word));
          fRawReader->AddFatalErrorLog(kWrongDRMHeader,Form("w=%x",word));
          break;
        }
     }
-    //    cout<<"   fNTRM "<<fNTRM<<endl;
     for (Int_t ntrm=0; ntrm< fNTRM; ntrm++)
       {
        //TRMheader  
        word = GetNextWord();
+       //      cout<<" TRM "<<word<<endl;
        header = AliBitPacking::UnpackWord(word,28,31);
-       //      cout<<" TRM header "<<word<<endl;
        if ( header != 4 )
          {
            AliWarning(Form(" !!!! wrong TRM header  %x!!!!", word));
@@ -150,13 +158,17 @@ Bool_t  AliT0RawReader::Next()
            break;
          }
        numberOfWordsInTRM=AliBitPacking::UnpackWord(word,4,16);
-       //      cout<<" numberOfWordsInTRM "<<numberOfWordsInTRM<<endl;
+       if(fPrintout) {
+         cout<<" TRM header :: event words "<<numberOfWordsInTRM;
+         cout<<" ACQ bits "<<AliBitPacking::UnpackWord(word,17,18);
+         cout<<" L bit "<<AliBitPacking::UnpackWord(word,19,19)<<endl;
+       }
        iTRM=AliBitPacking::UnpackWord(word,0,3);
        for( Int_t ichain=0; ichain<2; ichain++)
          {
            //chain header
            word = GetNextWord();
-           //  cout<<" chain header "<<word<<endl;
+           // cout<<" chain header "<<word<<endl;
            uu = word & trm_chain_header;
            if(uu != trm_chain_header) 
              {
@@ -164,14 +176,16 @@ Bool_t  AliT0RawReader::Next()
                fRawReader->AddMajorErrorLog(kWrongChain0Header,Form("w=%x",word));
                break;
              }
+           fBunchID=AliBitPacking::UnpackWord(word,4,15);
+           if(fPrintout)
+             cout<<" chain "<< ichain<<" header:: BunchID  "<<fBunchID;
            word = GetNextWord();
-           //      cout<<" next "<<word<<endl;
+           //   cout<<" next word "<<word<<endl;
            tdcTime =  AliBitPacking::UnpackWord(word,31,31);   
            //      for (; tdcTime==1; tdcTime) 
            while(tdcTime==1)
              {
                correct = kTRUE;
-               //cout<<" packed "<<word<<endl;
                itdc=AliBitPacking::UnpackWord(word,24,27);
                ichannel=AliBitPacking::UnpackWord(word,21,23);
                time=AliBitPacking::UnpackWord(word,0,20);
@@ -196,12 +210,12 @@ Bool_t  AliT0RawReader::Next()
                  koefhits[koef]++;
                }
                word = GetNextWord();
-               //              cout<<" next word in cycle "<<word<<endl;
+
                tdcTime =  AliBitPacking::UnpackWord(word,31,31);   
                
              }
            
-           // cout<<" chain trailer "<<word<<endl;
+           //   cout<<" trailer :: "<<word<<endl;
            uu = word&trm_chain_trailer;
            if(uu != trm_chain_trailer )
              {
@@ -209,6 +223,8 @@ Bool_t  AliT0RawReader::Next()
                fRawReader->AddMajorErrorLog(kWrongChain0Trailer,Form("w=%x",word));
                break;
              }
+           if(fPrintout)
+             cout<<" trailer:: event counter "<< AliBitPacking::UnpackWord(word,16,27)<<endl;
          }
             
        word = GetNextWord(); //TRM trailer
@@ -220,9 +236,11 @@ Bool_t  AliT0RawReader::Next()
            fRawReader->AddMajorErrorLog(kWrongTRMTrailer,Form("w=%x",word));
            break;
          }
+       if(fPrintout)
+         cout<<"  TRM trailer :: event counter "<< AliBitPacking::UnpackWord(word,16,27)<<endl;
       } //TRM loop
     word = GetNextWord(); //
-    // cout<<" after TRM trailer "<<word<<endl;
+    //  cout<<" after TRM trailer "<<word<<endl;
     if (word == filler )  word = GetNextWord(); 
      header = AliBitPacking::UnpackWord(word,28,31);
      if( header !=5 )
@@ -230,6 +248,8 @@ Bool_t  AliT0RawReader::Next()
         AliWarning(Form(" !!!! wrong DRM GLOBAL trailer  %x!!!!", word));
         fRawReader->AddFatalErrorLog(kWrongDRMTrailer,Form("w=%x",word));
       }
+     if(fPrintout)
+       cout<<" DRM trailer ::event counter "<< AliBitPacking::UnpackWord(word,4,15)<<endl;
      cout.setf( ios_base::dec, ios_base::basefield );
     
      return kTRUE;
index 16a7367..d049556 100644 (file)
@@ -53,6 +53,9 @@ class AliT0RawReader : public TTask {
   };
 
   Bool_t IsOnlineMode () {return fIsOnline;}
+  Int_t GetTRMBunchID() {return fBunchID;};
+
+  void SetPrintout(Bool_t pp ) {fPrintout = pp;}
      
   protected :
 
@@ -61,10 +64,11 @@ class AliT0RawReader : public TTask {
   Int_t            fPosition;     // current (32 bit) position in fData
   AliT0Parameters *fParam;       // instanse of  Parameters class
   Bool_t           fIsOnline;     // for case online DA usage
-  
+  Int_t            fBunchID;       //bunchID from TRM chain header
+  Bool_t           fPrintout;      // advanced printout
   Int_t            fAllData[110][5]; // container for raw data
   
- ClassDef(AliT0RawReader,2) //class for reading T0 Raw data
+ ClassDef(AliT0RawReader,3) //class for reading T0 Raw data
 };
 
 typedef AliT0RawReader AliSTARTRawReader; // for backward compatibility
index eb0d90e..34b9d39 100644 (file)
@@ -80,7 +80,9 @@ ClassImp(AliT0Reconstructor)
   
   // fdZonC = TMath::Abs(fParam->GetZPositionShift("T0/C/PMT1"));
   //fdZonA = TMath::Abs(fParam->GetZPositionShift("T0/A/PMT15"));
-
+  //here real Z position
+  fdZonC = TMath::Abs(fParam->GetZPosition("T0/C/PMT1"));
+  fdZonA = TMath::Abs(fParam->GetZPosition("T0/A/PMT15"));
 
   fCalib = new AliT0Calibrator();
   fESDTZEROfriend = new AliESDTZEROfriend();
@@ -147,10 +149,10 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
       else
        adc[ipmt] = 0;
       
-     // time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, adc[ipmt],  timeCFD->At(ipmt)) ;
+      time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, adc[ipmt],  timeCFD->At(ipmt)) ;
             
       Double_t sl = Double_t(timeLED->At(ipmt) - timeCFD->At(ipmt));
-      time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl),  timeCFD->At(ipmt) ) ;
+      //    time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl),  timeCFD->At(ipmt) ) ;
       AliDebug(10,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
                       ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl)));
 
@@ -185,11 +187,11 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
     }
   }
   if(besttimeA < 999999) {
-    frecpoints->SetTimeBestA(Int_t(besttimeA *channelWidth));
+    frecpoints->SetTimeBestA(Int_t(besttimeA *channelWidth - fdZonA/c));
     tr[1]=true;
   }
   if( besttimeC < 999999 ) {
-    frecpoints->SetTimeBestC(Int_t(besttimeC *channelWidth));
+    frecpoints->SetTimeBestC(Int_t(besttimeC *channelWidth - fdZonA/c));
     tr[2]=true;
   }
   AliDebug(10,Form(" besttimeA %f ch,  besttimeC %f ch",besttimeA, besttimeC));
@@ -197,7 +199,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
     //    timeDiff = (besttimeC - besttimeA)*channelWidth;
     timeDiff = (besttimeA - besttimeC)*channelWidth;
     meanTime = (besttimeA + besttimeC)/2;// * channelWidth); 
-    timeclock = meanTime *channelWidth ;
+    timeclock = meanTime *channelWidth -fdZonA/c ;
     vertex = meanVertex - c*(timeDiff)/2.;// + (fdZonA - fdZonC)/2;
     tr[0]=true; 
   }
@@ -206,7 +208,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   frecpoints->SetT0clock(timeclock);
   frecpoints->SetT0Trig(tr);
 
-  AliInfo(Form("T0 triggers %d %d %d %d %d",tr[0],tr[1],tr[2],tr[3],tr[4]));
+  AliDebug(10,Form("T0 triggers %d %d %d %d %d",tr[0],tr[1],tr[2],tr[3],tr[4]));
 
   //online mean
   frecpoints->SetOnlineMean(Int_t(onlineMean));
@@ -268,53 +270,55 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
     AliDebug(1,Form(" no raw data found!!"));
   else
     {  
-      if(type == 7) {  //only physics 
-      for (Int_t i=0; i<105; i++) {
+      Int_t fBCID=Int_t (rawReader->GetBCID());
+      Int_t trmbunch= myrawreader.GetTRMBunchID();
+      if(type == 7 &&( trmbunch -fBCID )==37 ) {  //only physics 
+       for (Int_t i=0; i<105; i++) {
        for (Int_t iHit=0; iHit<5; iHit++) 
          {
            allData[i][iHit] = myrawreader.GetData(i,iHit);
          }
-      }
-      Int_t ref=0;
-      if (refPoint>0) 
-      ref = allData[refPoint][0]-5000;
+       }
+       Int_t ref=0;
+       if (refPoint>0) 
+         ref = allData[refPoint][0]-5000;
+       
+       Float_t channelWidth = fParam->GetChannelWidth() ;  
+       
+       //       Int_t meanT0 = fParam->GetMeanT0();
+       
+       
+       for (Int_t in=0; in<12; in++)  
+         {
+           timeCFD[in] = allData[in+1][0] ;
+           timeCFD[in+12] = allData[in+56+1][0] ;
+           timeLED[in] = allData[in+12+1][0] ;
+           timeLED[in+12] = allData[in+68+1][0] ;
+           AliDebug(10, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ",
+                             in, timeCFD[in],timeCFD[in+12],timeLED[in], 
+                             timeLED[in+12]));   
+         }
+       
+       for (Int_t in=0; in<12;  in++)
+         {
+           chargeQT0[in]=allData[2*in+25][0];
+           chargeQT1[in]=allData[2*in+26][0];
+         }
+       
+       for (Int_t in=12; in<24;  in++)
+         {
+           chargeQT0[in]=allData[2*in+57][0];
+           chargeQT1[in]=allData[2*in+58][0];
+         }
+       
 
-      Float_t channelWidth = fParam->GetChannelWidth() ;  
-      
-      //       Int_t meanT0 = fParam->GetMeanT0();
-       
-         
-         for (Int_t in=0; in<12; in++)  
-           {
-             timeCFD[in] = allData[in+1][0] ;
-             timeCFD[in+12] = allData[in+56+1][0] ;
-             timeLED[in] = allData[in+12+1][0] ;
-             timeLED[in+12] = allData[in+68+1][0] ;
-             AliDebug(10, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ",
-                               in, timeCFD[in],timeCFD[in+12],timeLED[in], 
-                               timeLED[in+12]));   
-           }
-         
-         for (Int_t in=0; in<12;  in++)
-           {
-             chargeQT0[in]=allData[2*in+25][0];
-             chargeQT1[in]=allData[2*in+26][0];
-           }
-         
-          for (Int_t in=12; in<24;  in++)
-            {
-              chargeQT0[in]=allData[2*in+57][0];
-              chargeQT1[in]=allData[2*in+58][0];
-            }
-          
-          //    } //cosmic with physics event
-       for (Int_t in=0; in<24; in++)  
-        AliDebug(10, Form(" readed Raw %i %i %i %i %i",
-                          in, timeLED[in],timeCFD[in],chargeQT0[in],chargeQT1[in]));
+       for (Int_t in=0; in<24; in++)  
+         AliDebug(10, Form(" readed Raw %i %i %i %i %i",
+                           in, timeLED[in],timeCFD[in],chargeQT0[in],chargeQT1[in]));
         onlineMean = allData[49][0];       
-       
+       
        Double32_t time[24], adc[24],  noncalibtime[24];
-       for (Int_t ipmt=0; ipmt<24; ipmt++) {
+       for (Int_t ipmt=0; ipmt<24; ipmt++) {
         if(timeCFD[ipmt]>0 && timeLED[ipmt]>0){
           //for simulated data
             //for physics  data
@@ -325,17 +329,17 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
             adc[ipmt] = 0;
           
 
-          //      time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, adc[ipmt], timeCFD[ipmt] ) ;
+          time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, adc[ipmt], timeCFD[ipmt] ) ;
           
           Double_t sl = timeLED[ipmt] - timeCFD[ipmt];
-          time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD[ipmt] ) ;
+          // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD[ipmt] ) ;
           AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
                            ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl)));
           Double_t ampMip =( (TGraph*)fAmpLED.At(ipmt))->Eval(sl);
           Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]);
           AliDebug(10,Form("  Amlitude in MIPS LED %f ; QTC %f;  in channels %i\n ",ampMip,qtMip, adc[ipmt]));
           //bad peak removing
-          if(sl<540) {
+          if(sl<550) {
             frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
             // frecpoints->SetTime(ipmt,Double32_t(timeCFD[ipmt]));
             frecpoints->SetAmpLED(ipmt, Double32_t( qtMip)); //for cosmic &pp beam