42 #define RESULT_FILE "tpcPulser.root" 43 #define FILE_ID "pulser" 44 #define MAPPING_FILE "tpcMapping.root" 45 #define CONFIG_FILE "TPCPULSERda.conf" 46 #define Q_FILE "tpcPulserQ.data" 47 #define DEAD_FILE "tpcDeadChannelsPulser.data" 48 #define AliDebugLevel() -1 62 #include "TPluginManager.h" 64 #include "TObjString.h" 69 #include "AliRawReader.h" 70 #include "AliRawReaderDate.h" 90 int main(
int argc,
char **argv) {
95 printf(
"TPC Pulser DA started - %s\n",__FILE__);
98 printf(
"Wrong number of arguments\n");
106 gROOT->GetPluginManager()->AddHandler(
"TVirtualStreamerInfo",
129 status=monitorDeclareMp( __FILE__ );
131 printf(
"monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
138 unsigned long32 runNb=0;
147 printf(
"Failed to get mapping file (%s) from DAQdetDB, status=%d\n",
MAPPING_FILE, status);
153 mapping = (
AliTPCmapper*) fileMapping->Get(
"tpcMapping");
171 printf(
"Failed to get configuration file (%s) from DAQdetDB, status=%d\n",
CONFIG_FILE, status);
176 Bool_t skipAmore=kFALSE;
180 skipAmore=((TObjString*)config.
GetConfigurationMap()->GetValue(
"SkipAmore"))->GetString().Atoi();
181 printf(
"TPCPULSERda: Skip Amore set in config\n");
192 for(i=1;i<argc;i++) {
195 printf(
"Processing file %s\n", argv[i]);
196 status=monitorSetDataSource( argv[i] );
198 printf(
"monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
204 struct eventHeaderStruct *event;
207 if (daqDA_checkShutdown()) {
break;}
210 status=monitorGetEventDynamic((
void **)&event);
211 if (status==MON_ERR_EOF) {
212 printf (
"End of File %d detected\n",i);
217 printf(
"monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
227 runNb =
event->eventRunNb;
229 calibPulser.ProcessEvent(event);
239 calibPulser.Analyse();
240 printf (
"%d events processed\n",nevents);
242 TFile * fileTPC =
new TFile (
RESULT_FILE,
"recreate");
243 calibPulser.Write(
"tpcCalibPulser");
258 const char *amoreDANameorig=gSystem->Getenv(
"AMORE_DA_NAME");
270 for ( Int_t roc = 0; roc < 72; roc++ ) {
271 if ( !calibPulser.GetCalRocT0(roc) )
continue;
276 gSystem->Setenv(
"AMORE_DA_NAME",Form(
"%s-%s", gSystem->Getenv(
"DATE_ROLE_NAME"),
FILE_ID));
281 TObjString
info(Form(
"Run: %u; Date: %s",runNb,time.AsSQLString()));
283 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
285 statusDA+=amoreDA.Send(
"PulserT0",calibPulser.GetCalPadT0());
286 statusDA+=amoreDA.Send(
"PulserQ",calibPulser.GetCalPadQ());
287 statusDA+=amoreDA.Send(
"PulserRMS",calibPulser.GetCalPadRMS());
288 statusDA+=amoreDA.Send(
"arrayTmean",calibPulser.GetMeanTimeSectorArray());
289 statusDA+=amoreDA.Send(
"Info",&info);
291 printf(
"Waring: Failed to write one of the calib objects to the AMORE database\n");
293 printf(
"Waring: No data found!\n");
296 if (amoreDANameorig) gSystem->Setenv(
"AMORE_DA_NAME",amoreDANameorig);
302 ofstream deadchannelfile;
308 qfile << 19 << std::endl;
309 deadchannelfile << 14 << std::endl;
311 Int_t ctr_channel = 0;
316 for ( Int_t roc = 0; roc < 72; roc++ ) {
317 if ( !calibPulser.GetCalRocQ(roc) )
continue;
318 bool isIROC= mapping->
IsIROC(roc);
321 Int_t minrcu, maxrcu;
322 if( isIROC ) { minrcu=0; maxrcu=1; }
325 else { minrcu=2; maxrcu=5; }
326 for (
int rcu = minrcu; rcu <= maxrcu; rcu++ ) {
328 for (
int branch = 0; branch < 2; branch++ ) {
329 for (
int fec = 0; fec < mapping->
GetNfec(rcu, branch); fec++ ) {
330 for (
int altro = 0; altro < 8; altro++ ) {
331 for (
int channel = 0; channel < 16; channel++ ) {
332 Int_t hwadd = mapping->
CodeHWAddress(branch, fec, altro, channel);
333 Int_t row = mapping->
GetPadRow(rcu, hwadd);
335 Int_t pad = mapping->
GetPad(rcu, hwadd);
337 if ( (pad<1) || (pad>mapping->
GetNpads(globalrow)-2) )
continue;
338 Float_t Q = calibPulser.GetCalRocQ(roc)->GetValue(row,pad);
339 qfile << ctr_channel++ <<
"\t" << side <<
"\t" << sec <<
"\t" << rcu <<
"\t" << hwadd <<
"\t" << Q << std::endl;
341 deadchannelfile << ctr_dead++ <<
"\t" << side <<
"\t" << sec <<
"\t" 342 << rcu <<
"\t" << hwadd <<
"\t" << Q << std::endl;
352 deadchannelfile.close();
354 printf(
"Wrote ASCII file. Found %d dead channels.\n", 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
Int_t GetNpads(Int_t roc, Int_t padrow) const
static void SetClassDebugLevel(const char *className, Int_t level)
const TMap * GetConfigurationMap() const
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
Implementation of the TPC pulser calibration.
Int_t GetPadRow(Int_t patch, Int_t hwAddress) const
static void SetModuleDebugLevel(const char *module, Int_t level)
int main(int argc, char **argv)
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)