~ma5/madanalysis5/madanalysis-development

« back to all changes in this revision

Viewing changes to madanalysis/install/detector_manager.py

  • Committer: Benjamin Fuks
  • Date: 2018-05-04 10:44:49 UTC
  • mfrom: (115.1.81 v1.6beta)
  • Revision ID: fuks@cern.ch-20180504104449-60h8a00loxgr8zg0
Releasing v1.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
################################################################################
 
2
#  
 
3
#  Copyright (C) 2012-2016 Eric Conte, Benjamin Fuks
 
4
#  The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
 
5
#  
 
6
#  This file is part of MadAnalysis 5.
 
7
#  Official website: <https://launchpad.net/madanalysis5>
 
8
#  
 
9
#  MadAnalysis 5 is free software: you can redistribute it and/or modify
 
10
#  it under the terms of the GNU General Public License as published by
 
11
#  the Free Software Foundation, either version 3 of the License, or
 
12
#  (at your option) any later version.
 
13
#  
 
14
#  MadAnalysis 5 is distributed in the hope that it will be useful,
 
15
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
17
#  GNU General Public License for more details.
 
18
#  
 
19
#  You should have received a copy of the GNU General Public License
 
20
#  along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
 
21
#  
 
22
################################################################################
 
23
 
 
24
 
 
25
from madanalysis.install.install_manager      import InstallManager
 
26
 
 
27
 
 
28
class DetectorManager():
 
29
 
 
30
    def __init__(self, main):
 
31
        self.main   = main
 
32
        self.forced = self.main.forced
 
33
 
 
34
    def manage(self, detector):
 
35
        # initialization
 
36
        # Getting the 'already installed' flags
 
37
        if detector == 'delphes':
 
38
            installed     = self.main.archi_info.has_delphes
 
39
            uninstalled   = self.main.archi_info.has_delphesMA5tune
 
40
            otherdetector = 'delphesMA5tune'
 
41
        elif detector == 'delphesMA5tune':
 
42
            installed     = self.main.archi_info.has_delphesMA5tune
 
43
            uninstalled   = self.main.archi_info.has_delphes
 
44
            otherdetector = 'delphes'
 
45
        else:
 
46
            return True
 
47
        # Installing / activating if necessary
 
48
        self.main.forced=True
 
49
        if self.main.fastsim.package == detector and not installed:
 
50
            installer=InstallManager(self.main)
 
51
            if uninstalled:
 
52
                if not installer.Deactivate(otherdetector):
 
53
                    self.main.forced=self.forced
 
54
                    return False
 
55
            if installer.Activate(detector)==-1:
 
56
                self.main.forced=self.forced
 
57
                return False
 
58
        self.main.forced=self.forced
 
59
        return True
 
60