// //
///////////////////////////////////////////////////////////////////////////////
+#include <TGeoManager.h>
+#include <TGeoShape.h>
+#include <TGeoNode.h>
+#include <TGeoMatrix.h>
+#include <TGeoPhysicalNode.h>
#include <TObjString.h>
#include <TStopwatch.h>
#include <TSystem.h>
-#include "AliLog.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliAlignObj.h"
+#include "AliCentralTrigger.h"
+#include "AliDAQConfig.h"
#include "AliDigitizer.h"
#include "AliGenerator.h"
+#include "AliLog.h"
#include "AliModule.h"
#include "AliRun.h"
#include "AliRunDigitizer.h"
#include "AliRunLoader.h"
#include "AliSimulation.h"
#include "AliVertexGenFile.h"
+#include "AliCentralTrigger.h"
ClassImp(AliSimulation)
fRunSimulation(kTRUE),
fMakeSDigits("ALL"),
fMakeDigits("ALL"),
+ fMakeTrigger(""),
fMakeDigitsFromHits(""),
fWriteRawData(""),
fRawDataFileName(""),
fRunSimulation(sim.fRunSimulation),
fMakeSDigits(sim.fMakeSDigits),
fMakeDigits(sim.fMakeDigits),
+ fMakeTrigger(sim.fMakeTrigger),
fMakeDigitsFromHits(sim.fMakeDigitsFromHits),
fWriteRawData(sim.fWriteRawData),
fRawDataFileName(""),
fEventsPerFile.Add(obj);
}
+//_____________________________________________________________________________
+Bool_t AliSimulation::ApplyDisplacements(const char* fileName, const char* ClArrayName)
+{
+ // read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray ClArrayName in the file fileName and apply
+ // them to the TGeo geometry passed as argument
+ //
+
+ TFile* inFile = TFile::Open(fileName,"READ");
+ if (!inFile || !inFile->IsOpen()) {
+ AliErrorClass(Form("Could not open file %s !",fileName));
+ return kFALSE;
+ }
+
+ TClonesArray* AlObjArray = ((TClonesArray*) inFile->Get(ClArrayName));
+ inFile->Close();
+
+ return AliSimulation::ApplyDisplacements(AlObjArray);
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliSimulation::ApplyDisplacements(TClonesArray* AlObjArray)
+{
+ // Read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray ClArrayName and apply them to the geometry
+ // manager singleton.
+ //
+ Int_t nvols = AlObjArray->GetEntriesFast();
+
+ AliAlignObj::ELayerID layerId; // unique identity for volume in the alobj
+ Int_t modId; // unique identity for volume in the alobj
+ Bool_t ispathvalid; // false if volume path for alobj is not valid for TGeo
+
+ TGeoHMatrix dm;
+
+ for(Int_t j=0; j<nvols; j++)
+ {
+ AliAlignObj* alobj = (AliAlignObj*) AlObjArray->UncheckedAt(j);
+ const char* volpath = alobj->GetVolPath();
+ TGeoPhysicalNode* node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(volpath);
+ alobj->GetMatrix(dm);
+ alobj->GetVolUID(layerId, modId);
+ ispathvalid = gGeoManager->cd(volpath);
+ if(!ispathvalid){
+ AliWarningClass(Form("Volume path %s not valid!",volpath));
+ return kFALSE;
+ }
+ TGeoHMatrix* hm = gGeoManager->GetCurrentMatrix();
+ hm->MultiplyLeft(&dm);
+ AliInfoClass(Form("Aligning volume %s of detector layer %d with local ID %d",volpath,layerId,modId));
+ node->Align(hm);
+ }
+
+ return kTRUE;
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliSimulation::ApplyDisplacements(AliCDBParam* param, AliCDBId& Id)
+{
+ // read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray ClArrayName in the AliCDBEntry identified by
+ // param (to get the AliCDBStorage) and Id; apply the alignment objects
+ // to the TGeo geometry passed as argument
+ //
+
+ AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage(param);
+ AliCDBEntry* entry = storage->Get(Id);
+ TClonesArray* AlObjArray = ((TClonesArray*) entry->GetObject());
+
+ return AliSimulation::ApplyDisplacements(AlObjArray);
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliSimulation::ApplyDisplacements(const char* uri, const char* path, Int_t runnum, Int_t version, Int_t sversion)
+{
+ // read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray ClArrayName in the AliCDBEntry identified by
+ // param (to get the AliCDBStorage) and Id; apply the alignment objects
+ // to the TGeo geometry passed as argument
+ //
+
+ AliCDBParam* param = AliCDBManager::Instance()->CreateParameter(uri);
+ AliCDBId id(path, runnum, runnum, version, sversion);
+
+ return ApplyDisplacements(param, id);
+
+}
+
//_____________________________________________________________________________
void AliSimulation::MergeWith(const char* fileName, Int_t nSignalPerBkgrd)
{
}
}
+ // digits -> trigger
+ if (!fMakeTrigger.IsNull()) {
+ if (!RunTrigger(fMakeTrigger)) {
+ if (fStopOnError) return kFALSE;
+ }
+ }
+
// digits -> raw data
if (!fWriteRawData.IsNull()) {
if (!WriteRawData(fWriteRawData, fRawDataFileName,
return kTRUE;
}
+//_____________________________________________________________________________
+Bool_t AliSimulation::RunTrigger(const char* descriptors)
+{
+ // run the trigger
+
+ TStopwatch stopwatch;
+ stopwatch.Start();
+
+ AliRunLoader* runLoader = LoadRun("READ");
+ if (!runLoader) return kFALSE;
+ TString des = descriptors;
+ // Load Descriptors
+ AliCentralTrigger* aCTP = new AliCentralTrigger( des );
+
+ // digits -> trigger
+ if( !aCTP->RunTrigger( runLoader ) ) {
+ if (fStopOnError) {
+ delete aCTP;
+ return kFALSE;
+ }
+ }
+
+/*
+ // Process each event
+ for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
+ AliInfo(Form("processing event %d", iEvent));
+ runLoader->GetEvent(iEvent);
+
+ TObjArray* detArray = runLoader->GetAliRun()->Detectors();
+ for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) {
+ AliModule* det = (AliModule*) detArray->At(iDet);
+ if (!det || !det->IsActive()) continue;
+ if (IsSelected(det->GetName(), detStr)) {
+ AliInfo(Form("triggering from digits for %s", det->GetName()));
+
+ // AliLoader* loader = fLoader[iDet];
+ // loader->LoadDigits("read");
+ // TTree* digitsTree = loader->TreeD();
+ // det->Trigger( digitsTree );
+ // or
+ AliTriggerDetector* tdet = det->CreateTriggerDetector();
+ TObjArray* detInp = dtrg->GetTriggerInputs();
+ for( Int_t i=0; i<detInp->GetEntriesFast(); i++ )
+ fInputs.AddLast( detInp->At(i) );
+
+ AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs",
+ det->GetName(),stopwatchDet.RealTime(),stopwatchDet.CpuTime()));
+ }
+ }
+
+ if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
+ AliError(Form("the following detectors were not found: %s",
+ detStr.Data()));
+ if (fStopOnError) {
+ delete centralTP;
+ return kFALSE;
+ }
+ }
+
+ // Check trigger conditions
+ centralTP->TriggerConditions();
+
+ // Write trigger ????
+ centralTP->Write();
+
+ } */
+
+ AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
+
+ delete aCTP;
+ delete runLoader;
+
+ return kTRUE;
+}
+
+
+
//_____________________________________________________________________________
Bool_t AliSimulation::RunSimulation(Int_t nEvents)
{
delete runLoader;
- AliInfo("execution time:");
- StdoutToAliInfo(stopwatch.Print(););
+ AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
return kTRUE;
}
TStopwatch stopwatchDet;
stopwatchDet.Start();
det->Hits2SDigits();
- AliInfo(Form("execution time for %s:", det->GetName()));
- StdoutToAliInfo(stopwatchDet.Print(););
+ AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs",
+ det->GetName(),stopwatchDet.RealTime(),stopwatchDet.CpuTime()));
}
}
delete runLoader;
- AliInfo("execution time:");
- StdoutToAliInfo(stopwatch.Print(););
+ AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
return kTRUE;
}
delete manager;
- AliInfo("execution time:");
- StdoutToAliInfo(stopwatch.Print(););
-
+ AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
+
return kTRUE;
}
TStopwatch stopwatch;
stopwatch.Start();
- AliRunLoader* runLoader = LoadRun();
+ AliRunLoader* runLoader = LoadRun("READ");
if (!runLoader) return kFALSE;
TString detStr = detectors;
}
delete runLoader;
+ //PH Temporary fix to avoid interference with the PHOS loder/getter
+ //PH The problem has to be solved in more general way 09/06/05
- AliInfo("execution time:");
- StdoutToAliInfo(stopwatch.Print(););
+ AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
return kTRUE;
}
}
}
- AliInfo("execution time:");
- StdoutToAliInfo(stopwatch.Print(););
+ AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
return kTRUE;
}
{
// convert raw data DDL files to a DATE file with the program "dateStream"
- // DATE setup
- const Int_t kNDetectors = 17;
- const char* kDetectors[kNDetectors] = {"TPC", "ITSSPD", "ITSSDD", "ITSSSD",
- "TRD", "TOF", "PHOS", "RICH",
- "EMCAL", "MUON", "MUTR", "ZDC",
- "PMD", "START", "VZERO", "CRT",
- "FMD"};
- const Int_t kDetectorDDLs[kNDetectors] = {216, 20, 12, 16,
- 18, 72, 20, 20,
- 22, 20, 2, 1,
- 6, 1, 1, 1,
- 3};
- const Float_t kDetectorLDCs[kNDetectors] = {46, 2, 2, 1,
- 4, 2, 1, 2,
- 1, 2, 1, 1,
- 1, 0.5, 0.5, 1,
- 1};
-
char* path = gSystem->Which(gSystem->Getenv("PATH"), "dateStream");
if (!path) {
AliError("the program dateStream was not found");
if (!file) continue;
fseek(file, 0, SEEK_END);
unsigned long size = ftell(file);
- fseek(file, 0, SEEK_SET);
- if (!size) {
- fclose(file);
- continue;
- }
+ fclose(file);
+ if (!size) continue;
if (ldcID != prevLDC) {
fprintf(pipe, " LDC Id %d\n", ldcID);
// ALIMDC setup
const Int_t kDBSize = 1000000000;
+ const Int_t kTagDBSize = 1000000000;
const Bool_t kFilter = kFALSE;
const Int_t kCompression = 1;
gSystem->Exec("rm -rf /tmp/mdc1");
gSystem->Exec("rm -rf /tmp/mdc2");
+
+ gSystem->Exec("mkdir /tmp/mdc1");
+ gSystem->Exec("mkdir /tmp/mdc2");
+
char command[256];
- sprintf(command, "alimdc %d %d %d %s",
- kDBSize, kFilter, kCompression, dateFileName);
+ sprintf(command, "alimdc %d %d %d %d %s",
+ kDBSize, kTagDBSize, kFilter, kCompression, dateFileName);
Int_t result = gSystem->Exec(command);
sprintf(command, "mv /tmp/mdc1/*.root %s", rootFileName);
gSystem->Exec(command);