AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONAlignmentCompareDialog.cxx
Go to the documentation of this file.
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 
16 // $Id$
17 
19 
26 
27 #include "AliCDBManager.h"
28 #include "AliGeomManager.h"
29 #include "AliLog.h"
30 #include "AliMUON2DMap.h"
31 #include "AliMUONCalibParamND.h"
32 #include "AliMUONConstants.h"
35 #include "AliMUONTrackerData.h"
37 #include "AliMpConstants.h"
38 #include "AliMpDDLStore.h"
39 #include "AliMpDEIterator.h"
40 #include "AliMpDetElement.h"
41 #include "AliMpManuIterator.h"
42 #include "AliMpPad.h"
43 #include "AliMpSegmentation.h"
44 #include "AliMpVPadIterator.h"
45 #include "AliMpVSegmentation.h"
46 #include <TGComboBox.h>
47 #include <TGLabel.h>
48 #include <TGNumberEntry.h>
49 #include <TGTextEntry.h>
50 #include <TGeoManager.h>
51 #include <TTimer.h>
52 
56 
57 namespace
58 {
59 
60 #define PRECISION 1E-12
61 
62  Double_t Difference(Double_t v1, Double_t v2)
63  {
64  Double_t d = v1-v2;
65  return TMath::Abs(d) < PRECISION ? 0.0 : d;
66  }
67 }
68 
69 //_____________________________________________________________________________
70 AliMUONAlignmentCompareDialog::AliMUONAlignmentCompareDialog(const TGWindow* p, const TGWindow* main, UInt_t w, UInt_t h)
71 : TGTransientFrame(p,main,w,h),
72 fF1(new TGVerticalFrame(this)),
73 fOCDBPath1(0x0),
74 fRun1(0x0),
75 fF2(new TGVerticalFrame(this)),
76 fOCDBPath2(0x0),
77 fRun2(0x0),
78 fF3(new TGHorizontalFrame(this)),
79 fBasename(new TGTextEntry(fF3)),
80 fButtonFrame(new TGHorizontalFrame(this)),
81 fOK(new TGTextButton(fButtonFrame,"OK")),
82 fCancel(new TGTextButton(fButtonFrame,"Cancel"))
83 {
85 
86  SetCleanup(kDeepCleanup);
87 
88  AddInput(fF1,"First alignment",fOCDBPath1,fRun1);
89  AddInput(fF2,"Second alignment",fOCDBPath2,fRun2);
90 
91  fF3->AddFrame(new TGLabel(fF3,"Output basename"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
92  fF3->AddFrame(fBasename,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5));
93 
94  AddFrame(fF1,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
95  AddFrame(fF2,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
96  AddFrame(fF3,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
97 
98  fButtonFrame->AddFrame(fOK,new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
99  fButtonFrame->AddFrame(fCancel,new TGLayoutHints(kLHintsRight|kLHintsTop,5,5,5,5));
100 
101  AddFrame(fButtonFrame,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
102 
103  fOK->Connect("Clicked()", "AliMUONAlignmentCompareDialog",this,"DoOK()");
104  fCancel->Connect("Clicked()","AliMUONAlignmentCompareDialog",this,"DoCancel()");
105 }
106 
107 //_____________________________________________________________________________
109 {
111 }
112 
113 //_____________________________________________________________________________
114 void AliMUONAlignmentCompareDialog::AddInput(TGCompositeFrame* frame, const char* msg,
115  TGTextEntry*& text, TGNumberEntry*& run)
116 {
117 
118  TGHorizontalFrame* hf1 = new TGHorizontalFrame(frame);
119 
120  hf1->AddFrame(new TGLabel(hf1,TString(msg) + " ocdb path"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
121 
122  text = new TGTextEntry(hf1,"alien://folder=/alice/data/2012/OCDB");
123 
124  hf1->AddFrame(text,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5));
125 
126  TGHorizontalFrame* hf2 = new TGHorizontalFrame(frame);
127 
128  hf2->AddFrame(new TGLabel(hf2,TString(msg) + " run number"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
129 
130  run = new TGNumberEntry(hf2);
131 
132  hf2->AddFrame(run,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5));
133 
134  frame->AddFrame(hf1,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
135  frame->AddFrame(hf2,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
136 }
137 
138 //______________________________________________________________________________
139 void
141 {
143 
144  AliMUONVTrackerData* d = CompareAlignment(fOCDBPath1->GetText(),fRun1->GetNumber(),
145  fOCDBPath2->GetText(),fRun2->GetNumber());
146 
147  if (!d) return;
148 
149  TString basename = fBasename->GetText();
150 
152 
154 
155  TTimer::SingleShot(150,"AliMUONAlignmentCompareDialog",this,"CloseWindow()");
156 }
157 
158 //______________________________________________________________________________
159 void
161 {
163  TTimer::SingleShot(150,"AliMUONAlignmentCompareDialog",this,"CloseWindow()");
164 }
165 
166 //______________________________________________________________________________
168 AliMUONAlignmentCompareDialog::CompareAlignment(const char* ocdbPathForAlign1, Int_t run1,
169  const char* ocdbPathForAlign2, Int_t run2)
170 {
171  // ocdb access
172  AliCDBManager* cdbm = AliCDBManager::Instance();
173  cdbm->SetDefaultStorage("raw://");
174 
175  // get geometry transformers
176  AliMUONGeometryTransformer geoTransformer[2];
177 
178  const char* align[2] = {
179  ocdbPathForAlign1,
180  ocdbPathForAlign2
181  };
182 
183  Int_t runs[] = {
184  run1,run2
185  };
186 
187  for (Int_t i = 0; i < 2; i++)
188  {
189  cdbm->UnloadFromCache("GRP/Geometry/Data");
190  cdbm->UnloadFromCache("MUON/Align/Data");
191  AliGeomManager::GetGeometry()->UnlockGeometry();
192  AliGeomManager::LoadGeometry();
193  if (!AliGeomManager::GetGeometry()) return 0x0;
194  cdbm->SetSpecificStorage("MUON/Align/Data",align[i]);
195  cdbm->SetRun(runs[i]);
196  AliGeomManager::ApplyAlignObjsFromCDB("MUON");
197  geoTransformer[i].LoadGeometryData();
198  }
199 
200  // store for cluster shifts
201  AliMUON2DMap shiftStore(kTRUE);
202 
203  // loop over chamber
204  for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
205 
206  // loop over DEs
207  AliMpDEIterator nextDE;
208  nextDE.First(iCh);
209  while (!nextDE.IsDone()) {
210 
211  Int_t deId = nextDE.CurrentDE()->GetId();
212 
213  // loop over cathods
214  for (Int_t icath = 0; icath < 2; icath++) {
215 
217 
218  // loop over pads
219  AliMpVPadIterator *nextPad = seg->CreateIterator();
220  nextPad->First();
221  while (!nextPad->IsDone()) {
222 
223  AliMpPad pad = nextPad->CurrentItem();
224  Int_t manuId = pad.GetManuId();
225  Int_t manuChannel = pad.GetManuChannel();
226 
227  // local position
228  Double_t xl = pad.GetPositionX();
229  Double_t yl = pad.GetPositionY();
230  Double_t zl = 0.;
231 
232  // position with first alignment
233  Double_t x1, y1, z1;
234  geoTransformer[0].Local2Global(deId,xl,yl,zl,x1,y1,z1);
235 
236  // position with second alignment
237  Double_t x2, y2, z2;
238  geoTransformer[1].Local2Global(deId,xl,yl,zl,x2,y2,z2);
239 
240  // pad shift
241  Double_t dx = ::Difference(x2,x1);
242  Double_t dy = ::Difference(y2,y1);
243  Double_t dz = ::Difference(z2,z1);
244 
245  // store pad shifts
246  AliMUONVCalibParam* p = static_cast<AliMUONVCalibParam*>(shiftStore.FindObject(deId,manuId));
247  if (!p) {
248  p = new AliMUONCalibParamND(3,AliMpConstants::ManuNofChannels(),deId,manuId,0.);
249  shiftStore.Add(p);
250  }
251  p->SetValueAsDouble(manuChannel,0,dx);
252  p->SetValueAsDouble(manuChannel,1,dy);
253  p->SetValueAsDouble(manuChannel,2,dz);
254 
255  nextPad->Next();
256  }
257 
258  delete nextPad;
259 
260  }
261 
262  nextDE.Next();
263  }
264 
265  }
266 
267  // create tracker data
268  AliMUONTrackerData* data = new AliMUONTrackerData(fBasename->GetText(),fBasename->GetText(),3,kTRUE);
269  data->SetDimensionName(0,"dx"); // max shift in x
270  data->SetDimensionName(1,"dy"); // max shift in y
271  data->SetDimensionName(2,"dz"); // max shift in z
272  data->Add(shiftStore);
273 
274  return data;
275 }
Implementation of AliMUONVTrackerData.
The iterator over detection elements.
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
static AliMpSegmentation * Instance(Bool_t warn=true)
Bool_t LoadGeometryData(const TString &fileName)
AliTPCcalibAlign align
Definition: CalibAlign.C:43
static Int_t NTrackingCh()
Return number of tracking chambers.
Top container class for geometry transformations.
TGCompositeFrame * fF3
frame for difference type selection
Int_t GetManuId() const
Definition: AliMpPad.cxx:256
Bool_t IsDone() const
TGTextEntry * fBasename
basename of resulting (diff-ed) data
TGCompositeFrame * fButtonFrame
to hold OK and Cancel buttons
Producer of some AliMUONVTrackerData.
TGTextButton * fCancel
cancel button
Authors Philippe Pillot, Laurent Aphecetche, Subatech.
TGTextEntry * fOCDBPath2
to select second alignment path
virtual void SetDimensionName(Int_t index, const char *value)
Set the name of a given dimension.
AliMpDetElement * CurrentDE() const
virtual AliMpVPadIterator * CreateIterator(const AliMpArea &area) const =0
Create iterator over pads in the given area.
virtual Bool_t IsDone() const =0
Is iterator done.
TGTextEntry * fOCDBPath1
to select first alignment path
AliMUONAlignmentCompareDialog(const TGWindow *p=0, const TGWindow *main=0, UInt_t w=1, UInt_t h=1)
TGCompositeFrame * fF2
frame for align 2 selection
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetManuChannel() const
Definition: AliMpPad.cxx:264
void Register(AliMUONVTrackerDataMaker *reader)
static AliMUONPainterDataRegistry * Instance()
Container of calibration values for a given number of channels.
static Int_t ManuNofChannels()
Max number of channels per manu.
void Local2Global(Int_t detElemId, Float_t xl, Float_t yl, Float_t zl, Float_t &xg, Float_t &yg, Float_t &zg) const
virtual TObject * FindObject(Int_t i, Int_t j) const
Find an object using 2 ids.
virtual void Next()=0
Set iterator to the next pad.
An interface for an iterator over pads.
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
std::vector< RunInfo > runs
Implementation of AliMUONVCalibParam for tuples of double.
TGNumberEntry * fRun2
to select second run
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
TGNumberEntry * fRun1
to select first run
virtual AliMpPad CurrentItem() const =0
Return current pad.
Bool_t Add(const AliMUONTrackerData &data)
Basic implementation of AliMUONVStore container using AliMpExMap internally.
Definition: AliMUON2DMap.h:20
Simple wrapper of AliMUONVTrackerData (for backward compatibility)
virtual Bool_t Add(TObject *object)
Add an object to the store.
The abstract base class for the segmentation.
AliMUONVTrackerData * CompareAlignment(const char *ocdbPathForAlign1, Int_t run1, const char *ocdbPathForAlign2, Int_t run2)
virtual void First()=0
Set iterator to the first pad.
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
void AddInput(TGCompositeFrame *frame, const char *msg, TGTextEntry *&text, TGNumberEntry *&run)
Base class for MUON data that can be presented at different levels in the hierarchy of the MUON syste...
int main(int argc, char **argv)
Definition: TPCCEda.cxx:91
Int_t run1
Int_t GetId() const
Return Id.
TGCompositeFrame * fF1
frame for align 1 selection
virtual void SetValueAsDouble(Int_t i, Int_t j, Double_t value)