#include "AliITSOnlineSPDfoAnalyzer.h"
#include "AliLog.h"
+using std::ifstream;
+
AliITSOnlineSPDfoAnalyzer::AliITSOnlineSPDfoAnalyzer(const TString fileName, Bool_t readFromGridFile) :
fFileName(0),
fNdims(0),
//
for(Int_t iqual =0; iqual<3; iqual++) fGeneralThresholds[iqual] =foan.fGeneralThresholds[iqual];
- for (UInt_t chipNr=0; chipNr<11; chipNr++) {
+ for (UInt_t chipNr=0; chipNr<10; chipNr++) {
for (UInt_t hs=0; hs<6; hs++) {
for(Int_t i=0; i<kNqualityFlags;i++) fNh[i][hs][chipNr]=NULL;
}
//
for (UInt_t hs=0; hs<6; hs++) {
- for (UInt_t chipNr=0; chipNr<11; chipNr++) {
+ for (UInt_t chipNr=0; chipNr<10; chipNr++) {
for(Int_t i=0; i<kNqualityFlags ; i++ ) if(fNh[i][hs][chipNr]!=NULL) delete fNh[i][hs][chipNr];
}
}
// assignment operator, only copies the filename and params (not the processed data)
if (this!=&foan) {
for (UInt_t hs=0; hs<6; hs++) {
- for (UInt_t chipNr=0; chipNr<11; chipNr++) {
+ for (UInt_t chipNr=0; chipNr<10; chipNr++) {
for(Int_t i=0; i<kNqualityFlags ; i++ ) if(fNh[i][hs][chipNr]!=NULL) delete fNh[i][hs][chipNr];
}
}
Float_t counts = 0;
Int_t processedconfigurations = chip->GetNumberOfChipConfigs();
- if(fHighOccupancyCheck) processedconfigurations-=1;
+
+
+
for(Int_t isteps =0; isteps < processedconfigurations; isteps++){
Int_t matrixId = ((AliITSOnlineSPDfoChipConfig*)array->At(isteps))->GetChipConfigMatrixId();
counts = (Float_t)(((AliITSOnlineSPDfoChipConfig*)array->At(isteps))->GetChipConfigCounter());
-
if(matrixId==0 && counts > 0) return -1;
+ if(fHighOccupancyCheck && matrixId ==6) continue;
Float_t efficiency = counts/npulses;
- if(isteps > 0){
+ if(matrixId > 0){
Int_t response = IsSelected(efficiency);
if( response >=0) {
if(quality < response) quality = response;
//
// returns the quality of the selection
//
- for(Int_t i=0; i<3; i++){
+
+ for(Int_t i=0; i<3; i++){
if(eff <= 1.+ fGeneralThresholds[i] && eff >= 1. - fGeneralThresholds[i] ) return i;
}
return -1;
// - if the 4-tuple survives the selection, the chip-related histograms are filled.
// (- Per each histogram the mean values of each axis are taken)
//
+
if(!fFOHandler) {
Warning("AliITSOnlineSPDfoAnalyzer::Process","no fo object. Exiting.. \n");
return;
}
TKey *key;
- Double_t *dacvalues;
-
TIter iter((fFOHandler->GetFile())->GetListOfKeys());
while ((key = (TKey*)(iter.Next()))) {
TString classname = key->GetClassName();
TObjArray *array = (TObjArray*)(fFOHandler->GetFile())->Get(key->GetName()); // array of chips corresponding to the DACS (size 1-60)
if(!array){
- printf("no array found! Exiting...");
+ printf("no array found! Exiting...\n");
break;
}
- dacvalues = fFOHandler->GetDACvaluesD(key->GetName(), GetFOHandler()->GetFOscanInfo()->GetNumDACindex());
+ Double_t *dacvalues = fFOHandler->GetDACvaluesD(key->GetName(), GetFOHandler()->GetFOscanInfo()->GetNumDACindex());
for(Int_t i=0; i< array->GetSize(); i++){
- AliITSOnlineSPDfoChip *chip = (AliITSOnlineSPDfoChip *)array->At(i);
+ AliITSOnlineSPDfoChip *chip = (AliITSOnlineSPDfoChip *)array->At(i);
+
if(!chip) continue;
Int_t hs = chip->GetActiveHS();
Int_t chipid = chip->GetChipId();
if(!fNh[quality][hs][chipid]) BuildTHnSparse(hs,chipid);
fNh[quality][hs][chipid]->Fill(dacvalues);
}
+
+ if(dacvalues) delete [] dacvalues;
}
}
//---------------------------------------------
TFile * f = TFile::Open(outputfile.Data(),"recreate");
for(Int_t ihs =0; ihs < 6; ihs++) {
for(Int_t ichip =0; ichip < 10; ichip++){
- for(Int_t i=0; i<kNqualityFlags ; i++ ) if(fNh[i][ihs][ichip]) f->WriteObjectAny(fNh[i][ihs][ichip],"THnSparse",Form("h%i_hs%i_chip%i",i,ihs,ichip));
+ for(Int_t i=0; i<kNqualityFlags ; i++ ) {
+ if(fNh[i][ihs][ichip]) f->WriteObjectAny(fNh[i][ihs][ichip],"THnSparse",Form("h%i_hs%i_chip%i",i,ihs,ichip));
+ }
+
}
}
f->Close();
//
//
- if(!hn) {printf("no thnsparse...exiting!"); return;}
+ if(!hn) {printf("no thnsparse...exiting!\n"); return;}
gStyle->SetPalette(1);
TH2D *h2=0x0;
if(idim == 0) {
h1 = hn->Projection(k-1);
- if(!h1) printf("no histogram!!...\n\n\n");
+ if(!h1) {
+ printf("no histogram!!...\n\n\n");
+ } else {
h1->SetXTitle(Form("DAC %i ( %s )",k-1,dacname[k-1].Data()));
h1->SetYTitle("entries (eff within thresholds)");
h1->Draw();
+ }
}
if(idim==1) {
// closest value to the mean point in the n-dimensional histogram
// is taken.
- TH1D *h=0x0;
+ TH1D *tmp[5];
+ for(Int_t jj=0;jj<5;jj++)tmp[jj]=NULL;
+ if(fNdims > 5) printf("AliITSOnlineSPDfoAnalyzer::ChooseDACValues -> N. of dimensions are more than expected! Break! \n");
TArrayI dacs(fNdims+1);
for(Int_t i=0; i<fNdims+1; i++) dacs.AddAt(-1,i);
if(fNh[iqual][hs][chip]->GetEntries()==0) continue;
for(Int_t idim =0; idim<fNdims; idim++){
if(dacs.At(idim)>=0) continue;
- h = fNh[iqual][hs][chip]->Projection(idim);
- dacs.AddAt((Int_t)h->GetBinLowEdge(h->GetMaximumBin()+1),idim);
+ tmp[idim] = fNh[iqual][hs][chip]->Projection(idim);
+ dacs.AddAt((Int_t)tmp[idim]->GetBinLowEdge(tmp[idim]->GetMaximumBin()+1),idim);
Int_t bin=-1;
- if(fFOHandler->GetFOscanInfo()->GetDACindex(idim)==fFOHandler->kIdPreVTH && CorrectPreVTHChioce(h,bin)) {
- dacs.AddAt((Int_t)h->GetBinLowEdge(bin+1),idim);
+ if(fFOHandler->GetFOscanInfo()->GetDACindex(idim)==fFOHandler->kIdPreVTH && CorrectPreVTHChioce(tmp[idim],bin)) {
+ dacs.AddAt((Int_t)tmp[idim]->GetBinLowEdge(bin+1),idim);
}
dacs.AddAt(iqual,fNdims);
}//idim
}//iqual
if(!IsExisting(dacs,hs,chip) && dacs.At(fNdims)>-1) {
- TArrayI centraldacs = GetCentralDACS(dacs.At(fNdims),hs,chip,h);
+ TArrayI centraldacs = GetCentralDACS(dacs.At(fNdims),hs,chip,tmp);
dacs = centraldacs;
}
return dacs;
for(Int_t i=0; i<size; i++) entry[i] = dacs.At(i);
Int_t checkbin = fNh[dacs.At(dacs.GetSize()-1)][hs][chip]->GetBin(entry,kFALSE); // kFALSE does not allocate another bin
if(checkbin > -1) isOk = kTRUE;
- delete entry;
+ delete [] entry;
return isOk;
}
//-----------------------------------------------------------
-TArrayI AliITSOnlineSPDfoAnalyzer::GetCentralDACS(Int_t qualityflag, Int_t hs, Int_t chip, const TH1D *hd) const
+TArrayI AliITSOnlineSPDfoAnalyzer::GetCentralDACS(Int_t qualityflag, Int_t hs, Int_t chip, TH1D **hd) const
{
//
// This method gets the DAC values which are closest to the mean point in the N-dim histogram
Double_t *mean=new Double_t[fNdims];
Int_t *goodbins=new Int_t[fNdims];
- Double_t distance = 99999;
- for(Int_t i=0; i<fNdims ;i++){
- mean[i]=hd->GetMean();
+ Double_t distance = 9999999;
+ for(Int_t i=0; i<fNdims ;i++){
+ mean[i]=hd[i]->GetMean();
goodbins[i]=0;
dacs.AddAt(-1,i);
}
fNh[qualityflag][hs][chip]->GetBinContent(in,bins);
Double_t r2 = 0;
for(Int_t j=0; j<fNdims; j++) {
- val[j]=hd->GetBinCenter(bins[j]);
+ val[j] = hd[j]->GetBinCenter(bins[j]);
r2+=TMath::Power(val[j]-mean[j],2);
}
}
}
- for(Int_t k=0; k<fNdims; k++) {
- Int_t a = (Int_t)( hd->GetBinCenter(goodbins[k]) + 0.5 *hd->GetBinWidth(goodbins[k]) );
- dacs.AddAt(a,k);
+
+ for(Int_t k=0; k<fNdims; k++) {
+ dacs.AddAt((Int_t)(hd[k]->GetBinCenter(goodbins[k]) + 0.5*hd[k]->GetBinWidth(goodbins[k])),k);
}
+
dacs.AddAt(qualityflag,fNdims);
- delete mean;
- delete goodbins;
- delete bins;
- delete val;
+
+ delete [] mean;
+ delete [] goodbins;
+ delete [] bins;
+ delete [] val;
return dacs;
}
//-------------------------------------------------------
//
- Int_t maxbin = h->GetMaximum();
+ Int_t maxbin = (Int_t)h->GetMaximumBin();
Double_t maxentries = h->GetBinContent(maxbin);
- Int_t counts =0;
- Int_t bins[10]={0,0,0,0,0,0,0,0,0,0};
- Int_t binindex=0;
+ Int_t binindex = -1;
Bool_t check=kFALSE;
- for(Int_t i=0; i<= h->GetNbinsX(); i++){
+ for(Int_t i=0; i< h->GetNbinsX(); i++){
if(h->GetBinContent(i) == maxentries){
- counts++;
- bins[binindex]=i;
- binindex++;
+ if(binindex <= i) binindex =i;
}
}
- if(counts>0) {
- bin=bins[binindex-1];
+
+ if(binindex>-1) {
+ bin=binindex;
check = kTRUE;
}
return check;
}
-