/* $Id$ */
+////////////////////////////////////////////////////////////////////////////
+// //
+// AliTRDCalibraVdriftLinearFit //
+// //
+// Does the Vdrift an ExB calibration by applying a linear fit //
+// //
+// Author: //
+// R. Bailhache (R.Bailhache@gsi.de) //
+// //
+////////////////////////////////////////////////////////////////////////////
+
//Root includes
#include <TObjArray.h>
#include <TH2F.h>
#include <TMath.h>
#include <TTreeStream.h>
+
//header file
#include "AliTRDCalibraVdriftLinearFit.h"
fLinearFitterPArray(540),
fLinearFitterEArray(540)
{
- //
- // default constructor
- //
+ //
+ // default constructor
+ //
}
//_____________________________________________________________________
AliTRDCalibraVdriftLinearFit::AliTRDCalibraVdriftLinearFit(const AliTRDCalibraVdriftLinearFit &ped) : /*FOLD00*/
// copy constructor
//
for (Int_t idet = 0; idet < 540; idet++){
+
const TVectorD *vectorE = (TVectorD*)ped.fLinearFitterEArray.UncheckedAt(idet);
const TVectorD *vectorP = (TVectorD*)ped.fLinearFitterPArray.UncheckedAt(idet);
- const TH2F *hped = (TH2F*)ped.fLinearFitterHistoArray.UncheckedAt(idet);
+ const TH2S *hped = (TH2S*)ped.fLinearFitterHistoArray.UncheckedAt(idet);
if ( vectorE != 0x0 ) fLinearFitterEArray.AddAt(new TVectorD(*vectorE), idet);
if ( vectorP != 0x0 ) fLinearFitterPArray.AddAt(new TVectorD(*vectorP), idet);
if ( hped != 0x0 ){
- TH2F *hNew = new TH2F(*hped);
- hNew->SetDirectory(0);
+ TH2S *hNew = (TH2S *)hped->Clone();
+ //hNew->SetDirectory(0);
fLinearFitterHistoArray.AddAt(hNew,idet);
}
-
}
}
//_____________________________________________________________________
// constructor from a TObjArray
//
for (Int_t idet = 0; idet < 540; idet++){
- const TH2F *hped = (TH2F*)obja.UncheckedAt(idet);
+ const TH2S *hped = (TH2S*)obja.UncheckedAt(idet);
if ( hped != 0x0 ){
- TH2F *hNew = new TH2F(*hped);
- hNew->SetDirectory(0);
+ TH2S *hNew = (TH2S *)hped->Clone();
+ //hNew->SetDirectory(0);
fLinearFitterHistoArray.AddAt(hNew,idet);
}
}
//
// destructor
//
+ fLinearFitterHistoArray.Delete();
+ fLinearFitterPArray.Delete();
+ fLinearFitterEArray.Delete();
+
+}
+//_____________________________________________________________________________
+void AliTRDCalibraVdriftLinearFit::Copy(TObject &c) const
+{
+ //
+ // Copy function
+ //
+
+ AliTRDCalibraVdriftLinearFit& target = (AliTRDCalibraVdriftLinearFit &) c;
+
+ // Copy only the histos
+ for (Int_t idet = 0; idet < 540; idet++){
+ if(fLinearFitterHistoArray.UncheckedAt(idet)){
+ TH2S *hped1 = (TH2S *)target.GetLinearFitterHisto(idet,kTRUE);
+ //hped1->SetDirectory(0);
+ hped1->Add((const TH2S *)fLinearFitterHistoArray.UncheckedAt(idet));
+ }
+ }
+
+ TObject::Copy(c);
+
+}
+//_____________________________________________________________________________
+Long64_t AliTRDCalibraVdriftLinearFit::Merge(const TCollection* list)
+{
+ // Merge list of objects (needed by PROOF)
+
+ if (!list)
+ return 0;
+
+ if (list->IsEmpty())
+ return 1;
+
+ TIterator* iter = list->MakeIterator();
+ TObject* obj = 0;
+
+ // collection of generated histograms
+ Int_t count=0;
+ while((obj = iter->Next()) != 0)
+ {
+ AliTRDCalibraVdriftLinearFit* entry = dynamic_cast<AliTRDCalibraVdriftLinearFit*>(obj);
+ if (entry == 0) continue;
+
+ // Copy only the histos
+ for (Int_t idet = 0; idet < 540; idet++){
+ if(entry->GetLinearFitterHisto(idet)){
+ TH2S *hped1 = (TH2S *)GetLinearFitterHisto(idet,kTRUE);
+ Double_t entriesa = hped1->GetEntries();
+ Double_t entriesb = ((TH2S *)entry->GetLinearFitterHisto(idet))->GetEntries();
+ if((entriesa + entriesb) < 5*32767) hped1->Add(entry->GetLinearFitterHisto(idet));
+ }
+ }
+
+ count++;
+ }
+
+ return count;
}
//_____________________________________________________________________
-void AliTRDCalibraVdriftLinearFit::Add(AliTRDCalibraVdriftLinearFit *ped)
+void AliTRDCalibraVdriftLinearFit::Add(const AliTRDCalibraVdriftLinearFit *ped)
{
//
// Add histo
fVersion++;
for (Int_t idet = 0; idet < 540; idet++){
- const TH2F *hped = (TH2F*)ped->GetLinearFitterHisto(idet);
+ const TH2S *hped = (TH2S*)ped->GetLinearFitterHistoNoForce(idet);
//printf("idet %d\n",idet);
if ( hped != 0x0 ){
//printf("add\n");
- TH2F *hped1 = GetLinearFitterHisto(idet,kTRUE);
- //printf("test2\n");
- hped1->SetDirectory(0);
- //printf("test4\n");
- hped1->Add(hped);
- //printf("test3\n");
+ TH2S *hped1 = (TH2S *)GetLinearFitterHisto(idet,kTRUE);
+ Double_t entriesa = hped1->GetEntries();
+ Double_t entriesb = hped->GetEntries();
+ if((entriesa + entriesb) < 5*32767) hped1->Add(hped);
}
}
}
//______________________________________________________________________________________
-TH2F* AliTRDCalibraVdriftLinearFit::GetLinearFitterHisto(Int_t detector, Bool_t force)
+TH2S* AliTRDCalibraVdriftLinearFit::GetLinearFitterHisto(Int_t detector, Bool_t force)
{
//
// return pointer to TH2F histo
// if force is true create a new histo if it doesn't exist allready
//
if ( !force || fLinearFitterHistoArray.UncheckedAt(detector) )
- return (TH2F*)fLinearFitterHistoArray.UncheckedAt(detector);
-
- // if we are forced and TLinearFitter doesn't yes exist create it
+ return (TH2S*)fLinearFitterHistoArray.UncheckedAt(detector);
- // new TH2F
- TString name("LFDV");
- name += detector;
- name += "version";
- name += fVersion;
-
- TH2F *lfdv = new TH2F((const Char_t *)name,(const Char_t *) name
- ,100,-1.0,1.0,100
- ,-2.0,2.0);
- lfdv->SetXTitle("tan(phi_{track})");
- lfdv->SetYTitle("dy/dt");
- lfdv->SetZTitle("Number of clusters");
- lfdv->SetStats(0);
- lfdv->SetDirectory(0);
+ return GetLinearFitterHistoForce(detector);
- fLinearFitterHistoArray.AddAt(lfdv,detector);
- return lfdv;
+}
+//______________________________________________________________________________________
+TH2S* AliTRDCalibraVdriftLinearFit::GetLinearFitterHistoForce(Int_t detector)
+{
+ //
+ // return pointer to TH2F histo
+ // if NULL create a new histo if it doesn't exist allready
+ //
+ if (fLinearFitterHistoArray.UncheckedAt(detector))
+ return (TH2S*)fLinearFitterHistoArray.UncheckedAt(detector);
+
+ // if we are forced and TLinearFitter doesn't yes exist create it
+
+ // new TH2F
+ TString name("LFDV");
+ name += detector;
+ name += "version";
+ name += fVersion;
+
+ TH2S *lfdv = new TH2S((const Char_t *)name,(const Char_t *) name
+ ,36,-0.9,0.9,48
+ ,-1.2,1.2);
+ lfdv->SetXTitle("tan(phi_{track})");
+ lfdv->SetYTitle("dy/dt");
+ lfdv->SetZTitle("Number of clusters");
+ lfdv->SetStats(0);
+ lfdv->SetDirectory(0);
+
+ fLinearFitterHistoArray.AddAt(lfdv,detector);
+ return lfdv;
}
//______________________________________________________________________________________
Bool_t AliTRDCalibraVdriftLinearFit::GetParam(Int_t detector, TVectorD *param)
//
// Fill the 2D histos for debugging
//
-
- ((TH2F *) GetLinearFitterHisto(detector,kTRUE))->Fill(tnp,pars1);
+
+ TH2S *h = ((TH2S *) GetLinearFitterHisto(detector,kTRUE));
+ Double_t nbentries = h->GetEntries();
+ if(nbentries < 5*32767) h->Fill(tnp,pars1);
}
//____________Functions fit Online CH2d________________________________________
// Loop over histos
for(Int_t cb = 0; cb < 540; cb++){
- const TH2F *linearfitterhisto = (TH2F*)fLinearFitterHistoArray.UncheckedAt(cb);
+ const TH2S *linearfitterhisto = (TH2S*)fLinearFitterHistoArray.UncheckedAt(cb);
//printf("Processing the detector cb %d we find %d\n",cb, (Bool_t) linearfitterhisto);
if ( linearfitterhisto != 0 ){
fLinearFitterEArray.AddAt(parE,cb);
//par->Print();
//parE->Print();
- }
+ }
+
+ //delete linearfitterhisto;
+
}// if something
}