Coverity fix.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSSurvey1.cxx
CommitLineData
42c5218a 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15/* $Id$ */
16
17/* History of cvs commits:
18 *
19 * $Log$
d7a07f57 20 * Revision 1.1 2007/07/10 12:41:38 kharlov
21 * Added a new class AliPHOSSurvet1 which read survey data from EDMS files
22 *
42c5218a 23 */
24
d7a07f57 25// AliPHOSSurvey1 class is survey "reader" class, based on AliSurveyObj class.
26// The first ctor parameter is a survey file's name.
27// Now it's a "local" file, later, when AliSurveyObj will be modified,
28// survey files can be somewhere else.
29// The second parameter is a prefix, for example "T1_" or "T2_", it's used to select
30// survey (T1_ == data from 08.09.2006 and T2_ == data from 11.09.2006).
31// The survey data is available from http://dcdb.cern.ch/surveydepot-production/
32//!
33// Author: Timur Pocheptsov
34
42c5218a 35#include "AliSurveyPoint.h"
36#include "AliSurveyObj.h"
37
38#include "AliPHOSEMCAGeometry.h"
39#include "AliPHOSGeometry.h"
40#include "AliPHOSSurvey1.h"
41#include "AliLog.h"
42
43ClassImp(AliPHOSSurvey1)
44
45//____________________________________________________________________________
46AliPHOSSurvey1::AliPHOSSurvey1(const TString &fileName, const TString &namePrefix)
47{
d7a07f57 48 // AliPHOSSurvey1 ctor. Creates AliSurveyObj, which reads data from EDMS,
49 // convert this data (a set of AliSurveyPoint objects) into translations
50 // and rotations from strips.
51
42c5218a 52 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
53 if (!phosGeom) {
54 AliError("Cannot obtain AliPHOSGeometry instance.");
55 return;
56 }
57
58 AliSurveyObj survey;
59 survey.FillFromLocalFile(fileName);
60
61 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
62 fStrNum = emcaGeom->GetNStripX() * emcaGeom->GetNStripZ();
63
64 TObjArray *points = survey.GetData();
65 Int_t goodPoints = 0;
66 Int_t start = -1;
67 for (Int_t i = 0, e = points->GetEntries(); i < e; ++i) {
68 AliSurveyPoint *stripPoint = static_cast<AliSurveyPoint *>(points->At(i));
69 if (stripPoint->GetPointName().BeginsWith(namePrefix)) {
70 ++goodPoints;
71 if (start == -1)
72 start = i;
73 }
74 }
75
76 if (goodPoints != kNumberOfPoints) {
77 AliError("Wrong number of points with prefix" + namePrefix);
78 return;
79 }
80
81 Double_t *xReal = new Double_t[fStrNum * 2];//1
82 Double_t *zReal = new Double_t[fStrNum * 2];//2
83
84 for (Int_t i = 0; i < fStrNum * 2; ++i) {
85 AliSurveyPoint *stripPoint = static_cast<AliSurveyPoint *>(points->At(start + kStartingPoint + i));
86 xReal[i] = stripPoint->GetX() * 0.1;
87 zReal[i] = stripPoint->GetZ() * 0.1;
88 }
89
90 InitStripData(xReal, zReal);
91
92 delete [] zReal;//2
93 delete [] xReal;//1
94}
95
96//____________________________________________________________________________
97AliPHOSSurvey1::~AliPHOSSurvey1()
98{
99}