48 #define RESULT_FILE "tpcPedestal.root" 49 #define FILE_ID "pedestals" 50 #define MAPPING_FILE "tpcMapping.root" 51 #define CONFIG_FILE "TPCPEDESTALda.conf" 52 #define PED_FILE "tpcPedestals.data" 53 #define NOISE_FILE "tpcNoise.data" 54 #define PEDMEM_FILE "tpcPedestalMem.data" 55 #define NOISY_FILE "tpcNoisyChannels.data" 56 #define VERYNOISY_FILE "tpcVeryNoisyChannels.data" 57 #define DEAD_FILE "tpcDeadChannels.data" 58 #define AliDebugLevel() -1 75 #include "TPluginManager.h" 78 #include "TObjString.h" 83 #include "AliRawReader.h" 84 #include "AliRawReaderDate.h" 106 int main(
int argc,
char **argv) {
112 printf(
"TPC DA started - %s\n",__FILE__);
115 printf(
"Wrong number of arguments\n");
140 gROOT->GetPluginManager()->AddHandler(
"TVirtualStreamerInfo",
148 status=monitorDeclareMp( __FILE__ );
150 printf(
"monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
157 unsigned long32 runNb=0;
159 Bool_t timeAnalysis = kTRUE;
160 Bool_t fastDecoding = kFALSE;
167 printf(
"Failed to get mapping file (%s) from DAQdetDB, status=%d\n",
MAPPING_FILE, status);
173 mapping = (
AliTPCmapper*) fileMapping->Get(
"tpcMapping");
191 printf(
"Failed to get configuration file (%s) from DAQdetDB, status=%d\n",
CONFIG_FILE, status);
196 Bool_t skipAmore=kFALSE;
198 if ( (Int_t)config.
GetValue(
"NoTimeAnalysis") == 1 ) {
199 printf(
"WARNING: Time analysis was switched off in the configuration file!\n");
203 if ( (Int_t)config.
GetValue(
"UseFastDecoder") == 1 ){
204 printf(
"Info: The fast decoder will be used for the processing.\n");
209 skipAmore=((TObjString*)config.
GetConfigurationMap()->GetValue(
"SkipAmore"))->GetString().Atoi();
210 printf(
"TPCPEDESTALda: Skip Amore set in config\n");
217 calibPedestal.SetTimeAnalysis(timeAnalysis);
223 for ( i=1; i<argc; i++ ) {
226 printf(
"Processing file %s\n", argv[i]);
227 status=monitorSetDataSource( argv[i] );
229 printf(
"monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
235 struct eventHeaderStruct *event;
238 if (daqDA_checkShutdown()) {
break;}
241 status=monitorGetEventDynamic((
void **)&event);
242 if (status==MON_ERR_EOF) {
243 printf (
"End of File %d (%s) detected\n", i, argv[i]);
248 printf(
"monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
257 if ( (event->eventType != physicsEvent) && (event->eventType != calibrationEvent) )
262 runNb =
event->eventRunNb;
264 calibPedestal.ProcessEvent(event);
274 calibPedestal.Analyse();
275 calibPedestal.AnalyseTime(nevents);
276 printf (
"%d physics/calibration events processed.\n",nevents);
278 TFile *fileTPC =
new TFile(
RESULT_FILE,
"recreate");
279 calibPedestal.Write(
"tpcCalibPedestal");
293 const char *amoreDANameorig=gSystem->Getenv(
"AMORE_DA_NAME");
305 for ( Int_t roc = 0; roc < 72; roc++ ) {
306 if ( !calibPedestal.GetCalRocPedestal(roc) )
continue;
311 gSystem->Setenv(
"AMORE_DA_NAME",Form(
"%s-%s",gSystem->Getenv(
"DATE_ROLE_NAME"),
FILE_ID));
317 TObjString
info(Form(
"Run: %u; Date: %s",runNb,time.AsSQLString()));
319 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
321 statusDA+=amoreDA.Send(
"Pedestals",calibPedestal.GetCalPadPedestal());
322 statusDA+=amoreDA.Send(
"Noise",calibPedestal.GetCalPadRMS());
323 statusDA+=amoreDA.Send(
"Info",&info);
325 printf(
"Warning: Failed to write one of the calib objects to the AMORE database\n");
327 printf(
"Warning: No data found!\n");
330 if (amoreDANameorig) gSystem->Setenv(
"AMORE_DA_NAME",amoreDANameorig);
339 ofstream noisychannelfile;
340 ofstream verynoisychannelfile;
341 ofstream deadchannelfile;
350 TArrayF **timePed = calibPedestal.GetTimePedestals();
352 Int_t ctr_channel = 0;
354 Int_t ctr_pattern = 0;
356 Int_t ctr_vnoisy = 0;
359 pedfile << 10 << std::endl;
360 noisefile << 11 << std::endl;
361 pedmemfile << 12 << std::endl;
362 noisychannelfile << 14 << std::endl;
363 verynoisychannelfile << 14 << std::endl;
364 deadchannelfile << 14 << std::endl;
368 for ( Int_t roc = 0; roc < 72; roc++ ) {
369 if ( !calibPedestal.GetCalRocPedestal(roc) )
continue;
370 bool isIROC = mapping->
IsIROC(roc);
373 Int_t minrcu, maxrcu;
374 if ( isIROC ) { minrcu=0; maxrcu=1; }
377 else { minrcu=2; maxrcu=5; }
378 for (
int rcu = minrcu; rcu <= maxrcu; rcu++ ) {
380 for (
int branch = 0; branch < 2; branch++ ) {
381 for (
int fec = 0; fec < mapping->
GetNfec(rcu, branch); fec++ ) {
382 for (
int altro = 0; altro < 8; altro++ ) {
385 Float_t ctr_altrochannel = 0.;
386 for (
int channel = 0; channel < 16; channel++ ) {
387 Int_t hwadd = mapping->
CodeHWAddress(branch, fec, altro, channel);
388 Int_t row = mapping->
GetPadRow(rcu, hwadd);
390 Int_t pad = mapping->
GetPad(rcu, hwadd);
391 Float_t ped = calibPedestal.GetCalRocPedestal(roc)->GetValue(row,pad);
393 pedfile << ctr_channel++ <<
"\t" << side <<
"\t" << sector <<
"\t" << rcu <<
"\t" 394 << hwadd <<
"\t" << ped << std::endl;
396 if ( timePed && fabs(timePed[globalrow][pad].GetSum()) > 1e-10 ) {
397 pedmemfile << ctr_pattern++ <<
"\t" << side <<
"\t" << sector <<
"\t" << rcu
399 for ( Int_t timebin = 0; timebin < 1024; timebin++ )
400 pedmemfile <<
"\t" << timePed[globalrow][pad].At(timebin);
401 pedmemfile << std::endl;
404 Float_t rms2 = calibPedestal.GetCalRocRMS(roc)->GetValue(row,pad);
405 if ( fabs(ped) < 1.e-10 ) {
406 deadchannelfile << ctr_dead++ <<
"\t" << side <<
"\t" << sector <<
"\t" 407 << rcu <<
"\t" << hwadd <<
"\t" << rms2 << std::endl;
408 }
else if ( (ped > 1.e-10) && (rms2 > 1.e-10) ) {
411 verynoisychannelfile << ctr_vnoisy++ <<
"\t" << side <<
"\t" << sector <<
"\t" 412 << rcu <<
"\t" << hwadd <<
"\t" << rms2 << std::endl;
414 }
else if ( ((roc<36) && (rms2 > 2.0)) ||
415 ((roc>35) && (row<65) && (rms2 > 2.0)) ||
416 ((roc>35) && (row>64) && (rms2 > 3.0)) ) {
417 noisychannelfile << ctr_noisy++ <<
"\t" << side <<
"\t" << sector <<
"\t" 418 << rcu <<
"\t" << hwadd <<
"\t" << rms2 << std::endl;
422 ctr_altrochannel += 1.;
423 if (rms2 > maxrms) maxrms = rms2;
429 if ( ctr_altrochannel > 1.e-10 ) {
436 noisefile << ctr_altro <<
"\t" << side <<
"\t" << sector <<
"\t" << rcu <<
"\t" 437 << hwadd <<
"\t" << maxrms << std::endl;
449 noisychannelfile.close();
450 verynoisychannelfile.close();
451 deadchannelfile.close();
452 printf(
"Wrote ASCII files. Found %d noisy, %d very noisy and %d dead channels.\n", ctr_noisy, ctr_vnoisy, ctr_dead);
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Bool_t IsIROC(Int_t roc) const
Int_t GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
static void SetClassDebugLevel(const char *className, Int_t level)
const TMap * GetConfigurationMap() const
Implementation of the TPC pedestal calibration.
Int_t GetPad(Int_t patch, Int_t hwAddress) const
Int_t GetNfec(Int_t patch, Int_t branch) const
Int_t CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
int main(int argc, char **argv)
Float_t GetValue(const char *name) const
Int_t GetPadRow(Int_t patch, Int_t hwAddress) const
static void SetModuleDebugLevel(const char *module, Int_t level)
Int_t GetSectorFromRoc(Int_t roc) const
Class for Parsing simple text configuration files.
Int_t GetSideFromRoc(Int_t roc) const
AliTPCAltroMapping ** GetAltroMapping()
void SetAltroMapping(AliTPCAltroMapping **mapp)