* \verbinclude Altro/Altro.C.log
*
*/
+
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Class for emulation of the ALTRO chip (Altro digital Chain) in C++ //
// Author: Roland Bramm //
fReader(0), // for Altro Emulation on Raw Reader
fDecoder(0),
- fDDLFolderName("/tmp/"),
- fOutputDateFileName("/tmp/tmp.date"),
- fOutputRootFileName("/tmp/tmp.root"),
+ fRunNumber(0),
+ fDDLFolderName("./"),
+ fOutputDateFileName("./tmpRaw.date"),
+ fOutputRootFileName("./tmpRaw.root"),
fIsRandom(kTRUE),
fChannels(0),
fCDHs(0),
//
// Constructor of Altro Class
//
- /*
- ftimebins = timebins;
-
- fChannelShort_T = Channel;
-
- fOnBSL1 = 0;
- fOnTCF = 0;
- fOnBSL2 = 0;
- fOnClip = 0;
- fOnZSU = 0;
-
- fConfiguredAltro = 0;
- fConfiguredBSL1 = 0;
- fConfiguredTCF = 0;
- fConfiguredBSL2 = 0;
- fConfiguredZSU = 0;
- */
-}
+ fADCkeep = new Short_t[1024];
-AliTPCAltroEmulator::AliTPCAltroEmulator(const AliTPCAltroEmulator &altro):
- TNamed(),
- ftimebins(altro.ftimebins),
-// fChannelIn(Channel),
- fChannelShort(altro.fChannelShort),
- fADCkeep(0),
- fOnBSL1(0),
- fOnTCF(0),
- fOnBSL2(0),
- fOnClip(0),
- fOnZSU(0),
-
- fConfiguredAltro(0), // ConfiguredAltro
- fConfiguredBSL1(0), // ConfiguredBSL1
- fConfiguredTCF(0), // ConfiguredTCF
- fConfiguredTCFraw(0), // ConfiguredTCF
- fConfiguredBSL2(0), // ConfiguredBSL2
- fConfiguredZSU(0), // ConfiguredZSU
- fBSL1mode(0), // BSL1mode
- fBSL1ValuePeDestal(0), // BSL1ValuePeDestal
- fBSL1PedestalMem(0), // BSL1PedestalMem
- fBSL1polarity(0), // BSL1polarity
-
- fTCFK1(0), // K1
- fTCFK2(0), // K2
- fTCFK3(0), // K3
- fTCFL1(0), // L1
- fTCFL2(0), // L2
- fTCFL3(0), // L3
-
- fTCFK1Int(0), // K1Int
- fTCFK2Int(0), // K2Int
- fTCFK3Int(0), // K3Int
- fTCFL1Int(0), // L1Int
- fTCFL2Int(0), // L2Int
- fTCFL3Int(0), // L3Int
-
- fBSL2HighThreshold(0), // BSL2HighThreshold
- fBSL2LowThreshold(0), // BSL2LowThreshold
- fBSL2Offset(0), // BSL2Offset
- fBSL2Presamples(0), // BSL2Presamples(0),
- fBSL2Postsamples(0), // BSL2Postsamples
-
- fZSUThreshold(0), // ZSUThreshold
-
- fZSUMinSamplesaboveThreshold(0), // ZSUMinSamplesaboveThreshold
- fZSUPresamples(0), // ZSUPresamples
- fZSUPostsamples(0), // ZSUPostsamples
-
- fReader(0), // for Altro Emulation on Raw Reader
- fDecoder(0),
- fDDLFolderName("/tmp/"),
- fOutputDateFileName("/tmp/tmp.date"),
- fOutputRootFileName("/tmp/tmp.root"),
- fIsRandom(kTRUE),
- fChannels(0),
- fCDHs(0),
- fADCs(0),
- fTrailers(0),
- fRawData(0) {
- //
- // copy constructor of Altro Class
- //
+ fTCFK1IntROC[0]=0; fTCFK1IntROC[1]=0; // dummy defaults
+ fTCFK2IntROC[0]=0; fTCFK2IntROC[1]=0; // dummy defaults
+ fTCFK3IntROC[0]=0; fTCFK3IntROC[1]=0; // dummy defaults
+ fTCFL1IntROC[0]=0; fTCFL1IntROC[1]=0; // dummy defaults
+ fTCFL2IntROC[0]=0; fTCFL2IntROC[1]=0; // dummy defaults
+ fTCFL3IntROC[0]=0; fTCFL3IntROC[1]=0; // dummy defaults
}
+
/** @brief Destructor of Altro Class
*
* Destructor of Altro Class\n
// Destructor of Altro Class
//
- if(fConfiguredZSU == 1)
- delete fADCkeep;
+ // if(fConfiguredZSU == 1)
+ delete[] fADCkeep;
delete[] fChannels;
delete[] fCDHs ;
}
-//_____________________________________________________________________________
-AliTPCAltroEmulator& AliTPCAltroEmulator::operator = (const AliTPCAltroEmulator &source)
-{
- //
- // AliTPCAltroEmulator assignment operator
- //
-
- if (&source == this) return *this;
- new (this) AliTPCAltroEmulator(source);
-
- return *this;
-
-}
-
-
/** @brief Configures which modules of the Altro should be on.
*
//
// Configures the Base Line Correction 1 (BSL1) Module
//
- fBSL1mode = InRange(mode,0,10,"AliTPCAltroEmulator::ConfigBaselineCorrection1","mode");
+ fBSL1mode = InRange(mode,0,16,"AliTPCAltroEmulator::ConfigBaselineCorrection1","mode");
fBSL1ValuePeDestal = InRange(ValuePeDestal,0,1023,"AliTPCAltroEmulator::BaselineCorrection1","ValuePeDestal");
fBSL1PedestalMem = PedestalMem;
fBSL1polarity = InRange(polarity,0,1,"AliTPCAltroEmulator::BaselineCorrection1","polarity");
fTCFL3Int = InRange(L3,0,65535,"AliTPCAltroEmulator::ConfigTailCancellationFilter","L3");
fConfiguredTCF = 1;
}
-void AliTPCAltroEmulator::ConfigTailCancellationFilterForRAWfiles(Int_t *K1, Int_t *K2, Int_t *K3, Int_t *L1, Int_t *L2, Int_t *L3){
+void AliTPCAltroEmulator::ConfigTailCancellationFilterForRAWfiles(const Int_t *K1, const Int_t *K2, const Int_t *K3,
+ const Int_t *L1, const Int_t *L2, const Int_t *L3){
//
// Configures the Tail Cancellation Filter (TCF) Module - Different settings for IROC and OROC
//
fZSUMinSamplesaboveThreshold = InRange(MinSamplesaboveThreshold,1,3,"AliTPCAltroEmulator::BaselineCorrection1","MinSamplesaboveThreshold");
fZSUPresamples = InRange(Presamples,0,3,"AliTPCAltroEmulator::BaselineCorrection1","Presamples");
fZSUPostsamples = InRange(Postsamples,0,7,"AliTPCAltroEmulator::BaselineCorrection1","Postsamples");
- fADCkeep = (Short_t *)calloc(sizeof(short),ftimebins);
for(Int_t i = 0; i < ftimebins; i++){
fADCkeep[i] = 0;
//VPD == 0 !!
Int_t fixedPeDestal = 0;
-
+
+ // take first and last bins to calculate a mean pedestal value
+ Int_t window = 3;
+ Int_t meanPeDestal = 0;
+ if (mode == kDINxMPD && ftimebins>=6) {
+ for(Int_t i = 0; i < window; i++) {
+ meanPeDestal += fChannelShort[i];
+ meanPeDestal += fChannelShort[ftimebins-1-i];
+ }
+ meanPeDestal /= (window*2);
+ }
+
if(polarity ==1){
for(Int_t i = 0; i < ftimebins; i++){
fChannelShort[i] = 1023 - fChannelShort[i];
for(Int_t i = 0; i < ftimebins; i++)
fChannelShort[i] = PedestalMem[i] - fixedPeDestal;
break;
+ case kDINxMPD:
+ for(Int_t i = 0; i < ftimebins; i++)
+ fChannelShort[i] = fChannelShort[i] - meanPeDestal;
+ break;
}
}
long long retval;
long long pattern;
long long length = abs(left - right)+1;
- pattern = ((1<<length)-1)<<right;
+ pattern = ((((long long)1)<<length)-1)<<right;
retval = in&pattern;
return retval;
}
long long retval;
long long pattern;
long long length = abs(left - right)+1;
- pattern = ((1<<length)-1);
+ pattern = ((((long long)1)<<length)-1);
retval = (in>>right)&pattern;
return retval;
}
//Int_t setPostsample = 0;
for(Int_t i = 0; i < ftimebins; i++){
- if(fChannelShort[i] >= Threshold){
+ if(fChannelShort[i] >= Threshold)
fADCkeep[i] = 1;
- }
+ else
+ fADCkeep[i] = 0;
}
Int_t startofclustersequence = -1;
Int_t endofClustersInSequence = -1;
for(Int_t i = 0; i < ftimebins; i++){
- if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i-1) == -1) ){
+ if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i-1) == 0) ){
startofclustersequence = i;
}
- if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i+1) == -1) ){
+ if( (fADCkeep[i] == 1) && (GetElement(fADCkeep,i+1) == 0) ){
endofClustersInSequence = i;
}
//cout << i << " startofclustersequence: " << startofclustersequence << " endofClustersInSequence: " << endofClustersInSequence;
}
for(Int_t i = 0; i < ftimebins; i++){
- if( !GetKeepChannel(i) || GetShortChannel(i)<Threshold) {
+ if( !GetKeepChannel(i) ) {
SetElement(fChannelShort,i,-1); // set non relevant data to -1
}
}
char out[255];
Int_t retval;
if(parameter > High){
- sprintf(out,"Error | %s | Parameter %s is to big, has to be %d <= %s <= %d, is %d, now set to %d",Module,ParameterName,Low,ParameterName,High,parameter,High);
+ snprintf(out,255,"Error | %s | Parameter %s is to big, has to be %d <= %s <= %d, is %d, now set to %d",Module,ParameterName,Low,ParameterName,High,parameter,High);
cout << out << endl;
retval = High;
}else if(parameter < Low){
- sprintf(out,"Error | %s | Parameter %s is to small, has to be %d <= %s <= %d, is %d, now set to %d",Module,ParameterName,Low,ParameterName,High,parameter,Low);
+ snprintf(out,255,"Error | %s | Parameter %s is to small, has to be %d <= %s <= %d, is %d, now set to %d",Module,ParameterName,Low,ParameterName,High,parameter,Low);
cout << out << endl;
retval = Low;
}else{
FILE *file=fopen(Form("%s/raw%d/TPC_%03d.ddl",
fDDLFolderName.Data(),ievent,768+ddlID),
"wb");
- if (!file) return kFALSE;
- Int_t i32;
- // write CDH (first word to be altered later)
- for (i32=0;i32<8;++i32)
- fRawData[i32]=cdhDDL[i32];
-
- // process payload
- for (Int_t hwaddr=0;hwaddr<4096;++hwaddr) if (channelsDDL[hwaddr]) {
- Short_t *adcsChannel=adcsDDL+hwaddr*1024;
- // merge custers
- // TODO: acqusition window
- for (Int_t it=0;it<1024-3;++it) {
- if (adcsChannel[it]>=0&&adcsChannel[it+3]>=0) {
- if (adcsChannel[it+1]<0) {
- // printf("merge");
- adcsChannel[it+1]=0;
- }
- if (adcsChannel[it+2]<0) {
- // printf("merge");
- adcsChannel[it+2]=0;
+ if (!file) {
+ return kFALSE;
+ } else {
+ Int_t i32;
+ // write CDH (first word to be altered later)
+ for (i32=0;i32<8;++i32)
+ fRawData[i32]=cdhDDL[i32];
+
+ // process payload
+ for (Int_t hwaddr=0;hwaddr<4096;++hwaddr) if (channelsDDL[hwaddr]) {
+ Short_t *adcsChannel=adcsDDL+hwaddr*1024;
+ // merge custers
+ // TODO: acqusition window
+ for (Int_t it=0;it<1024-3;++it) {
+ if (adcsChannel[it]>=0&&adcsChannel[it+3]>=0) {
+ if (adcsChannel[it+1]<0) {
+ // printf("merge");
+ adcsChannel[it+1]=0;
+ }
+ if (adcsChannel[it+2]<0) {
+ // printf("merge");
+ adcsChannel[it+2]=0;
+ }
}
}
- }
- Int_t i10=3;
- Int_t icw=0;
- Int_t its=1;
- Int_t cw =0;
- Int_t ts =0;
- for (Int_t it=1023;it>=0;--it) {
- Short_t w10=adcsChannel[it];
- if (w10>=0) {
- if (cw<0) {
- icw=i10++;
- its=i10++;
- cw =0 ;
- ts=it ;
+ Int_t i10=3;
+ Int_t icw=0;
+ Int_t its=1;
+ Int_t cw =0;
+ Int_t ts =0;
+ for (Int_t it=1023;it>=0;--it) {
+ Short_t w10=adcsChannel[it];
+ if (w10>=0) {
+ if (cw<0) {
+ icw=i10++;
+ its=i10++;
+ cw =0 ;
+ ts=it ;
+ }
+ fRawData[i32+i10/3]|=w10<<(10*(2-i10%3));
+ ++i10;
+ ++cw;
}
- fRawData[i32+i10/3]|=w10<<(10*(2-i10%3));
- ++i10;
- ++cw;
- }
- else {
- if (cw>=0) {
- cw+=2;
- fRawData[i32+icw/3]|=cw <<(10*(2-icw%3));
- fRawData[i32+its/3]|=ts <<(10*(2-its%3));
- cw=-1;
+ else {
+ if (cw>=0) {
+ cw+=2;
+ fRawData[i32+icw/3]|=cw <<(10*(2-icw%3));
+ fRawData[i32+its/3]|=ts <<(10*(2-its%3));
+ cw=-1;
+ }
}
}
+ fRawData[i32]=0x1<<30|(i10-3)<<16|hwaddr;
+ i32+=(i10+2)/3;
+
+ // clean up
+ for (Int_t i=0;i<1024;++i) adcsChannel[i]=-1;
+ channelsDDL[hwaddr]=kFALSE;
}
- fRawData[i32]=0x1<<30|(i10-3)<<16|hwaddr;
- i32+=(i10+2)/3;
+
+ // write RCU trailer
+ fRawData[i32]=0x2<<30|(i32-8);i32++;
+ for (Int_t i=0;i<8;++i)
+ fRawData[i32++]=trailerDDL[i];
+
+ // write first word of CDH
+ fRawData[0]=i32*4;
+
+ Int_t nwritten=fwrite(fRawData,sizeof(UInt_t),i32,file);
+ fclose(file);
+ if (nwritten!=i32) return kFALSE;
+
// clean up
- for (Int_t i=0;i<1024;++i) adcsChannel[i]=-1;
- channelsDDL[hwaddr]=kFALSE;
+ do {fRawData[--i32]=0;} while (i32>0);
}
-
- // write RCU trailer
- fRawData[i32]=0x2<<30|(i32-8);i32++;
- for (Int_t i=0;i<8;++i)
- fRawData[i32++]=trailerDDL[i];
-
- // write first word of CDH
- fRawData[0]=i32*4;
-
- Int_t nwritten=fwrite(fRawData,sizeof(UInt_t),i32,file);
- if (nwritten!=i32) return kFALSE;
-
- // clean up
- do {fRawData[--i32]=0;} while (i32>0);
-
- fclose(file);
}
return kTRUE;
}
char command[100];
FILE *pipe;
- if (fReader->GetRunNumber()>0)
+
+ printf(" RAW to DATE CONVERSION: Run Number %d\n",fRunNumber);
+
+ if (fRunNumber>0)
pipe=gSystem->OpenPipe(Form("dateStream -c -s -D -o %s -C -# %d -run %d",
fOutputDateFileName.Data(),
nevents,
- fReader->GetRunNumber()),
+ fRunNumber),
"w");
else
pipe=gSystem->OpenPipe(Form("dateStream -c -s -D -o %s -C -# %d",
fprintf(stderr,"error: cannot execute command: %s",command);
return kFALSE;
}
-
+
for (Int_t ievent=0;ievent<nevents;++ievent) {
UInt_t detectorPattern = 0xFFFFFFFF;
fprintf(pipe, "GDC DetectorPattern %u\n", detectorPattern);
fprintf(pipe, " LDC Id %d\n", ldcID);
prevLDC = ldcID;
}
- fprintf(pipe,Form(" Equipment Id %d Payload %s/raw%d/%s\n",
+ fprintf(pipe," Equipment Id %d Payload %s/raw%d/%s\n",
ddlID,
fDDLFolderName.Data(),
ievent,
- AliDAQ::DdlFileName(iDet,iDDL))
- );
+ (char*)AliDAQ::DdlFileName(iDet,iDDL) );
}
}
}
// from $ALICE_ROOT/STEER/AliSimulation.cxx
+ printf(" DATE to ROOT CONVERSION: Run Number %d\n",fRunNumber);
+
// ALIMDC setup
const Int_t kDBSize = 2000000000; //2GB
const Int_t kTagDBSize = 1000000000;
InitBuffers();
- TH1F hisO("DINO","DINO",1014,0,1014);
- TH1F his("DIN","DIN",1014,0,1014);
-
Int_t chanCount=0;
+ TH1F hisO("DINO","DINO",1024,0,1024);
+ TH1F his("DIN","DIN",1024,0,1024);
his.GetYaxis()->SetRangeUser(-20,90);
- Short_t *data = new Short_t[1014];
+ Short_t *data = new Short_t[1024];
TCanvas *c1 =0;
if (plotFlag) {
c1 = new TCanvas("c1","c1");
Int_t ievent=0;
while (fReader->NextEvent()) {
+ if (fReader->GetRunNumber()>0) fRunNumber=fReader->GetRunNumber();
gSystem->Exec(Form("mkdir -p %s/raw%d/",fDDLFolderName.Data(),ievent));
GDC2DDLs(const_cast<AliRawVEvent*>(fReader->GetEvent()),ievent);
Int_t ddlID=fDecoder->GetDDLNumber();
printf("ddl: %d (%d/216)\n",ddlID,++ddlC);
- Bool_t *channelsDDL=fChannels+ddlID*4096 ;
- Short_t *adcsDDL =fADCs +ddlID*4096*1024;
- UInt_t *cdhDDL =fCDHs +ddlID*8 ;
- UInt_t *trailerDDL =fTrailers+ddlID*9 ;
+ Bool_t *channelsDDL=fChannels+ddlID*4096 ;
+ Short_t *adcsDDL =fADCs +ddlID*4096*1024 ;
+ UInt_t *cdhDDL =fCDHs +ddlID*8 ;
+ UInt_t *trailerDDL =fTrailers+ddlID*9 ;
// CDH
for (Int_t i=0;i<8;++i)
- // just to show how ugly it is...
- cdhDDL[i]=reinterpret_cast<UInt_t*>(const_cast<AliRawDataHeader*>(fReader->GetDataHeader()))[i];
+ // just to show how ugly it is...
+ cdhDDL[i]=reinterpret_cast<UInt_t*>(const_cast<AliRawDataHeader*>(fReader->GetDataHeader()))[i];
// PAYLOAD
while (fDecoder->NextChannel()) {
Short_t s=signals[ci];
Int_t t=ts-ci;
// TODO aqcuisition window
- if (20<=t&&t<=1014) {
+ if (0<=t&&t<(1024-3)) {
channelsDDL[hwaddr]=kTRUE;
if (adcsChannel[t]<0)
adcsChannel[t]=s;
// search start of aquisition
Int_t t0 = 0; while (adcsChannel[t0]==-1) t0++;
// search end of aquisition
- Int_t tE = 1014; while (adcsChannel[tE]==-1) tE--;
+ Int_t tE = 1024; while (adcsChannel[tE]==-1) tE--;
- // SR TEST:
// channel is complete - Perform Altro Emulation
if (plotFlag!=0 && !(chanCount%plotFlag) ) {
- for (Int_t t=0; t<1014; t++) {
+ for (Int_t t=0; t<1024; t++) {
his.SetBinContent(t+1,adcsChannel[t]);
}
his.SetTitle(Form("sig_sec%d_row%d_pad%d",sector,row,pad));
}
// FEED THE ALTRO EMULATOR WITH CLEAN SIGNAL (no aquisition-window ghosts)
- Int_t timebins = tE-t0;
+ Int_t timebins = tE-t0+1;
for (Int_t t=t0;t<(t0+timebins);t++)
data[t-t0]=adcsChannel[t];
SetChannelData(timebins,data);
for (Int_t t=t0;t<(t0+timebins);t++)
adcsChannel[t]=data[t-t0];
- // SR TEST:
if (plotFlag!=0 && !(chanCount%plotFlag) ) {
- for (Int_t t=0; t<1014; t++)
+ for (Int_t t=0; t<1024; t++)
hisO.SetBinContent(t+1,adcsChannel[t]);
hisO.SetStats(0); hisO.SetLineColor(2);
hisO.DrawCopy("same");
- c1->SaveAs(Form("/tmp/sig_sec%02d_row%02d_pad%03d_%d%d%d%d%d.png",
- sector,row,pad,fOnBSL1,fOnTCF,fOnBSL2,fOnClip,fOnZSU));
+ c1->SaveAs(Form("%s/sig_sec%02d_row%02d_pad%03d_%s_%d%d%d%d%d.png",
+ fDDLFolderName.Data(),sector,row,pad,
+ fOutputRootFileName.Data(),
+ fOnBSL1,fOnTCF,fOnBSL2,fOnClip,fOnZSU));
his.Reset();
hisO.Reset();
UChar_t *rcuTrailer;
fDecoder->GetRCUTrailerData(rcuTrailer);
for (Int_t i=0;i<= /* (!) */ fDecoder->GetRCUTrailerSize()/4;++i)
- trailerDDL[i]=reinterpret_cast<UInt_t*>(rcuTrailer)[i]; // again: UGLY!
+ trailerDDL[i]=reinterpret_cast<UInt_t*>(rcuTrailer)[i]; // again: UGLY!
}
- WriteEvent(ievent++);
+ if (ddlC>0) WriteEvent(ievent++);
}
- delete data; // free space
+ delete[] data; // free space
// convert to date and back
ConvertRawFilesToDate(ievent);