Converting PWG/TRD to native cmake
[u/mrichter/AliRoot.git] / ITS / MakeITSMilleSuperModules.C
CommitLineData
d3603b4d 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TError.h>
3#include <TFile.h>
4#include <TGeoManager.h>
5#include <TMath.h>
6#include <TString.h>
7#include <TSystem.h>
8#include "AliCDBPath.h"
9#include "AliCDBEntry.h"
10#include "AliCDBManager.h"
11#include "AliCDBStorage.h"
12#include "AliGeomManager.h"
13#include "AliITSMisalignMaker.h"
14#endif
15void MakeITSMilleSuperModules(char *geomfile="geometry.root") {
16//========================================================================
17//
18// Macro for building supermodules for ITS alignment
19//
20// Main author: M. Lunardon
21//
22//========================================================================
23
24 const char* macroname = "MakeITSMilleSuperModules.C";
25
26 if (!geomfile) { // look for default geometry
27 // Activate CDB storage and load geometry from CDB
28 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 29 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
d3603b4d 30 cdb->SetRun(0);
31
32 AliCDBStorage* storage = NULL;
33
34 TString compare("kTRUE");
35 if(gSystem->Getenv("TOCDB") == compare.Data()){
36 TString Storage = gSystem->Getenv("STORAGE");
37 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
38 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
39 return;
40 }
41 storage = cdb->GetStorage(Storage.Data());
42 if(!storage){
43 Error(macroname,"Unable to open storage %s\n",Storage.Data());
44 return;
45 }
46 AliCDBPath path("GRP","Geometry","Data");
47 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
48 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
49 entry->SetOwner(0);
50 TGeoManager* geom = (TGeoManager*) entry->GetObject();
51 AliGeomManager::SetGeometry(geom);
52 }else{
53 AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage
54 }
55 }
56 else
57 AliGeomManager::LoadGeometry(geomfile); //load geom from file
58 //////////////////////////////////////////////////////////////////
59
60 TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
61 TClonesArray &alobj = *array;
62 Int_t j = 0;
63
64 // custom ITS supermodules are stored as AliAlignObjParams as follow:
65 // symname, volid = SMsymname, SMvolid
66 // matrix = TGeoHMatrix of the SM in the global c.s.
67 // symname: the list of sensitive volumes, starting with "ITSMilleModuleList:"
68 // keyword, is appended to the symname
69 // example: "ITSMilleModuleList: N1 N2 N3-N4 ..."
70 // where N is a ITS sensitive volume INDEX (0-2197)
71
72 Char_t symname[4096];
73 UShort_t volid;
74 Char_t modlist[4096];
75 Double_t t[3]; // global translation
76 Double_t r[9]; // global rotation
77 TGeoHMatrix m;
78
79 // virtual volids start at layer 7
80 volid=14336;
81
82 // LAYERS: volids 14336 to 14341
83 strcpy(modlist,"ITSMilleModuleList: 0-79");
84 sprintf(symname,"%s %s","ITS/SPD0",modlist);
85 m.Clear(); // global frame
86 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
87 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
88 j++; volid++;
89
90 strcpy(modlist,"ITSMilleModuleList: 80-239");
91 sprintf(symname,"%s %s","ITS/SPD1",modlist);
92 m.Clear(); // global frame
93 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
94 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
95 j++; volid++;
96
97 strcpy(modlist,"ITSMilleModuleList: 240-323");
98 sprintf(symname,"%s %s","ITS/SDD2",modlist);
99 m.Clear(); // global frame
100 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
101 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
102 j++; volid++;
103
104 strcpy(modlist,"ITSMilleModuleList: 324-499");
105 sprintf(symname,"%s %s","ITS/SDD3",modlist);
106 m.Clear(); // global frame
107 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
108 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
109 j++; volid++;
110
111 strcpy(modlist,"ITSMilleModuleList: 500-1247");
112 sprintf(symname,"%s %s","ITS/SSD4",modlist);
113 m.Clear(); // global frame
114 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
115 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
116 j++; volid++;
117
118 strcpy(modlist,"ITSMilleModuleList: 1248-2197");
119 sprintf(symname,"%s %s","ITS/SSD5",modlist);
120 m.Clear(); // global frame
121 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
122 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
123 j++; volid++;
124
125 // SPD BARREL: volid 14342
126 strcpy(modlist,"ITSMilleModuleList: 0-239");
127 sprintf(symname,"%s %s","ITS/SPD/Barrel",modlist);
128 m.Clear(); // global frame
129 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
130 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
131 j++; volid++;
132
133 // SPD HALF BARREL: volids 14343-14344
134 strcpy(modlist,"ITSMilleModuleList: 0-39 80-159");
135 sprintf(symname,"%s %s","ITS/SPD/HalfBarrel0",modlist); // up
136 m.Clear(); // global frame
137 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
138 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
139 j++; volid++;
140
141 strcpy(modlist,"ITSMilleModuleList: 40-79 160-239");
142 sprintf(symname,"%s %s","ITS/SPD/HalfBarrel1",modlist); // down
143 m.Clear(); // global frame
144 //m.RotateZ(180.);
145 //m.RotateY(180.); // just negY->posY
146 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
147 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
148 j++; volid++;
149
150 // SPD sectors: volids 14345 to 14354
151 for (int is=0; is<10; is++) {
152 // sect 0: 0-7 80-95
153 // sect 1: 8-15 96-111
154 // ...
155 sprintf(modlist,"ITSMilleModuleList: %d-%d %d-%d",is*8,is*8+7,is*16+80,is*16+80+15);
156 sprintf(symname,"ITS/SPD0/Sector%d",is);
157 if (AliGeomManager::GetMatrix(symname))
158 m=(*AliGeomManager::GetMatrix(symname));
159 else {
160 Error(macroname,"cannot find matrix for SPD sector\n");
161 return;
162 }
163 sprintf(symname,"%s%d %s","ITS/SPD0/Sector",is,modlist);
164
165 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
166 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
167 j++; volid++;
168 }
169
170 // SPD staves: volids 14355 to 14414
171 for (int is=0; is<60; is++) {
172 // Stave0: 0-3
173// // ...
174 sprintf(modlist," ITSMilleModuleList: %d-%d",is*4,is*4+3);
175 strcpy(symname,AliITSgeomTGeo::GetSymName(is*4));
176 char *clad=strstr(symname,"Ladder");
177 if (clad) *(clad-1) = NULL;
178 else {
179 Error(macroname,"cannot find 'Ladder' in symname\n");
180 return;
181 }
182 //printf("Symname=%s\n",symname);
183 if (AliGeomManager::GetMatrix(symname))
184 m=(*AliGeomManager::GetMatrix(symname));
185 else {
186 Error(macroname,"cannot find matrix for SPD stave\n");
187 return;
188 }
189
190 clad=strstr(symname,"HalfStave");
191 if (clad) *(clad-1) = NULL;
192 else {
193 Error(macroname,"cannot find 'HalfStave' in symname\n");
194 return;
195 }
196 strcat(symname,modlist);
197
198 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
199 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
200 j++; volid++;
201 }
202
203
204 // SPD HALF staves: volids 14415 to 14534
205 for (int is=0; is<120; is++) {
206 // HalfStave0: 0-1
207// // ...
208 sprintf(modlist," ITSMilleModuleList: %d-%d ",is*2,is*2+1);
209 strcpy(symname,AliITSgeomTGeo::GetSymName(is*2));
210 char *clad=strstr(symname,"Ladder");
211 if (clad) *(clad-1) = NULL;
212 else {
213 Error(macroname,"cannot find 'Ladder' in symname\n");
214 return;
215 }
216 if (AliGeomManager::GetMatrix(symname))
217 m=(*AliGeomManager::GetMatrix(symname));
218 else {
219 Error(macroname,"cannot find matrix for SPD half-stave\n");
220 return;
221 }
222 strcat(symname,modlist);
223
224 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
225 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
226 j++; volid++;
227 }
228
229 // SPD HALF-HALF BARREL UP/DOWN FORWARD/BACKWARD (Y>0 and Z>0): volids 14535 to 14538
230 strcpy(modlist,"ITSMilleModuleList: ");
231 for (int ii=0; ii<40; ii++) {
232 int ij=ii/2;
233 if (!(ij%2)) sprintf(modlist,"%s %d",modlist,ii);
234 }
235 for (int ii=80; ii<160; ii++) {
236 int ij=ii/2;
237 if (!(ij%2)) sprintf(modlist,"%s %d",modlist,ii);
238 }
239 sprintf(symname,"%s %s","ITS/SPD/HalfBarrel0fw",modlist); // up/fw
240 m.Clear(); // global frame
241 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
242 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
243 j++; volid++;
244 //-----
245 strcpy(modlist,"ITSMilleModuleList: ");
246 for (int ii=0; ii<40; ii++) {
247 int ij=ii/2;
248 if ((ij%2)) sprintf(modlist,"%s %d",modlist,ii);
249 }
250 for (int ii=80; ii<160; ii++) {
251 int ij=ii/2;
252 if ((ij%2)) sprintf(modlist,"%s %d",modlist,ii);
253 }
254 sprintf(symname,"%s %s","ITS/SPD/HalfBarrel0bw",modlist); // up/bw
255 m.Clear(); // global frame
256 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
257 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
258 j++; volid++;
259 //-----
260 strcpy(modlist,"ITSMilleModuleList: ");
261 for (int ii=40; ii<80; ii++) {
262 int ij=ii/2;
263 if (!(ij%2)) sprintf(modlist,"%s %d",modlist,ii);
264 }
265 for (int ii=160; ii<240; ii++) {
266 int ij=ii/2;
267 if (!(ij%2)) sprintf(modlist,"%s %d",modlist,ii);
268 }
269 sprintf(symname,"%s %s","ITS/SPD/HalfBarrel1fw",modlist); // down/fw
270 m.Clear(); // global frame
271 //m.RotateZ(180.);
272 //m.RotateY(180.); // just negY->posY
273 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
274 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
275 j++; volid++;
276 //-----
277 strcpy(modlist,"ITSMilleModuleList: ");
278 for (int ii=40; ii<80; ii++) {
279 int ij=ii/2;
280 if ((ij%2)) sprintf(modlist,"%s %d",modlist,ii);
281 }
282 for (int ii=160; ii<240; ii++) {
283 int ij=ii/2;
284 if ((ij%2)) sprintf(modlist,"%s %d",modlist,ii);
285 }
286 sprintf(symname,"%s %s","ITS/SPD/HalfBarrel1bw",modlist); // down/bw
287 m.Clear(); // global frame
288 //m.RotateZ(180.);
289 //m.RotateY(180.); // just negY->posY
290 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
291 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
292 j++; volid++;
293 //-----
294
295 // SDD
296 // start at volid=15000
297 // - SDD2: 14 ladders da 6 elementi
298 // - SDD3: 22 ladders da 8 elementi
299 volid=15000;
300
301 // SDD2 Ladders: volids 15000 to 15013
302 for (int is=0; is<14; is++) {
303 // Ladder: 0-5
304 // // ...
305 sprintf(modlist," ITSMilleModuleList: %d-%d ",240+is*6,240+is*6+5);
306 strcpy(symname,AliITSgeomTGeo::GetSymName(240+is*6));
307 char *clad=strstr(symname,"Sensor");
308 if (clad) *(clad-1) = NULL;
309 else {
310 Error(macroname,"cannot find 'Sensor' in symname\n");
311 return;
312 }
313 if (AliGeomManager::GetMatrix(symname))
314 m=(*AliGeomManager::GetMatrix(symname));
315 else {
316 Error(macroname,"cannot find matrix for SDD ladder\n");
317 return;
318 }
319 strcat(symname,modlist);
320
321 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
322 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
323 j++; volid++;
324 }
325
326 // SDD3 Ladders: volids 15014 to 15035
327 for (int is=0; is<22; is++) {
328 // Ladder: 0-7
329 // // ...
330 sprintf(modlist," ITSMilleModuleList: %d-%d ",324+is*8,324+is*8+7);
331 strcpy(symname,AliITSgeomTGeo::GetSymName(324+is*8));
332 char *clad=strstr(symname,"Sensor");
333 if (clad) *(clad-1) = NULL;
334 else {
335 Error(macroname,"cannot find 'Sensor' in symname\n");
336 return;
337 }
338 if (AliGeomManager::GetMatrix(symname))
339 m=(*AliGeomManager::GetMatrix(symname));
340 else {
341 Error(macroname,"cannot find matrix for SDD ladder\n");
342 return;
343 }
344 strcat(symname,modlist);
345
346 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
347 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
348 j++; volid++;
349 }
350
351 //----------
352
353 // SSD
354 // start at volid=16000
355 // - SSD4: 34 ladders da 22 elementi
356 // - SSD5: 38 ladders da 25 elementi
357 volid=16000;
358
359 // SSD4 Ladders: volids 16000 to 16033
360 for (int is=0; is<34; is++) {
361 // Ladder: 0-5
362 // // ...
363 sprintf(modlist," ITSMilleModuleList: %d-%d ",500+is*22,500+is*22+21);
364 strcpy(symname,AliITSgeomTGeo::GetSymName(500+is*22));
365 char *clad=strstr(symname,"Sensor");
366 if (clad) *(clad-1) = NULL;
367 else {
368 Error(macroname,"cannot find 'Sensor' in symname\n");
369 return;
370 }
371 if (AliGeomManager::GetMatrix(symname))
372 m=(*AliGeomManager::GetMatrix(symname));
373 else {
374 Error(macroname,"cannot find matrix for SSD ladder\n");
375 return;
376 }
377 strcat(symname,modlist);
378
379 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
380 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
381 j++; volid++;
382 }
383
384 // SSD5 Ladders: volids 16034 to 16071
385 for (int is=0; is<38; is++) {
386 // Ladder: 0-7
387 // // ...
388 sprintf(modlist," ITSMilleModuleList: %d-%d ",1248+is*25,1248+is*25+24);
389 strcpy(symname,AliITSgeomTGeo::GetSymName(1248+is*25));
390 char *clad=strstr(symname,"Sensor");
391 if (clad) *(clad-1) = NULL;
392 else {
393 Error(macroname,"cannot find 'Sensor' in symname\n");
394 return;
395 }
396 if (AliGeomManager::GetMatrix(symname))
397 m=(*AliGeomManager::GetMatrix(symname));
398 else {
399 Error(macroname,"cannot find matrix for SDD ladder\n");
400 return;
401 }
402 strcat(symname,modlist);
403
404 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
405 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
406 j++; volid++;
407 }
408
409 // SSD BARREL: volid 16072
410 strcpy(modlist,"ITSMilleModuleList: 500-2197");
411 sprintf(symname,"%s %s","ITS/SSD/Barrel",modlist);
412 m.Clear(); // global frame
413 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
414 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
415 j++; volid++;
416
417
418 // SSD HALF BARREL: volids 16073-16074
419 // SSD HALF BARREL UP: volid 16073
420 strcpy(modlist,"ITSMilleModuleList: 500-873 1248-1722");
421 sprintf(symname,"%s %s","ITS/SSD/HalfBarrel0",modlist); // up
422 m.Clear(); // global frame
423 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
424 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
425 j++; volid++;
426
427 // SSD HALF BARREL DOWN: volid 16074
428 strcpy(modlist,"ITSMilleModuleList: 874-1246 1723-2197");
429 sprintf(symname,"%s %s","ITS/SSD/HalfBarrel1",modlist); // down
430 m.Clear(); // global frame
431 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
432 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
433 j++; volid++;
434
435
436 //----------
437 // SSD HALF-LADDERS
438 // - SSD4: 34x2=68 halfladders da 12+10 elementi
439 // - SSD5: 38x2=76 halfladders da 12+13 elementi
440
441 // SSD4 Ladders: volids 16075 to 16142
442 for (int is=0; is<34; is++) {
443 // Ladder: 0-33
444 // first half
445 sprintf(modlist," ITSMilleModuleList: %d-%d ",500+is*22,500+is*22+11);
446 strcpy(symname,AliITSgeomTGeo::GetSymName(500+is*22));
447 char *clad=strstr(symname,"Sensor");
448 if (clad) *(clad-1) = NULL;
449 else {
450 Error(macroname,"cannot find 'Sensor' in symname\n");
451 return;
452 }
453 if (AliGeomManager::GetMatrix(symname))
454 m=(*AliGeomManager::GetMatrix(symname));
455 else {
456 Error(macroname,"cannot find matrix for SSD ladder\n");
457 return;
458 }
459 strcat(symname,"Half0");
460 strcat(symname,modlist);
461
462 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
463 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
464 j++; volid++;
465
466 // second half
467 sprintf(modlist," ITSMilleModuleList: %d-%d ",500+is*22+12,500+is*22+21);
468 strcpy(symname,AliITSgeomTGeo::GetSymName(500+is*22));
469 char *clad=strstr(symname,"Sensor");
470 if (clad) *(clad-1) = NULL;
471 else {
472 Error(macroname,"cannot find 'Sensor' in symname\n");
473 return;
474 }
475 if (AliGeomManager::GetMatrix(symname))
476 m=(*AliGeomManager::GetMatrix(symname));
477 else {
478 Error(macroname,"cannot find matrix for SSD ladder\n");
479 return;
480 }
481 strcat(symname,"Half1");
482 strcat(symname,modlist);
483
484 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
485 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
486 j++; volid++;
487
488 }
489
490 // SSD5 Ladders: volids 16143 to 16218
491 for (int is=0; is<38; is++) {
492 // first half
493 sprintf(modlist," ITSMilleModuleList: %d-%d ",1248+is*25,1248+is*25+11);
494 strcpy(symname,AliITSgeomTGeo::GetSymName(1248+is*25));
495 char *clad=strstr(symname,"Sensor");
496 if (clad) *(clad-1) = NULL;
497 else {
498 Error(macroname,"cannot find 'Sensor' in symname\n");
499 return;
500 }
501 if (AliGeomManager::GetMatrix(symname))
502 m=(*AliGeomManager::GetMatrix(symname));
503 else {
504 Error(macroname,"cannot find matrix for SDD ladder\n");
505 return;
506 }
507 strcat(symname,"Half0");
508 strcat(symname,modlist);
509
510 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
511 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
512 j++; volid++;
513
514 // second half
515 sprintf(modlist," ITSMilleModuleList: %d-%d ",1248+is*25+12,1248+is*25+24);
516 strcpy(symname,AliITSgeomTGeo::GetSymName(1248+is*25));
517 char *clad=strstr(symname,"Sensor");
518 if (clad) *(clad-1) = NULL;
519 else {
520 Error(macroname,"cannot find 'Sensor' in symname\n");
521 return;
522 }
523 if (AliGeomManager::GetMatrix(symname))
524 m=(*AliGeomManager::GetMatrix(symname));
525 else {
526 Error(macroname,"cannot find matrix for SDD ladder\n");
527 return;
528 }
529 strcat(symname,"Half1");
530 strcat(symname,modlist);
531
532 new(alobj[j]) AliAlignObjParams(symname, volid, m, kTRUE);
533 *(strstr(symname,"ITSMilleModuleList"))=NULL ;printf("added module %s with volid %d \n",symname,volid);
534 j++; volid++;
535 }
536
537
538 //////////////////////////////////////////////////////////////////
539 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
540 // save on file
541 const char* filename = "ITSMilleSuperModules.root";
542 TFile f(filename,"RECREATE");
543 if(!f){
544 Error(macroname,"cannot open file for output\n");
545 return;
546 }
547 Info(macroname,"Saving ITS SuperModules as AliAlignObjs to the file %s", filename);
548 f.cd();
549 f.WriteObject(array,"ITSMilleSuperModules","kSingleKey");
550 f.Close();
551 }else{
552 // save in CDB storage
553 TString Storage = gSystem->Getenv("STORAGE");
554 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
555 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
556 return;
557 }
558 Info(macroname,"Saving ITS SuperModules in CDB storage %s",
559 Storage.Data());
560 AliCDBManager* cdb = AliCDBManager::Instance();
561 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
562 if(!storage){
563 Error(macroname,"Unable to open storage %s\n",Storage.Data());
564 return;
565 }
566 AliCDBMetaData *md= new AliCDBMetaData();
567 md->SetResponsible("Marcello Lunardon");
568 md->SetComment("ITS super modules for ITS alignment with Millepede");
569 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
570 AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
571 storage->Put(array,id, md);
572 }
573
574 array->Delete();
575 return;
576}