/* $Id$ */
-/////////////////////////////////////////////////////////////////////////////////
-//
-// AliTRDCalibraVector
-//
-// This class is for the vector methode of the TRD calibration.
-//
-// Author:
-// R. Bailhache (R.Bailhache@gsi.de)
-//
-//////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+// //
+// AliTRDCalibraVector //
+// //
+// This class is for the vector method of the TRD calibration. //
+// //
+// Author: //
+// R. Bailhache (R.Bailhache@gsi.de) //
+// //
+////////////////////////////////////////////////////////////////////////////
#include <TGraphErrors.h>
#include <TH1F.h>
-#include <TTree.h>
#include <TObjArray.h>
+#include <TObject.h>
#include <TMath.h>
-#include <TChain.h>
#include <TDirectory.h>
#include <TROOT.h>
#include <TFile.h>
+#include <TString.h>
#include "AliLog.h"
#include "AliTRDCalibraVector.h"
#include "AliTRDCommonParam.h"
+#include "AliTRDCalibraMode.h"
+#include "AliTRDPhInfo.h"
+#include "AliTRDEntriesInfo.h"
+#include "AliTRDPrfInfo.h"
+#include "AliTRDgeometry.h"
ClassImp(AliTRDCalibraVector)
//______________________________________________________________________________________
AliTRDCalibraVector::AliTRDCalibraVector()
:TObject()
- ,fVectorPH(new TObjArray())
- ,fPlaPH(new TObjArray())
- ,fVectorCH(new TObjArray())
- ,fPlaCH(new TObjArray())
- ,fVectorPRF(new TObjArray())
- ,fPlaPRF(new TObjArray())
+ ,fModeCH(0)
+ ,fModePH(0)
+ ,fModePRF(0)
+ ,fNbGroupPRF(0)
+ ,fDetectorPH(-1)
+ ,fDetectorCH(-1)
+ ,fDetectorPRF(-1)
+ ,fStopFillCH(kFALSE)
+ ,fHisto(0x0)
+ ,fGraph(0x0)
+ ,fCalVector(0x0)
,fNumberBinCharge(0)
,fNumberBinPRF(0)
,fTimeMax(0)
//
// Default constructor
//
-
-}
+ for (Int_t idet = 0; idet < 540; idet++){
+
+ fPHEntries[idet]= 0x0;
+ fPHMean[idet]= 0x0;
+ fPHSquares[idet]= 0x0;
+
+ fPRFEntries[idet]= 0x0;
+ fPRFMean[idet]= 0x0;
+ fPRFSquares[idet]= 0x0;
+
+
+ fCHEntries[idet]= 0x0;
+
+ }
+
+ for(Int_t k = 0; k < 3; k++){
+ fDetCha0[k] = 0;
+ fDetCha2[k] = 0;
+ }
+
+}
//______________________________________________________________________________________
AliTRDCalibraVector::AliTRDCalibraVector(const AliTRDCalibraVector &c)
:TObject(c)
- ,fVectorPH(new TObjArray())
- ,fPlaPH(new TObjArray())
- ,fVectorCH(new TObjArray())
- ,fPlaCH(new TObjArray())
- ,fVectorPRF(new TObjArray())
- ,fPlaPRF(new TObjArray())
+ ,fModeCH(c.fModeCH)
+ ,fModePH(c.fModePH)
+ ,fModePRF(c.fModePRF)
+ ,fNbGroupPRF(c.fNbGroupPRF)
+ ,fDetectorPH(-1)
+ ,fDetectorCH(-1)
+ ,fDetectorPRF(-1)
+ ,fStopFillCH(kFALSE)
+ ,fHisto(0x0)
+ ,fGraph(0x0)
+ ,fCalVector(0x0)
,fNumberBinCharge(c.fNumberBinCharge)
,fNumberBinPRF(c.fNumberBinPRF)
,fTimeMax(c.fTimeMax)
//
// Copy constructor
//
- for(Int_t k = 0; k < c.fVectorPH->GetEntriesFast(); k++){
- AliTRDPInfo *obj = new AliTRDPInfo();
- UShort_t *entries = new UShort_t[fTimeMax];
- Float_t *sum = new Float_t[fTimeMax];
- Float_t *sumsquare = new Float_t[fTimeMax];
- for(Int_t i = 0; i < fTimeMax; i++){
- entries[i] = ((AliTRDPInfo *)c.fVectorPH->UncheckedAt(k))->GetEntries()[i];
- sum[i] = ((AliTRDPInfo *)c.fVectorPH->UncheckedAt(k))->GetSum()[i];
- sumsquare[i] = ((AliTRDPInfo *)c.fVectorPH->UncheckedAt(k))->GetSumSquare()[i];
- }
- obj->SetEntries(entries);
- obj->SetSum(sum);
- obj->SetSumSquare(sumsquare);
- fVectorPH->AddAt((TObject *)obj,k);
- }
- for(Int_t k = 0; k < c.fVectorPRF->GetEntriesFast(); k++){
- AliTRDPInfo *obj = new AliTRDPInfo();
- UShort_t *entries = new UShort_t[fNumberBinPRF];
- Float_t *sum = new Float_t[fNumberBinPRF];
- Float_t *sumsquare = new Float_t[fNumberBinPRF];
- for(Int_t i = 0; i < fNumberBinPRF; i++){
- entries[i] = ((AliTRDPInfo *)c.fVectorPRF->UncheckedAt(k))->GetEntries()[i];
- sum[i] = ((AliTRDPInfo *)c.fVectorPRF->UncheckedAt(k))->GetSum()[i];
- sumsquare[i] = ((AliTRDPInfo *)c.fVectorPRF->UncheckedAt(k))->GetSumSquare()[i];
- }
- obj->SetEntries(entries);
- obj->SetSum(sum);
- obj->SetSumSquare(sumsquare);
- fVectorPRF->AddAt((TObject *)obj,k);
- }
- for(Int_t k = 0; k < c.fVectorCH->GetEntriesFast(); k++){
- AliTRDCTInfo *obj = new AliTRDCTInfo();
- UShort_t *entries = new UShort_t[fNumberBinCharge];
- for(Int_t i = 0; i < fNumberBinCharge; i++){
- entries[i] = ((AliTRDCTInfo *)c.fVectorCH->UncheckedAt(k))->GetEntries()[i];
+
+ for(Int_t k = 0; k < 3; k++){
+ fDetCha0[k] = c.fDetCha0[k];
+ fDetCha2[k] = c.fDetCha2[k];
+ }
+
+ for (Int_t idet = 0; idet < 540; idet++){
+
+ const AliTRDEntriesInfo *phEntries = (AliTRDEntriesInfo*)c.fPHEntries[idet];
+ const AliTRDPhInfo *phMean = (AliTRDPhInfo *)c.fPHMean[idet];
+ const AliTRDPhInfo *phSquares = (AliTRDPhInfo *)c.fPHSquares[idet];
+
+ const AliTRDEntriesInfo *prfEntries = (AliTRDEntriesInfo*)c.fPRFEntries[idet];
+ const AliTRDPrfInfo *prfMean = (AliTRDPrfInfo *)c.fPRFMean[idet];
+ const AliTRDPrfInfo *prfSquares = (AliTRDPrfInfo *)c.fPRFSquares[idet];
+
+ const AliTRDEntriesInfo *chEntries = (AliTRDEntriesInfo*)c.fCHEntries[idet];
+
+ if ( chEntries != 0x0 ) fCHEntries[idet] = new AliTRDEntriesInfo(*chEntries);
+
+ if ( phEntries != 0x0 ) {
+ fPHMean[idet] = new AliTRDPhInfo(*phMean);
+ fPHSquares[idet] = new AliTRDPhInfo(*phSquares);
+ fPHEntries[idet] = new AliTRDEntriesInfo(*phEntries);
}
- obj->SetEntries(entries);
- fVectorCH->AddAt((TObject *)obj,k);
- }
- for(Int_t k = 0; k < c.fPlaPH->GetEntriesFast(); k++){
- AliTRDPlace *obj = new AliTRDPlace();
- obj->SetPlace(((AliTRDPlace *)c.fPlaPH->UncheckedAt(k))->GetPlace());
- fPlaPH->AddAt((TObject *)obj,k);
- }
- for(Int_t k = 0; k < c.fPlaCH->GetEntriesFast(); k++){
- AliTRDPlace *obj = new AliTRDPlace();
- obj->SetPlace(((AliTRDPlace *)c.fPlaCH->UncheckedAt(k))->GetPlace());
- fPlaCH->AddAt((TObject *)obj,k);
- }
- for(Int_t k = 0; k < c.fPlaPRF->GetEntriesFast(); k++){
- AliTRDPlace *obj = new AliTRDPlace();
- obj->SetPlace(((AliTRDPlace *)c.fPlaPRF->UncheckedAt(k))->GetPlace());
- fPlaPRF->AddAt((TObject *)obj,k);
- }
+ if ( prfEntries != 0x0 ) {
+ fPRFEntries[idet] = new AliTRDEntriesInfo(*prfEntries);
+ fPRFMean[idet] = new AliTRDPrfInfo(*prfMean);
+ fPRFSquares[idet] = new AliTRDPrfInfo(*prfSquares);
+ }
+
+ }
+
}
-//____________________________________________________________________________________
-AliTRDCalibraVector::~AliTRDCalibraVector()
+//_____________________________________________________________________
+AliTRDCalibraVector& AliTRDCalibraVector::operator = (const AliTRDCalibraVector &source)
{
//
- // AliTRDCalibraVector destructor
+ // assignment operator
//
+ if (&source == this) return *this;
+ new (this) AliTRDCalibraVector(source);
+ return *this;
}
-
-//_____________________________________________________________________________
-Int_t AliTRDCalibraVector::SearchBin(Float_t value, Int_t i) const
+//____________________________________________________________________________________
+AliTRDCalibraVector::~AliTRDCalibraVector()
{
//
- // Search the bin
+ // AliTRDCalibraVector destructor
//
- Int_t reponse = 0;
- Float_t fbinmin = 0;
- Float_t fbinmax = value;
- Int_t fNumberOfBin = -1;
-
- // Charge
- if (i == 0) {
- fbinmax = 300.0;
- fbinmin = 0.0;
- fNumberOfBin = fNumberBinCharge;
+ for (Int_t i=0; i<540; i++) {
+ delete fPHEntries[i];
+ delete fPHMean[i];
+ delete fPHSquares[i];
+ delete fPRFEntries[i];
+ delete fPRFMean[i];
+ delete fPRFSquares[i];
+ delete fCHEntries[i];
}
- // PRF
- if (i == 2) {
- fbinmax = TMath::Abs(fPRFRange);
- fbinmin = -TMath::Abs(fPRFRange);
- fNumberOfBin = fNumberBinPRF;
- }
-
- // Return -1 if out
- if ((value >= fbinmax) ||
- (value < fbinmin)) {
- return -1;
- }
- // Sinon
- else {
- reponse = (Int_t) ((fNumberOfBin*(value-fbinmin)) / (fbinmax-fbinmin));
- }
-
- return reponse;
+ if(fHisto) delete fHisto;
+ if(fGraph) delete fGraph;
+ if(fCalVector) delete fCalVector;
}
+//_____________________________________________________________________________
+Long64_t AliTRDCalibraVector::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)
+ {
+ AliTRDCalibraVector* entry = dynamic_cast<AliTRDCalibraVector*>(obj);
+ if (entry == 0) continue;
+
+ if(this->Add(entry)) count++;
+
+ }
+
+ return count;
+}
//_____________________________________________________________________________
-Int_t AliTRDCalibraVector::SearchInVector(Int_t group, Int_t i) const
+void AliTRDCalibraVector::TestInit(Int_t i, Int_t detmax)
{
//
- // Search if the calibration group "group" has already been
- // initialised by a previous track in the vector
+ // Init to see the size
//
- if (i == 0) {
- for (Int_t k = 0; k < (Int_t) fPlaCH->GetEntriesFast(); k++) {
- if (((AliTRDPlace *) fPlaCH->At(k))->GetPlace() == group) {
- return k;
- }
- }
- return -1;
- }
+ for(Int_t det = 0; det < detmax; det++){
+
+ if(i==2) {
+
+ fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
+ fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
+ fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
- if (i == 1) {
- for (Int_t k = 0; k < (Int_t) fPlaPH->GetEntriesFast(); k++) {
- if (((AliTRDPlace *) fPlaPH->At(k))->GetPlace() == group) {
- return k;
- }
}
- return -1;
- }
- if (i == 2) {
- for (Int_t k = 0; k < (Int_t) fPlaPRF->GetEntriesFast(); k++) {
- if (((AliTRDPlace *) fPlaPRF->At(k))->GetPlace() == group) {
- return k;
- }
+ if(i==1) {
+
+ fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
+ fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
+ fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
+
}
- return -1;
- }
+
+ if(i==0) fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
- return -1;
+ }
}
-
//_____________________________________________________________________________
-Int_t AliTRDCalibraVector::SearchInTreeVector(TObjArray *vectorplace, Int_t group) const
+Int_t AliTRDCalibraVector::SearchBin(Float_t value, Int_t i) const
{
//
- // Search if the calibration group "group" is present in the tree
+ // Search the bin
//
- for (Int_t k = 0; k < (Int_t) vectorplace->GetEntriesFast(); k++) {
- if (((AliTRDPlace *) vectorplace->At(k))->GetPlace() == group) {
- return k;
+ Int_t reponse = 0;
+ Float_t fbinmin = 0;
+ Float_t fbinmax = value;
+ Int_t fNumberOfBin = -1;
+
+ switch(i)
+ {
+ case 0:
+ fbinmax = 300.0;
+ fbinmin = 0.0;
+ fNumberOfBin = fNumberBinCharge;
+ break;
+
+ case 2:
+ fbinmax = TMath::Abs(fPRFRange);
+ fbinmin = -TMath::Abs(fPRFRange);
+ fNumberOfBin = fNumberBinPRF;
+ break;
+
+ default:
+ return -1;
}
+
+ // Return -1 if out
+ if ((value >= fbinmax) ||
+ (value < fbinmin)) {
+ return -1;
+ }
+ else {
+ reponse = (Int_t) ((fNumberOfBin*(value-fbinmin)) / (fbinmax-fbinmin));
}
- return -1;
+ return reponse;
}
-
//_____________________________________________________________________________
-Bool_t AliTRDCalibraVector::UpdateVectorCH(Int_t group, Float_t value)
+Bool_t AliTRDCalibraVector::UpdateVectorCH(Int_t det, Int_t group, Float_t value)
{
//
- // Fill the vector if a new calibration group "group" or update the
- // values of the calibration group "group" if already here
+ // Fill the vector CH
//
// Search bin
Int_t bin = SearchBin(value,0);
// Out
- if ((bin < 0) || (bin >= fNumberBinCharge)) {
+ if (bin == -1) {
return kFALSE;
}
- // Search place
- Int_t place = SearchInVector(group,0);
-
- // New group
- if (place == -1) {
- AliTRDPlace *placegroup = new AliTRDPlace();
- placegroup->SetPlace(group);
- fPlaCH->Add((TObject *) placegroup);
- // Variable
- AliTRDCTInfo *fCHInfo = new AliTRDCTInfo();
- UShort_t *entries = new UShort_t[fNumberBinCharge];
- // Initialise first
- for(Int_t k = 0; k < fNumberBinCharge; k++) {
- entries[k] = 0;
- }
- // Add the value
- entries[bin]= 1;
- // Set
- fCHInfo->SetEntries(entries);
- // Set in the vector
- fVectorCH->Add((TObject *) fCHInfo);
+
+
+ if(fDetectorCH != det){
+ fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
}
- // Group already exits
- else {
- // Variable
- AliTRDCTInfo *fCHInfo = new AliTRDCTInfo();
- // Retrieve
- fCHInfo = ((AliTRDCTInfo *) fVectorCH->At(place));
- UShort_t *entries = fCHInfo->GetEntries();
- // Add
- entries[bin]++;
- // Set
- fCHInfo->SetEntries(entries);
- // Update the vector
- fVectorCH->AddAt((TObject *) fCHInfo,place);
+
+ Int_t entries = ((AliTRDEntriesInfo *)fCHEntries[det])->At(group*fNumberBinCharge+bin);
+
+ Int_t entriesn = entries+1;
+
+ if(entriesn > 65535) {
+ fStopFillCH = kTRUE;
+ return kTRUE;
}
+ ((AliTRDEntriesInfo *)fCHEntries[det])->AddAt(entriesn,group*fNumberBinCharge+bin);
+
+ fDetectorCH = det;
+
+
return kTRUE;
}
-
//_____________________________________________________________________________
-Bool_t AliTRDCalibraVector::UpdateVectorPRF(Int_t group, Float_t x, Float_t y)
+Bool_t AliTRDCalibraVector::UpdateVectorPRF(Int_t det, Int_t group, Float_t x, Float_t y)
{
//
- // Fill the vector if a new calibration group "group" or update the
- // values of the calibration group "group" if already here
+ // Fill the vector PRF
//
// Search bin
Int_t bin = SearchBin(x,2);
// Out
- if ((bin < 0) || (bin >= fNumberBinPRF)) {
+ if (bin == -1) {
return kFALSE;
}
- // Search place
- Int_t place = SearchInVector(group,2);
-
- // New group
- if (place == -1) {
-
- AliTRDPlace *placegroup = new AliTRDPlace();
- placegroup->SetPlace(group);
- fPlaPRF->Add((TObject *) placegroup);
- AliTRDPInfo *fPRFInfo = new AliTRDPInfo();
-
- Float_t *sum = new Float_t[fNumberBinPRF];
- Float_t *sumsquare = new Float_t[fNumberBinPRF];
- UShort_t *entries = new UShort_t[fNumberBinPRF];
-
- // Initialise first
- for (Int_t k = 0; k < fNumberBinPRF; k++) {
- sum[k] = 0.0;
- sumsquare[k] = 0.0;
- entries[k] = 0;
- }
-
- // Add the value
- sum[bin] += y;
- sumsquare[bin] += y*y;
- entries[bin]++;
-
- // Set
- fPRFInfo->SetSum(sum);
- fPRFInfo->SetSumSquare(sumsquare);
- fPRFInfo->SetEntries(entries);
-
- // Set in the vector
- fVectorPRF->Add((TObject *) fPRFInfo);
-
+
+ if(fDetectorPRF != det){
+ fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
+ fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
+ fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
}
- // Group already exits
- else {
- AliTRDPInfo *fPRFInfo = new AliTRDPInfo();
- // Retrieve
- fPRFInfo = (AliTRDPInfo *) fVectorPRF->At(place);
-
- Float_t *sum = fPRFInfo->GetSum();
- Float_t *sumsquare = fPRFInfo->GetSumSquare();
- UShort_t *entries = fPRFInfo->GetEntries();
-
- // Add
- Double_t calcul = (((Double_t) fPRFInfo->GetEntries()[bin])
- * ((Double_t) fPRFInfo->GetSum()[bin]) + (Double_t) y)
- / (((Double_t) fPRFInfo->GetEntries()[bin]) + 1);
- sum[bin] = (Float_t) calcul;
- Double_t calculsquare = (((Double_t) fPRFInfo->GetSumSquare()[bin])
- * ((Double_t) fPRFInfo->GetEntries()[bin]) + ((Double_t) y)*((Double_t) y))
- / (((Double_t) fPRFInfo->GetEntries()[bin]) + 1);
- sumsquare[bin] = (Float_t) calculsquare;
- entries[bin]++;
-
- // Set
- fPRFInfo->SetSum(sum);
- fPRFInfo->SetSumSquare(sumsquare);
- fPRFInfo->SetEntries(entries);
-
- // Update the vector
- fVectorPRF->AddAt((TObject *) fPRFInfo,place);
+ Int_t entries = ((AliTRDEntriesInfo *)fPRFEntries[det])->At((Int_t)group*fNumberBinPRF+bin);
+ Float_t mean = ((AliTRDPrfInfo *)fPRFMean[det])->At((Int_t)group*fNumberBinPRF+bin);
+ Float_t square = ((AliTRDPrfInfo *)fPRFSquares[det])->At((Int_t)group*fNumberBinPRF+bin);
+
+ Int_t entriesn = entries+1;
- }
+ if(entriesn > 65535) return kTRUE;
+
+ ((AliTRDEntriesInfo *)fPRFEntries[det])->AddAt(entriesn,(Int_t)group*fNumberBinPRF+bin);
+ Float_t meann = (mean*((Float_t)entries)+y)/((Float_t)entriesn);
+ ((AliTRDPrfInfo *)fPRFMean[det])->AddAt(meann,(Int_t)group*fNumberBinPRF+bin);
+ Float_t squaren = ((square*((Float_t)entries))+(y*y))/((Float_t)entriesn);
+ ((AliTRDPrfInfo *)fPRFSquares[det])->AddAt(squaren,(Int_t)group*fNumberBinPRF+bin);
- return kTRUE;
+
+ fDetectorPRF = det;
+ return kTRUE;
+
}
-
//_____________________________________________________________________________
-Bool_t AliTRDCalibraVector::UpdateVectorPH(Int_t group, Int_t time, Float_t value)
+Bool_t AliTRDCalibraVector::UpdateVectorPH(Int_t det, Int_t group, Int_t time, Float_t value)
{
//
- // Fill the vector if a new calibration group "group" or update
- // the values of the calibration group "group" if already here
+ // Fill the vector PH
//
// Search bin
return kFALSE;
}
- // Search place
- Int_t place = SearchInVector(group,1);
-
- // New group
- if(place == -1){
- AliTRDPlace *placegroup = new AliTRDPlace();
- placegroup->SetPlace(group);
- fPlaPH->Add((TObject *) placegroup);
- AliTRDPInfo *fPHInfo = new AliTRDPInfo();
-
- Float_t *sum = new Float_t[fTimeMax];
- Float_t *sumsquare = new Float_t[fTimeMax];
- UShort_t *entries = new UShort_t[fTimeMax];
+ if(fDetectorPH != det){
+ fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
+ fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
+ fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
+ }
- // Initialise first
- for (Int_t k = 0; k < fTimeMax; k++) {
- sum[k] = 0.0;
- sumsquare[k] = 0.0;
- entries[k] = 0;
- }
+ Int_t entries = ((AliTRDEntriesInfo *)fPHEntries[det])->At(group*fTimeMax+bin);
+ Float_t mean = ((AliTRDPhInfo *)fPHMean[det])->At(group*fTimeMax+bin);
+ Float_t square = ((AliTRDPhInfo *)fPHSquares[det])->AtS(group*fTimeMax+bin);
+
+ Int_t entriesn = entries+1;
+ Float_t meann = (mean*((Float_t)entries)+value)/((Float_t)entriesn);
+ Float_t squaren = ((square*((Float_t)entries))+(value*value))/((Float_t)entriesn);
+
+ if(entriesn > 65535) return kTRUE;
+ //printf("meann %f, squaren %f\n",meann,squaren);
+ if((meann > 3000.0) || (meann < 0.0) || (squaren > (3000.0*3000.0)) || (squaren < 0.0)) return kFALSE;
- // Add the value
- sum[bin] += value;
- sumsquare[bin] += value*value;
- entries[bin]++;
+ ((AliTRDEntriesInfo *)fPHEntries[det])->AddAt(entriesn,group*fTimeMax+bin);
+ ((AliTRDPhInfo *)fPHMean[det])->AddAt(meann,group*fTimeMax+bin);
+ ((AliTRDPhInfo *)fPHSquares[det])->AddAtS(squaren,group*fTimeMax+bin);
+
+ fDetectorPH = det;
- // Set
- fPHInfo->SetSum(sum);
- fPHInfo->SetSumSquare(sumsquare);
- fPHInfo->SetEntries(entries);
+ return kTRUE;
+
+}
+//_____________________________________________________________________________
+Bool_t AliTRDCalibraVector::FillVectorCH(Int_t det, Int_t group, Int_t bin, Int_t entries)
+{
+ //
+ // Fill the vector CH
+ //
- // Set in the vector
- fVectorPH->Add((TObject *) fPHInfo);
+ if(entries > 65535) return kFALSE;
+ if(fDetectorCH != det){
+ fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
}
- // Group already exits
- else {
- AliTRDPInfo *fPHInfo = new AliTRDPInfo();
- // Retrieve
- fPHInfo = (AliTRDPInfo *) fVectorPH->At(place);
-
- Float_t *sum = fPHInfo->GetSum();
- Float_t *sumsquare = fPHInfo->GetSumSquare();
- UShort_t *entries = fPHInfo->GetEntries();
-
- // Add
- Double_t calcul = (((Double_t) fPHInfo->GetEntries()[bin])
- * ((Double_t) fPHInfo->GetSum()[bin]) + (Double_t) value)
- / (((Double_t) fPHInfo->GetEntries()[bin]) + 1);
- sum[bin] = (Float_t) calcul;
- Double_t calculsquare = ((((Double_t) fPHInfo->GetSumSquare()[bin])
- * ((Double_t) fPHInfo->GetEntries()[bin]))
- + (((Double_t) value) * ((Double_t)value)))
- / (((Double_t) fPHInfo->GetEntries()[bin]) + 1);
- sumsquare[bin] = (Float_t) calculsquare;
- entries[bin]++;
-
- // Set
- fPHInfo->SetSum(sum);
- fPHInfo->SetSumSquare(sumsquare);
- fPHInfo->SetEntries(entries);
-
- // Update the vector
- fVectorPH->AddAt((TObject *) fPHInfo,place);
+ ((AliTRDEntriesInfo *)fCHEntries[det])->AddAt(entries,group*fNumberBinCharge+bin);
+
+ fDetectorCH = det;
+
+
+ return kTRUE;
+
+}
+//_____________________________________________________________________________
+Bool_t AliTRDCalibraVector::FillVectorPRF(Int_t det, Int_t group, Int_t bin, Int_t entries, Float_t mean, Float_t square)
+{
+ //
+ // Fill the vector PRF
+ //
+
+ if((entries > 65535) || (mean > 1.0) || (mean < 0.0) || (square > 1.0) || (square < 0.0)) return kFALSE;
+ if(fDetectorPRF != det){
+ fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
+ fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
+ fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
}
- return kTRUE;
+ ((AliTRDEntriesInfo *)fPRFEntries[det])->AddAt(entries,(Int_t)group*fNumberBinPRF+bin);
+ ((AliTRDPrfInfo *)fPRFMean[det])->AddAt(mean,(Int_t)group*fNumberBinPRF+bin);
+ ((AliTRDPrfInfo *)fPRFSquares[det])->AddAt(square,(Int_t)group*fNumberBinPRF+bin);
-}
+
+ fDetectorPRF = det;
+ return kTRUE;
+
+}
//_____________________________________________________________________________
-TGraphErrors *AliTRDCalibraVector::ConvertVectorPHisto(Int_t place
- , const Char_t * name) const
+Bool_t AliTRDCalibraVector::FillVectorPH(Int_t det, Int_t group, Int_t bin, Int_t entries, Float_t mean, Float_t square)
{
//
- // Convert the PInfo in a TGraphErrors
+ // Fill the vector PH
//
- AliTRDPInfo *pInfo = new AliTRDPInfo();
- // Retrieve
- pInfo = ((AliTRDPInfo *) fVectorPH->At(place));
- TGraphErrors *histo;
- histo = ConvertVectorPHistoI((AliTRDPInfo *)pInfo, name);
-
- return histo;
+ if((entries > 65535) || (mean > 3000.0) || (mean < 0.0) || (square > (3000.0*3000.0)) || (square < 0.0)) return kFALSE;
-}
-//_____________________________________________________________________________
-TGraphErrors *AliTRDCalibraVector::ConvertVectorPHistoI(AliTRDPInfo *pInfo
- , const Char_t *name) const
+ if(fDetectorPH != det){
+ fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
+ fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
+ fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
+ }
+
+ ((AliTRDEntriesInfo *)fPHEntries[det])->AddAt(entries,group*fTimeMax+bin);
+ ((AliTRDPhInfo *)fPHMean[det])->AddAt(mean,group*fTimeMax+bin);
+ ((AliTRDPhInfo *)fPHSquares[det])->AddAtS(square,group*fTimeMax+bin);
+
+ fDetectorPH = det;
+
+ return kTRUE;
+
+}
+//__________________________________________________________________________________
+Bool_t AliTRDCalibraVector::Add(AliTRDCalibraVector *calvect)
{
//
- // Convert the PInfo in a 1D grapherror, name must contains "PRF"
- // if PRF calibration and not "PRF" for Vdrift calibration
+ // Add a other AliTRCalibraVector to this one
//
-
- TGraphErrors *histo;
- const Char_t *pattern1 = "PRF";
- Float_t sf = 10.0;
- AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
- if (!parCom) {
- AliInfo("Could not get CommonParam, take the default 10MHz");
+ Bool_t result = kTRUE;
+
+ // Check compatibility
+ if(fNumberBinCharge != calvect->GetNumberBinCharge()) return kFALSE;
+ if(fNumberBinPRF != calvect->GetNumberBinPRF()) return kFALSE;
+ if(fPRFRange != calvect->GetPRFRange()) return kFALSE;
+ if(fTimeMax != calvect->GetTimeMax()) return kFALSE;
+ for(Int_t k = 0; k < 3; k++){
+ if(fDetCha0[k] != calvect->GetDetCha0(k)) return kFALSE;
+ if(fDetCha2[k] != calvect->GetDetCha2(k)) return kFALSE;
}
+
+ //printf("All ok for variables before adding!\n");
+
+ // Add
+ for (Int_t idet = 0; idet < 540; idet++){
+
+ //printf("Detector %d\n",idet);
+
+ const AliTRDEntriesInfo *phEntriesvect = (AliTRDEntriesInfo *) calvect->GetPHEntries(idet);
+ const AliTRDPhInfo *phMeanvect = (AliTRDPhInfo *) calvect->GetPHMean(idet);
+ const AliTRDPhInfo *phSquaresvect = (AliTRDPhInfo *) calvect->GetPHSquares(idet);
+
+ const AliTRDEntriesInfo *prfEntriesvect = (AliTRDEntriesInfo *) calvect->GetPRFEntries(idet);
+ const AliTRDPrfInfo *prfMeanvect = (AliTRDPrfInfo *) calvect->GetPRFMean(idet);
+ const AliTRDPrfInfo *prfSquaresvect = (AliTRDPrfInfo *) calvect->GetPRFSquares(idet);
+
+ const AliTRDEntriesInfo *chEntriesvect = (AliTRDEntriesInfo *) calvect->GetCHEntries(idet);
+
+ if ( phEntriesvect != 0x0 ){
+ //Take the stuff
+ fPHEntries[idet] = ((AliTRDEntriesInfo *)GetPHEntries(idet,kTRUE));
+ fPHMean[idet] = ((AliTRDPhInfo *)GetPHMean(idet,kTRUE));
+ fPHSquares[idet] = ((AliTRDPhInfo *)GetPHSquares(idet,kTRUE));
+
+ Int_t total = fPHEntries[idet]->GetSize();
+ //printf("Total size PH %d\n",total);
+ // Add
+ for(Int_t k = 0; k < total; k++){
+ Int_t entriesv = ((AliTRDEntriesInfo *)phEntriesvect)->At(k);
+ Float_t meanv = ((AliTRDPhInfo *)phMeanvect)->At(k);
+ Float_t squarev = ((AliTRDPhInfo *)phSquaresvect)->AtS(k);
+
+ Int_t entries = ((AliTRDEntriesInfo *)fPHEntries[idet])->At(k);
+ Float_t mean = ((AliTRDPhInfo *)fPHMean[idet])->At(k);
+ Float_t square = ((AliTRDPhInfo *)fPHSquares[idet])->AtS(k);
- sf = parCom->GetSamplingFrequency();
+ Int_t entriesn = entries+entriesv;
+ Float_t meann = (mean*((Float_t)entries)+meanv*((Float_t)entriesv))/((Float_t)entriesn);
+ Float_t squaren = ((square*((Float_t)entries))+(squarev*((Float_t)entriesv)))/((Float_t)entriesn);
+
+ if((entriesn > 0) && (entriesn <= 65535) && (meann >= 0) && (meann < 3000.0) && (squaren >= 0.0) && (squaren < (3000.0*3000.0))) {
+
+ ((AliTRDEntriesInfo *)fPHEntries[idet])->AddAt(entriesn,k);
+ ((AliTRDPhInfo *)fPHMean[idet])->AddAt(meann,k);
+ ((AliTRDPhInfo *)fPHSquares[idet])->AddAtS(squaren,k);
+
+ }
+ }
+ }
- // Axis
- Double_t *x;
- Double_t *y;
- Double_t *ex;
- Double_t *ey;
- Double_t step = 0.0;
- Double_t min = 0.0;
+ if ( prfEntriesvect != 0x0 ){
+ //Take the stuff
+ fPRFEntries[idet] = ((AliTRDEntriesInfo *)GetPRFEntries(idet,kTRUE));
+ fPRFMean[idet] = ((AliTRDPrfInfo *)GetPRFMean(idet,kTRUE));
+ fPRFSquares[idet] = ((AliTRDPrfInfo *)GetPRFSquares(idet,kTRUE));
+
+ Int_t total = fPRFEntries[idet]->GetSize();
+ //Int_t total0 = fPRFMean[idet]->GetSize();
+ //Int_t total1 = fPRFSquares[idet]->GetSize();
+ //printf("Total size PRF %d\n",total);
+ //printf("Total0 size PRF %d\n",total0);
+ //printf("Total1 size PRF %d\n",total1);
+ // Add
+ for(Int_t k = 0; k < total; k++){
- // Ntimes
- Int_t ntimes = 0;
- if (strstr(name,pattern1)) {
- ntimes = fNumberBinPRF;
- }
- else {
- ntimes = fTimeMax;
- }
- x = new Double_t[ntimes]; // Xaxis
- y = new Double_t[ntimes]; // Sum
- ex = new Double_t[ntimes]; // Nentries
- ey = new Double_t[ntimes]; // Sum of square/nentries
-
- // Init histo
- if (!strstr(name,pattern1)) {
- step = 1.0 / sf;
- min = 0.0;
- }
- else {
- step = (2*TMath::Abs(fPRFRange)) / fNumberBinPRF;
- min = -TMath::Abs(fPRFRange) + step / 2.0;
- }
- // Fill histo
- for (Int_t k = 0; k < ntimes; k++) {
- x[k] = min + k*step;
- y[k] = 0.0;
- ex[k] = 0.0;
- ey[k] = 0.0;
- // Fill only if there is more than 0 something
- if (pInfo->GetEntries()[k] > 0) {
- ex[k] = pInfo->GetEntries()[k];
- y[k] = pInfo->GetSum()[k];
- ey[k] = pInfo->GetSumSquare()[k];
- }
- }
+ Int_t entries = ((AliTRDEntriesInfo *)fPRFEntries[idet])->At(k);
+ Float_t mean = ((AliTRDPrfInfo *)fPRFMean[idet])->At(k);
+ Float_t square = ((AliTRDPrfInfo *)fPRFSquares[idet])->At(k);
- // Define the TGraphErrors
- histo = new TGraphErrors(ntimes,x,y,ex,ey);
- histo->SetTitle(name);
- return histo;
+ Int_t entriesv = ((AliTRDEntriesInfo *)prfEntriesvect)->At(k);
+ Float_t meanv = ((AliTRDPrfInfo *)prfMeanvect)->At(k);
+ Float_t squarev = ((AliTRDPrfInfo *)prfSquaresvect)->At(k);
-}
+ Int_t entriesn = entries + entriesv;
+
+ if((entriesn > 0) && (entriesn <= 65535)) {
+
+ ((AliTRDEntriesInfo *)fPRFEntries[idet])->AddAt(entriesn,k);
+
+ Float_t meann = (mean*((Float_t)entries)+meanv*((Float_t)entriesv))/((Float_t)entriesn);
+ //printf("test0\n");
+ ((AliTRDPrfInfo *)fPRFMean[idet])->AddAt(meann,k);
+ //printf("test1\n");
+
+ Float_t squaren = ((square*((Float_t)entries))+(squarev*((Float_t)entriesv)))/((Float_t)entriesn);
+ //printf("test2\n");
+ ((AliTRDPrfInfo *)fPRFSquares[idet])->AddAt(squaren,k);
+ //printf("test3\n");
+
+ }
+ }
+ }
-//_____________________________________________________________________________
-TH1F *AliTRDCalibraVector::ConvertVectorCTHisto(Int_t place
- , const Char_t * name) const
+ if ( chEntriesvect != 0x0 ){
+ //Take the stuff
+ fCHEntries[idet] = ((AliTRDEntriesInfo *)GetCHEntries(idet,kTRUE));
+ //printf("TestAdd\n");
+ fStopFillCH = ((AliTRDEntriesInfo *)fCHEntries[idet])->TestAdd((AliTRDEntriesInfo *)chEntriesvect);
+ //
+ if(!fStopFillCH) {
+ fStopFillCH = kTRUE;
+ result = kFALSE;
+ }
+ else {
+
+ ((AliTRDEntriesInfo *)fCHEntries[idet])->Add(chEntriesvect);
+ //printf("Add\n");
+ }
+ }
+ }
+
+ return result;
+}
+//_____________________________________________________________________________________________________________________
+AliTRDCalibraVector *AliTRDCalibraVector::AddStatsPerDetectorCH()
{
//
- // Convert the CTInfo in a 1D histo
+ // Create a AliTRDCalibraVector detector wise
//
- AliTRDCTInfo *cHInfo = new AliTRDCTInfo();
- // Retrieve
- cHInfo = ((AliTRDCTInfo *) fVectorCH->At(place));
- TH1F *histo;
- histo = ConvertVectorCTHistoI((AliTRDCTInfo *)cHInfo,(const Char_t *) name);
+ // Use a AliTRDCalibraMode to navigate in the calibration groups
+ AliTRDCalibraMode calibMode = AliTRDCalibraMode();
+ calibMode.SetNz(0,GetNz(0));
+ calibMode.SetNrphi(0,GetNrphi(0));
+ if(((calibMode.GetNz(0) == 100) && (calibMode.GetNrphi(0) == 100)) || ((calibMode.GetNz(0) == 10) && (calibMode.GetNrphi(0) == 10))) return 0x0;
+
+ Int_t nybins = 6*4*18*fDetCha0[0]+6*18*fDetCha2[0];
+ Int_t nxbins = fNumberBinCharge;
- return histo;
+ // Check
+ Int_t perChamber2 = 0;
+ Int_t perChamber0 = 0;
+ calibMode.ModePadCalibration(2,0);
+ calibMode.ModePadFragmentation(0,2,0,0);
+ calibMode.SetDetChamb2(0);
+ perChamber2 = (Int_t) calibMode.GetDetChamb2(0);
+ calibMode.ModePadCalibration(0,0);
+ calibMode.ModePadFragmentation(0,0,0,0);
+ calibMode.SetDetChamb0(0);
+ perChamber0 = (Int_t) calibMode.GetDetChamb0(0);
+ if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return 0x0;
+
+ // Create calvector
+ if(!fCalVector) fCalVector = new AliTRDCalibraVector();
+ else{
+ fCalVector->~AliTRDCalibraVector();
+ new(fCalVector) AliTRDCalibraVector();
+ }
+ fCalVector->SetNumberBinCharge(nxbins);
+ fCalVector->SetDetCha0(0,1);
+ fCalVector->SetDetCha2(0,1);
+ fCalVector->SetNzNrphi(0,0,0);
+
+
+ for(Int_t det = 0; det < 540; det++){
+
+ // Take
+ AliTRDEntriesInfo *entriesch = (AliTRDEntriesInfo *)GetCHEntries(det,kFALSE);
+ if(!entriesch) continue;
+
+ // Number of groups
+ Int_t numberofgroup = 0;
+ if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
+ else numberofgroup = perChamber0;
+
+ // Check if one can merge calibration groups for this chamber
+ // entries is the number of entries in each bin after adding the different the calibration group in the detector
+ fStopFillCH = kFALSE;
+ Int_t firstnumberofgroup = -1;
+ Int_t entries[500];
+ for(Int_t k = 0; k < nxbins; k++){
+ entries[k] = 0;
+ }
+ // Loop over group in the detector
+ for(Int_t k = 0; k < numberofgroup; k++){
+ // Loop over bins
+ for(Int_t nx = 0; nx < nxbins; nx++) {
+ Int_t binnumber = k*nxbins+nx;
+ entries[nx] += entriesch->At(binnumber);
+ // as soon as one bin is over threshold stop
+ if(!fStopFillCH) {
+ if(entries[nx] > 65535) {
+ firstnumberofgroup = k;
+ fStopFillCH = kTRUE;
+ }
+ }
+ else continue;
+ }
+ }
+ if(fStopFillCH && (firstnumberofgroup == 0)) return 0x0;
+ if(!fStopFillCH) firstnumberofgroup = numberofgroup;
+
+ // Now add up to possible
+ for(Int_t k = 0; k < nxbins; k++){
+ entries[k] = 0;
+ }
+ for(Int_t k = 0; k < firstnumberofgroup; k++){
+ for(Int_t nx = 0; nx < nxbins; nx++) {
+ Int_t binnumber = k*nxbins+nx;
+ entries[nx] += entriesch->At(binnumber);
+ }
+ }
+ // Finally fill
+ for(Int_t nx = 0; nx < nxbins; nx++){
+ fCalVector->FillVectorCH(det,0,nx,(Int_t)entries[nx]);
+ }
+ }
+
+ return fCalVector;
}
-
-//_____________________________________________________________________________
-TH1F *AliTRDCalibraVector::ConvertVectorCTHistoI(AliTRDCTInfo *cTInfo
- , const Char_t * name) const
+//_____________________________________________________________________________________________________________________
+AliTRDCalibraVector *AliTRDCalibraVector::AddStatsPerDetectorPH()
{
//
- // Convert the CTInfo in a 1D histo
+ // Create a AliTRDCalibraVector detector wise
//
- TH1F *histo;
+ AliTRDCalibraMode calibMode = AliTRDCalibraMode();
+ calibMode.SetNz(1,GetNz(1));
+ calibMode.SetNrphi(1,GetNrphi(1));
+ if(((calibMode.GetNz(1) == 100) && (calibMode.GetNrphi(1) == 100)) || ((calibMode.GetNz(1) == 10) && (calibMode.GetNrphi(1) == 10))) return 0x0;
- Int_t ntimes = fNumberBinCharge;
- UShort_t *entries = cTInfo->GetEntries();
+
+ // Check
+ Int_t nybins = 6*4*18*fDetCha0[1]+6*18*fDetCha2[1];
+ Int_t nxbins = fTimeMax;
+
+ Int_t perChamber2 = 0;
+ Int_t perChamber0 = 0;
+ calibMode.ModePadCalibration(2,1);
+ calibMode.ModePadFragmentation(0,2,0,1);
+ calibMode.SetDetChamb2(1);
+ perChamber2 = (Int_t) calibMode.GetDetChamb2(1);
+ calibMode.ModePadCalibration(0,1);
+ calibMode.ModePadFragmentation(0,0,0,1);
+ calibMode.SetDetChamb0(1);
+ perChamber0 = (Int_t) calibMode.GetDetChamb0(1);
- // Init histo
- histo = new TH1F(name,name,fNumberBinCharge,0,300);
- histo->Sumw2();
- // Fill histo
- for (Int_t k = 0; k < ntimes; k++) {
- histo->SetBinContent(k+1,entries[k]);
- histo->SetBinError(k+1,TMath::Sqrt(TMath::Abs(entries[k])));
+ if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return 0x0;
+
+ // Create calvector
+ if(!fCalVector) fCalVector = new AliTRDCalibraVector();
+ else{
+ fCalVector->~AliTRDCalibraVector();
+ new(fCalVector) AliTRDCalibraVector();
}
+ fCalVector->SetTimeMax(nxbins);
+ fCalVector->SetDetCha0(1,1);
+ fCalVector->SetDetCha2(1,1);
+ fCalVector->SetNzNrphi(1,0,0);
- return histo;
+
+ for(Int_t det = 0; det < 540; det++){
+
+ // Take
+ AliTRDEntriesInfo *entriesph = (AliTRDEntriesInfo *)GetPHEntries(det,kFALSE);
+ if(!entriesph) continue;
+ AliTRDPhInfo *meanph = (AliTRDPhInfo *)GetPHMean(det,kFALSE);
+ AliTRDPhInfo *squaresph = (AliTRDPhInfo *)GetPHSquares(det,kFALSE);
+
+ // Number of groups
+ Int_t numberofgroup = 0;
+ if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
+ else numberofgroup = perChamber0;
+
+ // PH
+ for(Int_t nx = 0; nx < nxbins; nx++) {
+
+ Double_t entries = 0.0;
+ Double_t sumw2 = 0.0;
+ Double_t sumw = 0.0;
+
+ // Sum the contributions of the different calibration group in the detector
+ for(Int_t k = 0; k < numberofgroup; k++){
+
+ Int_t binnumber = k*nxbins+nx;
+
+ Int_t entriesv = ((AliTRDEntriesInfo *)entriesph)->At(binnumber);
+ Float_t sumw2v = ((AliTRDPhInfo *)squaresph)->AtS(binnumber)*entriesv;
+ Float_t sumwv = ((AliTRDPhInfo *)meanph)->At(binnumber)*entriesv;
+
+
+ if(((entries+entriesv) > 65535) || ((entries+entriesv) <= 0)) continue;
-}
+ entries += entriesv;
+ sumw2 += sumw2v;
+ sumw += sumwv;
+
+ }
-//_____________________________________________________________________________
-TTree *AliTRDCalibraVector::ConvertVectorCTTreeHisto(TObjArray *vVectorCT
- , TObjArray *pPlaCT
- , const Char_t *name
- , const Char_t *nametitle) const
+ if(entries > 0) {
+ sumw2 = sumw2/((Float_t)entries);
+ sumw = sumw/((Float_t)entries);
+ }
+
+ fCalVector->FillVectorPH(det,0,nx,(Int_t)entries,(Float_t)sumw,(Float_t)sumw2);
+ }
+ }
+
+ return fCalVector;
+
+}
+//_____________________________________________________________________________________________________________________
+AliTRDCalibraVector *AliTRDCalibraVector::AddStatsPerDetectorPRF()
{
//
- // Convert the vector in a tree with two branchs: the group number
- // and the TH1F histo reconstructed from the vector
+ // Create a AliTRDCalibraVector detector wise
//
- // Size of the things
- Int_t ntotal = (Int_t) pPlaCT->GetEntriesFast();
- if (ntotal == 0) {
- AliInfo("nothing to write!");
- TTree *treeCT = new TTree(name,nametitle);
- return treeCT;
+ AliTRDCalibraMode calibMode = AliTRDCalibraMode();
+ calibMode.SetNz(2,GetNz(2));
+ calibMode.SetNrphi(2,GetNrphi(2));
+ if(((calibMode.GetNz(2) == 100) && (calibMode.GetNrphi(2) == 100)) || ((calibMode.GetNz(2) == 10) && (calibMode.GetNrphi(2) == 10))) return 0x0;
+
+ // Check
+ Int_t nybins = 6*4*18*fDetCha0[2]+ 6*18*fDetCha2[2];
+ Int_t nxbins = fNumberBinPRF;
+
+ Int_t perChamber2 = 0;
+ Int_t perChamber0 = 0;
+ calibMode.ModePadCalibration(2,2);
+ calibMode.ModePadFragmentation(0,2,0,2);
+ calibMode.SetDetChamb2(2);
+ perChamber2 = (Int_t) calibMode.GetDetChamb2(2);
+ calibMode.ModePadCalibration(0,2);
+ calibMode.ModePadFragmentation(0,0,0,2);
+ calibMode.SetDetChamb0(2);
+ perChamber0 = (Int_t) calibMode.GetDetChamb0(2);
+
+ if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return 0x0;
+
+ // Create calvector
+ if(!fCalVector) fCalVector = new AliTRDCalibraVector();
+ else{
+ fCalVector->~AliTRDCalibraVector();
+ new(fCalVector) AliTRDCalibraVector();
}
+ fCalVector->SetNumberBinPRF(nxbins);
+ fCalVector->SetDetCha0(2,1);
+ fCalVector->SetDetCha2(2,1);
+ fCalVector->SetNzNrphi(2,0,0);
+ fCalVector->SetNbGroupPRF(fNbGroupPRF);
+
- // Variable of the tree
- Int_t groupnumber = -1; // Group calibration
- TH1F *histo = 0x0;
- TObjArray vectorCT = *vVectorCT;
- TObjArray plaCT = *pPlaCT;
-
- // Init the tree
- TTree *treeCT = new TTree(name,nametitle);
- treeCT->Branch("groupnumber",&groupnumber,"groupnumber/I");
- treeCT->Branch("histo","TH1F",&histo,32000,0);
-
- // Fill
- Int_t k = 0;
- while (k < ntotal) {
- TString nome(name);
- groupnumber = ((AliTRDPlace *) plaCT.At(0))->GetPlace();
- nome += groupnumber;
- histo = ConvertVectorCTHistoI(((AliTRDCTInfo *) vectorCT.At(0)),nome);
- treeCT->Fill();
- vectorCT.RemoveAt(0);
- vectorCT.Compress();
- plaCT.RemoveAt(0);
- plaCT.Compress();
- k++;
- }
+ for(Int_t det = 0; det < 540; det++){
+
+ // Take
+ AliTRDEntriesInfo *entriesprf = (AliTRDEntriesInfo *) GetPRFEntries(det,kFALSE);
+ if(!entriesprf) continue;
+ AliTRDPrfInfo *meanprf = (AliTRDPrfInfo *) GetPRFMean(det,kFALSE);
+ AliTRDPrfInfo *squaresprf = (AliTRDPrfInfo *) GetPRFSquares(det,kFALSE);
+
+ // Number of groups
+ Int_t numberofgroup = 0;
+ if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
+ else numberofgroup = perChamber0;
+
+ for(Int_t nx = 0; nx < nxbins; nx++) {
+
+ Double_t entries = 0.0;
+ Double_t sumw2 = 0.0;
+ Double_t sumw = 0.0;
+
+ // Sum the contributions of the different groups in the detector for one bin
+ for(Int_t k = 0; k < numberofgroup; k++){
+
+ Int_t binnumber = k*nxbins+nx;
+
+ Int_t entriesv = ((AliTRDEntriesInfo *)entriesprf)->At(binnumber);
+ Float_t sumw2v = ((AliTRDPrfInfo *)squaresprf)->At(binnumber)*entriesv;
+ Float_t sumwv = ((AliTRDPrfInfo *)meanprf)->At(binnumber)*entriesv;
+
+ if(((entries+entriesv) > 65535) || ((entries+entriesv) <= 0)) continue;
- return treeCT;
+ entries += entriesv;
+ sumw2 += sumw2v;
+ sumw += sumwv;
+
+ }
-}
+ if(entries > 0) {
+ sumw2 = sumw2/((Float_t)entries);
+ sumw = sumw/((Float_t)entries);
+ }
+
+ fCalVector->FillVectorPRF(det,0,nx,(Int_t)entries,(Float_t)sumw,(Float_t)sumw2);
+
+ }
+ }
-//_____________________________________________________________________________
-TTree *AliTRDCalibraVector::ConvertVectorPTreeHisto(TObjArray *vVectorP
- , TObjArray *pPlaP
- , const Char_t *name
- , const Char_t *nametitle) const
+ return fCalVector;
+}
+//_______________________________________________________________________________
+Bool_t AliTRDCalibraVector::FindTheMaxEntries(Int_t i, Int_t &detectormax, Int_t &groupmax)
{
//
- // Convert the vector in a tree with two branchs: the group number
- // and the TGraphErrors histo reconstructed from the vector.
- // The name must contain "PRF" for PRF calibration and not "PRF"
- // for Vdrift calibration
+ // Find detectormax and groupmax with the biggest number of entries
//
- // Size of the things
- Int_t ntotal = (Int_t) pPlaP->GetEntriesFast();
- if (ntotal == 0) {
- AliInfo("nothing to write!");
- TTree *treeP = new TTree(name,nametitle);
- return treeP;
+ Int_t numberofTB = 0;
+ if(i==0) numberofTB = (Int_t) GetNumberBinCharge();
+ if(i==1) numberofTB = GetTimeMax();
+ if(i==2) numberofTB = GetNumberBinPRF();
+ if((i!=0) && (i!=1) && (i!=2)) AliInfo("Didn't understand i");
+
+
+ // Init
+ Double_t entries [540];
+ for(Int_t idet = 0; idet < 540; idet++){
+ entries[idet] = 0.0;
}
- // Variable of the tree
- Int_t groupnumber = -1; // Group calibration
- TGraphErrors *histo = 0x0;
- TObjArray vectorP = *vVectorP;
- TObjArray plaP = *pPlaP;
-
- // Init the tree
- TTree *treeP = new TTree(name,nametitle);
- treeP->Branch("groupnumber",&groupnumber,"groupnumber/I");
- treeP->Branch("histo","TGraphErrors",&histo,32000,0);
-
- // Fill
- Int_t k = 0;
- while (k < ntotal) {
- TString nome(name);
- groupnumber = ((AliTRDPlace *) plaP.At(0))->GetPlace();
- nome += groupnumber;
- histo = ConvertVectorPHistoI((AliTRDPInfo *) vectorP.At(0),nome);
- treeP->Fill();
- vectorP.RemoveAt(0);
- vectorP.Compress();
- plaP.RemoveAt(0);
- plaP.Compress();
- k++;
- }
+ AliTRDEntriesInfo *entriesd = 0x0;
+ // Take the number of entries per detector
+ for(Int_t idet = 0; idet < 540; idet++){
+
+ if(i==0) entriesd = (AliTRDEntriesInfo *) GetCHEntries(idet,kFALSE);
+ if(i==1) entriesd = (AliTRDEntriesInfo *) GetPHEntries(idet,kFALSE);
+ if(i==2) entriesd = (AliTRDEntriesInfo *) GetPRFEntries(idet,kFALSE);
+ if(!entriesd) continue;
- return treeP;
+ entries[idet] = entriesd->GetSum();
+
+ }
-}
+ // Search detector max
+ Double_t max = -10;
+ detectormax = -1;
+ for(Int_t idet = 0; idet < 540; idet++){
+ if(entries[idet] > max) {
+ max = entries[idet];
+ detectormax = idet;
+ }
+ }
+ if((max == 0.0) || (detectormax <0.0)) return kFALSE;
+
+ // Search group max
+ if(i==0) entriesd = (AliTRDEntriesInfo *) GetCHEntries(detectormax,kFALSE);
+ if(i==1) entriesd = (AliTRDEntriesInfo *) GetPHEntries(detectormax,kFALSE);
+ if(i==2) entriesd = (AliTRDEntriesInfo *) GetPRFEntries(detectormax,kFALSE);
+ if(!entriesd) return kFALSE;
+ // Number of groups
+ Int_t numberofgroup = 0;
+ if(AliTRDgeometry::GetStack(detectormax) == 2) numberofgroup = fDetCha2[i];
+ else numberofgroup = fDetCha0[i];
+ // Init
+ Double_t nbgroup [2304];
+ for(Int_t k = 0; k < 2304; k++){
+ nbgroup[k] = 0.0;
+ }
+ Int_t nxbins = 0;
+ if(i==0) nxbins = fNumberBinCharge;
+ if(i==1) nxbins = fTimeMax;
+ if(i==2) nxbins = fNumberBinPRF;
+ // Compute the number of entries per group
+ for(Int_t k = 0; k < numberofgroup; k++){
+ for(Int_t nx = 0; nx < nxbins; nx++) {
+ Int_t binnumber = k*nxbins+nx;
+ nbgroup[k] += ((AliTRDEntriesInfo *)entriesd)->At(binnumber);
+ }
+ }
+ max = -10.0;
+ groupmax = -1;
+ for(Int_t io = 0; io < numberofgroup; io++){
+ if(nbgroup[io] > max){
+ max = nbgroup[io];
+ groupmax = io;
+ }
+ }
+ if((max == 0.0) || (groupmax < 0.0) || (groupmax >= numberofgroup)) return kFALSE;
+ return kTRUE;
+
+}
//_____________________________________________________________________________
-TObjArray *AliTRDCalibraVector::ConvertTreeVector(TTree *tree) const
+TGraphErrors *AliTRDCalibraVector::ConvertVectorPHTGraphErrors(Int_t det, Int_t group , const Char_t * name)
{
//
- // Convert the branch groupnumber of the tree taken from
- // TRD.calibration.root in case of vector method in a std::vector
- // to be faster
+ // Convert the fVectorPHMean, fVectorPHSquares and fVectorPHEntries in TGraphErrors
//
- // Initialise
- TObjArray *vectorplace = new TObjArray();
+ // Take the info
+ fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
+ fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
+ fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
- // Variable of the tree
- Int_t groupnumber = -1; // Group calibration
- // Set the branch
- tree->SetBranchAddress("groupnumber",&groupnumber);
-
- // Fill
- Int_t ntotal = tree->GetEntries();
- for (Int_t k = 0; k < ntotal; k++) {
- tree->GetEntry(k);
- AliTRDPlace *placegroupnumber = new AliTRDPlace();
- placegroupnumber->SetPlace(groupnumber);
- vectorplace->Add((TObject *) placegroupnumber);
+ // Axis
+ Float_t sf = 10.0;
+ AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
+ if (parCom) {
+ sf = parCom->GetSamplingFrequency();
}
+ else {
+ AliInfo("Could not get CommonParam, take the default 10MHz");
+ }
+ // Axis
+ Double_t x[35]; // Xaxis
+ Double_t y[35]; // Sum/entries
+ Double_t ex[35]; // Nentries
+ Double_t ey[35]; // Sum of square/nentries
+ Double_t step = 0.0;
+ Double_t min = 0.0;
+ if(sf > 0.0) step = 1.0 / sf;
+ min = 0.0;
+ Int_t offset = group*fTimeMax;
- return vectorplace;
+ // Fill histo
+ for (Int_t k = 0; k < fTimeMax; k++) {
+ x[k] = min + k*step;
+ y[k] = 0.0;
+ ex[k] = 0.0;
+ ey[k] = 0.0;
+ Int_t bin = offset+k;
+ // Fill only if there is more than 0 something
+ if (((AliTRDEntriesInfo *)fPHEntries[det])->At(bin) > 0) {
+ ex[k] = ((AliTRDEntriesInfo *)fPHEntries[det])->At(bin);
+ y[k] = ((AliTRDPhInfo *)fPHMean[det])->At(bin);
+ ey[k] = ((AliTRDPhInfo *)fPHSquares[det])->AtS(bin);
+ }
+ }
-}
+ // Define the TGraphErrors
+ if(!fGraph) fGraph = new TGraphErrors(fTimeMax,&x[0],&y[0],&ex[0],&ey[0]);
+ else{
+ fGraph->~TGraphErrors();
+ new(fGraph) TGraphErrors(fTimeMax,&x[0],&y[0],&ex[0],&ey[0]);
+ }
+ fGraph->SetTitle(name);
+ return fGraph;
+
+}
//_____________________________________________________________________________
-Bool_t AliTRDCalibraVector::MergeVectorCT(TObjArray *vVectorCT2, TObjArray *pPlaCT2)
+TGraphErrors *AliTRDCalibraVector::ConvertVectorPRFTGraphErrors(Int_t det, Int_t group , const Char_t * name)
{
//
- // Add the two vectors and place the result in the first
+ // Convert the fVectorPRFMean, fVectorPRFSquares and fVectorPRFEntries in TGraphErrors
//
- if (((Int_t) pPlaCT2->GetEntriesFast()) != ((Int_t) vVectorCT2->GetEntriesFast())){
- AliInfo("VectorCT2 doesn't correspond to PlaCT2!");
- return kFALSE;
- }
-
- // CH case
- for (Int_t k = 0; k < (Int_t) fPlaCH->GetEntriesFast(); k++) {
-
- // Look if PlaCT1[k] it is also in the second vector
- Int_t place = -1;
- for (Int_t j = 0; j < (Int_t) pPlaCT2->GetEntriesFast(); j++) {
- if (((AliTRDPlace *) pPlaCT2->At(j))->GetPlace() ==
- ((AliTRDPlace *) fPlaCH->At(k))->GetPlace()) {
- place = j;
- break;
- }
+ // Take the info
+ fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
+ fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
+ fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
+
+
+ // Axis
+ Double_t x[200]; // Xaxis
+ Double_t y[200]; // Sum/entries
+ Double_t ex[200]; //Nentries
+ Double_t ey[200]; // Sum of square/nentries
+ Double_t step = 0.0;
+ Double_t min = 0.0;
+ if(fNumberBinPRF) step = (2*TMath::Abs(fPRFRange)) / fNumberBinPRF;
+ min = -TMath::Abs(fPRFRange) + step / 2.0;
+ Int_t offset = group*fNumberBinPRF;
+ //printf("number of total: %d\n",fNumberBinPRF);
+ // Fill histo
+ for (Int_t k = 0; k < fNumberBinPRF; k++) {
+ x[k] = min + k*step;
+ y[k] = 0.0;
+ ex[k] = 0.0;
+ ey[k] = 0.0;
+ Int_t bin = offset+k;
+ // Fill only if there is more than 0 something
+ if (((AliTRDEntriesInfo *)fPRFEntries[det])->At(bin) > 0) {
+ ex[k] = ((AliTRDEntriesInfo *)fPRFEntries[det])->At(bin);
+ y[k] = ((AliTRDPrfInfo *)fPRFMean[det])->At(bin);
+ ey[k] = ((AliTRDPrfInfo *)fPRFSquares[det])->At(bin);
}
-
- // If not in the second vector nothing to do
+ //printf("Number of entries %f for %d\n",ex[k],k);
+ }
- // If in the second vector
- if (place != -1) {
-
- AliTRDCTInfo *fCTInfo = new AliTRDCTInfo();
- UShort_t *entries = new UShort_t[fNumberBinCharge];
-
- for (Int_t nu = 0; nu < fNumberBinCharge; nu++) {
- entries[nu] = ((AliTRDCTInfo *) fVectorCH->At(((AliTRDPlace *) fPlaCH->At(k))->GetPlace()))->GetEntries()[nu]
- + ((AliTRDCTInfo *) vVectorCT2->At(((AliTRDPlace *) fPlaCH->At(k))->GetPlace()))->GetEntries()[nu];
- }
-
- // Set
- fCTInfo->SetEntries(entries);
+ // Define the TGraphErrors
+ if(!fGraph) fGraph = new TGraphErrors(fNumberBinPRF,&x[0],&y[0],&ex[0],&ey[0]);
+ else{
+ fGraph->~TGraphErrors();
+ new(fGraph) TGraphErrors(fNumberBinPRF,&x[0],&y[0],&ex[0],&ey[0]);
+ }
+ fGraph->SetTitle(name);
- // Nothing to do on PlaCT1
-
- // Update the vector
- fVectorCH->AddAt((TObject *) fCTInfo,((AliTRDPlace *) fPlaCH->At(k))->GetPlace());
+ return fGraph;
- }
-
- }
-
- // And at the end the vector in CT2 but not in CH1
- for (Int_t k = 0; k < (Int_t) pPlaCT2->GetEntriesFast(); k++) {
-
- // Look if pPlaCT2[k] it is also in the second vector
- Int_t place = -1;
- for (Int_t j = 0; j < (Int_t) fPlaCH->GetEntriesFast(); j++) {
- if (((AliTRDPlace *) fPlaCH->At(j))->GetPlace() == ((AliTRDPlace *) pPlaCT2->At(k))->GetPlace()) {
- place = j;
- break;
- }
- }
- // If not in the first vector
- if (place == -1) {
-
- AliTRDCTInfo *fCTInfo = new AliTRDCTInfo();
- fCTInfo = ((AliTRDCTInfo *) vVectorCT2->At(((AliTRDPlace *) pPlaCT2->At(k))->GetPlace()));
-
- // Add at the end
- fPlaCH->Add((TObject *) (pPlaCT2->At(k)));
- fVectorCH->Add((TObject *) fCTInfo);
- }
-
- }
-
- return kTRUE;
-
}
-
//_____________________________________________________________________________
-Bool_t AliTRDCalibraVector::MergeVectorP(TObjArray *vVectorP2
- , TObjArray *pPlaP2
- , Int_t i)
+TH1F *AliTRDCalibraVector::CorrectTheError(const TGraphErrors *hist, Int_t &nbEntries)
{
//
- // Add the two vectors and place the result in the first
+ // In the case of the vectors method the trees contains TGraphErrors for PH and PRF
+ // to be able to add them after
+ // We convert it to a TH1F to be able to applied the same fit function method
+ // After having called this function you can not add the statistics anymore
//
- if (((Int_t) pPlaP2->GetEntriesFast()) != ((Int_t) vVectorP2->GetEntriesFast())) {
- AliInfo("VectorP2 doesn't correspond to PlaP2!");
- return kFALSE;
+ Int_t nbins = hist->GetN();
+ Double_t *x = hist->GetX();
+ Double_t *entries = hist->GetEX();
+ Double_t *mean = hist->GetY();
+ Double_t *square = hist->GetEY();
+ nbEntries = 0;
+
+ if (nbins < 2) {
+ return 0x0;
}
- // PH case
- if (i == 1) {
-
- for (Int_t k = 0; k < (Int_t) fPlaPH->GetEntriesFast(); k++) {
-
- // Look if fPlaPH[k] it is also in the second vector
- Int_t place = -1;
- for (Int_t j = 0; j < (Int_t) pPlaP2->GetEntriesFast(); j++) {
- if (((AliTRDPlace *) pPlaP2->At(j))->GetPlace() == ((AliTRDPlace *) fPlaPH->At(k))->GetPlace()) {
- place = j;
- break;
- }
- }
-
- // If not in the second vector nothing to do
-
- // If in the second vector
- if (place != -1) {
-
- AliTRDPInfo *fPInfo = new AliTRDPInfo();
- UShort_t *entries = new UShort_t[fTimeMax];
- Float_t *sum = new Float_t[fTimeMax];
- Float_t *sumsquare = new Float_t[fTimeMax];
-
- for (Int_t nu = 0; nu < fTimeMax; nu++) {
-
- entries[nu] = ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]
- + ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu];
-
- Double_t calcul = ((((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSum()[nu])
- * ((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]))
- + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSum()[nu])
- * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu])))
- / ((Double_t) fPInfo->GetEntries()[nu]);
-
- sum[nu] = (Float_t) calcul;
-
- Double_t calculsquare = ((((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSumSquare()[nu])
- * ((Double_t) ((AliTRDPInfo *) fVectorPH->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu]))
- + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetSumSquare()[nu])
- * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPH->At(k))->GetPlace()))->GetEntries()[nu])))
- / ((Double_t) fPInfo->GetEntries()[nu]);
-
- sumsquare[nu] = calculsquare;
-
- }
-
- // Set
- fPInfo->SetSum(sum);
- fPInfo->SetSumSquare(sumsquare);
- fPInfo->SetEntries(entries);
-
- // Nothing to do on PlaCT1
-
- // Update the vector VectorCT1
- fVectorPH->AddAt((TObject *) fPInfo,((AliTRDPlace *) fPlaPH->At(k))->GetPlace());
-
- }
-
- }
-
- // And at the end the vector in P2 but not in CH1
- for (Int_t k = 0; k < (Int_t) pPlaP2->GetEntriesFast(); k++) {
-
- // Look if PlaCT2[k] it is also in the second vector
- Int_t place = -1;
- for (Int_t j = 0; j < (Int_t) fPlaPH->GetEntriesFast(); j++) {
- if (((AliTRDPlace *) fPlaPH->At(j))->GetPlace() == ((AliTRDPlace *) pPlaP2->At(k))->GetPlace()) {
- place = j;
- break;
- }
- }
-
- // If not in the first vector
- if (place == -1) {
-
- AliTRDPInfo *fPInfo = new AliTRDPInfo();
- fPInfo = (AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) pPlaP2->At(k))->GetPlace());
-
- // Add at the end of CH1
- fPlaPH->Add(((TObject *) pPlaP2->At(k)));
- fVectorPH->Add((TObject *) fPInfo);
-
- }
-
- }
-
- }
-
- // PRF case
- if (i == 1) {
-
- for (Int_t k = 0; k < (Int_t) fPlaPRF->GetEntriesFast(); k++) {
-
- // Look if fPlaPRF[k] it is also in the second vector
- Int_t place = -1;
- for (Int_t j = 0; j < (Int_t) pPlaP2->GetEntriesFast(); j++) {
- if (((AliTRDPlace *) pPlaP2->At(j))->GetPlace() == ((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()) {
- place = j;
- break;
- }
- }
-
- // If not in the second vector nothing to do
-
- // If in the second vector
- if (place != -1) {
-
- AliTRDPInfo *fPInfo = new AliTRDPInfo();
- UShort_t *entries = new UShort_t[fNumberBinPRF];
- Float_t *sum = new Float_t[fNumberBinPRF];
- Float_t *sumsquare = new Float_t[fNumberBinPRF];
-
- for (Int_t nu = 0; nu < fNumberBinPRF; nu++) {
-
- entries[nu] = ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]
- + ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu];
-
- Double_t calcul = ((((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSum()[nu])
- * ((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]))
- + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSum()[nu])
- * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu])))
- / ((Double_t) fPInfo->GetEntries()[nu]);
-
- sum[nu] = (Float_t) calcul;
-
- Double_t calculsquare = ((((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSumSquare()[nu])
- * ((Double_t) ((AliTRDPInfo *) fVectorPRF->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu]))
- + (((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetSumSquare()[nu])
- * ((Double_t) ((AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) fPlaPRF->At(k))->GetPlace()))->GetEntries()[nu])))
- / ((Double_t) fPInfo->GetEntries()[nu]);
-
- sumsquare[nu] = calculsquare;
-
- }
-
- // Set
- fPInfo->SetSum(sum);
- fPInfo->SetSumSquare(sumsquare);
- fPInfo->SetEntries(entries);
-
- // Nothing to do on PlaCT1
-
- // Update the vector VectorCT1
- fVectorPRF->AddAt((TObject *) fPInfo,((AliTRDPlace *) fPlaPRF->At(k))->GetPlace());
-
- }
-
- }
-
- // And at the end the vector in P2 but not in CH1
- for (Int_t k = 0; k < (Int_t) pPlaP2->GetEntriesFast(); k++) {
-
- // Look if PlaCT2[k] it is also in the second vector
- Int_t place = -1;
- for (Int_t j = 0; j < (Int_t) fPlaPRF->GetEntriesFast(); j++) {
- if (((AliTRDPlace *) fPlaPRF->At(j))->GetPlace() == ((AliTRDPlace *) pPlaP2->At(k))->GetPlace()) {
- place = j;
- break;
- }
- }
-
- // If not in the first vector
- if (place == -1) {
-
- AliTRDPInfo *fPInfo = new AliTRDPInfo();
- fPInfo = (AliTRDPInfo *) vVectorP2->At(((AliTRDPlace *) pPlaP2->At(k))->GetPlace());
-
- // Add at the end of CH1
- fPlaPRF->Add(((TObject *) pPlaP2->At(k)));
- fVectorPRF->Add((TObject *) fPInfo);
-
- }
-
- }
-
- }
-
- return kTRUE;
+ Double_t step = x[1] - x[0];
+ Double_t minvalue = x[0] - step/2;
+ Double_t maxvalue = x[(nbins-1)] + step/2;
-}
+ if(!fHisto) fHisto = new TH1F("projcorrecterror","",nbins,minvalue,maxvalue);
+ else{
+ fHisto->~TH1F();
+ new(fHisto) TH1F("projcorrecterror","",nbins,minvalue,maxvalue);
+ }
+
+ for (Int_t k = 0; k < nbins; k++) {
+ fHisto->SetBinContent(k+1,mean[k]);
+ if (entries[k] > 0.0) {
+ nbEntries += (Int_t) entries[k];
+ Double_t d = TMath::Abs(square[k] - (mean[k]*mean[k]));
+ fHisto->SetBinError(k+1,TMath::Sqrt(d/entries[k]));
+ }
+ else {
+ fHisto->SetBinError(k+1,0.0);
+ }
+ }
+ return fHisto;
+
+}
//_____________________________________________________________________________
-TTree *AliTRDCalibraVector::Sum2Trees(const Char_t *filename1
- , const Char_t *filename2
- , const Char_t *variablecali)
+TH1F *AliTRDCalibraVector::ConvertVectorCHHisto(Int_t det, Int_t group, const Char_t * name)
{
//
- // It returns the sum of two trees with the name variablecali
- // in the files filenam1 and filename2 equivalent of merging two 2D histos
- // The name of the resulting tree is the same as the two input trees
- // variablecali can be treeCH2d, treePH2d or treePRF2d
+ // Convert the fVectorCHEntries in TH1F
//
- // Variables
- TChain *treeChain = new TChain(variablecali);
- TObjArray *vectorplace = new TObjArray();
- TObjArray *where = new TObjArray();
+ // Take the info
+ fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
- // First tree
- // Take the tree
- TFile *file1 = new TFile(filename1,"READ");
- TTree *tree1 = (TTree *) file1->Get(variablecali);
-
- gDirectory = gROOT;
-
- // Take the places
- vectorplace = ConvertTreeVector(tree1);
-
- // Say where it is in tree 1
- for (Int_t jui = 0; jui < (Int_t) vectorplace->GetEntriesFast(); jui++) {
- AliTRDPlace *placejui = new AliTRDPlace();
- placejui->SetPlace(jui);
- TObjArray *chainplace = new TObjArray();
- chainplace->Add((TObject *) placejui);
- where->Add((TObject *) chainplace);
+ // Init the stuff
+ if(!fHisto) fHisto = new TH1F(name,name,fNumberBinCharge,0,300);
+ else{
+ fHisto->~TH1F();
+ new(fHisto) TH1F(name,name,fNumberBinCharge,0,300);
}
-
- // Add to the chain
- treeChain->Add(filename1);
- delete file1;
-
- // Second tree
- // Take the tree
- TFile *file2 = new TFile(filename2,"READ");
- TTree *tree2 = (TTree *) file2->Get(variablecali);
-
- gDirectory = gROOT;
-
- // Take the places
- TObjArray *vector2 = ConvertTreeVector(tree2);
- Int_t j = treeChain->GetEntries();
-
- for (Int_t jui = 0; jui < (Int_t) vector2->GetEntriesFast(); jui++) {
- // Search if already found
- Int_t place = SearchInTreeVector(vectorplace,((AliTRDPlace *) vector2->At(jui))->GetPlace());
- // Create a new element in the two std vectors
- if (place == -1) {
- AliTRDPlace *placejjui = new AliTRDPlace();
- placejjui->SetPlace((j+jui));
- TObjArray *chainplace = new TObjArray();
- chainplace->Add((TObject *) placejjui);
- vectorplace->Add((TObject *) (vector2->At(jui)));
- where->Add((TObject *) chainplace);
- }
- // Update the element at the place "place" in the std vector whereinthechain
- else {
- AliTRDPlace *placejjui = new AliTRDPlace();
- placejjui->SetPlace((j+jui));
- TObjArray *chainplace = ((TObjArray *) where->At(place));
- chainplace->Add((TObject *) placejjui);
- where->AddAt((TObject *) chainplace,place);
- }
+ fHisto->Sumw2();
+ Int_t offset = group*fNumberBinCharge;
+ // Fill histo
+ for (Int_t k = 0; k < fNumberBinCharge; k++) {
+ Int_t bin = offset+k;
+ fHisto->SetBinContent(k+1,((AliTRDEntriesInfo *)fCHEntries[det])->At(bin));
+ fHisto->SetBinError(k+1,TMath::Sqrt(TMath::Abs(((AliTRDEntriesInfo *)fCHEntries[det])->At(bin))));
}
+
+ return fHisto;
- // Add to the Chain
- treeChain->Add(filename2);
- delete file2;
-
- // Take care of the profile
- const Char_t *pattern = "P";
- TTree *tree = 0x0;
-
- if (!strstr(variablecali,pattern)) {
+}
+//_____________________________________________________________________
+TObject* AliTRDCalibraVector::GetPHEntries(Int_t det
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to Carge ROC Calibration
+ // if force is true create a new histogram if it doesn't exist allready
+ //
+ AliTRDEntriesInfo**arr = &fPHEntries[0];
+ return (TObject *) GetEntriesPH(det, arr, force);
+}
+//_____________________________________________________________________
+TObject* AliTRDCalibraVector::GetPRFEntries(Int_t det
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to Carge ROC Calibration
+ // if force is true create a new histogram if it doesn't exist allready
+ //
+ AliTRDEntriesInfo**arr = &fPRFEntries[0];
+ return (TObject *) GetEntriesPRF(det, arr, force);
+}
+//_____________________________________________________________________
+TObject* AliTRDCalibraVector::GetCHEntries(Int_t det
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to Carge ROC Calibration
+ // if force is true create a new histogram if it doesn't exist allready
+ //
+ AliTRDEntriesInfo**arr = &fCHEntries[0];
+ return (TObject *) GetEntriesCH(det, arr, force);
+}
+//_____________________________________________________________________
+TObject* AliTRDCalibraVector::GetPHMean(Int_t det
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to ROC Calibration
+ // if force is true create a new array
+ //
+ AliTRDPhInfo**arr = &fPHMean[0];
+ return (TObject *) GetMeanSquaresPH(det, arr, force);
+}
+//_____________________________________________________________________
+TObject* AliTRDCalibraVector::GetPHSquares(Int_t det
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to ROC Calibration
+ // if force is true create a new array
+ //
+ AliTRDPhInfo**arr = &fPHSquares[0];
+ return (TObject *) GetMeanSquaresPH(det, arr, force);
+}
+//_____________________________________________________________________
+TObject* AliTRDCalibraVector::GetPRFMean(Int_t det
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to ROC Calibration
+ // if force is true create a new array
+ //
+ AliTRDPrfInfo**arr = &fPRFMean[0];
+ return (TObject *) GetMeanSquaresPRF(det, arr, force);
+}
+//_____________________________________________________________________
+TObject* AliTRDCalibraVector::GetPRFSquares(Int_t det
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to ROC Calibration
+ // if force is true create a new array
+ //
+ AliTRDPrfInfo**arr = &fPRFSquares[0];
+ return (TObject *) GetMeanSquaresPRF(det, arr, force);
+}
+//_____________________________________________________________________
+AliTRDEntriesInfo* AliTRDCalibraVector::GetEntriesCH(Int_t det
+ , AliTRDEntriesInfo** arr
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to UShort_t array Entries
+ // if force is true create a new UShort_t array if it doesn't exist allready
+ //
+ if ( (!force) || (arr[det]))
+ return (AliTRDEntriesInfo*)arr[det];
+
+ // if we are forced and TArrayI doesn't yes exist create it
+ Int_t ngroup = GetTotalNumberOfBinsInDetector(det,0,fNumberBinCharge);
+ // init
+ arr[det] = new AliTRDEntriesInfo(ngroup);
+
+ return (AliTRDEntriesInfo*)arr[det];
- // Ready to read the chain
- TH1F *his = 0x0;
- treeChain->SetBranchAddress("histo",&his);
+}
+//_____________________________________________________________________
+AliTRDEntriesInfo* AliTRDCalibraVector::GetEntriesPRF(Int_t det
+ , AliTRDEntriesInfo** arr
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to UShort_t array Entries
+ // if force is true create a new UShort_t array if it doesn't exist allready
+ //
+ if ( (!force) || (arr[det]))
+ return (AliTRDEntriesInfo*)arr[det];
+
+ // if we are forced and TArrayI doesn't yes exist create it
+ Int_t ngroup = GetTotalNumberOfBinsInDetector(det,2,fNumberBinPRF);
+ // init
+ arr[det] = new AliTRDEntriesInfo(ngroup);
+
+ return (AliTRDEntriesInfo*)arr[det];
- // Initialise the final tree
- Int_t group = -1;
- TH1F *histsum = 0x0;
+}
+//_____________________________________________________________________
+AliTRDEntriesInfo *AliTRDCalibraVector::GetEntriesPH(Int_t det
+ , AliTRDEntriesInfo ** arr
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to UShort_t array Entries
+ // if force is true create a new UShort_t array if it doesn't exist allready
+ //
+ if ( (!force) || (arr[det]))
+ return (AliTRDEntriesInfo *)arr[det];
+
+ // if we are forced and UShort_t doesn't yet exist create it
+ Int_t ngroup = GetTotalNumberOfBinsInDetector(det,1,fTimeMax);
+ // init
+ arr[det] = new AliTRDEntriesInfo(ngroup);
+
+ return (AliTRDEntriesInfo*)arr[det];
- tree = new TTree(variablecali,variablecali);
- tree->Branch("groupnumber",&group,"groupnumber/I");
- tree->Branch("histo","TH1F",&histsum,32000,0);
-
- // Init histsum
- if (treeChain->GetEntries() < 1) {
- return tree1;
- }
+}
+//_____________________________________________________________________
+AliTRDPhInfo* AliTRDCalibraVector::GetMeanSquaresPH(Int_t det
+ , AliTRDPhInfo** arr
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to Float_t array Mean or Squares
+ // if force is true create a new Float_t array if it doesn't exist allready
+ //
+ if ( (!force) || (arr[det]))
+ return (AliTRDPhInfo*)arr[det];
+
+ // if we are forced and Float_t array doesn't yes exist create it
+ Int_t ngroup = GetTotalNumberOfBinsInDetector(det,1,fTimeMax);
+ // init
+ arr[det] = new AliTRDPhInfo(ngroup);
- for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) {
- group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace();
- TObjArray *chainplace = ((TObjArray *) where->At(h));
- treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace());
- //Init for the first time
- if (h == 0) {
- histsum = new TH1F("","",his->GetXaxis()->GetNbins()
- ,his->GetXaxis()->GetBinLowEdge(1)
- ,his->GetXaxis()->GetBinUpEdge(his->GetXaxis()->GetNbins()));
- histsum->Sumw2();
- }
- // Reset for each new group
- histsum->SetEntries(0.0);
- for (Int_t l = 0; l <= histsum->GetXaxis()->GetNbins(); l++) {
- histsum->SetBinContent(l,0.0);
- histsum->SetBinError(l,0.0);
- }
- histsum->Add(his,1);
- if ((Int_t) chainplace->GetEntriesFast() > 1) {
- for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) {
- treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace());
- histsum->Add(his,1);
- }
- }
- tree->Fill();
- }
+ return ((AliTRDPhInfo *)arr[det]);
+}
+//_____________________________________________________________________
+AliTRDPrfInfo* AliTRDCalibraVector::GetMeanSquaresPRF(Int_t det
+ , AliTRDPrfInfo** arr
+ , Bool_t force) /*FOLD00*/
+{
+ //
+ // return pointer to Float_t array Mean or Squares
+ // if force is true create a new array if it doesn't exist allready
+ //
+ if ( (!force) || (arr[det]))
+ return arr[det];
+
+ // if we are forced and the array doesn't yet exist create it
+ Int_t ngroup = GetTotalNumberOfBinsInDetector(det,2,fNumberBinPRF);
+ // init
+ arr[det] = new AliTRDPrfInfo(ngroup);
+
+ return (AliTRDPrfInfo*)arr[det];
+
+}
+//_____________________________________________________________________________
+Int_t AliTRDCalibraVector::GetTotalNumberOfBinsInDetector(Int_t det, Int_t i, Int_t nbBin) const
+{
+ //
+ // Get the total number of bins (Nb of bins*Nb of groups) in the detector det for the group i
+ //
- }
- else {
+ Int_t ngroup = 0;
+ Int_t stack = AliTRDgeometry::GetStack(det);
+ if(stack == 2) ngroup = fDetCha2[i]*nbBin;
+ else ngroup = fDetCha0[i]*nbBin;
- // Ready to read the chain
- TGraphErrors *his = 0x0;
- treeChain->SetBranchAddress("histo",&his);
-
- // Initialise the final tree
- Int_t group = -1;
- TGraphErrors *histsum = 0x0;
- Double_t *xref = 0x0;
+ return ngroup;
+
+}
+//____________________________________________________________________________
+Int_t AliTRDCalibraVector::GetNz(Int_t i) const
+{
+ //
+ // Get Nz the granularity in row
+ //
+
+ Int_t nz = 0;
+ if(i==0) nz = (Int_t)(fModeCH>>4);
+ if(i==1) nz = (Int_t)(fModePH>>4);
+ if(i==2) nz = (Int_t)(fModePRF>>4);
- tree = new TTree(variablecali,variablecali);
- tree->Branch("groupnumber",&group,"groupnumber/I");
- tree->Branch("histo","TGraphErrors",&histsum,32000,0);
+ return nz;
- // Init histsum
- if (treeChain->GetEntries() < 1) {
- return tree1;
- }
+}
+//____________________________________________________________________________
+Int_t AliTRDCalibraVector::GetNrphi(Int_t i) const
+{
+ //
+ // Get Nrphi the granularity in col
+ //
- for (Int_t h = 0; h < (Int_t) vectorplace->GetEntriesFast(); h++) {
-
- group = ((AliTRDPlace *) vectorplace->At(h))->GetPlace();
- TObjArray *chainplace = ((TObjArray *) where->At(h));
- treeChain->GetEntry(((AliTRDPlace *) chainplace->At(0))->GetPlace());
- //Init or reset for a new group
- Int_t nbins = his->GetN();
- Double_t *x;
- x = new Double_t[nbins];
- xref = his->GetX();
- Double_t *ex;
- ex = new Double_t[nbins];
- Double_t *y;
- y = new Double_t[nbins];
- Double_t *ey;
- ey = new Double_t[nbins];
-
- for (Int_t lo = 0; lo < nbins; lo++) {
- x[lo] = xref[lo];
- ex[lo] = 0.0;
- y[lo] = 0.0;
- ey[lo] = 0.0;
- }
- delete histsum;
- histsum = new TGraphErrors(nbins,x,y,ex,ey);
-
- // Add the first
- histsum = AddProfiles(his,histsum);
- if ((Int_t) chainplace->GetEntriesFast() > 1) {
- for (Int_t s = 1; s < (Int_t) chainplace->GetEntriesFast(); s++) {
- treeChain->GetEntry(((AliTRDPlace *) chainplace->At(s))->GetPlace());
- histsum = AddProfiles(his,histsum);
- }
- }
+ Int_t nrphi = 0;
+ if(i==0) nrphi = (Int_t)(fModeCH&15);
+ if(i==1) nrphi = (Int_t)(fModePH&15);
+ if(i==2) nrphi = (Int_t)(fModePRF&15);
+
+ return nrphi;
- tree->Fill();
+}
+//_________________________________________________________________________________
+TString AliTRDCalibraVector::GetNamePH() const
+{
+ //
+ // Get the name of PH to know the granularity
+ //
+
+ Int_t nz = GetNz(1);
+ Int_t nrphi = GetNrphi(1);
- }
+ TString name("Nz");
+ name += nz;
+ name += "Nrphi";
+ name += nrphi;
+
+ return name;
- }
-
- return tree;
+}
+//_________________________________________________________________________________
+TString AliTRDCalibraVector::GetNameCH() const
+{
+ //
+ // Get the name of CH to know the granularity
+ //
+
+ Int_t nz = GetNz(0);
+ Int_t nrphi = GetNrphi(0);
-}
+ TString name("Nz");
+ name += nz;
+ name += "Nrphi";
+ name += nrphi;
+
+ return name;
-//_____________________________________________________________________________
-TGraphErrors *AliTRDCalibraVector::AddProfiles(TGraphErrors *hist1
- , TGraphErrors *hist2) const
+}
+//_________________________________________________________________________________
+TString AliTRDCalibraVector::GetNamePRF() const
{
//
- // In the case of the vectors method we use TGraphErrors for PH and PRF
- // to be able to add the them after
- // Here we add the TGraphErrors
+ // Get the name of PRF to know the granularity
//
- // First TGraphErrors
- Int_t nbins1 = hist1->GetN();
- Double_t *x1 = hist1->GetX();
- Double_t *ex1 = hist1->GetEX();
- Double_t *y1 = hist1->GetY();
- Double_t *ey1 = hist1->GetEY();
-
- TGraphErrors *rehist = new TGraphErrors(nbins1);
-
- // Second TGraphErrors
- Double_t *ex2 = hist2->GetEX();
- Double_t *y2 = hist2->GetY();
- Double_t *ey2 = hist2->GetEY();
-
- // Define the Variables for the new TGraphErrors
- Double_t x;
- Double_t ex;
- Double_t y;
- Double_t ey;
+ Int_t nz = GetNz(2);
+ Int_t nrphi = GetNrphi(2);
- for (Int_t k = 0; k < nbins1; k++) {
- Double_t nentries = 0.0;
- x = x1[k];
- y = 0.0;
- ey = 0.0;
- ex = 0.0;
- if ((ex2[k] == 0.0) &&
- (ex1[k] == 0.0)) {
- nentries = 0.0;
- }
- if ((ex2[k] == 0.0) &&
- (ex1[k] > 0.0)) {
- nentries = ex1[k];
- y = y1[k];
- ey = ey1[k];
- ex = ex1[k];
- }
- if ((ex2[k] > 0.0) &&
- (ex1[k] == 0.0)) {
- nentries = ex2[k];
- y = y2[k];
- ey = ey2[k];
- ex = ex2[k];
- }
- if ((ex2[k] > 0.0) &&
- (ex1[k] > 0.0)) {
- nentries = ex1[k] + ex2[k];
- y = ( y1[k]*ex1[k]+ y2[k]*ex2[k]) / nentries;
- ey = (ey1[k]*ex1[k]+ey2[k]*ex2[k]) / nentries;
- ex = nentries;
- }
- rehist->SetPoint(k,x,y);
- rehist->SetPointError(k,ex,ey);
- }
-
- return rehist;
+ TString name("Nz");
+ name += nz;
+ name += "Nrphi";
+ name += nrphi;
+ name += "Ngp";
+ name += fNbGroupPRF;
+
+ return name;
}
+//____________________________________________________________________________
+void AliTRDCalibraVector::SetNzNrphi(Int_t i, Int_t nz, Int_t nrphi)
+{
+ //
+ // Set NzNrphi for the granularity
+ //
+
+ if(i==0) {
+ fModeCH = nz;
+ fModeCH = fModeCH << 4;
+ fModeCH |= nrphi;
+ }
+ if(i==1) {
+ fModePH = nz;
+ fModePH = fModePH << 4;
+ fModePH |= nrphi;
+ }
+ if(i==2) {
+ fModePRF = nz;
+ fModePRF = fModePRF << 4;
+ fModePRF |= nrphi;
+ }
+
+}
+