Added QA for digits during reconstruction (Yves)
[u/mrichter/AliRoot.git] / T0 / AliT0.cxx
index 7020921..1d9f9be 100644 (file)
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <Riostream.h>
-
-#include <TFile.h>
-#include <TGeometry.h>
-#include <TMath.h>
-#include <TNode.h>
-#include <TParticle.h>
-#include <TRandom.h>
-#include <TTUBE.h>
-#include <TVirtualMC.h>
-#include <AliESD.h>
+#include "TClonesArray.h"
 
+#include "AliLoader.h"
+#include "AliLog.h"
 #include "AliLog.h"
 #include "AliMC.h"
-#include "AliLoader.h"
 #include "AliRun.h"
-#include "TClonesArray.h"
 #include "AliT0.h"
-#include "AliT0Loader.h"
-#include "AliT0digit.h"
-#include "AliT0hit.h"
 #include "AliT0Digitizer.h"
 #include "AliT0RawData.h"
 #include "AliT0RecPoint.h"
-#include "AliLog.h"
+#include "AliT0digit.h"
+#include "AliT0hit.h"
 
 ClassImp(AliT0)
 
@@ -103,6 +91,7 @@ AliT0::AliT0(const char *name, const char *title)
 //_____________________________________________________________________________
 AliT0::~AliT0() {
   
+  //destructor
   if (fHits) {
     fHits->Delete();
     delete fHits;
@@ -135,8 +124,8 @@ void AliT0::AddHit(Int_t track, Int_t *vol, Float_t *hits)
 //_____________________________________________________________________________
 
 void AliT0::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime, 
-                       Int_t timediff, Int_t sumMult,
-                       TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp)
+                    Int_t timediff, Int_t sumMult, Int_t refpoint,
+                       TArrayI *timeCFD, TArrayI *qt0, TArrayI *timeLED, TArrayI *qt1)
 {
   
   //  Add a T0 digit to the list.
@@ -145,55 +134,18 @@ void AliT0::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime,
   if (!fDigits) {
     fDigits = new AliT0digit();
   }
-  fDigits-> SetTimeBestRight(besttimeright);
-  fDigits->SetTimeBestLeft(besttimeleft);
+  fDigits-> SetTimeBestA(besttimeright);
+  fDigits->SetTimeBestC(besttimeleft);
   fDigits-> SetMeanTime(meantime);
   fDigits-> SetDiffTime(timediff);
   fDigits-> SetSumMult(sumMult);
-  fDigits->SetTime(*time);
-  fDigits->SetTimeAmp(*timeAmp);
-  fDigits->SetADC(*adc);
-  fDigits->SetADCAmp(*adcAmp);
+  fDigits->SetTimeCFD(*timeCFD);
+  fDigits->SetTimeLED(*timeLED);
+  fDigits->SetQT0(*qt0);
+  fDigits->SetQT1(*qt1);
+  fDigits->SetRefPoint(refpoint);
 }
 
-
-//_____________________________________________________________________________
-void AliT0::BuildGeometry()
-{
-  //
-  // Build simple ROOT TNode geometry for event display
-  //
-  TNode *node, *top;
-  const int kColorT0  = 19;
-
-  top=gAlice->GetGeometry()->GetNode("alice");
-
-  // T0 define the different volumes
-  new TRotMatrix("rotx999","rot999",  90,0,90,90,180,0);
-
-  new TTUBE("S_0ST1","T0  volume 1","void",5.,10.7,5.3);
-  top->cd();
-  node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
-  node->SetLineColor(kColorT0);
-  fNodes->Add(node);
-
-  new TTUBE("S_0ST2","T0 volume 2","void",5.,10.7,5.3);
-  top->cd();
-  node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
-  node->SetLineColor(kColorT0);
-  fNodes->Add(node);
-}
-//_____________________________________________________________________________
-Int_t AliT0::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
-{
-  //
-  // Calculate the distance from the mouse to the T0 on the screen
-  // Dummy routine
-  //
-  return 9999;
-}
 //-------------------------------------------------------------------------
 void AliT0::Init()
 {
@@ -261,6 +213,9 @@ void AliT0::MakeBranch(Option_t* option)
 //_____________________________________________________________________________
 void AliT0::ResetHits()
 {
+  //
+  //reset hits
+  //
   AliDetector::ResetHits();
   
 }
@@ -277,8 +232,7 @@ void AliT0::ResetDigits()
 void AliT0::SetTreeAddress()
 {
 
-  TTree    *treeH;
-  treeH = TreeH();
+  TTree    *treeH = fLoader->TreeH();
   
   if (treeH)
     {
@@ -357,3 +311,62 @@ void AliT0::Digits2Raw()
   fLoader->UnloadDigits();
   
 }
+
+//____________________________________________________________________________
+void AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree)
+{
+
+ //T0 raw data-> digits conversion
+ // reconstruct time information from raw data
+ // cout<<"  AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree) "<<
+  // rawReader<<" "<<digitsTree<<endl;
+
+  //  AliT0RawReader myrawreader(rawReader,digitsTree);
+   AliT0RawReader myrawreader(rawReader);
+   if (!myrawreader.Next())
+     AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
+   Int_t allData[110][5];
+   for (Int_t i=0; i<110; i++) {
+     allData[i][0]=myrawreader.GetData(i,0);
+   }
+
+
+   fDigits = new AliT0digit();
+   digitsTree->Branch("T0","AliT0digit",&fDigits,405,1);
+   
+   
+   TArrayI *timeLED = new TArrayI(24);
+   TArrayI * timeCFD = new TArrayI(24);
+   TArrayI *chargeQT0 = new TArrayI(24);
+   TArrayI *chargeQT1 = new TArrayI(24);
+   
+   for (Int_t in=0; in<24; in++)
+     {
+       timeLED->AddAt(allData[in+1][0],in);
+       timeCFD->AddAt(allData[in+25][0],in);
+       chargeQT0->AddAt(allData[in+55][0],in);
+       chargeQT1->AddAt(allData[in+79][0],in);
+       AliDebug(2, Form(" readed Raw %i %i %i %i %i", in, timeLED->At(in),timeCFD->At(in),chargeQT0->At(in),chargeQT1->At(in)));
+     }
+  
+   fDigits->SetTimeCFD(*timeCFD);
+   fDigits->SetQT0(*chargeQT1);
+
+   fDigits->SetTimeLED(*timeLED);
+   fDigits->SetQT1(*chargeQT1);
+
+   fDigits->SetMeanTime(allData[49][0]);
+   fDigits->SetDiffTime(allData[50][0]);
+   fDigits->SetTimeBestA(allData[51][0]);
+   fDigits->SetTimeBestC(allData[52][0]);
+   digitsTree->Fill();
+   fDigits->Write();
+   delete timeCFD ;
+   delete chargeQT0;
+   delete timeLED ;
+   delete chargeQT1;
+
+
+}