#include "AliDetectorTag.h"
#include "AliEventTag.h"
+#include "AliGeomManager.h"
#include "AliTrackPointArray.h"
#include "AliCDBManager.h"
#include "AliCDBEntry.h"
fOptions(),
fLoadAlignFromCDB(kTRUE),
fLoadAlignData("ALL"),
+ fESDPar(""),
fRunLoader(NULL),
fRawReader(NULL),
fOptions(),
fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
fLoadAlignData(rec.fLoadAlignData),
+ fESDPar(rec.fESDPar),
fRunLoader(NULL),
fRawReader(NULL),
}
+
+
+
//_____________________________________________________________________________
Bool_t AliReconstruction::SetRunNumber()
{
return kTRUE;
}
-//_____________________________________________________________________________
-Bool_t AliReconstruction::ApplyAlignObjsToGeom(TObjArray* alObjArray)
-{
- // Read collection of alignment objects (AliAlignObj derived) saved
- // in the TClonesArray ClArrayName and apply them to the geometry
- // manager singleton.
- //
- alObjArray->Sort();
- Int_t nvols = alObjArray->GetEntriesFast();
-
- Bool_t flag = kTRUE;
-
- for(Int_t j=0; j<nvols; j++)
- {
- AliAlignObj* alobj = (AliAlignObj*) alObjArray->UncheckedAt(j);
- if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
- }
-
- if (AliDebugLevelClass() >= 1) {
- gGeoManager->GetTopNode()->CheckOverlaps(20);
- TObjArray* ovexlist = gGeoManager->GetListOfOverlaps();
- if(ovexlist->GetEntriesFast()){
- AliError("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
- }
- }
-
- return flag;
-
-}
-
-//_____________________________________________________________________________
-Bool_t AliReconstruction::SetAlignObjArraySingleDet(const char* detName)
-{
- // Fills array of single detector's alignable objects from CDB
-
- AliDebug(2, Form("Loading alignment data for detector: %s",detName));
-
- AliCDBEntry *entry;
-
- AliCDBPath path(detName,"Align","Data");
-
- entry=AliCDBManager::Instance()->Get(path.GetPath());
- if(!entry){
- AliDebug(2,Form("Couldn't load alignment data for detector %s",detName));
- return kFALSE;
- }
- entry->SetOwner(1);
- TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
- alignArray->SetOwner(0);
- AliDebug(2,Form("Found %d alignment objects for %s",
- alignArray->GetEntries(),detName));
-
- AliAlignObj *alignObj=0;
- TIter iter(alignArray);
-
- // loop over align objects in detector
- while( ( alignObj=(AliAlignObj *) iter.Next() ) ){
- fAlignObjArray->Add(alignObj);
- }
- // delete entry --- Don't delete, it is cached!
-
- AliDebug(2, Form("fAlignObjArray entries: %d",fAlignObjArray->GetEntries() ));
- return kTRUE;
-
-}
-
//_____________________________________________________________________________
Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
{
// Load alignment data from CDB and fill fAlignObjArray
if(fLoadAlignFromCDB){
- if(!fAlignObjArray) fAlignObjArray = new TObjArray();
- //fAlignObjArray->RemoveAll();
- fAlignObjArray->Clear();
- fAlignObjArray->SetOwner(0);
-
- TString detStr = detectors;
- TString dataNotLoaded="";
- TString dataLoaded="";
-
- for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
- if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
- if(!SetAlignObjArraySingleDet(fgkDetectorName[iDet])){
- dataNotLoaded += fgkDetectorName[iDet];
- dataNotLoaded += " ";
- } else {
- dataLoaded += fgkDetectorName[iDet];
- dataLoaded += " ";
- }
- } // end loop over detectors
-
- if ((detStr.CompareTo("ALL") == 0)) detStr = "";
- dataNotLoaded += detStr;
- if(!dataLoaded.IsNull()) AliInfo(Form("Alignment data loaded for: %s",
- dataLoaded.Data()));
- if(!dataNotLoaded.IsNull()) AliInfo(Form("Didn't/couldn't load alignment data for: %s",
- dataNotLoaded.Data()));
- } // fLoadAlignFromCDB flag
-
- // Check if the array with alignment objects was
- // provided by the user. If yes, apply the objects
- // to the present TGeo geometry
- if (fAlignObjArray) {
- if (gGeoManager && gGeoManager->IsClosed()) {
- if (ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
- AliError("The misalignment of one or more volumes failed!"
- "Compare the list of simulated detectors and the list of detector alignment data!");
+ TString detStr = detectors;
+ TString loadAlObjsListOfDets = "";
+
+ for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+ if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
+ loadAlObjsListOfDets += fgkDetectorName[iDet];
+ loadAlObjsListOfDets += " ";
+ } // end loop over detectors
+ (AliGeomManager::Instance())->ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
+ }else{
+ // Check if the array with alignment objects was
+ // provided by the user. If yes, apply the objects
+ // to the present TGeo geometry
+ if (fAlignObjArray) {
+ if (gGeoManager && gGeoManager->IsClosed()) {
+ if ((AliGeomManager::Instance())->ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
+ AliError("The misalignment of one or more volumes failed!"
+ "Compare the list of simulated detectors and the list of detector alignment data!");
+ return kFALSE;
+ }
+ }
+ else {
+ AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
return kFALSE;
}
}
- else {
- AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
- return kFALSE;
- }
}
-
+
delete fAlignObjArray; fAlignObjArray=0;
// Update the TGeoPhysicalNodes
stopwatch.Start();
// get the possibly already existing ESD file and tree
- AliESD* esd = new AliESD; AliESD* hltesd = new AliESD;
+ AliESD* esd = new AliESD(); AliESD* hltesd = new AliESD();
TFile* fileOld = NULL;
TTree* treeOld = NULL; TTree *hlttreeOld = NULL;
if (!gSystem->AccessPathName("AliESDs.root")){
fileOld = TFile::Open("AliESDs.old.root");
if (fileOld && fileOld->IsOpen()) {
treeOld = (TTree*) fileOld->Get("esdTree");
- if (treeOld) treeOld->SetBranchAddress("ESD", &esd);
+ if (treeOld)esd->ReadFromTree(treeOld);
hlttreeOld = (TTree*) fileOld->Get("HLTesdTree");
- if (hlttreeOld) hlttreeOld->SetBranchAddress("ESD", &hltesd);
+ if (hlttreeOld) hltesd->ReadFromTree(hlttreeOld);
}
}
// create the ESD output file and tree
TFile* file = TFile::Open("AliESDs.root", "RECREATE");
+ file->SetCompressionLevel(2);
if (!file->IsOpen()) {
AliError("opening AliESDs.root failed");
if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;}
}
+
TTree* tree = new TTree("esdTree", "Tree with ESD objects");
- tree->Branch("ESD", "AliESD", &esd);
+ esd = new AliESD();
+ esd->CreateStdContent();
+ esd->WriteToTree(tree);
+
TTree* hlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
- hlttree->Branch("ESD", "AliESD", &hltesd);
+ hltesd = new AliESD();
+ hltesd->CreateStdContent();
+ hltesd->WriteToTree(hlttree);
+
+ /* CKB Why?
delete esd; delete hltesd;
esd = NULL; hltesd = NULL;
-
+ */
// create the branch with ESD additions
- AliESDfriend *esdf=0;
+ AliESDfriend *esdf = 0;
if (fWriteESDfriend) {
- TBranch *br=tree->Branch("ESDfriend.", "AliESDfriend", &esdf);
- br->SetFile("AliESDfriends.root");
+ esdf = new AliESDfriend();
+ TBranch *br=tree->Branch("ESDfriend.","AliESDfriend", &esdf);
+ br->SetFile("AliESDfriends.root");
+ esd->AddObject(esdf);
}
-
+
// Get the diamond profile from OCDB
AliCDBEntry* entry = AliCDBManager::Instance()
->Get("GRP/Calib/MeanVertex");
if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
// copy old ESD to the new one
if (treeOld) {
- treeOld->SetBranchAddress("ESD", &esd);
+ esd->ReadFromTree(treeOld);
treeOld->GetEntry(iEvent);
}
tree->Fill();
if (hlttreeOld) {
- hlttreeOld->SetBranchAddress("ESD", &hltesd);
+ esd->ReadFromTree(hlttreeOld);
hlttreeOld->GetEntry(iEvent);
}
hlttree->Fill();
continue;
}
-
+
AliInfo(Form("processing event %d", iEvent));
fRunLoader->GetEvent(iEvent);
}
}
- esd = new AliESD; hltesd = new AliESD;
+
esd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
hltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
esd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
hltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
-
+
// Set magnetic field from the tracker
esd->SetMagneticField(AliTracker::GetBz());
hltesd->SetMagneticField(AliTracker::GetBz());
+
+
// Fill raw-data error log into the ESD
if (fRawReader) FillRawDataErrorLog(iEvent,esd);
}
//Try to improve the reconstructed primary vertex position using the tracks
- AliESDVertex *pvtx=tVertexer.FindPrimaryVertex(esd);
+ AliESDVertex *pvtx=0;
+ Bool_t dovertex=kTRUE;
+ TObject* obj = fOptions.FindObject("ITS");
+ if (obj) {
+ TString optITS = obj->GetTitle();
+ if (optITS.Contains("cosmics") || optITS.Contains("COSMICS"))
+ dovertex=kFALSE;
+ }
+ if(dovertex) pvtx=tVertexer.FindPrimaryVertex(esd);
if(fDiamondProfile) esd->SetDiamond(fDiamondProfile);
if (pvtx)
// write ESD
if (fWriteESDfriend) {
- esdf=new AliESDfriend();
- esd->GetESDfriend(esdf);
+ new (esdf) AliESDfriend(); // Reset...
+ esd->GetESDfriend(esdf);
}
tree->Fill();
hlttree->Fill();
if (fCheckPointLevel > 0) WriteESD(esd, "final");
-
- delete esd; delete esdf; delete hltesd;
- esd = NULL; esdf=NULL; hltesd = NULL;
+ esd->Reset();
+ hltesd->Reset();
+ // esdf->Reset();
+ // delete esdf; esdf = 0;
+ }
+
+
+ tree->GetUserInfo()->Add(esd);
+ hlttree->GetUserInfo()->Add(hltesd);
+
+
+
+ if(fESDPar.Contains("ESD.par")){
+ AliInfo("Attaching ESD.par to Tree");
+ TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par");
+ tree->GetUserInfo()->Add(fn);
}
+
AliInfo(Form("Execution time for filling ESD : R:%.2fs C:%.2fs",
stopwatch.RealTime(),stopwatch.CpuTime()));
aodFile->Close();
}
+ gROOT->cd();
// Create tags for the events in the ESD tree (the ESD tree is always present)
// In case of empty events the tags will contain dummy values
CreateTag(file);
- CleanUp(file, fileOld);
+
+ CleanUp(file, fileOld);
return kTRUE;
}
vertex->SetName("default");
}
else {
- vertex->SetTruePos(vtxPos); // store also the vertex from MC
vertex->SetName("reconstructed");
}
}
esd->SetVertex(vertex);
// if SPD multiplicity has been determined, it is stored in the ESD
- AliMultiplicity *mult= fVertexer->GetMultiplicity();
+ AliMultiplicity *mult = fVertexer->GetMultiplicity();
if(mult)esd->SetMultiplicity(mult);
for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
AliInfo("running tracking");
//Fill the ESD with the T0 info (will be used by the TOF)
- GetReconstructor(11)->FillESD(fRunLoader, esd);
+ if (fReconstructor[11])
+ GetReconstructor(11)->FillESD(fRunLoader, esd);
// pass 1: TPC + ITS inwards
for (Int_t iDet = 1; iDet >= 0; iDet--) {
// run tracking
if (fTracker[iDet]->PropagateBack(esd) != 0) {
AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
- return kFALSE;
+ // return kFALSE;
}
if (fCheckPointLevel > 1) {
WriteESD(esd, Form("%s.back", fgkDetectorName[iDet]));
// run tracking
if (fTracker[iDet]->RefitInward(esd) != 0) {
AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
- return kFALSE;
+ // return kFALSE;
}
if (fCheckPointLevel > 1) {
WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet]));
return ;
}
Int_t lastEvent = 0;
- TTree *t = (TTree*) file->Get("esdTree");
- TBranch * b = t->GetBranch("ESD");
- AliESD *esd = 0;
- b->SetAddress(&esd);
+ TTree *b = (TTree*) file->Get("esdTree");
+ AliESD *esd = new AliESD();
+ esd->ReadFromTree(b);
b->GetEntry(fFirstEvent);
Int_t iInitRunNumber = esd->GetRunNumber();
}
}
+
+TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString fName){
+ ifstream in;
+ in.open(fPath.Data(),ios::in | ios::binary|ios::ate);
+ Int_t kBytes = (Int_t)in.tellg();
+ printf("Size: %d \n",kBytes);
+ TNamed *fn = 0;
+ if(in.good()){
+ char* memblock = new char [kBytes];
+ in.seekg (0, ios::beg);
+ in.read (memblock, kBytes);
+ in.close();
+ TString fData(memblock,kBytes);
+ fn = new TNamed(fName,fData);
+ printf("fData Size: %d \n",fData.Sizeof());
+ printf("fName Size: %d \n",fName.Sizeof());
+ printf("fn Size: %d \n",fn->Sizeof());
+ delete[] memblock;
+ }
+ else{
+ AliInfo(Form("Could not Open %s\n",fPath.Data()));
+ }
+
+ return fn;
+}
+
+void AliReconstruction::TNamedToFile(TTree* fTree, TString fName){
+
+ // This is not really needed in AliReconstruction at the moment
+ // but can serve as a template
+
+ TList *fList = fTree->GetUserInfo();
+ TNamed *fn = (TNamed*)fList->FindObject(fName.Data());
+ printf("fn Size: %d \n",fn->Sizeof());
+
+ TString fTmp(fn->GetName()); // to be 100% sure in principle fName also works
+ const char* cdata = fn->GetTitle();
+ printf("fTmp Size %d\n",fTmp.Sizeof());
+
+ int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()...
+ printf("calculated size %d\n",size);
+ ofstream out(fName.Data(),ios::out | ios::binary);
+ out.write(cdata,size);
+ out.close();
+
+}
+