20 #include "AliCodeTimer.h"
22 #include "AliHeader.h"
35 #include "AliRawDataHeaderSim.h"
36 #include "AliLoader.h"
37 #include "AliRunLoader.h"
38 #include <TClonesArray.h>
42 #include <TStopwatch.h>
87 fDateFileName(filename),
88 fGAliceFileName("galice.root"),
91 fPedestals(fCalibrationData->Pedestals()),
100 if (!gSystem->IsAbsoluteFileName(fGAliceFileName))
102 char* absFileName = gSystem->ConcatFileName(gSystem->WorkingDirectory(),
104 fGAliceFileName = absFileName;
105 delete[] absFileName;
108 AliRunLoader* runLoader = LoadRun(
"recreate");
111 AliError(
"Could not create RunLoader");
115 runLoader->SetNumberOfEventsPerFile(nevents);
118 runLoader->MakeTree(
"E");
120 for ( Int_t iEvent = 0; iEvent < nevents; ++iEvent )
122 runLoader->SetEventNumber(iEvent);
123 runLoader->GetHeader()->Reset(runNumber,iEvent);
124 runLoader->TreeE()->Fill();
126 runLoader->WriteHeader(
"OVERWRITE");
127 runLoader->CdGAFile();
128 runLoader->Write(0, TObject::kOverwrite);
140 AliInfo(Form(
"make a digit counter %d",
fgCounter));
152 AliCodeTimerAuto(
"",0)
154 AliInfo(
"Converting raw to date");
156 const Int_t kIDet = AliDAQ::DetectorID(
"MUONTRK");
158 const Int_t kNLDCs = 5;
160 char* path = gSystem->Which(gSystem->Getenv(
"PATH"),
"dateStream");
163 AliError(
"the program dateStream was not found");
169 AliRunLoader* runLoader =
LoadRun(
"read");
170 if (!runLoader)
return kFALSE;
172 AliInfo(Form(
"converting raw data DDL files to DATE files %s",
fDateFileName.Data()));
173 FILE** pipe =
new FILE*[kNLDCs];
175 for ( Int_t iFile = 0; iFile < kNLDCs; ++iFile)
180 snprintf(command, 256,
"dateStream -c -D -o %s.LDC%d -# %d -C",
181 fDateFileName.Data(), iFile, runLoader->GetNumberOfEvents());
182 pipe[iFile] = gSystem->OpenPipe(command,
"w");
185 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); ++iEvent)
190 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls(kIDet); ++iDDL)
192 Int_t ddlID = AliDAQ::DdlID(kIDet,iDDL);
193 Int_t ldcID = Int_t(ldc + 0.0001);
194 ldc += AliDAQ::NumberOfLdcs(kIDet) / AliDAQ::NumberOfDdls(kIDet);
196 char rawFileName[256];
197 snprintf(rawFileName, 256,
"raw%d/%s",
198 iEvent, AliDAQ::DdlFileName(kIDet,iDDL));
201 FILE* file = fopen(rawFileName,
"rb");
203 fseek(file, 0, SEEK_END);
204 unsigned long size = ftell(file);
208 if (ldcID != prevLDC) {
209 fprintf(pipe[ldcID],
" LDC Id %d\n", ldcID);
212 fprintf(pipe[ldcID],
" Equipment Id %d Payload %s\n", ddlID, rawFileName);
218 for ( Int_t iFile = 0; iFile < kNLDCs; ++iFile)
220 result += gSystem->ClosePipe(pipe[iFile]);
223 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); ++iEvent)
226 snprintf(command, 256,
"rm -r raw%d", iEvent);
227 gSystem->Exec(command);
233 return (result == 0);
252 AliCodeTimerAuto(
"",0)
256 AliError(
"No pedestal store. Cannot proceed.");
260 AliRunLoader* runLoader =
LoadRun(
"update");
262 Int_t nevents = runLoader->GetNumberOfEvents();
264 for ( Int_t i = 0; i < nevents ; ++i )
266 runLoader->GetEvent(i);
268 fLoader->MakeDigitsContainer();
269 TTree* treeD =
fLoader->TreeD();
272 AliError(Form(
"Could not get TreeD for event %d",i));
288 AliCodeTimerStart(
"WriteDigits")
289 fLoader->WriteDigits(
"OVERWRITE");
290 AliCodeTimerStop(
"WriteDigits")
296 AliCodeTimerAuto(
"Digits2Raw",1);
301 runLoader->WriteRunLoader(
"OVERWRITE");
308 AliCodeTimerAuto(
"ConvertRawFilesToDate",1)
312 AliError(
"DATE output failed. Exiting.");
324 AliCodeTimerAuto(
"",0)
328 AliRawDataHeaderSim header;
336 TString
baseDir = gSystem->WorkingDirectory();
339 snprintf(dirName, 256,
"raw%d", event);
340 gSystem->MakeDirectory(dirName);
341 if (!gSystem->ChangeDirectory(dirName))
343 AliError(Form(
"couldn't change to directory %s", dirName));
349 gSystem->ChangeDirectory(baseDir);
359 AliCodeTimerAuto(
"",0)
368 while ( ( pedestals = static_cast<AliMUONVCalibParam*>(next())) )
370 Int_t detElemId = pedestals->
ID0();
371 Int_t manuId = pedestals->ID1();
383 for ( Int_t manuChannel = 0; manuChannel < pedestals->Size(); ++manuChannel )
385 Float_t mean = pedestals->ValueAsFloat(manuChannel,0);
393 else if ( mean < 1 || mean > 4095 )
395 AliFatal(Form(
"Got an invalid mean pedestal value for DE %d Manu %d"
396 " channel %d : mean = %e",detElemId,manuId,manuChannel,
401 Float_t sigma = pedestals->ValueAsFloat(manuChannel,1);
405 AliWarning(Form(
"Got a negative sigma pedestal value for DE %d Manu %d"
406 " channel %d : sigma = %e, will use Abs()=%e",
407 detElemId,manuId,manuChannel,
419 ped = gRandom->Gaus(mean,sigma);
421 Int_t pedADC = TMath::FloorNint(ped);
433 AliDebug(1,Form(
"ngenerated=%d nmanus=%d",ngenerated,nmanus));
441 while (AliRunLoader::Instance())
443 AliDebug(1,Form(
"Deleting AliRunLoader %p",AliRunLoader::Instance()));
444 delete AliRunLoader::Instance();
447 AliRunLoader* runLoader =
451 AliDebug(1,Form(
"AliRunLoader(%s)=%p",mode,runLoader));
455 AliError(
"No run loader found in file galice.root");
462 if (smode.Contains(
"RECREATE"))
464 AliInfo(
"Creating folder structure");
465 AliConfig::Instance()
466 ->CreateDetectorFolders(runLoader->GetEventFolder(),
468 fLoader =
new AliLoader(
"MUON",runLoader->GetEventFolder());
472 fLoader =
static_cast<AliLoader*
>(runLoader->GetDetectorLoader(
"MUON"));
virtual TIterator * CreateIterator() const =0
Return an iterator to loop over the whole store.
TFile * Open(const char *filename, Long64_t &nevents)
AliMUONCalibrationData * fCalibrationData
! access to pedestal CDB
static Float_t InvalidFloatValue()
Return 1E38 as invalid float value.
Generate pedestal events (only for tracker).
static AliMpDEStore * Instance(Bool_t warn=true)
Interface for a digit container.
static Int_t fgCounter
! counter
AliRunLoader * LoadRun(const char *mode)
AliLoader * fLoader
! to access trees
Bool_t fMakeDDL
! whether to generate DDL ascii files or not
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
The class defines the electronics properties of detection element.
virtual void SetCharge(Float_t q)=0
Set the charge of this digit.
AliMUONVDigitStore * DigitStore()
AliMUONRawWriter * fRawWriter
! to convert digits to raw data
Container of calibration values for a given number of channels.
Int_t Digits2Raw(const AliMUONVDigitStore *digitStore, const AliMUONVTriggerStore *triggerStore)
void GenerateDigits(AliMUONVDigitStore &digitStore)
virtual AliMUONVDigitStore * Create() const =0
Create an (empty) object of the same concrete class as *this.
virtual void SetADC(Int_t adc)=0
Set the ADC value.
void Digits2Raw(Int_t event)
virtual Int_t ID0() const
First id of this object.
AliMUONVDigitStore * fDigitStore
! digit container
void Exec(Option_t *option)
AliMUONVStore * fPedestals
! pedestals
Raw data class for trigger and tracker chambers.
virtual ~AliMUONPedestalEventGenerator()
Single entry point to access MUON calibration data.
AliMp::CathodType GetCathodType(AliMp::PlaneType planeType) const
Bool_t ConvertRawFilesToDate()
void SetHeader(AliRawDataHeaderSim &header)
Set the header of DDL.
TString fGAliceFileName
! absolute path to galice.root file
virtual void Clear(Option_t *opt="")=0
Clear ourselves (i.e. Reset)
TString fDateFileName
! basefilename of the DATE output file
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)
static Int_t ManuMask(AliMp::PlaneType planeType)
virtual Bool_t Add(TObject *object)
Add an object, if it is of the right class.