fOldRCUformat(kTRUE),
fTimeAnalysis(kFALSE),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fCalRocArrayPedestal(72),
fCalRocArrayRMS(72),
fHistoPedestalArray(72),
fOldRCUformat(ped.fOldRCUformat),
fTimeAnalysis(ped.fTimeAnalysis),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fCalRocArrayPedestal(72),
fCalRocArrayRMS(72),
fHistoPedestalArray(72),
delete [] fTimeSignal;
fTimeSignal = 0;
}
+
+ // do not delete fMapping, because we do not own it.
+
}
Int_t iChannel = fROC->GetRowIndexes(icsector)[icRow]+icPad; // global pad position in sector
- // fast filling methode.
+ // fast filling method
// 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 = (iChannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
// Event processing loop - AliRawReader
//
- AliTPCRawStream rawStream(rawReader);
+ // if fMapping is NULL the rawstream will crate its own mapping
+ AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping);
rawReader->Select("TPC");
return ProcessEvent(&rawStream);
}
//_____________________________________________________________________
TH2F* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/
- Int_t nbinsY, Float_t ymin, Float_t ymax,
- Char_t *type, Bool_t force)
+ Int_t nbinsY, Float_t ymin, Float_t ymax,
+ Char_t *type, Bool_t force)
{
//
// return pointer to Q histogram
fNpadrow(0),
fNpadrowIROC(0),
fNpadrowOROC(0),
- fTpcDdlOffset(0),
- fROC(NULL)
+ fTpcDdlOffset(0)
{
//
// Constructor
{
// Destructor
- delete fROC;
-
for ( Int_t i = 0; i < fNrcu; i++ ) {
delete fMapping[i];
fMapping[i] = 0;
fNpadrow(mapper.fNpadrow),
fNpadrowIROC(mapper.fNpadrowIROC),
fNpadrowOROC(mapper.fNpadrowOROC),
- fTpcDdlOffset(mapper.fTpcDdlOffset),
- fROC(mapper.fROC)
+ fTpcDdlOffset(mapper.fTpcDdlOffset)
{
// Copy Constructor
for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
((TObject *)this)->operator=(mapper);
for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
- fROC = mapper.fROC;
fNside = mapper.fNside;
fNsector = mapper.fNsector;
}
// Create instance of AliTPCROC object
- fROC = AliTPCROC::Instance();
-
+ AliTPCROC *fROC = AliTPCROC::Instance();
fNpadrowIROC = fROC->GetNRows(0);
fNpadrowOROC = fROC->GetNRows(36);
- fNpadrow = fNpadrowIROC+fNpadrowOROC;
+ fNpadrow = fNpadrowIROC+fNpadrowOROC;
AliDAQ daq;
fTpcDdlOffset = daq.DdlIDOffset("TPC");
//______________________________________________________________
Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
// Get number of pads in padrow for this ROC.
- return fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
+ AliTPCROC *fROC = AliTPCROC::Instance();
+ Int_t retval = fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
+ return retval;
}
Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
{
// Get number of padrows
- return fROC->GetNRows(roc);
+ if (roc < 36) return fNpadrowIROC;
+ else if (roc < 72) return fNpadrowOROC;
+ return -1;
}
if( (branch == 1) && (patch == 1) ){
retval = 12;
}
+
return retval;
}
TPCda_pedestal.cxx - calibration algorithm for TPC pedestal runs
10/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
+19/10/2007 christian.lippmann@cern.ch : Possibility to write output to ASCII file
+24/10/2007 christian.lippmann@cern.ch : Including pedestal calibration for time bins
+23/11/2007 christian.lippmann@cern.ch : Fix in order to avoid streamer problems in case of
+ invalid ROOTSTYS. The famous magic line provided by Rene.
+28/11/2007 christian.lippmann@cern.ch : TPC mapping file is read from DaqDetDB
contact: marian.ivanov@cern.ch
-
This process reads RAW data from the files provided as command line arguments
and save results in a file (named from RESULT_FILE define - see below).
*/
-#define RESULT_FILE "tpcPedestal.root"
+#define RESULT_FILE "tpcPedestal.root"
+#define MAPPING_FILE "tpcMapping.root"
extern "C" {
}
#include "event.h"
#include "monitor.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <fstream.h>
+
+#include "stdio.h"
+#include "stdlib.h"
+#include <fstream>
//
//Root includes
//
-#include <TFile.h>
-#include <TArrayF.h>
+#include "TFile.h"
+#include "TArrayF.h"
#include "TROOT.h"
#include "TPluginManager.h"
#include "AliRawReaderDate.h"
#include "AliTPCmapper.h"
#include "AliTPCRawStream.h"
+#include "AliTPCAltroMapping.h"
#include "AliTPCROC.h"
#include "AliTPCCalROC.h"
#include "AliTPCCalPad.h"
// Main for TPC pedestal detector algorithm
//
- gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
- "*",
- "TStreamerInfo",
- "RIO",
- "TStreamerInfo()");
Bool_t timeAnalysis = kTRUE;
- int i,status;
- AliTPCCalibPedestal calibPedestal; // pedestal and noise calibration
- calibPedestal.SetTimeAnalysis(timeAnalysis); // pedestal(t) calibration
-
if (argc<2) {
printf("Wrong number of arguments\n");
return -1;
}
+ /* magic line */
+ gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
+ "*",
+ "TStreamerInfo",
+ "RIO",
+ "TStreamerInfo()");
+ int i, status;
+
/* log start of process */
printf("TPC DA started - %s\n",__FILE__);
return -1;
}
+ /* copy locally the mapping file from daq detector config db */
+ status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
+ if (status) {
+ printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
+ printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ //return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+
+ /* open the mapping file and retrieve mapping object */
+ TFile *fileMapping = new TFile(MAPPING_FILE, "read");
+ AliTPCmapper *mapping = 0; // The TPC mapping
+ mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
+ if (mapping == 0) {
+ printf("Failed to get mapping object from %s. Exiting ...\n", MAPPING_FILE);
+ delete fileMapping;
+ return -1;
+ } else {
+ printf("Got mapping object from %s\n", MAPPING_FILE);
+ }
+ AliTPCAltroMapping **altromapp = mapping->GetAltroMapping();
+
+ AliTPCCalibPedestal calibPedestal; // pedestal and noise calibration
+ calibPedestal.SetTimeAnalysis(timeAnalysis); // pedestal(t) calibration
+ calibPedestal.SetAltroMapping(altromapp); // Use altro mapping we got from daqDetDb
+
/* loop over RAW data files */
int nevents=0;
for ( i=1; i<argc; i++ ) {
printf("Processing file %s\n", argv[i]);
status=monitorSetDataSource( argv[i] );
if (status!=0) {
- printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
+ printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
+ delete fileMapping;
return -1;
}
}
}
- calibPedestal.Analyse();
- calibPedestal.AnalyseTime(nevents);
- printf ("%d physics/calibration events processed\n",nevents);
+ //
+ // Analyse pedestals and write them to rootfile
+ //
+
+ calibPedestal.Analyse();
+ calibPedestal.AnalyseTime(nevents);
+ printf ("%d physics/calibration events processed.\n",nevents);
TFile *fileTPC = new TFile(RESULT_FILE, "recreate");
calibPedestal.Write("calibPedestal");
delete fileTPC;
- printf("Wrote %s\n",RESULT_FILE);
+ printf("Wrote %s.\n",RESULT_FILE);
//
- // Now prepare ASCII files for local ALTRO configuration through DDL
+ // Now prepare ASCII files for local ALTRO configuration through DDL.
//
ofstream pedfile;
sprintf(filename,"tpcPedestalMem.data");
pedmemfile.open(filename);
- TArrayF **timePed = calibPedestal.GetTimePedestals();
- AliTPCmapper mapping;
+ TArrayF **timePed = calibPedestal.GetTimePedestals(); // pedestal values for each time bin
Int_t ctr_channel = 0;
Int_t ctr_altro = 0;
Int_t ctr_pattern = 0;
- pedfile << 10 << std::endl; // PEDESTALS per channel
- noisefile << 11 << std::endl; // NOISE per altro
- pedmemfile << 12 << std::endl; // PEDESTALs per time bin
+ pedfile << 10 << std::endl; // mark file to contain PEDESTALS per channel
+ noisefile << 11 << std::endl; // mark file to contain NOISE per altro
+ pedmemfile << 12 << std::endl; // mark file to contain PEDESTALs per time bin
for ( Int_t roc = 0; roc < 72; roc++ ) {
if ( !calibPedestal.GetCalRocPedestal(roc) ) continue;
- Int_t side = mapping.GetSideFromRoc(roc);
- Int_t sector = mapping.GetSectorFromRoc(roc);
+ Int_t side = mapping->GetSideFromRoc(roc);
+ Int_t sector = mapping->GetSectorFromRoc(roc);
//printf("Analysing ROC %d (side %d, sector %d) ...\n", roc, side, sector);
- Int_t nru = mapping.IsIROC(roc) ? 2 : 4;
+ Int_t nru = mapping->IsIROC(roc) ? 2 : 4;
for ( int rcu = 0; rcu < nru; rcu++ ) {
- Int_t patch = mapping.IsIROC(roc) ? rcu : rcu+2;
+ Int_t patch = mapping->IsIROC(roc) ? rcu : rcu+2;
for ( int branch = 0; branch < 2; branch++ ) {
- for ( int fec = 0; fec < mapping.GetNfec(patch, branch); fec++ ) {
+ for ( int fec = 0; fec < mapping->GetNfec(patch, branch); fec++ ) {
for ( int altro = 0; altro < 8; altro++ ) {
Float_t rms = 0.;
Float_t ctr = 0.;
for ( int channel = 0; channel < 16; channel++ ) {
- Int_t hwadd = mapping.CodeHWAddress(branch, fec, altro, channel);
- Int_t row = mapping.GetPadRow(patch, hwadd);
- Int_t pad = mapping.GetPad(patch, hwadd);
+ Int_t hwadd = mapping->CodeHWAddress(branch, fec, altro, channel);
+ Int_t row = mapping->GetPadRow(patch, hwadd);
+ Int_t pad = mapping->GetPad(patch, hwadd);
Float_t ped = calibPedestal.GetCalRocPedestal(roc)->GetValue(row,pad);
// fixed pedestal
if ( ped > 1.e-10 ) {
- pedfile << ctr_channel << "\t" << side << "\t" << sector << "\t" << patch << "\t" << hwadd << "\t" << ped << std::endl;
+ pedfile << ctr_channel << "\t" << side << "\t" << sector << "\t" << patch << "\t"
+ << hwadd << "\t" << ped << std::endl;
ctr_channel++;
}
// pedestal(t)
if ( timePed && fabs(timePed[row][pad].GetSum()) > 1e-10 ) {
- pedmemfile << ctr_pattern << "\t" << side << "\t" << sector << "\t" << patch << "\t" << hwadd;
+ pedmemfile << ctr_pattern << "\t" << side << "\t" << sector << "\t" << patch
+ << "\t" << hwadd;
for ( Int_t timebin = 0; timebin < 1024; timebin++ )
pedmemfile << "\t" << timePed[row][pad].At(timebin);
pedmemfile << std::endl;
if ( rms2 > 1.e-10 ) { rms += rms2; ctr += 1.; }
} // end channel for loop
// noise data (rms) averaged over all channels in this ALTRO.
- Int_t hwadd = mapping.CodeHWAddress(branch, fec, altro, 0);
+ Int_t hwadd = mapping->CodeHWAddress(branch, fec, altro, 0);
if ( ctr > 1.e-10 ) {
- noisefile << ctr_altro << "\t" << side << "\t" << sector << "\t" << patch << "\t" << hwadd << "\t" << rms/ctr << std::endl;
+ noisefile << ctr_altro << "\t" << side << "\t" << sector << "\t" << patch << "\t"
+ << hwadd << "\t" << rms/ctr << std::endl;
ctr_altro++;
}
} // end altro for loop
pedfile.close();
noisefile.close();
pedmemfile.close();
+ printf("Wrote ASCII files.\n");
- printf("Wrote ASCII files\n");
+ delete fileMapping;
return status;
}