2 #if !defined(__CINT__) || defined(__MAKECINT__)
3 #include "AliCDBManager.h"
4 #include "AliCDBStorage.h"
6 #include "AliCDBMetaData.h"
7 #include "AliGeomManager.h"
11 #include <TGeoManager.h>
13 #include <TInterpreter.h>
16 Bool_t DiffGeometry(const char* recipient, const char* cdbUri="local://$ALICE_ROOT/OCDB", const char* cfgFile="$ALICE_ROOT/macros/Config.C"){
17 // Compare the geometry created in the current AliRoot with the one
18 // in the OCDB directory of the current aliroot. If they differ,
19 // warn the recipients to update the geometry in $ALICE_ROOT/OCDB
20 // before tagging and to consider updating it in the raw OCDB.
22 // Running this macro always before creating a release tag will
23 // allow to have in release tags OCDBs the geometry corresponding
26 // The recipient string is supposed to contain comma-separated
27 // valid email addresses, at least the one of the librarian and
28 // probably also the one of the guy in charge of the geometry object.
31 // Uplaod the geometry from $ALICE_ROOT/OCDB and get the number of nodes
32 AliCDBManager* cdb = AliCDBManager::Instance();
33 cdb->SetDefaultStorage(cdbUri);
34 cdb->Get("GRP/Geometry/Data",0);
35 Int_t svnocdb_nnodes = gGeoManager->GetNNodes();
36 Printf("The geometry in OCDB has %d nodes",svnocdb_nnodes);
41 // Create the geometry and get the number of nodes
42 if(!gSystem->AccessPathName("geometry.root")){
43 Printf("Deleting existing \"geometry.root\"");
44 gSystem->Exec("rm -rf geometry.root");
47 gROOT->LoadMacro(cfgFile);
48 gInterpreter->ProcessLine(gAlice->GetConfigFunction());
49 gAlice->GetMCApp()->Init();
52 Printf("Unable to produce a valid geometry to be put in the CDB!");
56 if(gSystem->AccessPathName("geometry.root")){
57 Printf("Did not find freshly written \"geometry.root\" file. Exiting ...");
61 Printf("Reloading freshly written geometry.root file");
62 if (TGeoManager::IsLocked()) TGeoManager::UnlockGeometry();
63 AliGeomManager::LoadGeometry("geometry.root");
65 Int_t svncode_nnodes = gGeoManager->GetNNodes();
66 Printf("The generated geometry has %d nodes",svncode_nnodes);
68 // If the number of nodes differs, remove the geometry file from the local OCDB
69 // and replace it by calling the UpdateCDBIdealGeom.C macro
70 if (svncode_nnodes != svnocdb_nnodes){
71 Printf("The geometry generated and the one in the current OCDB differ.");
72 Printf("Remove \"$ALICE_ROOT/OCDB/GRP/Geometry/Data/Run0_999999999_v0_s0.root\".");
73 Printf("and run $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C(\"local://$ALICE_ROOT/OCDB\",%s)",cfgFile);
75 // Get root and AliRoot versions
76 const char* rootv = gROOT->GetVersion();
77 TString av(ALIROOT_SVN_BRANCH);
78 Int_t revnum = ALIROOT_SVN_REVISION;
79 Printf("root version: %s. AliRoot %s, revision number %d",rootv,av.Data(),revnum);
81 // create and send mail
82 TString subject(Form("AliRoot revision %d is about to be tagged and the geometry changed!",revnum));
84 TString bodyFileName("mailbody.txt");
85 // bodyFileName.Form("%s/mail.body", GetShuttleLogDir());
86 gSystem->ExpandPathName(bodyFileName);
89 mailBody.open(bodyFileName, ofstream::out);
91 if (!mailBody.is_open())
93 Printf("Could not open mail body file %s", bodyFileName.Data());
97 TString recipients(recipient);
100 body = Form("Dear AliRoot librarian or geometry expert,\n\n");
101 body += Form("while tagging the current revision - r%d - the geometry produced by the code\n"
102 "appears to have changed w.r.t. to the one saved at the previous tag.\n\n"
103 "You should remove \"$ALICE_ROOT/OCDB/GRP/Geometry/Data/Run0_999999999_v0_s0.root\"\n"
104 "and run $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C(\"local://$ALICE_ROOT/OCDB\",%s) "
105 "before tagging.\n\n"
106 "Also consider updating the raw geometry on the raw OCDB.\n\n"
107 "Je vous prie de bien vouloir croire en l'assurance de mes respectueuses et honorables salutations.",revnum,cfgFile);
108 mailBody << body.Data();
111 Printf("Sending mail to \"%s\"",recipients.Data());
112 if(recipients.CountChar(',')==0){
113 TString mailCommand = Form("mail -s \"%s\" %s < %s",
116 bodyFileName.Data());
118 TString cc(recipients);
119 recipients.Remove(recipients.First(','));
120 cc.Replace(0,cc.First(',')+1,"");
121 TString mailCommand = Form("mail -s \"%s\" -c %s %s < %s",
125 bodyFileName.Data());
128 Bool_t result = gSystem->Exec(mailCommand.Data());
130 Printf("There are no changes between the geometry generated with current code and the one in the current OCDB.");