// TH1F *histo = ped.GetHisto(31); //
// histo->SetEntries(1); //
// histo->Draw(); //
-// //
+//
+// Authors:
+// R. Bailhache (R.Bailhache@gsi.de, rbailhache@ikf.uni-frankfurt.de)
+// J. Book (jbook@ikf.uni-frankfurt.de)
+// //
////////////////////////////////////////////////////////////////////////////
//header file
#include "AliLog.h"
#include "AliTRDCalibPadStatus.h"
-#include "AliTRDrawStreamBase.h"
#include "AliTRDgeometry.h"
#include "AliTRDCommonParam.h"
#include "./Cal/AliTRDCalROC.h"
#include "./Cal/AliTRDCalPad.h"
#include "./Cal/AliTRDCalSingleChamberStatus.h"
+#include "AliTRDdigitsManager.h"
+#include "AliTRDdigitsParam.h"
+#include "AliTRDSignalIndex.h"
+#include "AliTRDarraySignal.h"
+#include "AliTRDarrayADC.h"
+#include "AliTRDfeeParam.h"
+
+#include "AliTRDrawStream.h"
+
#ifdef ALI_DATE
#include "event.h"
#endif
}
//_____________________________________________________________________
Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
- const Int_t icRow,
- const Int_t icCol,
- const Int_t csignal,
- const Int_t crowMax,
- const Int_t ccold,
- const Int_t icMcm)
+ const Int_t icRow,
+ const Int_t icCol,
+ const Int_t csignal,
+ const Int_t crowMax,
+ const Int_t ccold,
+ const Int_t icMcm,
+ const Int_t icRob
+ )
{
//
// Signal filling methode
//
Int_t nbchannel = icRow+icCol*crowMax;
+ Int_t mCm = icMcm%4;
+ Int_t rOb = icRob%2;
// now the case of double read channel
if(ccold > 0){
- nbchannel = (((ccold-1)*8+ icMcm)*crowMax+icRow)+144*crowMax;
+ nbchannel = (((ccold-1)*8+ (mCm+rOb*4))*crowMax+icRow)+144*crowMax;
//printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
}
// fast filling methode.
// Attention: the entry counter of the histogram is not increased
// this means that e.g. the colz draw option gives an empty plot
+
Int_t bin = 0;
+
if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
//GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
-
+
GetHisto(icdet,kTRUE)->GetArray()[bin]++;
return 0;
}
//_____________________________________________________________________
-Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
+Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader)
{
+ //
+ // RawReader = AliTRDrawStream (Jochen Klein)
//
// Event Processing loop - AliTRDRawStreamCosmic
// 0 time bin problem or zero suppression
// [3,31] non zero suppressed
// 2,4 and [32,63] zero suppressed
//
+
+
Int_t withInput = 1;
- rawStream->SetSharedPadReadout(kTRUE);
-
- if(!nocheck) {
-
- // Check the raw version and if all have the same number of timebins.
-
- while (rawStream->Next()) {
-
- Int_t rawversion = rawStream->GetRawVersion(); // current raw version
- //printf("Raw version is %d\n",rawversion);
-
- // Could eventually change, have to check with time
- if((rawversion < 3) || (rawversion > 31)) {
- AliInfo(Form("this is not no-zero-suppressed data, the version is %d",rawversion));
- return 0;
- }
- Int_t idetector = rawStream->GetDet(); // current detector
- Int_t iRow = rawStream->GetRow(); // current row
- Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
- Int_t iCol = rawStream->GetCol(); // current col
- Int_t iADC = 21-rawStream->GetADC(); // current ADC
-
- // It goes in the opposite direction
- Int_t col = 0;
- if(iADC == 1) col = 1;
- else {
- col = TMath::Max(0,(Int_t)(iADC-19));
- if(col > 0) col++;
- }
- Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
- if(col > 1) mcm -= 1;
- if(col ==1) mcm += 1;
-
- // printf to check
- //Bool_t shared = rawStream->IsCurrentPadShared();
- //printf("ADC %d, iCol %d, col %d, mcm %d, shared %d\n",iADC,iCol,col,mcm,(Int_t)shared);
-
- // Take the signal
- Int_t *signal = rawStream->GetSignals(); // current ADC signal
- Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
-
- if((fDetector != -1) && (nbtimebin != fNumberOfTimeBins)) {
- AliInfo(Form("the number of time bins is %d, is different from the previous one %d",nbtimebin,fNumberOfTimeBins));
- return 0;
- }
- fNumberOfTimeBins = nbtimebin;
- fDetector = idetector;
-
- for(Int_t k = 0; k < fNumberOfTimeBins; k++){
- if(signal[k]>0) UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
- }
-
- withInput = 2;
- }
- }
- else {
+ AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
+ digitsManager->CreateArrays();
- while (rawStream->Next()) {
-
- Int_t idetector = rawStream->GetDet(); // current detector
- Int_t iRow = rawStream->GetRow(); // current row
- Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
- Int_t iCol = rawStream->GetCol(); // current col
- Int_t iADC = 21-rawStream->GetADC(); // current ADC
-
- // It goes in the opposite direction
- Int_t col = 0;
- if(iADC == 1) col = 1;
- else {
- col = TMath::Max(0,(Int_t)(iADC-19));
- if(col > 0) col++;
- }
- Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
- if(col > 1) mcm -= 1;
- if(col ==1) mcm += 1;
+ AliTRDrawStream *rawStream = new AliTRDrawStream(rawReader);
+ rawStream->SetDigitsManager(digitsManager);
+ //rawStream->SetNoErrorWarning();
+ //rawStream->SetSharedPadReadout(kTRUE);
+
+ AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
- // Take the signal
- Int_t *signal = rawStream->GetSignals(); // current ADC signal
- Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
-
+ Int_t det = 0;
+ while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
+ if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
+ // printf("there is ADC data on this chamber!\n");
- //printf("det %d, row %d, signal[0] %d, signal[1] %d, signal [2] %d\n", idetector, iRow, signal[0], signal[1], signal[2]);
-
- for(Int_t k = 0; k < nbtimebin; k++){
- if(signal[k]>0) {
- UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
- //printf("Update with det %d, row %d, col %d, signal %d, rowmax %d, col %d, mcm %d\n",idetector,iRow,iCol,signal[n],iRowMax,col,mcm);
+ AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
+ if (digits->HasData()) { //array
+
+ AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det);
+ if (indexes->IsAllocated() == kFALSE) {
+ AliError("Indexes do not exist!");
+ break;
}
- }
-
- withInput = 2;
- }
- }
-
- return withInput;
-}
-//_____________________________________________________________________
-Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader, Bool_t nocheck)
-{
- //
- // Event processing loop - AliRawReader
- //
-
- Int_t result;
-
- rawReader->Select("TRD");
-
- AliTRDrawStreamBase *pstream = AliTRDrawStreamBase::GetRawStream(rawReader);
-
- result = ProcessEvent(pstream, nocheck);
-
- delete pstream;
-
- return result;
-}
-
-//_________________________________________________________________________
-Int_t AliTRDCalibPadStatus::ProcessEvent(
-#ifdef ALI_DATE
- const eventHeaderStruct *event,
- Bool_t nocheck
-#else
- const eventHeaderStruct* /*event*/,
- Bool_t /*nocheck*/
+ Int_t iRow = 0;
+ Int_t iCol = 0;
+ indexes->ResetCounters();
+
+ while (indexes->NextRCIndex(iRow, iCol)) { //column,row
+
+ AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
+
+ Int_t mcm = 0; // MCM from AliTRDfeeParam
+ Int_t rob = 0; // ROB from AliTRDfeeParam
+ Int_t extCol = 0; // extended column from AliTRDfeeParam
+ mcm = feeParam->GetMCMfromPad(iRow,iCol);
+ rob = feeParam->GetROBfromPad(iRow,iCol);
+
+ Int_t idetector = det; // current detector
+ Int_t iRowMax = 16; // current rowmax
+ if(GetStack(det) == 2) iRowMax = 12;
+
+ Int_t adc = 20 - (iCol%18) -1; // current adc
+ Int_t col = 0; // col!=0 ->Shared Pad
+ extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc);
+ //printf(" iCol %d iRow %d iRowMax %d rob %d mcm %d adc %d extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol);
+
+ // Signal for regular pads
+ Int_t nbtimebin = digitParam->GetNTimeBins(idetector); // number of time bins read from data
+ for(Int_t k = 0; k < nbtimebin; k++){
+ Short_t signal = 0;
+ signal = digits->GetData(iRow,iCol,k);
+
+ if(signal>0) {
+ UpdateHisto(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
+ }
+ }
+
+
+
+ if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) ) { //SHARED PADS
-#endif
- )
-{
- //
- // process date event
- //
-#ifdef ALI_DATE
- AliRawReader *rawReader = new AliRawReaderDate((void*)event);
- Bool_t result=ProcessEvent(rawReader, nocheck);
- delete rawReader;
- return result;
-#else
- Fatal("AliTRDCalibPadStatus", "this class was compiled without DATE");
- return 0;
-#endif
-
-}
-
-//_____________________________________________________________________
-Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent, Int_t sm, Int_t ch) /*FOLD00*/
-{
- //
- // Test event loop
- // fill one oroc and one iroc with random gaus
- //
-
- gRandom->SetSeed(0);
-
- for (Int_t ism=sm; ism<sm+1; ism++){
- for (Int_t ich=ch; ich < ch+1; ich++){
- for (Int_t ipl=0; ipl < 6; ipl++){
- for(Int_t irow = 0; irow < fGeo->GetRowMax(ipl,ich,ism); irow++){
- for(Int_t icol = 0; icol < fGeo->GetColMax(ipl); icol++){
- for (Int_t iTimeBin=0; iTimeBin<(30*nevent); iTimeBin++){
- Int_t signal=TMath::Nint(gRandom->Gaus(10,1.5));
- if ( signal>0 )UpdateHisto((ipl+ich*6+ism*6*5),irow,icol,signal,fGeo->GetRowMax(ipl,ich,ism),0,0);
- }
- }
+ switch(adc) {
+ case 2:
+ adc = 20; //shared Pad adc
+ mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
+ col = 1;
+ break;
+ case 19:
+ adc = 1; //shared Pad adc
+ mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
+ col = 2;
+ break;
+ case 18:
+ adc = 0; //shared Pad adc
+ mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
+ col = 3;
+ break;
+ }
+ rob = feeParam->GetROBfromSharedPad(iRow,iCol); //shared Pad rob
+
+
+ extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); //extended pad col via the shared pad rob,mcm and adc
+
+ //printf("SHARED PAD --- iCol %d iRow %d rob %d mcm %d adc %d extCol %d col %d\n",iCol,iRow,rob,mcm,adc,extCol,col);
+ for(Int_t k = 0; k < nbtimebin; k++){
+ Short_t signal = 0;
+ signal = digits->GetDataByAdcCol(iRow,extCol,k);
+
+ if(signal>0) {
+ UpdateHisto(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
}
}
- }
- }
- return kTRUE;
+ } //shared pads end
+
+
+ withInput = 2;
+ }//column,row
+
+ }//array
+ }//QA
+ digitsManager->ClearArrays(det);
+ }//idetector
+ delete digitsManager;
+ delete rawStream;
+ return withInput;
+
}
//_____________________________________________________________________
// if we are forced and histogram doesn't yes exist create it
Char_t name[255], title[255];
- sprintf(name,"hCalib%s%.3d",type,det);
- sprintf(title,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det);
+ snprintf(name,255,"hCalib%s%.3d",type,det);
+ snprintf(title,255,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det);
Int_t nbchannels = fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))*fGeo->GetColMax(GetLayer(det));
// bridge if previous pad found something
if(!pb) {
- if((meanprevious == mean) && (rmsprevious == rms) && (mean > 0.0001)) {
+ if((TMath::Abs(meanprevious-mean)<0.000001) && (TMath::Abs(rmsprevious-rms)<0.000001) && (mean > 0.0001)) {
//printf("mean previous %f, mean %f, rms %f, rmsprevious %f, col %d\n",meanprevious,mean,rms,rmsprevious,icol);
calROC->SetStatus(icol -1 ,irow, AliTRDCalPadStatus::kPadBridgedRight);
calROC->SetStatus(icol ,irow, AliTRDCalPadStatus::kPadBridgedLeft);
}
+